Update numbered at when refreshing invoice report

Closes #14462
(grafted from 19c5422323c6b0da87e4ba76a95075d95d735e5e)

--HG--
branch : 7.0
This commit is contained in:
Cédric Krier
2026-01-03 19:18:24 +01:00
parent 3ebc155d56
commit 05a449a1b3
5 changed files with 108 additions and 1 deletions
@@ -16,3 +16,6 @@ def register():
account_invoice.PaymentTermLine,
account_invoice.PaymentTermLineRelativeDelta,
module='account_invoice_history', type_='model')
Pool.register(
account_invoice.RefreshInvoiceReport,
module='account_invoice_history', type_='wizard')
@@ -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
@@ -47,6 +47,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',
@@ -70,7 +72,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',
@@ -116,6 +118,9 @@ setup(name=name,
license='GPL-3',
python_requires='>=3.8',
install_requires=requires,
extras_require={
'test': tests_require,
},
zip_safe=False,
entry_points="""
[trytond.modules]
@@ -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
@@ -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)