Skip to content

Commit

Permalink
[FIX] account_ux: when an account move line don´t have account no che…
Browse files Browse the repository at this point in the history
…ck company

closes #431

Signed-off-by: Katherine Zaoral <kz@adhoc.com.ar>
  • Loading branch information
zaoral committed Jul 18, 2023
1 parent 716f419 commit c597c75
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions account_ux/models/account_move.py
Expand Up @@ -137,9 +137,12 @@ def _compute_invoice_date_due(self):
@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)))
lines_with_problem = s = move.line_ids.filtered(lambda x: x.account_id and x.account_id.company_id != move.company_id)
if lines_with_problem:
raise UserError(_(
"There is at least 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)\n- %s" % (
move.id, '\n- '.join(lines_with_problem.mapped('display_name')))))

def _compute_currency_id(self):
""" Si la factura tenía currency_id no queremos cambiarla si cambia el diario """
Expand Down

0 comments on commit c597c75

Please sign in to comment.