changeset 9820cc1404e6 in modules/account_payment:default
details:
https://hg.tryton.org/modules/account_payment?cmd=changeset;node=9820cc1404e6
description:
Add date to Pay Lines wizard
issue7915
review51591002
diffstat:
CHANGELOG | 2 ++
__init__.py | 1 +
account.py | 27 ++++++++++++++++++++++++---
account.xml | 6 ++++++
tests/scenario_account_payment.rst | 16 ++++++++++++----
tests/scenario_account_payment_invoice.rst | 9 ++++++---
view/move_line_pay_start_form.xml | 7 +++++++
7 files changed, 58 insertions(+), 10 deletions(-)
diffs (192 lines):
diff -r 4aee9cae550a -r 9820cc1404e6 CHANGELOG
--- a/CHANGELOG Tue Jan 08 16:46:13 2019 +0100
+++ b/CHANGELOG Thu Jan 17 17:19:24 2019 +0100
@@ -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
diff -r 4aee9cae550a -r 9820cc1404e6 __init__.py
--- a/__init__.py Tue Jan 08 16:46:13 2019 +0100
+++ b/__init__.py Thu Jan 17 17:19:24 2019 +0100
@@ -13,6 +13,7 @@
payment.Payment,
account.MoveLine,
payment.ProcessPaymentStart,
+ account.PayLineStart,
account.PayLineAskJournal,
account.Configuration,
account.ConfigurationPaymentGroupSequence,
diff -r 4aee9cae550a -r 9820cc1404e6 account.py
--- a/account.py Tue Jan 08 16:46:13 2019 +0100
+++ b/account.py Thu Jan 17 17:19:24 2019 +0100
@@ -177,6 +177,20 @@
})
+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 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 @@
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 @@
kind=kind,
amount=line.payment_amount,
line=line,
+ date=self.start.date,
)
def do_pay(self, action):
diff -r 4aee9cae550a -r 9820cc1404e6 account.xml
--- a/account.xml Tue Jan 08 16:46:13 2019 +0100
+++ b/account.xml Thu Jan 17 17:19:24 2019 +0100
@@ -70,6 +70,12 @@
<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>
diff -r 4aee9cae550a -r 9820cc1404e6 tests/scenario_account_payment.rst
--- a/tests/scenario_account_payment.rst Tue Jan 08 16:46:13 2019 +0100
+++ b/tests/scenario_account_payment.rst Thu Jan 17 17:19:24 2019 +0100
@@ -11,6 +11,7 @@
... 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 @@
>>> 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 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 @@
>>> 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 @@
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: ...
diff -r 4aee9cae550a -r 9820cc1404e6 tests/scenario_account_payment_invoice.rst
--- a/tests/scenario_account_payment_invoice.rst Tue Jan 08 16:46:13
2019 +0100
+++ b/tests/scenario_account_payment_invoice.rst Thu Jan 17 17:19:24
2019 +0100
@@ -76,7 +76,8 @@
>>> 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 @@
>>> 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')
diff -r 4aee9cae550a -r 9820cc1404e6 view/move_line_pay_start_form.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/view/move_line_pay_start_form.xml Thu Jan 17 17:19:24 2019 +0100
@@ -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>