Skip to content

Commit 6d5ace8

Browse files
committed
[18.0][ADD] sale_analytic
1 parent 11b8419 commit 6d5ace8

File tree

14 files changed

+786
-0
lines changed

14 files changed

+786
-0
lines changed

sale_analytic/README.rst

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
=============
2+
Sale Analytic
3+
=============
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:95d633c8841b121283e33b43805969ea3564c8980b15ebf731ea9c651bf97c3d
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
: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/sale_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-sale_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|
30+
31+
The goal of this module is to ease analytic distribution management on
32+
sale order. This module add analytic distribution on sale order.
33+
34+
If all lines of the sale order have the same analytic distribution, the
35+
analytic distribution on the sale order is automatically set with this
36+
value. If a analytic distribution is set on the sale order, all lines of
37+
the sale will take this value.
38+
39+
**Table of contents**
40+
41+
.. contents::
42+
:local:
43+
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:%20sale_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+
54+
Credits
55+
=======
56+
57+
Authors
58+
-------
59+
60+
* Exo Software
61+
* Acsone SA/NV
62+
63+
Contributors
64+
------------
65+
66+
- Laetitia Gangloff <[email protected]>
67+
- Cédric Pigeon <[email protected]>
68+
- Pimolnat Suntian <[email protected]>
69+
- `Jarsa <https://www.jarsa.com>`__
70+
71+
- Alan Ramos
72+
73+
- Lois Rilo <[email protected]>
74+
- `Quartile <https://www.quartile.co>`__:
75+
76+
- Aung Ko Ko Lin
77+
78+
- `Exo Software <https://www.exosoftware.pt>`__:
79+
80+
- André Leite <[email protected]>
81+
- Fábio Paiva <[email protected]>
82+
83+
Maintainers
84+
-----------
85+
86+
This module is maintained by the OCA.
87+
88+
.. image:: https://odoo-community.org/logo.png
89+
:alt: Odoo Community Association
90+
:target: https://odoo-community.org
91+
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.
95+
96+
.. |maintainer-andrel-exo| image:: https://github.com/andrel-exo.png?size=40px
97+
:target: https://github.com/andrel-exo
98+
:alt: andrel-exo
99+
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/sale_analytic>`_ project on GitHub.
105+
106+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

sale_analytic/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

sale_analytic/__manifest__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# © 2016 Laetitia Gangloff, Acsone SA/NV (http://www.acsone.eu)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
{
5+
"name": "Sale Analytic",
6+
"version": "18.0.1.0.0",
7+
"author": "Exo Software, Acsone SA/NV, Odoo Community Association (OCA)",
8+
"category": "Sale Management",
9+
"website": "https://github.com/OCA/account-analytic",
10+
"depends": ["sale", "base_view_inheritance_extension"],
11+
"data": ["views/sale_order_views.xml"],
12+
"license": "AGPL-3",
13+
"installable": True,
14+
"application": False,
15+
"maintainers": ["andrel-exo"],
16+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * sale_analytic
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 18.0+e\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2025-08-29 08:21+0000\n"
10+
"PO-Revision-Date: 2025-08-29 08:21+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: sale_analytic
19+
#: model:ir.model.fields,field_description:sale_analytic.field_sale_order__analytic_distribution
20+
msgid "Analytic Distribution"
21+
msgstr ""
22+
23+
#. module: sale_analytic
24+
#: model:ir.model.fields,field_description:sale_analytic.field_sale_order__analytic_precision
25+
msgid "Analytic Precision"
26+
msgstr ""
27+
28+
#. module: sale_analytic
29+
#: model:ir.model.fields,field_description:sale_analytic.field_sale_order__distribution_analytic_account_ids
30+
msgid "Distribution Analytic Account"
31+
msgstr ""
32+
33+
#. module: sale_analytic
34+
#: model:ir.model,name:sale_analytic.model_sale_order
35+
msgid "Sales Order"
36+
msgstr ""

sale_analytic/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import sale_order

sale_analytic/models/sale_order.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from odoo import api, fields, models
2+
3+
4+
class SaleOrder(models.Model):
5+
_name = "sale.order"
6+
_inherit = ["sale.order", "analytic.mixin"]
7+
8+
analytic_distribution = fields.Json(inverse="_inverse_analytic_distribution")
9+
10+
@api.depends("order_line.analytic_distribution")
11+
def _compute_analytic_distribution(self):
12+
"""If all lines have the same analytic distribution, set it on the order.
13+
14+
If no lines exist, respect the value given by the user.
15+
"""
16+
for so in self:
17+
if so.order_line:
18+
al = so.order_line[0].analytic_distribution or False
19+
for ol in so.order_line:
20+
if ol.analytic_distribution != al:
21+
al = False
22+
break
23+
so.analytic_distribution = al
24+
25+
def _inverse_analytic_distribution(self):
26+
"""When setting the analytic distribution`, apply it to all order lines."""
27+
for so in self:
28+
if so.analytic_distribution:
29+
so.order_line.write({"analytic_distribution": so.analytic_distribution})
30+
31+
@api.onchange("analytic_distribution")
32+
def _onchange_analytic_distribution(self):
33+
"""When changing the analytic distribution, apply it to all order lines."""
34+
if self.analytic_distribution:
35+
self.order_line.update(
36+
{"analytic_distribution": self.analytic_distribution}
37+
)

sale_analytic/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- Laetitia Gangloff \<<[email protected]>\>
2+
- Cédric Pigeon \<<[email protected]>\>
3+
- Pimolnat Suntian \<<[email protected]>\>
4+
- [Jarsa](https://www.jarsa.com)
5+
- Alan Ramos
6+
- Lois Rilo \<<[email protected]>\>
7+
- [Quartile](https://www.quartile.co):
8+
- Aung Ko Ko Lin
9+
- [Exo Software](https://www.exosoftware.pt):
10+
- André Leite \<<[email protected]>\>
11+
- Fábio Paiva \<<[email protected]>\>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
The goal of this module is to ease analytic distribution management on
2+
sale order. This module add analytic distribution on sale order.
3+
4+
If all lines of the sale order have the same analytic distribution,
5+
the analytic distribution on the sale order is automatically set
6+
with this value. If a analytic distribution is set on the sale
7+
order, all lines of the sale will take this value.
9.23 KB
Loading

0 commit comments

Comments
 (0)