Skip to content

Commit d08395a

Browse files
committed
[16.0][ADD] account_analytic_distribution_model_recalculate
1 parent 70a3991 commit d08395a

File tree

5 files changed

+51
-84
lines changed

5 files changed

+51
-84
lines changed

account_analytic/README.rst

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,22 @@
22
Account Analytic
33
================
44

5-
..
5+
..
66
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:043875970c87ac25390dd30f6366fdd0d1d0bbbb6b11980a0e45d4fd131eb6ff
10+
!! source digest: sha256:29d3f50e7cbdae1f7229b3dfc42c99a7b4be74e67d1052ab6da4244b671b81d2
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
13-
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
13+
.. |badge_devstat| image:: https://img.shields.io/badge/maturity-beta-brightgreen.png
1414
:target: https://odoo-community.org/page/development-status
1515
:alt: Beta
16-
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17-
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18-
:alt: License: AGPL-3
19-
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github
20-
:target: https://github.com/OCA/account-analytic/tree/18.0/account_analytic
21-
:alt: OCA/account-analytic
22-
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/account-analytic-18-0/account-analytic-18-0-account_analytic
24-
:alt: Translate me on Weblate
25-
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-analytic&target_branch=18.0
27-
:alt: Try me on Runboat
28-
29-
|badge1| |badge2| |badge3| |badge4| |badge5|
16+
17+
.. |badge_license| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
18+
:alt: AGPL-3
19+
20+
|badge_devstat| |badge_license|
3021

3122
The goal of this module is to ease analytic distribution management on
3223
account move. This module adds analytic distribution on account move.
@@ -41,16 +32,6 @@ lines of the account move will take this value.
4132
.. contents::
4233
:local:
4334

44-
Bug Tracker
45-
===========
46-
47-
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-analytic/issues>`_.
48-
In case of trouble, please check there if your issue has already been reported.
49-
If you spotted it first, help us to smash it by providing a detailed and welcomed
50-
`feedback <https://github.com/OCA/account-analytic/issues/new?body=module:%20account_analytic%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
51-
52-
Do not contact contributors directly about support or help with technical issues.
53-
5435
Credits
5536
=======
5637

@@ -83,24 +64,17 @@ Contributors
8364
Maintainers
8465
-----------
8566

86-
This module is maintained by the OCA.
67+
This module is maintained by Exo Software.
68+
69+
Contact the maintainer through their official support channels in case you find
70+
any issues with this module.
8771

88-
.. image:: https://odoo-community.org/logo.png
89-
:alt: Odoo Community Association
90-
:target: https://odoo-community.org
9172

92-
OCA, or the Odoo Community Association, is a nonprofit organization whose
93-
mission is to support the collaborative development of Odoo features and
94-
promote its widespread use.
9573

9674
.. |maintainer-andrel-exo| image:: https://github.com/andrel-exo.png?size=40px
9775
:target: https://github.com/andrel-exo
9876
:alt: andrel-exo
9977

100-
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
101-
102-
|maintainer-andrel-exo|
103-
104-
This module is part of the `OCA/account-analytic <https://github.com/OCA/account-analytic/tree/18.0/account_analytic>`_ project on GitHub.
78+
Current maintainer:
10579

106-
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
80+
|maintainer-andrel-exo|

account_analytic/models/account_move.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ class AccountMove(models.Model):
77

88
analytic_distribution = fields.Json(inverse="_inverse_analytic_distribution")
99

10-
@api.depends("line_ids.analytic_distribution")
10+
@api.depends("invoice_line_ids.analytic_distribution")
1111
def _compute_analytic_distribution(self):
1212
"""If all lines have the same analytic distribution, set it on the order.
1313
1414
If no lines exist, respect the value given by the user.
1515
"""
1616
for am in self:
17-
if am.line_ids:
18-
al = am.line_ids[0].analytic_distribution or False
19-
for ol in am.line_ids:
17+
if am.invoice_line_ids:
18+
al = am.invoice_line_ids[0].analytic_distribution or False
19+
for ol in am.invoice_line_ids:
2020
if ol.analytic_distribution != al:
2121
al = False
2222
break
@@ -26,10 +26,14 @@ def _inverse_analytic_distribution(self):
2626
"""When setting the analytic distribution`, apply it to all order lines."""
2727
for am in self:
2828
if am.analytic_distribution:
29-
am.line_ids.write({"analytic_distribution": am.analytic_distribution})
29+
am.invoice_line_ids.write(
30+
{"analytic_distribution": am.analytic_distribution}
31+
)
3032

3133
@api.onchange("analytic_distribution")
3234
def _onchange_analytic_distribution(self):
3335
"""When changing the analytic distribution, apply it to all order lines."""
3436
if self.analytic_distribution:
35-
self.line_ids.update({"analytic_distribution": self.analytic_distribution})
37+
self.invoice_line_ids.update(
38+
{"analytic_distribution": self.analytic_distribution}
39+
)
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
The goal of this module is to ease analytic distribution management on
2-
account move. This module adds analytic distribution on account move.
1+
The goal of this module is to ease analytic distribution management on account move.
2+
This module adds analytic distribution on account move.
33

4-
If all lines of the account move have the same analytic distribution,
5-
the analytic distribution on the account move is automatically set
6-
with this value. If an analytic distribution is set on the account
7-
move, all lines of the account move will take this value.
4+
If all lines of the account move have the same analytic distribution, the analytic
5+
distribution on the account move is automatically set with this value. If an analytic
6+
distribution is set on the account move, all lines of the account move will take this
7+
value.

account_analytic/static/description/index.html

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ <h1 class="title">Account Analytic</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:043875970c87ac25390dd30f6366fdd0d1d0bbbb6b11980a0e45d4fd131eb6ff
370+
!! source digest: sha256:29d3f50e7cbdae1f7229b3dfc42c99a7b4be74e67d1052ab6da4244b671b81d2
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
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-analytic/tree/18.0/account_analytic"><img alt="OCA/account-analytic" src="https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-analytic-18-0/account-analytic-18-0-account_analytic"><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-analytic&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-brightgreen.png" /></a> <img alt="AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></p>
373373
<p>The goal of this module is to ease analytic distribution management on
374374
account move. This module adds analytic distribution on account move.</p>
375375
<p>If all lines of the account move have the same analytic distribution,
@@ -379,34 +379,25 @@ <h1 class="title">Account Analytic</h1>
379379
<p><strong>Table of contents</strong></p>
380380
<div class="contents local topic" id="contents">
381381
<ul class="simple">
382-
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
383-
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
384-
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
385-
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
386-
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
382+
<li><a class="reference internal" href="#credits" id="toc-entry-1">Credits</a><ul>
383+
<li><a class="reference internal" href="#authors" id="toc-entry-2">Authors</a></li>
384+
<li><a class="reference internal" href="#contributors" id="toc-entry-3">Contributors</a></li>
385+
<li><a class="reference internal" href="#maintainers" id="toc-entry-4">Maintainers</a></li>
387386
</ul>
388387
</li>
389388
</ul>
390389
</div>
391-
<div class="section" id="bug-tracker">
392-
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
393-
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-analytic/issues">GitHub Issues</a>.
394-
In case of trouble, please check there if your issue has already been reported.
395-
If you spotted it first, help us to smash it by providing a detailed and welcomed
396-
<a class="reference external" href="https://github.com/OCA/account-analytic/issues/new?body=module:%20account_analytic%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
397-
<p>Do not contact contributors directly about support or help with technical issues.</p>
398-
</div>
399390
<div class="section" id="credits">
400-
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
391+
<h1><a class="toc-backref" href="#toc-entry-1">Credits</a></h1>
401392
<div class="section" id="authors">
402-
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
393+
<h2><a class="toc-backref" href="#toc-entry-2">Authors</a></h2>
403394
<ul class="simple">
404395
<li>Exo Software</li>
405396
<li>Acsone SA/NV</li>
406397
</ul>
407398
</div>
408399
<div class="section" id="contributors">
409-
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
400+
<h2><a class="toc-backref" href="#toc-entry-3">Contributors</a></h2>
410401
<ul class="simple">
411402
<li>Laetitia Gangloff &lt;<a class="reference external" href="mailto:laetitia.gangloff&#64;acsone.eu">laetitia.gangloff&#64;acsone.eu</a>&gt;</li>
412403
<li>Cédric Pigeon &lt;<a class="reference external" href="mailto:cedric.pigeon&#64;acsone.eu">cedric.pigeon&#64;acsone.eu</a>&gt;</li>
@@ -428,18 +419,12 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
428419
</ul>
429420
</div>
430421
<div class="section" id="maintainers">
431-
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
432-
<p>This module is maintained by the OCA.</p>
433-
<a class="reference external image-reference" href="https://odoo-community.org">
434-
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
435-
</a>
436-
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
437-
mission is to support the collaborative development of Odoo features and
438-
promote its widespread use.</p>
439-
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
422+
<h2><a class="toc-backref" href="#toc-entry-4">Maintainers</a></h2>
423+
<p>This module is maintained by Exo Software.</p>
424+
<p>Contact the maintainer through their official support channels in case you find
425+
any issues with this module.</p>
426+
<p>Current maintainer:</p>
440427
<p><a class="reference external image-reference" href="https://github.com/andrel-exo"><img alt="andrel-exo" src="https://github.com/andrel-exo.png?size=40px" /></a></p>
441-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-analytic/tree/18.0/account_analytic">OCA/account-analytic</a> project on GitHub.</p>
442-
<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>
443428
</div>
444429
</div>
445430
</div>

account_analytic/views/account_move_views.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@
1010
name="analytic_distribution"
1111
widget="analytic_distribution"
1212
groups="analytic.group_analytic_accounting"
13-
readonly="state == 'cancel'"
13+
readonly="state in ('done', 'cancel')"
14+
invisible="move_type not in ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')"
1415
/>
1516
</xpath>
16-
<field name="line_ids" position="attributes">
17+
<xpath
18+
expr="//page[@id='aml_tab']//field[@name='line_ids']"
19+
position="attributes"
20+
>
1721
<attribute name="context" operation="update">
1822
{
1923
"default_analytic_distribution": analytic_distribution,
2024
}
2125
</attribute>
22-
</field>
26+
</xpath>
2327
</field>
2428
</record>
2529
</odoo>

0 commit comments

Comments
 (0)