Get payable or receivable payment type when on_change party from account_kind field

This commit is contained in:
Raimon Esteve 2019-11-20 09:54:50 +01:00
parent 2f48858738
commit de09fd56c3
1 changed files with 7 additions and 11 deletions

View File

@ -333,19 +333,15 @@ class Line(BankMixin, metaclass=PoolMeta):
if self.payment_type and self.party:
self._get_bank_account()
@fields.depends('party', 'debit', 'credit', 'move', '_parent_move.id')
@fields.depends('party', 'account_kind', 'move', '_parent_move.id')
def on_change_with_payment_type(self, name=None):
if self.party:
if self.credit > 0 or self.debit < 0:
name = 'supplier_payment_type'
elif self.debit > 0 or self.credit < 0:
name = 'customer_payment_type'
else:
return
payment_type = getattr(self.party, name)
if payment_type:
return payment_type.id
return
if self.account_kind == 'payable':
return (self.party.supplier_payment_type.id
if self.party.supplier_payment_type else None)
elif self.account_kind == 'receivable':
return (self.party.customer_payment_type.id
if self.party.customer_payment_type else None)
@classmethod
def copy(cls, lines, default=None):