Skip to content

Commit

Permalink
[FIX] account_ux: invoice-journal-type constraint
Browse files Browse the repository at this point in the history
Only apply to journals that use documents.
  • Loading branch information
zaoral committed Aug 12, 2020
1 parent 7c123ac commit 07008b0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions account_ux/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ def _compute_payments_widget_to_reconcile_info(self):
def check_invoice_and_journal_type(self, default=None):
""" Only let to create customer invoices/vendor bills in respective sale/purchase journals """
error = self.filtered(
lambda x: x.is_sale_document() and x.journal_id.type != 'sale' or
not x.is_sale_document() and x.journal_id.type == 'sale' or
x.is_purchase_document() and x.journal_id.type != 'purchase' or
not x.is_purchase_document() and x.journal_id.type == 'purchase')
lambda x: x.journal_id.l10n_latam_use_documents and (
x.is_sale_document() and x.journal_id.type != 'sale' or
not x.is_sale_document() and x.journal_id.type == 'sale' or
x.is_purchase_document() and x.journal_id.type != 'purchase' or
not x.is_purchase_document() and x.journal_id.type == 'purchase'))
if error:
raise ValidationError(_(
'You can create sales/purchase invoices exclusively in the respective sales/purchase journals'))

0 comments on commit 07008b0

Please sign in to comment.