diff options
| author | Katherine Zaoral <kz@adhoc.com.ar> | 2020-02-06 16:41:52 +0000 |
|---|---|---|
| committer | Josse Colpaert <jco@odoo.com> | 2020-02-18 14:09:25 +0000 |
| commit | 62516ae5ffd80563a48749e5c591d66c61692c1b (patch) | |
| tree | 40c3bc4534799638240c8ed23104e5b93996170c /addons/l10n_latam_invoice_document | |
| parent | 7dd70438e1ec5799a91623bbf7f4798453882b67 (diff) | |
[FW][FIX] l10n_latam_invoice_document: proper validate vendor bills
Formerly the vendor bills, customer invoices and regular journal items were
evaluated by the _check_unique_sequence_number method, but this is wrong
and also was overwritten Odoo original constraint error message.
Now the _check_unique_sequence_number evaluate the account.moves that are
not vendor bills that use documents because this kind of bills uniqueness
depends on the vendor: we can have same name of vendor bill from different
partners. This is evaluated in the already existing
_check_unique_vendor_number method
closes odoo/odoo#44813
closes odoo/odoo#45643
Original-signed-off-by: Josse Colpaert <jco@openerp.com>
X-original-commit: beaa3bbacd4bd35ed11962a7466f111e5e85f0d8
Signed-off-by: Josse Colpaert <jco@openerp.com>
Diffstat (limited to 'addons/l10n_latam_invoice_document')
| -rw-r--r-- | addons/l10n_latam_invoice_document/models/account_move.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/addons/l10n_latam_invoice_document/models/account_move.py b/addons/l10n_latam_invoice_document/models/account_move.py index 327476726a9..71b2fbf305d 100644 --- a/addons/l10n_latam_invoice_document/models/account_move.py +++ b/addons/l10n_latam_invoice_document/models/account_move.py @@ -70,14 +70,10 @@ class AccountMove(models.Model): @api.constrains('name', 'journal_id', 'state') def _check_unique_sequence_number(self): - """ Do not apply unique sequence number for vendoer bills and refunds. - Also apply constraint when state change """ - vendor = self.filtered(lambda x: x.type in ['in_refund', 'in_invoice']) - try: - return super(AccountMove, self - vendor)._check_unique_sequence_number() - except ValidationError: - raise ValidationError(_('Duplicated invoice number detected. You probably added twice the same vendor' - ' bill/debit note.')) + """ This uniqueness verification is only valid for customer invoices, and vendor bills that does not use + documents. A new constraint method _check_unique_vendor_number has been created just for validate for this purpose """ + vendor = self.filtered(lambda x: x.is_purchase_document() and x.l10n_latam_use_documents) + return super(AccountMove, self - vendor)._check_unique_sequence_number() @api.constrains('state', 'l10n_latam_document_type_id') def _check_l10n_latam_documents(self): @@ -163,11 +159,10 @@ class AccountMove(models.Model): ) for group, amounts in res] super(AccountMove, self - move_with_doc_type)._compute_invoice_taxes_by_group() - @api.constrains('name', 'partner_id', 'company_id') + @api.constrains('name', 'partner_id', 'company_id', 'posted_before') def _check_unique_vendor_number(self): """ The constraint _check_unique_sequence_number is valid for customer bills but not valid for us on vendor - bills because the uniqueness must be per partner and also because we want to validate on entry creation and - not on entry validation """ + bills because the uniqueness must be per partner """ for rec in self.filtered(lambda x: x.is_purchase_document() and x.l10n_latam_use_documents): domain = [ ('type', '=', rec.type), |
