details: https://code.tryton.org/tryton/commit/f1dff2886e67
branch: 7.8
user: Cédric Krier <[email protected]>
date: Sat Jan 03 19:18:24 2026 +0100
description:
Update numbered at when refreshing invoice report
Closes #14462
(grafted from 19c5422323c6b0da87e4ba76a95075d95d735e5e)
diffstat:
modules/account_invoice_history/account_invoice.py |
14 +
modules/account_invoice_history/setup.py |
7 +-
modules/account_invoice_history/tests/scenario_invoice_report_revision.rst |
72 ++++++++++
modules/account_invoice_history/tests/test_scenario.py |
8 +
modules/account_invoice_history/tryton.cfg |
2 +
5 files changed, 102 insertions(+), 1 deletions(-)
diffs (155 lines):
diff -r f54bcdb6ac81 -r f1dff2886e67
modules/account_invoice_history/account_invoice.py
--- a/modules/account_invoice_history/account_invoice.py Sat Jan 03
19:17:20 2026 +0100
+++ b/modules/account_invoice_history/account_invoice.py Sat Jan 03
19:18:24 2026 +0100
@@ -1,5 +1,8 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
+
+from sql.functions import CurrentTimestamp
+
from trytond.pool import PoolMeta
@@ -16,3 +19,14 @@
class PaymentTermLineRelativeDelta(metaclass=PoolMeta):
__name__ = 'account.invoice.payment_term.line.delta'
_history = True
+
+
+class RefreshInvoiceReport(metaclass=PoolMeta):
+ __name__ = 'account.invoice.refresh_invoice_report'
+
+ def transition_archive(self):
+ if records := [r for r in self.records if r.numbered_at]:
+ self.model.write(records, {
+ 'numbered_at': CurrentTimestamp(),
+ })
+ return super().transition_archive()
diff -r f54bcdb6ac81 -r f1dff2886e67 modules/account_invoice_history/setup.py
--- a/modules/account_invoice_history/setup.py Sat Jan 03 19:17:20 2026 +0100
+++ b/modules/account_invoice_history/setup.py Sat Jan 03 19:18:24 2026 +0100
@@ -50,6 +50,8 @@
requires.append(get_require_version('trytond_%s' % dep))
requires.append(get_require_version('trytond'))
+tests_require = [get_require_version('proteus')]
+
setup(name=name,
version=version,
description='Tryton module to historize invoices',
@@ -74,7 +76,7 @@
),
package_data={
'trytond.modules.account_invoice_history': (info.get('xml', [])
- + ['tryton.cfg', 'locale/*.po']),
+ + ['tryton.cfg', 'locale/*.po', 'tests/*.rst']),
},
classifiers=[
'Development Status :: 5 - Production/Stable',
@@ -120,6 +122,9 @@
license='GPL-3',
python_requires='>=3.9',
install_requires=requires,
+ extras_require={
+ 'test': tests_require,
+ },
zip_safe=False,
entry_points="""
[trytond.modules]
diff -r f54bcdb6ac81 -r f1dff2886e67
modules/account_invoice_history/tests/scenario_invoice_report_revision.rst
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/modules/account_invoice_history/tests/scenario_invoice_report_revision.rst
Sat Jan 03 19:18:24 2026 +0100
@@ -0,0 +1,72 @@
+================================
+Invoice Report Revision Scenario
+================================
+
+Imports::
+
+ >>> import datetime as dt
+ >>> from decimal import Decimal
+
+ >>> from proteus import Model, Wizard
+ >>> from trytond.modules.account.tests.tools import (
+ ... create_chart, create_fiscalyear, get_accounts)
+ >>> from trytond.modules.account_invoice.tests.tools import (
+ ... set_fiscalyear_invoice_sequences)
+ >>> from trytond.modules.company.tests.tools import create_company
+ >>> from trytond.tests.tools import activate_modules, assertNotEqual
+
+ >>> today = dt.date.today()
+
+Activate modules::
+
+ >>> config = activate_modules(
+ ... 'account_invoice_history', create_company, create_chart)
+
+ >>> Invoice = Model.get('account.invoice')
+ >>> Journal = Model.get('account.journal')
+ >>> Move = Model.get('account.move')
+ >>> Party = Model.get('party.party')
+ >>> PaymentMethod = Model.get('account.invoice.payment.method')
+ >>> ProductCategory = Model.get('product.category')
+ >>> ProductTemplate = Model.get('product.template')
+ >>> ProductUom = Model.get('product.uom')
+ >>> Sequence = Model.get('ir.sequence')
+
+Create fiscal year::
+
+ >>> fiscalyear = set_fiscalyear_invoice_sequences(
+ ... create_fiscalyear())
+ >>> fiscalyear.click('create_period')
+ >>> period = fiscalyear.periods[0]
+
+Get accounts::
+
+ >>> accounts = get_accounts()
+
+Create party::
+
+ >>> party = Party(name="Party")
+ >>> party.save()
+
+Post an invoice::
+
+ >>> invoice = Invoice()
+ >>> invoice.type = 'out'
+ >>> invoice.party = party
+ >>> invoice.invoice_date = today
+ >>> line = invoice.lines.new()
+ >>> line.account = accounts['revenue']
+ >>> line.quantity = 5
+ >>> line.unit_price = Decimal('20')
+ >>> invoice.click('post')
+ >>> invoice.state
+ 'posted'
+
+ >>> numbered_at = invoice.numbered_at
+
+Execute update invoice report wizard::
+
+ >>> refresh_invoice_report = Wizard(
+ ... 'account.invoice.refresh_invoice_report', [invoice])
+
+ >>> assertNotEqual(invoice.numbered_at, numbered_at)
diff -r f54bcdb6ac81 -r f1dff2886e67
modules/account_invoice_history/tests/test_scenario.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/account_invoice_history/tests/test_scenario.py Sat Jan 03
19:18:24 2026 +0100
@@ -0,0 +1,8 @@
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+
+from trytond.tests.test_tryton import load_doc_tests
+
+
+def load_tests(*args, **kwargs):
+ return load_doc_tests(__name__, __file__, *args, **kwargs)
diff -r f54bcdb6ac81 -r f1dff2886e67 modules/account_invoice_history/tryton.cfg
--- a/modules/account_invoice_history/tryton.cfg Sat Jan 03 19:17:20
2026 +0100
+++ b/modules/account_invoice_history/tryton.cfg Sat Jan 03 19:18:24
2026 +0100
@@ -13,3 +13,5 @@
account_invoice.PaymentTerm
account_invoice.PaymentTermLine
account_invoice.PaymentTermLineRelativeDelta
+wizard:
+ account_invoice.RefreshInvoiceReport