From e8504a80388a0edbf690ddc44de75eeaf023a30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 17 Jan 2019 17:19:24 +0100 Subject: [PATCH] Add date to Pay Lines wizard issue7915 review51591002 --- 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(-) create mode 100644 view/move_line_pay_start_form.xml diff --git a/CHANGELOG b/CHANGELOG index 2c8571975f..49d3dfd70e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 --git a/__init__.py b/__init__.py index d83109df82..36a7898544 100644 --- a/__init__.py +++ b/__init__.py @@ -13,6 +13,7 @@ def register(): payment.Payment, account.MoveLine, payment.ProcessPaymentStart, + account.PayLineStart, account.PayLineAskJournal, account.Configuration, account.ConfigurationPaymentGroupSequence, diff --git a/account.py b/account.py index 00127874c4..c7464d4f25 100644 --- a/account.py +++ b/account.py @@ -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): diff --git a/account.xml b/account.xml index ebd9f665b2..5c0a347a27 100644 --- a/account.xml +++ b/account.xml @@ -70,6 +70,12 @@ this repository contains the full copyright notices and license terms. --> + + account.move.line.pay.start + form + move_line_pay_start_form + + account.move.line.pay.ask_journal form diff --git a/tests/scenario_account_payment.rst b/tests/scenario_account_payment.rst index e4d835a819..401fee3d6a 100644 --- a/tests/scenario_account_payment.rst +++ b/tests/scenario_account_payment.rst @@ -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: ... diff --git a/tests/scenario_account_payment_invoice.rst b/tests/scenario_account_payment_invoice.rst index 6d3cfa8141..f5e86e824b 100644 --- a/tests/scenario_account_payment_invoice.rst +++ b/tests/scenario_account_payment_invoice.rst @@ -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') diff --git a/view/move_line_pay_start_form.xml b/view/move_line_pay_start_form.xml new file mode 100644 index 0000000000..e65847939d --- /dev/null +++ b/view/move_line_pay_start_form.xml @@ -0,0 +1,7 @@ + + +
+