[FIX] l10n_nl: duplicate tax report

Impossible to duplicate the Dutch tax report due to a unique code constraint. I also made sure that this issue does not occur in any other localization.

How to reproduce:
 - Activate debug mode
 - Configuration>Accounting Reports
 - Open the form view of the Dutch VAT Report
 - action>duplicate

 ==> Validation Error:
The operation cannot be completed: A report line with the same code already exists.

closes odoo/odoo#124176

Task: 3199129
X-original-commit: affd307665f3e745e9d2a84b3c9ec213370956c3
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
Signed-off-by: hupo-odoo <hupo@odoo.com>
This commit is contained in:
hupo-odoo
2023-06-07 21:34:46 +02:00
parent d0f3341f8d
commit c2db5515a2
2 changed files with 3 additions and 2 deletions
+3 -1
View File
@@ -296,7 +296,7 @@ class AccountReportLine(models.Model):
copied_line = self.copy({
'report_id': copied_report.id,
'parent_id': parent and parent.id,
'code': self.code and self._get_copied_code(),
'code': self._get_copied_code(),
})
# Keep track of old_code -> new_code in a mutable dict
@@ -327,6 +327,8 @@ class AccountReportLine(models.Model):
:return: an unique code for the copied account.report.line
'''
self.ensure_one()
if not self.code:
return False
code = self.code + '_COPY'
while self.search_count([('code', '=', code)]) > 0:
code += '_COPY'
@@ -287,7 +287,6 @@
</record>
<record id="tax_report_rub_btw_5c" model="account.report.line">
<field name="name">5c. Subtotal (heading 5a minus 5b) (VAT)</field>
<field name="code"/>
<field name="aggregation_formula">NLTAX_B1.balance + NLTAX_B2.balance + NLTAX_B4a.balance + NLTAX_B4b.balance - NLTAX_B5b.balance</field>
</record>
<record id="tax_report_rub_btw_5d" model="account.report.line">