From bc782cfc916f39a1d34d4a2a07acefd18f3d29e5 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Wed, 15 Dec 2021 11:37:51 +0000 Subject: [PATCH] [FIX] l10n_sa_invoice: relax constraint for delivery date We had a constraint(raise) that said that the delivery date needed to be after the invoice date, but this is putting too many constraints. However, we put a help message to say that they should put the date of the last delivery. Also, the delivery date should not be changed once confirmed like the other information in the invoice. X-original-commit: 9e1a0fb37930de3c8cbc0ecf88052e5ddf55d474 Part-of: odoo/odoo#81620 --- addons/l10n_sa_invoice/models/account_move.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/l10n_sa_invoice/models/account_move.py b/addons/l10n_sa_invoice/models/account_move.py index ebf0acab229..1e03454853e 100644 --- a/addons/l10n_sa_invoice/models/account_move.py +++ b/addons/l10n_sa_invoice/models/account_move.py @@ -9,7 +9,9 @@ from odoo.exceptions import UserError class AccountMove(models.Model): _inherit = 'account.move' - l10n_sa_delivery_date = fields.Date(string='Delivery Date', default=fields.Date.context_today, copy=False) + l10n_sa_delivery_date = fields.Date(string='Delivery Date', default=fields.Date.context_today, copy=False, + readonly=True, states={'draft': [('readonly', False)]}, + help="In case of multiple deliveries, you should take the date of the latest one. ") l10n_sa_show_delivery_date = fields.Boolean(compute='_compute_show_delivery_date') l10n_sa_qr_code_str = fields.Char(string='Zatka QR Code', compute='_compute_qr_code_str') l10n_sa_confirmation_datetime = fields.Datetime(string='Confirmation Date', readonly=True, copy=False) @@ -50,8 +52,6 @@ class AccountMove(models.Model): if record.country_code == 'SA' and record.move_type in ('out_invoice', 'out_refund'): if not record.l10n_sa_show_delivery_date: raise UserError(_('Delivery Date cannot be empty')) - if record.l10n_sa_delivery_date < record.invoice_date: - raise UserError(_('Delivery Date cannot be before Invoice Date')) self.write({ 'l10n_sa_confirmation_datetime': fields.Datetime.now() })