-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Description
Odoo Version
- 16.0
- 17.0
- 18.0
- Other (specify)
Steps to Reproduce
Editing CZ Company's address fails with Validation Error.
Also happens for any other company that has cz chart template and bills similar to the standard demo data. Typically this occurs for address edits in these situations:
- In a demo database: With Invoicing module and
l10n_czmodules installed and demo data loaded. - When running unit tests: Some (Odoo or 3rd party module) tests create journal entries in previous months leaving the
taxable_supply_dateemtpy which leads to change of names of those entries whenever company address is edited (or some other reason for recomputing dates occures). - In production databases when the user or some (3rd party) module creates/updates a journal entry providing inconsistent values for
dateandtaxable_supply_datefields.
Steps to reproduce
- Login as
admininto a runbot environment for 18.0 Community (or Enterprise) - Install
l10n_cz - Switch to
CZ Companycompany - Go to Settings / Users & Companies
- Open
CZ Company - Change City from
PrahatoBrno. Alternatively change ZIP or some other address field. - Click Save
- => Error popup with the Validation Error is displayed and it's not possible to save the changes
Current behavior
The address change is not saved and an error message is displayed instead:
Validation Error
The Date (06/30/2024) you've entered isn't aligned with the existing sequence number (BILL/2025/09/0002). Clear the sequence number to proceed.
To maintain date-based sequences, select entries and use the resequence option from the actions menu, available in developer mode.
Expected behavior
The address update is saved without any error messages.
Root cause
The problem is related to commit 1038a22edbb9ad1ea7ffecf532e0ab6592b6dc26 and does not occur in previous versions:
Author: Hesham Saleh <hsal@odoo.com>
AuthorDate: Fri May 30 14:08:10 2025 +0300
Commit: Hesham Saleh <hsal@odoo.com>
CommitDate: Fri Aug 29 18:06:17 2025 +0000
[ADD] l10n_pl_taxable_supply_date: Added taxable supply date for Poland
This new module aims at adding support for taxable supply date in Poland.
The account module provides demo data for a vendor bill (with XML ID demo_invoice_equipment_purchase) with invoice_date field set to 2024-06-17 (fifteen months ago from the current date). A bill with those values is created for CZ Company as follows:
- A compute function in
accountmodule sets thedateof the bill to 2024-06-30 (as the end of the month ofinvoice_datefield). - The data has no value for
taxable_supply_datefield so compute funcion in the new code in this commit computes a value for it as today's date - 2025-09-09. - The new code also makes the
datefield dependent ontaxable_supply_dateso thedateis computed once more and the value oftaxable_supply_dateis copied intodate. So thedateis effectively overridden by new code ofl10n_czto 2025-09-09. - The bill is posted and gets name BILL/2025/09/0002 - based on its date.
When the bill's company's address is edited it basically means that country_code of every journal entry of the company is edited as it is a related field. But the new code in l10n_cz makes taxable_supply_date dependent on country_code so taxable_supply_date is recomuted as well. And transitively date is recomputed as well (see step 3 above). The initial value for date is taken as the end of the month of the invoice_date value - as implemented in a compute function in the account module. So we have an initial date value 2024-06-30. The extension of the compute function in l10n_cz kicks in again but this time it does not override the value because it skips updating of records that have already been posted.
So the end result is that BILL/2025/09/0002 bill's date is changed from 2025-09-09 to 2024-06-30 which means that the account module starts computing a new name for it. And it produces a new name: 'BILL/2024/'. The account module also applies a validation function for each name change. And this validation refuses to accept the new name and throws the Validation error.
Ideas for solution
- Ideal fix is to prevent Odoo from changing accounting date of posted journal entries.
- If that is not feasible then the next best thing is to make the date computation nin
l10n_czmore consistent: So that it computes the same date regardless if the record is in draft or a posted.
Workaround for fixing the issue for the demo bills
I see a possibility to change l10n_cz code so that it provides reasonable values for taxable_supply_date field. Setting it into the same month into which invoice_date belongs. Can be done by adding new _get_demo_data_move() function into l10n_cz/models/chart_template.cz - similarly as l10n_ar does.
Traceback
Traceback (most recent call last):
File "/data/build/odoo/odoo/http.py", line 2233, in _transactioning
return service_model.retrying(func, env=self.env)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/build/odoo/odoo/service/model.py", line 178, in retrying
env.cr.flush() # submit the changes to the database
^^^^^^^^^^^^^^
File "/data/build/odoo/odoo/sql_db.py", line 179, in flush
self.transaction.flush()
File "/data/build/odoo/odoo/orm/environments.py", line 579, in flush
self.default_env.flush_all()
File "/data/build/odoo/odoo/orm/environments.py", line 370, in flush_all
self._recompute_all()
File "/data/build/odoo/odoo/orm/environments.py", line 363, in _recompute_all
self[field.model_name]._recompute_field(field)
File "/data/build/odoo/odoo/orm/models.py", line 6646, in _recompute_field
field.recompute(records)
File "/data/build/odoo/odoo/orm/fields.py", line 1892, in recompute
apply_except_missing(self.compute_value, recs)
File "/data/build/odoo/odoo/orm/fields.py", line 1865, in apply_except_missing
func(records)
File "/data/build/odoo/odoo/orm/fields.py", line 1914, in compute_value
records._compute_field_value(self)
File "/data/build/odoo/addons/mail/models/mail_thread.py", line 469, in _compute_field_value
return super()._compute_field_value(field)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/build/odoo/odoo/orm/models.py", line 4626, in _compute_field_value
determine(field.compute, self)
File "/data/build/odoo/odoo/orm/fields.py", line 81, in determine
return needle(*args)
^^^^^^^^^^^^^
File "/data/build/odoo/addons/l10n_cz/models/account_move.py", line 17, in _compute_date
super()._compute_date()
File "/data/build/odoo/addons/account/models/account_move.py", line 816, in _compute_date
accounting_date = move._get_accounting_date(accounting_date, move._affect_tax_report())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/build/odoo/addons/account/models/account_move.py", line 6020, in _get_accounting_date
highest_name = self.highest_name or self._get_last_sequence(relaxed=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/build/odoo/addons/account/models/sequence_mixin.py", line 306, in _get_last_sequence
self.flush_model([self._sequence_field, 'sequence_number', 'sequence_prefix'])
File "/data/build/odoo/odoo/orm/models.py", line 6050, in flush_model
self._recompute_model(fnames)
File "/data/build/odoo/odoo/orm/models.py", line 6618, in _recompute_model
self._recompute_field(field)
File "/data/build/odoo/odoo/orm/models.py", line 6646, in _recompute_field
field.recompute(records)
File "/data/build/odoo/odoo/orm/fields.py", line 1892, in recompute
apply_except_missing(self.compute_value, recs)
File "/data/build/odoo/odoo/orm/fields.py", line 1865, in apply_except_missing
func(records)
File "/data/build/odoo/odoo/orm/fields.py", line 1914, in compute_value
records._compute_field_value(self)
File "/data/build/odoo/addons/mail/models/mail_thread.py", line 469, in _compute_field_value
return super()._compute_field_value(field)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/build/odoo/odoo/orm/models.py", line 4631, in _compute_field_value
self.filtered('id')._validate_fields(fnames)
File "/data/build/odoo/odoo/orm/models.py", line 1261, in _validate_fields
check(records)
File "/data/build/odoo/odoo/orm/models.py", line 521, in wrapper
return func(self)
^^^^^^^^^^
File "/data/build/odoo/addons/account/models/sequence_mixin.py", line 173, in _constrains_date_sequence
raise ValidationError(_(
odoo.exceptions.ValidationError: The Date (06/30/2024) you've entered isn't aligned with the existing sequence number (BILL/2025/09/0002). Clear the sequence number to proceed.
To maintain date-based sequences, select entries and use the resequence option from the actions menu, available in developer mode.
Affected versions
- 18.0
- 18.4
Log Output
Support Ticket
No response