Skip to content
Extraits de code Groupes Projets
Valider e8dde255 rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[UPD] MR Hervé for OPM

parent eb7a1acd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models from odoo import api, fields, models
from odoo.exceptions import UserError, ValidationError from odoo.exceptions import UserError
class ScopAccountMove(models.Model): class ScopAccountMove(models.Model):
_inherit = "account.move" _inherit = "account.move"
...@@ -50,27 +51,26 @@ class ScopAccountMove(models.Model): ...@@ -50,27 +51,26 @@ class ScopAccountMove(models.Model):
for invoice in self: for invoice in self:
invoice.partner_id.get_vat() invoice.partner_id.get_vat()
# ------------------------------------------------------ # ------------------------------------------------------
# Override confirm button action # Inherit parent
# ------------------------------------------------------ # ------------------------------------------------------
def _post(self, soft=True): def _post(self, soft=True):
"""
Vérifie le compte client pour OPM
"""
# On effectue qq tests spécifiques à l'UR OPM # On effectue qq tests spécifiques à l'UR OPM
ur_opm = self.env.ref("cgscop_partner.riga_14243").id ur_opm = self.env.ref("cgscop_partner.riga_14243")
current_ur = self.env["res.company"]._ur_default_get().id
if current_ur == ur_opm: for move in self:
for rec in self: if move.partner_id and move.company_id.ur_id == ur_opm:
if rec.partner_id:
# On doit avoir un no de compte pour le client # On doit avoir un no de compte pour le client
if not rec.partner_id.property_account_receivable_id: if not move.partner_id.property_account_receivable_id:
raise UserError("Numéro de compte comptable client obligatoire.") raise UserError("Numéro de compte comptable client obligatoire.")
# Qui ne doit pas être le 411 par défaut # Qui ne doit pas être le 411 par défaut
if rec.partner_id.property_account_receivable_id.code.startswith('411'): if move.partner_id.property_account_receivable_id.code.startswith('411'):
raise UserError("Numéro de compte client invalide.") raise UserError("Numéro de compte client invalide.")
# Et d'une longueur <= 7 # Et d'une longueur <= 7
if len(rec.partner_id.property_account_receivable_id.code) > 7: if len(move.partner_id.property_account_receivable_id.code) > 7:
raise UserError("Numéro de compte client trop long.") raise UserError("Numéro de compte client trop long.")
return super(ScopAccountMove,self)._post(soft) return super()._post(soft)
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter