From 3621bb6e29b317cf4f197693ee2e2e26f3305dee Mon Sep 17 00:00:00 2001 From: AaronHForgeFlow Date: Wed, 24 Apr 2024 17:39:25 +0200 Subject: [PATCH] [IMP] account_operating_unit: allow to pay multiple invoices with different operating units. That was possible in old versions 1: - return payments - for payment in payments: - to_reconcile = self.env["account.move.line"] - reconciled_moves = self._get_reconciled_moves(payment) - if len(reconciled_moves.operating_unit_id) > 1: - raise UserError( - _( - "The OU in the Bills/Invoices to register payment must be the same." - ) - ) - if reconciled_moves.operating_unit_id != payment.operating_unit_id: - destination_account = payment.destination_account_id - line = payment.move_id.line_ids.filtered( - lambda l: l.account_id == destination_account - ) - line.write( - { - "operating_unit_id": reconciled_moves.operating_unit_id.id, - } - ) - # reconcile with case self balanced only - if payment.move_id.company_id.ou_is_self_balanced: - to_reconcile |= line - to_reconcile |= reconciled_moves.line_ids.filtered( - lambda l: l.account_id == destination_account - ) - payment.action_draft() - payment.action_post() - to_reconcile.filtered(lambda r: not r.reconciled).reconcile() - return payments