Add on_change_with_payment_type methods in account.move.line and account.move.compensation_move.start that doesn't exist

From changeset-3d185c0f089f
This commit is contained in:
Raimon Esteve 2018-09-10 16:44:22 +02:00
parent a881707765
commit f1ecc37bed
2 changed files with 21 additions and 6 deletions

View file

@ -341,6 +341,18 @@ class Line(BankMixin, metaclass=PoolMeta):
if self.payment_type and self.party:
self._get_bank_account()
@fields.depends('party', 'debit', 'credit', 'move')
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'
payment_type = getattr(self.party, name)
if payment_type:
return payment_type.id
return None
@classmethod
def copy(cls, lines, default=None):
if default is None:
@ -533,6 +545,9 @@ class CompensationMoveStart(ModelView, BankMixin):
if party.account_payable else None)
return defaults
def on_change_with_payment_type(self, name=None):
pass
class CompensationMove(Wizard):
'Create Compensation Move'

View file

@ -147,8 +147,8 @@ Create invoice::
>>> invoice.bank_account = bank_account
>>> invoice.save()
>>> invoice.click('post')
>>> invoice.state
u'posted'
>>> invoice.state == 'posted'
True
>>> invoice.amount_to_pay == Decimal(240)
True
>>> line1, line2, _, _ = invoice.move.lines
@ -184,8 +184,8 @@ Create credit note::
>>> credit_note.save()
>>> Invoice.post([credit_note.id], config.context)
>>> credit_note.reload()
>>> credit_note.state
u'posted'
>>> credit_note.state == 'posted'
True
>>> credit_note.amount_to_pay == Decimal(-44)
True
@ -244,5 +244,5 @@ Create a move that pays the pending amount::
>>> invoice.reload()
>>> invoice.amount_to_pay
Decimal('0.0')
>>> invoice.state
u'paid'
>>> invoice.state == 'paid'
True