Refactor payment wizard so statement lines can be updated through inheritance.
This commit is contained in:
parent
bddae61ca6
commit
be34acc103
21
sale.py
21
sale.py
|
@ -2,10 +2,8 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
from decimal import Decimal
|
||||
from sql import Cast, Literal
|
||||
from sql.aggregate import Sum
|
||||
from sql.conditionals import Coalesce
|
||||
from sql.functions import Substring, Position
|
||||
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
|
@ -222,7 +220,7 @@ class WizardSalePayment(Wizard):
|
|||
'party': sale.party.id,
|
||||
}
|
||||
|
||||
def transition_pay_(self):
|
||||
def get_statement_line(self, sale):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
Sale = pool.get('sale.sale')
|
||||
|
@ -238,8 +236,6 @@ class WizardSalePayment(Wizard):
|
|||
raise UserError(gettext('sale_payment.not_draft_statement',
|
||||
journal=form.journal.name))
|
||||
|
||||
active_id = Transaction().context.get('active_id', False)
|
||||
sale = Sale(active_id)
|
||||
if not sale.number:
|
||||
Sale.set_number([sale])
|
||||
|
||||
|
@ -252,16 +248,25 @@ class WizardSalePayment(Wizard):
|
|||
party=sale.party.name))
|
||||
|
||||
if form.payment_amount:
|
||||
payment = StatementLine(
|
||||
return StatementLine(
|
||||
statement=statements[0].id,
|
||||
date=Date.today(),
|
||||
amount=form.payment_amount,
|
||||
party=sale.party.id,
|
||||
account=account,
|
||||
description=sale.number,
|
||||
sale=active_id
|
||||
sale=sale.id,
|
||||
)
|
||||
payment.save()
|
||||
|
||||
def transition_pay_(self):
|
||||
Sale = Pool().get('sale.sale')
|
||||
|
||||
active_id = Transaction().context.get('active_id', False)
|
||||
sale = Sale(active_id)
|
||||
|
||||
line = self.get_statement_line(sale)
|
||||
if line:
|
||||
line.save()
|
||||
|
||||
if sale.total_amount != sale.paid_amount:
|
||||
return 'start'
|
||||
|
|
Loading…
Reference in New Issue