details: https://code.tryton.org/tryton/commit/55e9ae928305
branch: 7.0
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/__init__.py |
3 +
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 |
77 ++++++++++
modules/account_invoice_history/tests/test_scenario.py |
8 +
5 files changed, 108 insertions(+), 1 deletions(-)
diffs (161 lines):
diff -r 95b8c52d3bdc -r 55e9ae928305 modules/account_invoice_history/__init__.py
--- a/modules/account_invoice_history/__init__.py Sat Jan 03 13:45:10
2026 +0100
+++ b/modules/account_invoice_history/__init__.py Sat Jan 03 19:18:24
2026 +0100
@@ -16,3 +16,6 @@
account_invoice.PaymentTermLine,
account_invoice.PaymentTermLineRelativeDelta,
module='account_invoice_history', type_='model')
+ Pool.register(
+ account_invoice.RefreshInvoiceReport,
+ module='account_invoice_history', type_='wizard')
diff -r 95b8c52d3bdc -r 55e9ae928305
modules/account_invoice_history/account_invoice.py
--- a/modules/account_invoice_history/account_invoice.py Sat Jan 03
13:45:10 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 95b8c52d3bdc -r 55e9ae928305 modules/account_invoice_history/setup.py
--- a/modules/account_invoice_history/setup.py Sat Jan 03 13:45:10 2026 +0100
+++ b/modules/account_invoice_history/setup.py Sat Jan 03 19:18:24 2026 +0100
@@ -47,6 +47,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',
@@ -70,7 +72,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',
@@ -116,6 +118,9 @@
license='GPL-3',
python_requires='>=3.8',
install_requires=requires,
+ extras_require={
+ 'test': tests_require,
+ },
zip_safe=False,
entry_points="""
[trytond.modules]
diff -r 95b8c52d3bdc -r 55e9ae928305
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,77 @@
+================================
+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
+
+ >>> today = dt.date.today()
+
+Activate modules::
+
+ >>> config = activate_modules('account_invoice_history')
+
+ >>> 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 company::
+
+ >>> _ = create_company()
+
+Create fiscal year::
+
+ >>> fiscalyear = set_fiscalyear_invoice_sequences(
+ ... create_fiscalyear())
+ >>> fiscalyear.click('create_period')
+ >>> period = fiscalyear.periods[0]
+
+Get accounts::
+
+ >>> _ = create_chart()
+ >>> 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])
+
+ >>> invoice.numbered_at != numbered_at
+ True
diff -r 95b8c52d3bdc -r 55e9ae928305
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)