[16.0][FIX] account_chart_update: avoid fiscal position duplication when it's archived

This commit is contained in:
Eduardo López Peñalver
2024-11-19 11:19:52 +01:00
parent 47f7fb4820
commit dd6bf4fc41
4 changed files with 51 additions and 8 deletions

View File

@@ -117,6 +117,20 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
.. |maintainer-yajo| image:: https://github.com/yajo.png?size=40px
:target: https://github.com/yajo
:alt: yajo
.. |maintainer-rafaelbn| image:: https://github.com/rafaelbn.png?size=40px
:target: https://github.com/rafaelbn
:alt: rafaelbn
.. |maintainer-edlopen| image:: https://github.com/edlopen.png?size=40px
:target: https://github.com/edlopen
:alt: edlopen
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-yajo| |maintainer-rafaelbn| |maintainer-edlopen|
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/16.0/account_chart_update>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -8,11 +8,10 @@
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
@@ -275,7 +274,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +300,7 @@ span.option {
span.pre {
white-space: pre }
span.problematic, pre.problematic {
span.problematic {
color: red }
span.section-subtitle {
@@ -456,12 +455,12 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/yajo"><img alt="yajo" src="https://github.com/yajo.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/rafaelbn"><img alt="rafaelbn" src="https://github.com/rafaelbn.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/edlopen"><img alt="edlopen" src="https://github.com/edlopen.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/16.0/account_chart_update">OCA/account-financial-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>

View File

@@ -466,3 +466,33 @@ class TestAccountChartUpdate(TestAccountChartUpdateCommon):
self.assertTrue(list(self.fp.get_external_id().values())[0])
self.assertEqual(fp_rec.get_external_id().get(fp_id), expected_xmlid)
wizard.unlink()
def test_01_archived_fiscal_position(self):
# Test wizard won't duplicate existing fiscal positions when archived
self.fp_template.tax_ids.tax_dest_id = self.tax_template.id
self.fp_template.tax_ids.tax_src_id = self.tax_template.id
fiscal_position = self.env["account.fiscal.position"].search(
[("name", "=", self.fp_template.name), ("company_id", "=", self.company.id)]
)
wizard = self.wizard_obj.create(self.wizard_vals)
wizard.action_find_records()
wizard.action_update_records()
wizard.unlink()
fiscal_position.active = False
self.assertEqual(
fiscal_position.tax_ids.tax_src_id.name, self.tax_template.name
)
self.assertEqual(
fiscal_position.tax_ids.tax_dest_id.name, self.tax_template.name
)
wizard = self.wizard_obj.create(self.wizard_vals)
wizard.action_find_records()
wizard.action_update_records()
wizard.unlink()
self.assertTrue(fiscal_position.exists())
self.assertEqual(
fiscal_position.tax_ids.tax_src_id.name, self.tax_template.name
)
self.assertEqual(
fiscal_position.tax_ids.tax_dest_id.name, self.tax_template.name
)

View File

@@ -680,7 +680,7 @@ class WizardUpdateChartsAccounts(models.TransientModel):
continue
criteria = (field_name, "in", field_values)
result = fp_model.search(
result = fp_model.with_context(active_test=False).search(
[criteria, ("company_id", "=", self.company_id.id)], limit=1
)
if result: