Skip to content

Commit

Permalink
[ADD] account_ux: company of the accounts of lines different from the…
Browse files Browse the repository at this point in the history
… company of the invoice

Ticket: 61691
Prevent posting moves that have lines in the journal entry with accounts belonging to companies that are different from the company of the invoice. How to reply: https://drive.google.com/file/d/1vHo9xtn_5bFcbYzTbyFDY5LFOKzQreLZ/view

closes #427

Signed-off-by: Juan José Scarafía <jjs@adhoc.com.ar>
  • Loading branch information
pablohmontenegro committed Jul 12, 2023
1 parent 7eb324b commit 2678dd7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions account_ux/models/account_move.py
Expand Up @@ -133,3 +133,10 @@ def _compute_invoice_date_due(self):
if inv.invoice_date:
inv.invoice_date_due = inv.invoice_date
return super(AccountMove, invoices)._compute_invoice_date_due()

@api.constrains('state')
def _check_company_on_lines(self):
for move in self.filtered(lambda x: x.state == 'posted'):
if any(line.account_id.company_id != self.company_id for line in self.line_ids):
raise UserError(_("There is almost one account in the journal entry of this move that belongs to a company that "
"is different to the company of the move (id: %s)" % (move.id)))

0 comments on commit 2678dd7

Please sign in to comment.