Skip to content

Commit 3c7bdee

Browse files
committed
[ADD] sale_price_compliance
1 parent bfd443f commit 3c7bdee

44 files changed

Lines changed: 2943 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: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
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+
This functionality only applies to Sales.
46+
47+
A sale with a line with Non Compliant price (doesn't fit in any defined
48+
tiers) can't be confirmed. Only Sale Administrators can validate this
49+
sales and a message will be posted.
50+
51+
Price Compliance thresholds are selected in this order: Product >
52+
Product Category > Company
53+
54+
Each Tier represents the maximun discount applied to the Price of the
55+
Product to achieve the target tier.
56+
57+
**Color Compliance Tiers**
58+
59+
- Tier 1 🟩: High-yield (Fully compliant)
60+
- Tier 2 🟨: Medium-yield (Moderately compliant)
61+
- Tier 3 🟧: Low-yield (Low compliant)
62+
- Non Compliant 🟥: Non Compliant price (blocked)
63+
- Pricelist 🟦: Price is the same as the pricelist
64+
65+
**Information Display on Price Compliant Tiers** Includes a popup to
66+
display detailed information about the price ranges within each price
67+
compliance tiers.
68+
69+
Also displays Product Base UoM and Product List Price in Sale Currency
70+
in the Top Right corner of the Popup.
71+
72+
|Price Compliance Widget|
73+
74+
|Price Compliance Sale Line Form|
75+
76+
|Price Compliance Sale Line List|
77+
78+
|Price Compliance Sale Line Kanban|
79+
80+
.. |Price Compliance Widget| image:: https://raw.githubusercontent.com/OCA/sale-workflow/16.0/sale_price_compliance/static/img/price_compliance_widget.png
81+
.. |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
82+
.. |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
83+
.. |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
84+
85+
.. IMPORTANT::
86+
This is an alpha version, the data model and design can change at any time without warning.
87+
Only for development or testing purpose, do not use in production.
88+
`More details on development status <https://odoo-community.org/page/development-status>`_
89+
90+
**Table of contents**
91+
92+
.. contents::
93+
:local:
94+
95+
Use Cases / Context
96+
===================
97+
98+
This module was developed because sometimes commercial users are
99+
incentivized to sell at prices that are more beneficial to the company.
100+
101+
It will be useful if you want to visually show your commercial users
102+
whether the price they are selling at is in line with the company's
103+
pricing policy.
104+
105+
Usage
106+
=====
107+
108+
To use this module, you need to:
109+
110+
**Configure: Product Price Compliance Thresholds configuration**
111+
112+
1. Go to Sales > Products > Products > Select one > Sales tab
113+
2. Enable Use Price Compliance Thresholds under Sale Price Compliance
114+
Thresholds
115+
3. Fill from 1 to 3 tiers that you want to use in this product.
116+
117+
Example: Tier 1: 10%, Tier 2: 20%, Tier 3: 30%. (Use all tiers)
118+
119+
**Configure: Product Category Price Compliance Thresholds
120+
configuration**
121+
122+
1. Go to Sales > Configuration > Products > Product Categories > Select
123+
one
124+
2. Enable Use Price Compliance Thresholds under Sale Price Compliance
125+
Thresholds
126+
3. Fill from 1 to 3 tiers that you want to use in this category.
127+
128+
Example: Tier 1: 15%, Tier 2: 25%, Tier 3: 0%. (Don't use tier 3)
129+
130+
**Configure: Company Price Compliance Thresholds configuration**
131+
132+
1. Go to Sales > Configuration > Settings
133+
2. Enable Use Price Compliance Thresholds under Pricing section
134+
3. Fill from 1 to 3 tiers that you want to use for the company.
135+
136+
Example: Tier 1: 30%, Tier 2: 0%, Tier 3: 0%. (Don't use tier 2 and 3)
137+
138+
**Sale: As a Salesman user**
139+
140+
1. Create a new sale and fill contact field
141+
2. Add a new line with a product that has been configured to use Price
142+
Compliance
143+
3. Click on the 🟩, 🟨, 🟧, 🟥 or 🟦 icon at the start of the line.
144+
4. You will see a popup with useful information about the Tier ranges.
145+
5. Play with it and then set a Non Compliant price (change price or
146+
discount to achieve this).
147+
6. Try to confirm the Sale and see the error.
148+
149+
**Sale: As a Sales Administrator**
150+
151+
1. Confirm the previous Sale.
152+
2. See the message on the chatter.
153+
154+
**Reporting: Sales report**
155+
156+
1. Go to Sales > Reporting > Sales
157+
2. Select bar chart or Pivot view
158+
3. Group by Price Compliance Level
159+
160+
**Reporting: Salesperson report**
161+
162+
1. Go to Sales > Reporting > Salesperson
163+
2. Select Bar chart + stacked or Pivot view
164+
3. Group by Price Compliance Level
165+
166+
**Reporting: Product report**
167+
168+
1. Go to Sales > Reporting > Product
169+
2. Select Pie chart + stacked or Pivot view
170+
3. Group by Price Compliance Level
171+
172+
**Reporting: Customers report**
173+
174+
1. Go to Sales > Reporting > Customers
175+
2. Select Bar chart + stacked or Pivot view
176+
3. Group by Price Compliance Level
177+
178+
Known issues / Roadmap
179+
======================
180+
181+
- Display icons appropriate for visual impairments (color blindness)
182+
- Widget is not shown properly if the order is not saved and refreshed.
183+
184+
Bug Tracker
185+
===========
186+
187+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
188+
In case of trouble, please check there if your issue has already been reported.
189+
If you spotted it first, help us to smash it by providing a detailed and welcomed
190+
`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**>`_.
191+
192+
Do not contact contributors directly about support or help with technical issues.
193+
194+
Credits
195+
=======
196+
197+
Authors
198+
-------
199+
200+
* Moduon
201+
202+
Contributors
203+
------------
204+
205+
- Eduardo de Miguel (`Moduon <https://www.moduon.team/>`__)
206+
207+
Maintainers
208+
-----------
209+
210+
This module is maintained by the OCA.
211+
212+
.. image:: https://odoo-community.org/logo.png
213+
:alt: Odoo Community Association
214+
:target: https://odoo-community.org
215+
216+
OCA, or the Odoo Community Association, is a nonprofit organization whose
217+
mission is to support the collaborative development of Odoo features and
218+
promote its widespread use.
219+
220+
.. |maintainer-Shide| image:: https://github.com/Shide.png?size=40px
221+
:target: https://github.com/Shide
222+
:alt: Shide
223+
.. |maintainer-rafaelbn| image:: https://github.com/rafaelbn.png?size=40px
224+
:target: https://github.com/rafaelbn
225+
:alt: rafaelbn
226+
227+
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
228+
229+
|maintainer-Shide| |maintainer-rafaelbn|
230+
231+
This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/16.0/sale_price_compliance>`_ project on GitHub.
232+
233+
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)