Skip to content

Commit

Permalink
[FIX] l10n_sa_invoice: relax constraint for delivery date
Browse files Browse the repository at this point in the history
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: 9e1a0fb
Part-of: odoo#81611
  • Loading branch information
jco-odoo committed Dec 17, 2021
1 parent 03bf311 commit b7b11e9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions addons/l10n_sa_invoice/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
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)
Expand Down Expand Up @@ -50,8 +52,6 @@ def _post(self, soft=True):
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()
})
Expand Down

0 comments on commit b7b11e9

Please sign in to comment.