Skip to content

Commit beaa1b8

Browse files
Joel EstradaEmilioPascual
authored andcommitted
[IMP] account_chart_update: Visible unchecked fields by default
@moduon MT-12947
1 parent 3994f4e commit beaa1b8

File tree

4 files changed

+67
-37
lines changed

4 files changed

+67
-37
lines changed

account_chart_update/README.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
===========================================================
62
Detect changes and update the Account Chart from a template
73
===========================================================
@@ -17,7 +13,7 @@ Detect changes and update the Account Chart from a template
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Beta
20-
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2218
:alt: License: AGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github
@@ -112,6 +108,7 @@ Contributors
112108
- Luis J. Salvatierra
113109

114110
- Daniel Reis (dreis@opensourceintegrators.com)
111+
- Joel Estrada (https://www.moduon.team/)
115112

116113
Maintainers
117114
-----------

account_chart_update/readme/CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
- [Factor Libre](https://factorlibre.com):
1313
- Luis J. Salvatierra
1414
- Daniel Reis (dreis@opensourceintegrators.com)
15+
- Joel Estrada (<https://www.moduon.team/>)

account_chart_update/static/description/index.html

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Detect changes and update the Account Chart from a template</title>
77
<style type="text/css">
88

99
/*
@@ -360,21 +360,16 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="detect-changes-and-update-the-account-chart-from-a-template">
364+
<h1 class="title">Detect changes and update the Account Chart from a template</h1>
364365

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="detect-changes-and-update-the-account-chart-from-a-template">
370-
<h1>Detect changes and update the Account Chart from a template</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375370
!! source digest: sha256:4d72193905c8f22ba5d52b73b3102141bdfff6d614502cd05450666c53c0b727
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/18.0/account_chart_update"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-18-0/account-financial-tools-18-0-account_chart_update"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/18.0/account_chart_update"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-18-0/account-financial-tools-18-0-account_chart_update"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378373
<p>This is a pretty useful tool to update Odoo installations after tax
379374
reforms on the official charts of accounts, or to apply fixes performed
380375
on the chart template.</p>
@@ -402,7 +397,7 @@ <h1>Detect changes and update the Account Chart from a template</h1>
402397
</ul>
403398
</div>
404399
<div class="section" id="usage">
405-
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
400+
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
406401
<p>The wizard, accesible from <em>Accounting &gt; Settings &gt; Update Chart
407402
Template</em>, lets the user select what kind of objects must be
408403
checked/updated, and whether old records must be checked for changes and
@@ -412,7 +407,7 @@ <h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
412407
to exclude records individually.</p>
413408
</div>
414409
<div class="section" id="known-issues-roadmap">
415-
<h2><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h2>
410+
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
416411
<ul class="simple">
417412
<li>Generate and update account reconcile models.</li>
418413
<li>Generate XML-ID for fiscal position tax and account mapping lines.</li>
@@ -422,25 +417,25 @@ <h2><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h2>
422417
</ul>
423418
</div>
424419
<div class="section" id="bug-tracker">
425-
<h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
420+
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
426421
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>.
427422
In case of trouble, please check there if your issue has already been reported.
428423
If you spotted it first, help us to smash it by providing a detailed and welcomed
429424
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_chart_update%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
430425
<p>Do not contact contributors directly about support or help with technical issues.</p>
431426
</div>
432427
<div class="section" id="credits">
433-
<h2><a class="toc-backref" href="#toc-entry-4">Credits</a></h2>
428+
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
434429
<div class="section" id="authors">
435-
<h3><a class="toc-backref" href="#toc-entry-5">Authors</a></h3>
430+
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
436431
<ul class="simple">
437432
<li>Tecnativa</li>
438433
<li>BCIM</li>
439434
<li>Okia</li>
440435
</ul>
441436
</div>
442437
<div class="section" id="contributors">
443-
<h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
438+
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
444439
<ul class="simple">
445440
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
446441
<li>Pedro M. Baeza</li>
@@ -460,10 +455,11 @@ <h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
460455
</ul>
461456
</li>
462457
<li>Daniel Reis (<a class="reference external" href="mailto:dreis&#64;opensourceintegrators.com">dreis&#64;opensourceintegrators.com</a>)</li>
458+
<li>Joel Estrada (<a class="reference external" href="https://www.moduon.team/">https://www.moduon.team/</a>)</li>
463459
</ul>
464460
</div>
465461
<div class="section" id="maintainers">
466-
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
462+
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
467463
<p>This module is maintained by the OCA.</p>
468464
<a class="reference external image-reference" href="https://odoo-community.org">
469465
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -476,6 +472,5 @@ <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
476472
</div>
477473
</div>
478474
</div>
479-
</div>
480475
</body>
481476
</html>

account_chart_update/wizard/wizard_chart_update.py

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -211,41 +211,62 @@ def _domain_per_name(self, name):
211211
]
212212

213213
def _domain_tax_group_field_ids(self):
214-
return self._domain_per_name("account.tax.group")
214+
return self._domain_per_name("account.tax.group") + [
215+
("ttype", "!=", "one2many")
216+
]
215217

216218
def _domain_tax_field_ids(self):
217-
return self._domain_per_name("account.tax")
219+
# Allow specific o2m fields critical for comparison
220+
# (repartition_line_ids and variants) but exclude other o2m
221+
return self._domain_per_name("account.tax") + [
222+
"|",
223+
("ttype", "!=", "one2many"),
224+
(
225+
"name",
226+
"in",
227+
[
228+
"invoice_repartition_line_ids",
229+
"refund_repartition_line_ids",
230+
"repartition_line_ids",
231+
],
232+
),
233+
]
218234

219235
def _domain_account_field_ids(self):
220-
return self._domain_per_name("account.account")
236+
return self._domain_per_name("account.account") + [("ttype", "!=", "one2many")]
221237

222238
def _domain_account_group_field_ids(self):
223-
return self._domain_per_name("account.group")
239+
return self._domain_per_name("account.group") + [("ttype", "!=", "one2many")]
224240

225241
def _domain_fp_field_ids(self):
226-
return self._domain_per_name("account.fiscal.position")
242+
return self._domain_per_name("account.fiscal.position") + [
243+
("ttype", "!=", "one2many")
244+
]
227245

228246
def _default_tax_group_field_ids(self):
229247
return [
230248
(4, x.id)
231249
for x in self.env["ir.model.fields"].search(
232-
self._domain_tax_group_field_ids() + [("ttype", "!=", "one2many")],
250+
self._domain_tax_group_field_ids()
251+
+ self.get_uncheck_fields_domain("account.tax.group"),
233252
)
234253
]
235254

236255
def _default_tax_field_ids(self):
237256
return [
238257
(4, x.id)
239258
for x in self.env["ir.model.fields"].search(
240-
self._domain_tax_field_ids() + [("ttype", "!=", "one2many")],
259+
self._domain_tax_field_ids()
260+
+ self.get_uncheck_fields_domain("account.tax"),
241261
)
242262
]
243263

244264
def _default_account_field_ids(self):
245265
return [
246266
(4, x.id)
247267
for x in self.env["ir.model.fields"].search(
248-
self._domain_account_field_ids() + [("ttype", "!=", "one2many")],
268+
self._domain_account_field_ids()
269+
+ self.get_uncheck_fields_domain("account.account"),
249270
)
250271
]
251272

@@ -254,13 +275,17 @@ def _default_account_group_field_ids(self):
254275
(4, x.id)
255276
for x in self.env["ir.model.fields"].search(
256277
self._domain_account_group_field_ids()
278+
+ self.get_uncheck_fields_domain("account.group")
257279
)
258280
]
259281

260282
def _default_fp_field_ids(self):
261283
return [
262284
(4, x.id)
263-
for x in self.env["ir.model.fields"].search(self._domain_fp_field_ids())
285+
for x in self.env["ir.model.fields"].search(
286+
self._domain_fp_field_ids()
287+
+ self.get_uncheck_fields_domain("account.fiscal.position")
288+
)
264289
]
265290

266291
def _get_matching_ids(self, model_name, ordered_opts):
@@ -494,22 +519,18 @@ def padded_code(self, code):
494519
def fields_to_ignore(self, name):
495520
"""Get fields that will not be used when checking differences.
496521
497-
:param str template: A template record.
498522
:param str name: The name of the template model.
499523
:return set: Fields to ignore in diff.
500524
"""
501525
mail_thread_fields = set(self.env["mail.thread"]._fields)
502526
specials_mapping = {
503527
"account.tax.group": mail_thread_fields | {"sequence"},
504-
"account.tax": mail_thread_fields | {"children_tax_ids", "sequence"},
528+
"account.tax": mail_thread_fields | {"children_tax_ids"} | {"sequence"},
505529
"account.account": mail_thread_fields
506530
| {
507531
"root_id",
508532
},
509-
"account.group": {"parent_id", "code_prefix_end"},
510-
"account.fiscal.position": {
511-
"sequence",
512-
},
533+
"account.group": {"parent_id"},
513534
}
514535
specials = {
515536
"display_name",
@@ -518,6 +539,22 @@ def fields_to_ignore(self, name):
518539
} | specials_mapping.get(name, set())
519540
return set(models.MAGIC_COLUMNS) | specials
520541

542+
@api.model
543+
def get_default_unchecked_fields(self, name):
544+
"""Get fields that should be unchecked by default for a given model.
545+
546+
:param str name: The name of the template model.
547+
:return set: Fields to uncheck by default.
548+
"""
549+
unchecked_mapping = {
550+
"account.fiscal.position": {"sequence"},
551+
}
552+
return unchecked_mapping.get(name, set())
553+
554+
def get_uncheck_fields_domain(self, name):
555+
unchecked_fields = list(self.get_default_unchecked_fields(name))
556+
return [("name", "not in", unchecked_fields)]
557+
521558
@api.model
522559
def diff_fields(self, record_values, real): # noqa: C901
523560
"""Get fields that are different in record values and real records.

0 commit comments

Comments
 (0)