Update numbered at when refreshing invoice report

Closes #14462
This commit is contained in:
Cédric Krier
2026-01-03 19:18:24 +01:00
parent 9a518c653f
commit 7f0ffc22e6
5 changed files with 102 additions and 1 deletions
@@ -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 PaymentTermLine(metaclass=PoolMeta):
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()
+6 -1
View File
@@ -50,6 +50,8 @@ for dep in info.get('depends', []):
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 @@ setup(name=name,
),
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 @@ setup(name=name,
license='GPL-3',
python_requires='>=3.9',
install_requires=requires,
extras_require={
'test': tests_require,
},
zip_safe=False,
entry_points="""
[trytond.modules]
@@ -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)
@@ -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)
@@ -13,3 +13,5 @@ model:
account_invoice.PaymentTerm
account_invoice.PaymentTermLine
account_invoice.PaymentTermLineRelativeDelta
wizard:
account_invoice.RefreshInvoiceReport