Add date to Pay Lines wizard

issue7915
review51591002
This commit is contained in:
Cédric Krier committed 2019-01-17 17:19:24 +01:00
1 parent 41319487ce
commit e8504a8038
7 files changed
+58 -10

No files matched your search

+2
View File
@@ -1,3 +1,5 @@
* Add date to Pay Lines wizard
Version 5.0.0 - 2018-10-01
* Bug fixes (see mercurial logs for details)
* Remove support for Python 2.7
+1
View File
@@ -13,6 +13,7 @@ def register():
payment.Payment,
account.MoveLine,
payment.ProcessPaymentStart,
account.PayLineStart,
account.PayLineAskJournal,
account.Configuration,
account.ConfigurationPaymentGroupSequence,
+24 -3
View File
@@ -177,6 +177,20 @@ class MoveLine(metaclass=PoolMeta):
})
class PayLineStart(ModelView):
"Pay Line"
__name__ = 'account.move.line.pay.start'
date = fields.Date(
"Date", required=True,
help="When the payments are scheduled to happen.")
@classmethod
def default_date(cls):
pool = Pool()
Date = pool.get('ir.date')
return Date.today()
class PayLineAskJournal(ModelView):
'Pay Line'
__name__ = 'account.move.line.pay.ask_journal'
@@ -196,11 +210,17 @@ class PayLineAskJournal(ModelView):
class PayLine(Wizard):
'Pay Line'
__name__ = 'account.move.line.pay'
start = StateTransition()
start = StateView(
'account.move.line.pay.start',
'account_payment.move_line_pay_start_view_form', [
Button("Cancel", 'end', 'tryton-cancel'),
Button("Pay", 'next_', 'tryton-ok', default=True),
])
next_ = StateTransition()
ask_journal = StateView('account.move.line.pay.ask_journal',
'account_payment.move_line_pay_ask_journal_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Pay', 'start', 'tryton-ok', default=True),
Button('Pay', 'next_', 'tryton-ok', default=True),
])
pay = StateAction('account_payment.act_payment_form')
@@ -236,7 +256,7 @@ class PayLine(Wizard):
if key not in journals:
return key
def transition_start(self):
def transition_next_(self):
if self._missing_journal():
return 'ask_journal'
else:
@@ -276,6 +296,7 @@ class PayLine(Wizard):
kind=kind,
amount=line.payment_amount,
line=line,
date=self.start.date,
)
def do_pay(self, action):
+6
View File
@@ -70,6 +70,12 @@ this repository contains the full copyright notices and license terms. -->
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.ui.view" id="move_line_pay_start_view_form">
<field name="model">account.move.line.pay.start</field>
<field name="type">form</field>
<field name="name">move_line_pay_start_form</field>
</record>
<record model="ir.ui.view" id="move_line_pay_ask_journal_view_form">
<field name="model">account.move.line.pay.ask_journal</field>
<field name="type">form</field>
+12 -4
View File
@@ -11,6 +11,7 @@ Imports::
... get_company
>>> from trytond.modules.account.tests.tools import create_fiscalyear, \
... create_chart, get_accounts
>>> tomorrow = datetime.date.today() + datetime.timedelta(days=1)
Install account_payment::
@@ -65,10 +66,14 @@ Partially pay line::
>>> Payment = Model.get('account.payment')
>>> line, = [l for l in move.lines if l.account == payable]
>>> pay_line = Wizard('account.move.line.pay', [line])
>>> pay_line.form.date = tomorrow
>>> pay_line.execute('next_')
>>> pay_line.form.journal == payment_journal
True
>>> pay_line.execute('start')
>>> pay_line.execute('next_')
>>> payment, = Payment.find()
>>> payment.date == tomorrow
True
>>> payment.party == supplier
True
>>> payment.amount
@@ -89,7 +94,8 @@ Partially pay line::
Partially fail to pay the remaining::
>>> pay_line = Wizard('account.move.line.pay', [line])
>>> pay_line.execute('start')
>>> pay_line.execute('next_')
>>> pay_line.execute('next_')
>>> payment, = Payment.find([('state', '=', 'draft')])
>>> payment.amount
Decimal('30.00')
@@ -113,7 +119,8 @@ Pay line and block it after::
>>> move.click('post')
>>> line, = [l for l in move.lines if l.account == payable]
>>> pay_line = Wizard('account.move.line.pay', [line])
>>> pay_line.execute('start')
>>> pay_line.execute('next_')
>>> pay_line.execute('next_')
>>> len(line.payments)
1
@@ -124,7 +131,8 @@ Pay line and block it after::
Try to pay blocked line::
>>> pay_line = Wizard('account.move.line.pay', [line])
>>> pay_line.execute('start') # doctest: +IGNORE_EXCEPTION_DETAIL
>>> pay_line.execute('next_')
>>> pay_line.execute('next_') # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
BlockedWarning: ...
+6 -3
View File
@@ -76,7 +76,8 @@ Partially pay line::
>>> Payment = Model.get('account.payment')
>>> pay_line = Wizard('account.move.line.pay', [line_to_pay])
>>> pay_line.execute('start')
>>> pay_line.execute('next_')
>>> pay_line.execute('next_')
>>> payment, = Payment.find()
>>> payment.amount = Decimal('20')
>>> payment.click('approve')
@@ -112,9 +113,11 @@ Create multiple valid payments for one line::
>>> line_to_pay, = invoice.lines_to_pay
>>> pay_line = Wizard('account.move.line.pay', [line_to_pay])
>>> pay_line.execute('start')
>>> pay_line.execute('next_')
>>> pay_line.execute('next_')
>>> pay_line = Wizard('account.move.line.pay', [line_to_pay])
>>> pay_line.execute('start')
>>> pay_line.execute('next_')
>>> pay_line.execute('next_')
>>> payments = Payment.find([('state', '=', 'draft')])
>>> for payment in payments:
... payment.amount = Decimal('30')
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="date"/>
<field name="date"/>
</form>