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

View file

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