changeset 8e9d429ef1b5 in modules/account_invoice:default details: https://hg.tryton.org/modules/account_invoice?cmd=changeset&node=8e9d429ef1b5 description: Rename split lines into reschedule lines
issue11069 review387661002 diffstat: __init__.py | 2 +- account.py | 8 +- doc/design.rst | 4 +- invoice.py | 2 +- tests/scenario_invoice_reschedule_lines.rst | 110 ++++++++++++++++++++++++++++ tests/scenario_invoice_split_lines.rst | 109 --------------------------- tests/test_account_invoice.py | 2 +- 7 files changed, 119 insertions(+), 118 deletions(-) diffs (299 lines): diff -r 02be5467be12 -r 8e9d429ef1b5 __init__.py --- a/__init__.py Tue Jan 25 23:30:35 2022 +0100 +++ b/__init__.py Wed Jan 26 00:32:20 2022 +0100 @@ -47,7 +47,7 @@ party.Replace, party.Erase, account.RenewFiscalYear, - account.SplitLines, + account.RescheduleLines, module='account_invoice', type_='wizard') Pool.register( invoice.InvoiceReport, diff -r 02be5467be12 -r 8e9d429ef1b5 account.py --- a/account.py Tue Jan 25 23:30:35 2022 +0100 +++ b/account.py Wed Jan 26 00:32:20 2022 +0100 @@ -413,14 +413,14 @@ return fiscalyear -class SplitLines(metaclass=PoolMeta): - __name__ = 'account.move.line.split' +class RescheduleLines(metaclass=PoolMeta): + __name__ = 'account.move.line.reschedule' @classmethod - def split_lines(cls, lines, journal, terms): + def reschedule_lines(cls, lines, journal, terms): pool = Pool() Invoice = pool.get('account.invoice') - move, balance_line = super().split_lines(lines, journal, terms) + move, balance_line = super().reschedule_lines(lines, journal, terms) move_ids = list({l.move.id for l in lines}) invoices = Invoice.search(['OR', diff -r 02be5467be12 -r 8e9d429ef1b5 doc/design.rst --- a/doc/design.rst Tue Jan 25 23:30:35 2022 +0100 +++ b/doc/design.rst Wed Jan 26 00:32:20 2022 +0100 @@ -108,8 +108,8 @@ ^^^^^^^^^^^^^^^^^^^^^^^ The *Reschedule Lines to Pay* wizard allows to modify the payment terms of the -remaining lines to pay using the `Split Lines <wizard-account.move.line.split>` -wizard. +remaining lines to pay using the `Reschedule Lines +<wizard-account.move.line.reschedule>` wizard. Reports ------- diff -r 02be5467be12 -r 8e9d429ef1b5 invoice.py --- a/invoice.py Tue Jan 25 23:30:35 2022 +0100 +++ b/invoice.py Wed Jan 26 00:32:20 2022 +0100 @@ -3226,7 +3226,7 @@ class RescheduleLinesToPay(Wizard): "Reschedule Lines to Pay" __name__ = 'account.invoice.lines_to_pay.reschedule' - start = StateAction('account.act_split_lines_wizard') + start = StateAction('account.act_reschedule_lines_wizard') def do_start(self, action): return action, { diff -r 02be5467be12 -r 8e9d429ef1b5 tests/scenario_invoice_reschedule_lines.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/scenario_invoice_reschedule_lines.rst Wed Jan 26 00:32:20 2022 +0100 @@ -0,0 +1,110 @@ +================================= +Invoice Reschedule Lines Scenario +================================= + +Imports:: + + >>> from decimal import Decimal + >>> from proteus import Model, Wizard + >>> from trytond.tests.tools import activate_modules + >>> from trytond.modules.company.tests.tools import ( + ... create_company, get_company) + >>> from trytond.modules.account.tests.tools import ( + ... create_fiscalyear, create_chart, get_accounts) + >>> from trytond.modules.account_invoice.tests.tools import ( + ... set_fiscalyear_invoice_sequences) + +Activate modules:: + + >>> config = activate_modules('account_invoice') + + >>> Invoice = Model.get('account.invoice') + >>> Journal = Model.get('account.journal') + >>> PaymentMethod = Model.get('account.invoice.payment.method') + +Create company:: + + >>> _ = create_company() + >>> company = get_company() + +Create fiscal year:: + + >>> fiscalyear = set_fiscalyear_invoice_sequences( + ... create_fiscalyear(company)) + >>> fiscalyear.click('create_period') + >>> period = fiscalyear.periods[0] + +Create chart of accounts:: + + >>> _ = create_chart(company) + >>> accounts = get_accounts(company) + + >>> journal_cash, = Journal.find([ + ... ('code', '=', 'CASH'), + ... ]) + + >>> payment_method = PaymentMethod() + >>> payment_method.name = "Cash" + >>> payment_method.journal = journal_cash + >>> payment_method.credit_account = accounts['cash'] + >>> payment_method.debit_account = accounts['cash'] + >>> payment_method.save() + +Create party:: + + >>> Party = Model.get('party.party') + >>> party = Party(name='Party') + >>> party.save() + +Post customer invoice:: + + >>> invoice = Invoice() + >>> invoice.party = party + >>> line = invoice.lines.new() + >>> line.account = accounts['revenue'] + >>> line.quantity = 1 + >>> line.unit_price = Decimal(10) + >>> invoice.click('post') + >>> invoice.state + 'posted' + >>> len(invoice.lines_to_pay) + 1 + >>> invoice.amount_to_pay + Decimal('10.00') + +Reschedule line:: + + >>> reschedule = Wizard( + ... 'account.invoice.lines_to_pay.reschedule', [invoice]) + >>> reschedule_lines, = reschedule.actions + >>> reschedule_lines.form.total_amount + Decimal('10.00') + >>> reschedule_lines.form.start_date = period.end_date + >>> reschedule_lines.form.frequency ='monthly' + >>> reschedule_lines.form.number = 2 + >>> reschedule_lines.execute('preview') + >>> reschedule_lines.execute('reschedule') + + >>> invoice.reload() + >>> invoice.state + 'posted' + >>> len(invoice.lines_to_pay) + 4 + >>> len([l for l in invoice.lines_to_pay if not l.reconciliation]) + 2 + >>> invoice.amount_to_pay + Decimal('10.00') + +Pay the invoice:: + + >>> pay = Wizard('account.invoice.pay', [invoice]) + >>> pay.form.amount + Decimal('10.00') + >>> pay.form.payment_method = payment_method + >>> pay.execute('choice') + >>> pay.state + 'end' + >>> invoice.state + 'paid' + >>> len(invoice.reconciliation_lines) + 1 diff -r 02be5467be12 -r 8e9d429ef1b5 tests/scenario_invoice_split_lines.rst --- a/tests/scenario_invoice_split_lines.rst Tue Jan 25 23:30:35 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -============================ -Invoice Split Lines Scenario -============================ - -Imports:: - - >>> from decimal import Decimal - >>> from proteus import Model, Wizard - >>> from trytond.tests.tools import activate_modules - >>> from trytond.modules.company.tests.tools import ( - ... create_company, get_company) - >>> from trytond.modules.account.tests.tools import ( - ... create_fiscalyear, create_chart, get_accounts) - >>> from trytond.modules.account_invoice.tests.tools import ( - ... set_fiscalyear_invoice_sequences) - -Activate modules:: - - >>> config = activate_modules('account_invoice') - - >>> Invoice = Model.get('account.invoice') - >>> Journal = Model.get('account.journal') - >>> PaymentMethod = Model.get('account.invoice.payment.method') - -Create company:: - - >>> _ = create_company() - >>> company = get_company() - -Create fiscal year:: - - >>> fiscalyear = set_fiscalyear_invoice_sequences( - ... create_fiscalyear(company)) - >>> fiscalyear.click('create_period') - >>> period = fiscalyear.periods[0] - -Create chart of accounts:: - - >>> _ = create_chart(company) - >>> accounts = get_accounts(company) - - >>> journal_cash, = Journal.find([ - ... ('code', '=', 'CASH'), - ... ]) - - >>> payment_method = PaymentMethod() - >>> payment_method.name = "Cash" - >>> payment_method.journal = journal_cash - >>> payment_method.credit_account = accounts['cash'] - >>> payment_method.debit_account = accounts['cash'] - >>> payment_method.save() - -Create party:: - - >>> Party = Model.get('party.party') - >>> party = Party(name='Party') - >>> party.save() - -Post customer invoice:: - - >>> invoice = Invoice() - >>> invoice.party = party - >>> line = invoice.lines.new() - >>> line.account = accounts['revenue'] - >>> line.quantity = 1 - >>> line.unit_price = Decimal(10) - >>> invoice.click('post') - >>> invoice.state - 'posted' - >>> len(invoice.lines_to_pay) - 1 - >>> invoice.amount_to_pay - Decimal('10.00') - -Reschedule line:: - - >>> reschedule = Wizard('account.invoice.lines_to_pay.reschedule', [invoice]) - >>> split_lines, = reschedule.actions - >>> split_lines.form.total_amount - Decimal('10.00') - >>> split_lines.form.start_date = period.end_date - >>> split_lines.form.frequency ='monthly' - >>> split_lines.form.number = 2 - >>> split_lines.execute('preview') - >>> split_lines.execute('split') - - >>> invoice.reload() - >>> invoice.state - 'posted' - >>> len(invoice.lines_to_pay) - 4 - >>> len([l for l in invoice.lines_to_pay if not l.reconciliation]) - 2 - >>> invoice.amount_to_pay - Decimal('10.00') - -Pay the invoice:: - - >>> pay = Wizard('account.invoice.pay', [invoice]) - >>> pay.form.amount - Decimal('10.00') - >>> pay.form.payment_method = payment_method - >>> pay.execute('choice') - >>> pay.state - 'end' - >>> invoice.state - 'paid' - >>> len(invoice.reconciliation_lines) - 1 diff -r 02be5467be12 -r 8e9d429ef1b5 tests/test_account_invoice.py --- a/tests/test_account_invoice.py Tue Jan 25 23:30:35 2022 +0100 +++ b/tests/test_account_invoice.py Wed Jan 26 00:32:20 2022 +0100 @@ -310,7 +310,7 @@ checker=doctest_checker, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) suite.addTests(doctest.DocFileSuite( - 'scenario_invoice_split_lines.rst', + 'scenario_invoice_reschedule_lines.rst', tearDown=doctest_teardown, encoding='utf-8', checker=doctest_checker, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))