Skip to content

Commit bfc3c0d

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

File tree

4 files changed

+45
-32
lines changed

4 files changed

+45
-32
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: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def _domain_per_name(self, name):
208208
return [
209209
("model", "=", name),
210210
("name", "not in", tuple(self.fields_to_ignore(name))),
211+
("ttype", "!=", "one2many"),
211212
]
212213

213214
def _domain_tax_group_field_ids(self):
@@ -229,23 +230,26 @@ def _default_tax_group_field_ids(self):
229230
return [
230231
(4, x.id)
231232
for x in self.env["ir.model.fields"].search(
232-
self._domain_tax_group_field_ids() + [("ttype", "!=", "one2many")],
233+
self._domain_tax_group_field_ids()
234+
+ self.get_uncheck_fields_domain("account.tax.group"),
233235
)
234236
]
235237

236238
def _default_tax_field_ids(self):
237239
return [
238240
(4, x.id)
239241
for x in self.env["ir.model.fields"].search(
240-
self._domain_tax_field_ids() + [("ttype", "!=", "one2many")],
242+
self._domain_tax_field_ids()
243+
+ self.get_uncheck_fields_domain("account.tax"),
241244
)
242245
]
243246

244247
def _default_account_field_ids(self):
245248
return [
246249
(4, x.id)
247250
for x in self.env["ir.model.fields"].search(
248-
self._domain_account_field_ids() + [("ttype", "!=", "one2many")],
251+
self._domain_account_field_ids()
252+
+ self.get_uncheck_fields_domain("account.account"),
249253
)
250254
]
251255

@@ -254,13 +258,17 @@ def _default_account_group_field_ids(self):
254258
(4, x.id)
255259
for x in self.env["ir.model.fields"].search(
256260
self._domain_account_group_field_ids()
261+
+ self.get_uncheck_fields_domain("account.group")
257262
)
258263
]
259264

260265
def _default_fp_field_ids(self):
261266
return [
262267
(4, x.id)
263-
for x in self.env["ir.model.fields"].search(self._domain_fp_field_ids())
268+
for x in self.env["ir.model.fields"].search(
269+
self._domain_fp_field_ids()
270+
+ self.get_uncheck_fields_domain("account.fiscal.position")
271+
)
264272
]
265273

266274
def _get_matching_ids(self, model_name, ordered_opts):
@@ -494,22 +502,18 @@ def padded_code(self, code):
494502
def fields_to_ignore(self, name):
495503
"""Get fields that will not be used when checking differences.
496504
497-
:param str template: A template record.
498505
:param str name: The name of the template model.
499506
:return set: Fields to ignore in diff.
500507
"""
501508
mail_thread_fields = set(self.env["mail.thread"]._fields)
502509
specials_mapping = {
503510
"account.tax.group": mail_thread_fields | {"sequence"},
504-
"account.tax": mail_thread_fields | {"children_tax_ids", "sequence"},
511+
"account.tax": mail_thread_fields | {"children_tax_ids"} | {"sequence"},
505512
"account.account": mail_thread_fields
506513
| {
507514
"root_id",
508515
},
509-
"account.group": {"parent_id", "code_prefix_end"},
510-
"account.fiscal.position": {
511-
"sequence",
512-
},
516+
"account.group": {"parent_id"},
513517
}
514518
specials = {
515519
"display_name",
@@ -518,6 +522,22 @@ def fields_to_ignore(self, name):
518522
} | specials_mapping.get(name, set())
519523
return set(models.MAGIC_COLUMNS) | specials
520524

525+
@api.model
526+
def get_default_unchecked_fields(self, name):
527+
"""Get fields that should be unchecked by default for a given model.
528+
529+
:param str name: The name of the template model.
530+
:return set: Fields to uncheck by default.
531+
"""
532+
unchecked_mapping = {
533+
"account.fiscal.position": {"sequence"},
534+
}
535+
return unchecked_mapping.get(name, set())
536+
537+
def get_uncheck_fields_domain(self, name):
538+
unchecked_fields = list(self.get_default_unchecked_fields(name))
539+
return [("name", "not in", unchecked_fields)]
540+
521541
@api.model
522542
def diff_fields(self, record_values, real): # noqa: C901
523543
"""Get fields that are different in record values and real records.

0 commit comments

Comments
 (0)