Skip to content
Snippets Groups Projects
Commit 9e1a0fb3 authored by Josse Colpaert's avatar Josse Colpaert
Browse files

[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.

Part-of: odoo/odoo#81464
parent 71e28fcb
Branches
Tags
No related merge requests found
......@@ -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()
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment