diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 267272da279..150f49df9e2 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -2802,6 +2802,12 @@ class AccountMove(models.Model): }) for move in to_post: + # Fix inconsistencies that may occure if the OCR has been editing the invoice at the same time of a user. We force the + # partner on the lines to be the same as the one on the move, because that's the only one the user can see/edit. + wrong_lines = move.is_invoice() and move.line_ids.filtered(lambda aml: aml.partner_id != move.commercial_partner_id) + if wrong_lines: + wrong_lines.write({'partner_id': move.commercial_partner_id.id}) + move.message_subscribe([p.id for p in [move.partner_id] if p not in move.sudo().message_partner_ids]) # Compute 'ref' for 'out_invoice'.