From e8dde255c31eeca3f11fad31e0a24bc123b567e9 Mon Sep 17 00:00:00 2001 From: benjamin <benjamin@le-filament.com> Date: Wed, 15 Jan 2025 09:14:01 +0100 Subject: [PATCH] =?UTF-8?q?[UPD]=20MR=20Herv=C3=A9=20for=20OPM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/account_move.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/models/account_move.py b/models/account_move.py index 7fce870..1b4c420 100644 --- a/models/account_move.py +++ b/models/account_move.py @@ -2,7 +2,8 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import api, fields, models -from odoo.exceptions import UserError, ValidationError +from odoo.exceptions import UserError + class ScopAccountMove(models.Model): _inherit = "account.move" @@ -50,27 +51,26 @@ class ScopAccountMove(models.Model): for invoice in self: invoice.partner_id.get_vat() - # ------------------------------------------------------ - # Override confirm button action + # Inherit parent # ------------------------------------------------------ def _post(self, soft=True): - + """ + Vérifie le compte client pour OPM + """ # On effectue qq tests spécifiques à l'UR OPM - ur_opm = self.env.ref("cgscop_partner.riga_14243").id - current_ur = self.env["res.company"]._ur_default_get().id + ur_opm = self.env.ref("cgscop_partner.riga_14243") - if current_ur == ur_opm: - for rec in self: - if rec.partner_id: - # On doit avoir un no de compte pour le client - if not rec.partner_id.property_account_receivable_id: - raise UserError("Numéro de compte comptable client obligatoire.") - # Qui ne doit pas être le 411 par défaut - if rec.partner_id.property_account_receivable_id.code.startswith('411'): - raise UserError("Numéro de compte client invalide.") - # Et d'une longueur <= 7 - if len(rec.partner_id.property_account_receivable_id.code) > 7: - raise UserError("Numéro de compte client trop long.") + for move in self: + if move.partner_id and move.company_id.ur_id == ur_opm: + # On doit avoir un no de compte pour le client + if not move.partner_id.property_account_receivable_id: + raise UserError("Numéro de compte comptable client obligatoire.") + # Qui ne doit pas être le 411 par défaut + if move.partner_id.property_account_receivable_id.code.startswith('411'): + raise UserError("Numéro de compte client invalide.") + # Et d'une longueur <= 7 + if len(move.partner_id.property_account_receivable_id.code) > 7: + raise UserError("Numéro de compte client trop long.") - return super(ScopAccountMove,self)._post(soft) + return super()._post(soft) -- GitLab