Skip to content

Commit

Permalink
[13.0] [FIX] account_ux: Set partner_id compute writable for use the …
Browse files Browse the repository at this point in the history
…partner in entries.
  • Loading branch information
nicomacr committed Jul 21, 2021
1 parent 5d87442 commit 10eb20c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions account_ux/models/account_move.py
Expand Up @@ -15,6 +15,20 @@ class AccountMove(models.Model):
'account.move',
states={'draft': [('readonly', False)]},
)
partner_id = fields.Many2one(
compute='_compute_partner_id',
readonly=False,
store=True,
)

@api.depends('line_ids.partner_id')
def _compute_partner_id(self):
for move in self:
if move.type == 'entry':
partner = move.line_ids.mapped('partner_id')
move.partner_id = partner.id if len(partner) == 1 else False
else:
move.partner_id = move.partner_id

def delete_number(self):
self.filtered(lambda x: x.state == 'cancel').write({'name': '/'})
Expand Down

0 comments on commit 10eb20c

Please sign in to comment.