Skip to content

Commit 8bbe02d

Browse files
committed
[ADD] sale_price_compliance
1 parent 9440924 commit 8bbe02d

45 files changed

Lines changed: 3254 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

sale_price_compliance/README.rst

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
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+
5+
=====================
6+
Sale Price Compliance
7+
=====================
8+
9+
..
10+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11+
!! This file is generated by oca-gen-addon-readme !!
12+
!! changes will be overwritten. !!
13+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14+
!! source digest: sha256:f260e276fb4e11d03fc4654e03277b5e5d55090c447b6619ead20cc260e5687c
15+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16+
17+
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
18+
:target: https://odoo-community.org/page/development-status
19+
:alt: Alpha
20+
.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png
21+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
22+
:alt: License: LGPL-3
23+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
24+
:target: https://github.com/OCA/sale-workflow/tree/16.0/sale_price_compliance
25+
:alt: OCA/sale-workflow
26+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27+
:target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_price_compliance
28+
:alt: Translate me on Weblate
29+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&target_branch=16.0
31+
:alt: Try me on Runboat
32+
33+
|badge1| |badge2| |badge3| |badge4| |badge5|
34+
35+
This module extends the sales pricing functionality to display a color
36+
code based on the price at which products are being sold.
37+
38+
Managing Price Compliance Thresholds can be done by adding *Manage Price
39+
Compliance* group to any user. Compliance Tiers can be filtered on sale
40+
reports.
41+
42+
You can use up to 3 different price compliance tiers for products,
43+
categories or for all company.
44+
45+
You can customize the texts and icons of the tiers via the System
46+
Parameters.
47+
48+
Labels of the tier fields will change according to
49+
``sale_price_compliance.price_compliance_selection_tiers_text`` System
50+
Parameter in views.
51+
52+
This functionality only applies to Sales.
53+
54+
A sale with a line with Non Compliant price (doesn't fit in any defined
55+
tiers) can't be confirmed. Only Sale Administrators can validate this
56+
sales and a message will be posted.
57+
58+
Price Compliance thresholds are selected in this order: Product >
59+
Product Category > Company
60+
61+
Each Tier represents the maximun discount applied to the Price of the
62+
Product to achieve the target tier.
63+
64+
**Color Compliance Tiers**
65+
66+
- Tier 1 🟩: High-yield (Fully compliant)
67+
- Tier 2 🟨: Medium-yield (Moderately compliant)
68+
- Tier 3 🟧: Low-yield (Low compliant)
69+
- Non Compliant 🟥: Non Compliant price (blocked)
70+
- Pricelist 🟦: Pricelist has been used and it's price is between
71+
pricelist and last compliant tier.
72+
73+
**Information Display on Price Compliant Tiers** Includes a popup to
74+
display detailed information about the price ranges within each price
75+
compliance tiers.
76+
77+
Also displays Product Base UoM and Product List Price in Sale Currency
78+
in the Top Right corner of the Popup.
79+
80+
|Price Compliance Widget|
81+
82+
|Price Compliance Sale Line Form|
83+
84+
|Price Compliance Sale Line List|
85+
86+
|Price Compliance Sale Line Kanban|
87+
88+
.. |Price Compliance Widget| image:: https://raw.githubusercontent.com/OCA/sale-workflow/16.0/sale_price_compliance/static/img/price_compliance_widget.png
89+
.. |Price Compliance Sale Line Form| image:: https://raw.githubusercontent.com/OCA/sale-workflow/16.0/sale_price_compliance/static/img/price_compliance_sale_line_form.png
90+
.. |Price Compliance Sale Line List| image:: https://raw.githubusercontent.com/OCA/sale-workflow/16.0/sale_price_compliance/static/img/price_compliance_sale_line_list.png
91+
.. |Price Compliance Sale Line Kanban| image:: https://raw.githubusercontent.com/OCA/sale-workflow/16.0/sale_price_compliance/static/img/price_compliance_sale_line_kanban.png
92+
93+
.. IMPORTANT::
94+
This is an alpha version, the data model and design can change at any time without warning.
95+
Only for development or testing purpose, do not use in production.
96+
`More details on development status <https://odoo-community.org/page/development-status>`_
97+
98+
**Table of contents**
99+
100+
.. contents::
101+
:local:
102+
103+
Use Cases / Context
104+
===================
105+
106+
This module was developed because sometimes commercial users are
107+
incentivized to sell at prices that are more beneficial to the company.
108+
109+
It will be useful if you want to visually show your commercial users
110+
whether the price they are selling at is in line with the company's
111+
pricing policy.
112+
113+
Usage
114+
=====
115+
116+
To use this module, you need to:
117+
118+
**Configure Parameter Text: Change the default price compliance tiers
119+
texts**
120+
121+
1. Go to System Parameters.
122+
2. Create a new parameter with key
123+
``sale_price_compliance.price_compliance_selection_tiers_text``.
124+
3. Write a *dictionary* with the values for tiers that you want to
125+
change it's default text.
126+
4. Save the parameter.
127+
5. Create a new parameter with key
128+
``sale_price_compliance.price_compliance_selection_tiers_icon``.
129+
6. Write a *dictionary* with the values for tiers that you want to
130+
change it's default icon.
131+
7. Save the parameter.
132+
133+
Example:
134+
135+
Param *sale_price_compliance.price_compliance_selection_tiers_text*:
136+
137+
{'t1': 'Gold', 't2': 'Silver', 't3': 'Bronze', 'pricelist': 'Draw'}
138+
139+
Param *sale_price_compliance.price_compliance_selection_tiers_icon*:
140+
141+
{'t1': '🥇', 't2': '🥈', 't3': '🥉', 'non_compliant': '⛔️', 'pricelist':
142+
'🤝'}
143+
144+
Resulting texts and icons will be:
145+
146+
- Gold: 🥇
147+
- Silver: 🥈
148+
- Bronze: 🥉
149+
- Non Compliant: ⛔️
150+
- Draw: 🤝
151+
152+
Available keys to be used in the dictionary are:
153+
154+
- t1: Tier 1
155+
- t2: Tier 2
156+
- t3: Tier 3
157+
- non_compliant: Non Compliant
158+
- pricelist: Pricelist
159+
160+
**Configure: Product Price Compliance Thresholds configuration**
161+
162+
1. Go to Sales > Products > Products > Select one > Sales tab
163+
2. Enable Use Price Compliance Thresholds under Sale Price Compliance
164+
Thresholds
165+
3. Fill from 1 to 3 tiers that you want to use in this product.
166+
167+
Example: Tier 1: 10%, Tier 2: 20%, Tier 3: 30%. (Use all tiers)
168+
169+
**Configure: Product Category Price Compliance Thresholds
170+
configuration**
171+
172+
1. Go to Sales > Configuration > Products > Product Categories > Select
173+
one
174+
2. Enable Use Price Compliance Thresholds under Sale Price Compliance
175+
Thresholds
176+
3. Fill from 1 to 3 tiers that you want to use in this category.
177+
178+
Example: Tier 1: 15%, Tier 2: 25%, Tier 3: 0%. (Don't use tier 3)
179+
180+
**Configure: Company Price Compliance Thresholds configuration**
181+
182+
1. Go to Sales > Configuration > Settings
183+
2. Enable Use Price Compliance Thresholds under Pricing section
184+
3. Fill from 1 to 3 tiers that you want to use for the company.
185+
186+
Example: Tier 1: 30%, Tier 2: 0%, Tier 3: 0%. (Don't use tier 2 and 3)
187+
188+
**Sale: As a Salesman user**
189+
190+
1. Create a new sale and fill contact field
191+
2. Add a new line with a product that has been configured to use Price
192+
Compliance
193+
3. Click on the 🟩, 🟨, 🟧, 🟥 or 🟦 icon at the start of the line.
194+
4. You will see a popup with useful information about the Tier ranges.
195+
5. Play with it and then set a Non Compliant price (change price or
196+
discount to achieve this).
197+
6. Try to confirm the Sale and see the error.
198+
199+
**Sale: As a Sales Administrator**
200+
201+
1. Confirm the previous Sale.
202+
2. See the message on the chatter.
203+
204+
**Reporting: Sales report**
205+
206+
1. Go to Sales > Reporting > Sales
207+
2. Select bar chart or Pivot view
208+
3. Group by Price Compliance Level
209+
210+
**Reporting: Salesperson report**
211+
212+
1. Go to Sales > Reporting > Salesperson
213+
2. Select Bar chart + stacked or Pivot view
214+
3. Group by Price Compliance Level
215+
216+
**Reporting: Product report**
217+
218+
1. Go to Sales > Reporting > Product
219+
2. Select Pie chart + stacked or Pivot view
220+
3. Group by Price Compliance Level
221+
222+
**Reporting: Customers report**
223+
224+
1. Go to Sales > Reporting > Customers
225+
2. Select Bar chart + stacked or Pivot view
226+
3. Group by Price Compliance Level
227+
228+
Known issues / Roadmap
229+
======================
230+
231+
- Widget is not shown properly if the order is not saved and refreshed.
232+
233+
Bug Tracker
234+
===========
235+
236+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
237+
In case of trouble, please check there if your issue has already been reported.
238+
If you spotted it first, help us to smash it by providing a detailed and welcomed
239+
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_price_compliance%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
240+
241+
Do not contact contributors directly about support or help with technical issues.
242+
243+
Credits
244+
=======
245+
246+
Authors
247+
-------
248+
249+
* Moduon
250+
251+
Contributors
252+
------------
253+
254+
- Eduardo de Miguel (`Moduon <https://www.moduon.team/>`__)
255+
256+
Maintainers
257+
-----------
258+
259+
This module is maintained by the OCA.
260+
261+
.. image:: https://odoo-community.org/logo.png
262+
:alt: Odoo Community Association
263+
:target: https://odoo-community.org
264+
265+
OCA, or the Odoo Community Association, is a nonprofit organization whose
266+
mission is to support the collaborative development of Odoo features and
267+
promote its widespread use.
268+
269+
.. |maintainer-Shide| image:: https://github.com/Shide.png?size=40px
270+
:target: https://github.com/Shide
271+
:alt: Shide
272+
.. |maintainer-rafaelbn| image:: https://github.com/rafaelbn.png?size=40px
273+
:target: https://github.com/rafaelbn
274+
:alt: rafaelbn
275+
276+
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
277+
278+
|maintainer-Shide| |maintainer-rafaelbn|
279+
280+
This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/16.0/sale_price_compliance>`_ project on GitHub.
281+
282+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

sale_price_compliance/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import models
2+
from . import report
3+
from .hooks import pre_init_hook
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2025 Moduon Team S.L.
2+
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
3+
4+
{
5+
"name": "Sale Price Compliance",
6+
"summary": "Visual price compliance based on product, category and company thresholds",
7+
"version": "16.0.1.0.0",
8+
"development_status": "Alpha",
9+
"category": "Sales/Sales",
10+
"website": "https://github.com/OCA/sale-workflow",
11+
"author": "Moduon, Odoo Community Association (OCA)",
12+
"maintainers": ["Shide", "rafaelbn"],
13+
"license": "LGPL-3",
14+
"application": False,
15+
"installable": True,
16+
"depends": [
17+
"sale",
18+
],
19+
"data": [
20+
"security/sale_price_compliance.xml",
21+
"views/res_config_settings_view.xml",
22+
"views/product_category_view.xml",
23+
"views/product_template_view.xml",
24+
"views/product_product_view.xml",
25+
"views/sale_order_line_view.xml",
26+
"views/sale_order_view.xml",
27+
"report/sale_report_view.xml",
28+
],
29+
"pre_init_hook": "pre_init_hook",
30+
"assets": {
31+
"web.assets_backend": [
32+
"sale_price_compliance/static/src/**/*",
33+
],
34+
},
35+
}

sale_price_compliance/hooks.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2026 Moduon Team S.L.
2+
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
3+
4+
import logging
5+
6+
from odoo.tools import sql
7+
8+
logger = logging.getLogger(__name__)
9+
10+
11+
def pre_init_hook(cr):
12+
"""Create table columns for computed fields to not get them computed by Odoo."""
13+
if not sql.column_exists(cr, "sale_order_line", "price_compliance_tier"):
14+
sql.create_column(
15+
cr,
16+
"sale_order_line",
17+
"price_compliance_tier",
18+
"VARCHAR",
19+
comment="Price Compliance Tier",
20+
)
21+
if not sql.column_exists(cr, "sale_order_line", "price_compliance_data"):
22+
sql.create_column(
23+
cr,
24+
"sale_order_line",
25+
"price_compliance_data",
26+
"JSONB",
27+
comment="Price Compliance Data",
28+
)

0 commit comments

Comments
 (0)