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() })