Skip to content

Commit 19b6337

Browse files
committed
[ADD] sale_order_minimum_amount
1 parent e221dc9 commit 19b6337

18 files changed

Lines changed: 780 additions & 0 deletions

File tree

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
=========================
2+
Sale Order Minimum Amount
3+
=========================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:c1f1cc6f2022e0eca132a58db7e3a718e58735d697f42d0b406083eb8a92ef16
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Alpha
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%2Fsale--workflow-lightgray.png?logo=github
20+
:target: https://github.com/OCA/sale-workflow/tree/16.0/sale_order_minimum_amount
21+
:alt: OCA/sale-workflow
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_minimum_amount
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/sale-workflow&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module restricts sales order confirmation below a configured minimum amount for sales users, with sales managers exempt from this rule.
32+
33+
.. IMPORTANT::
34+
This is an alpha version, the data model and design can change at any time without warning.
35+
Only for development or testing purpose, do not use in production.
36+
`More details on development status <https://odoo-community.org/page/development-status>`_
37+
38+
**Table of contents**
39+
40+
.. contents::
41+
:local:
42+
43+
Configuration
44+
=============
45+
46+
To configure the minimum allowed amount for confirming sales orders:
47+
48+
#. Go to **Sales > Configuration > Settings**
49+
#. Find the field **Minimum Allowed Sales Order Amount**
50+
#. Enter the desired minimum amount (e.g., 100.00)
51+
#. Click **Save** to apply the changes
52+
#. Ensure the user has the **Salesperson (Normal User)** role:
53+
- Go to **Settings > Users**
54+
- Open the user form
55+
- In the **Sales** section, ensure the access level is set to **Salesperson**
56+
57+
Usage
58+
=====
59+
60+
To use this module, you need to:
61+
62+
#. Create a new **Sale Order**
63+
#. Add products to the order
64+
#. If the **Total Amount** is **less than** the configured **Minimum Allowed Sales Order Amount**:
65+
66+
- A regular sales user **cannot confirm** the order
67+
- A **UserError** is raised:
68+
69+
*"Only sale orders over X.XX can be confirmed."*
70+
#. If the user belongs to the **Sales Manager** group:
71+
- The order **can be confirmed**, even if it’s below the threshold
72+
73+
Bug Tracker
74+
===========
75+
76+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
77+
In case of trouble, please check there if your issue has already been reported.
78+
If you spotted it first, help us to smash it by providing a detailed and welcomed
79+
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_minimum_amount%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
80+
81+
Do not contact contributors directly about support or help with technical issues.
82+
83+
Credits
84+
=======
85+
86+
Authors
87+
~~~~~~~
88+
89+
* BizzAppDev Systems Pvt. Ltd.
90+
91+
Contributors
92+
~~~~~~~~~~~~
93+
94+
* `BizzAppDev Systems <https://www.bizzappdev.com>`_:
95+
96+
* Ruchir Shukla
97+
98+
Other credits
99+
~~~~~~~~~~~~~
100+
101+
The development of this module has been financially supported by:
102+
103+
- Agent ERP GmbH
104+
105+
Maintainers
106+
~~~~~~~~~~~
107+
108+
This module is maintained by the OCA.
109+
110+
.. image:: https://odoo-community.org/logo.png
111+
:alt: Odoo Community Association
112+
:target: https://odoo-community.org
113+
114+
OCA, or the Odoo Community Association, is a nonprofit organization whose
115+
mission is to support the collaborative development of Odoo features and
116+
promote its widespread use.
117+
118+
This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/16.0/sale_order_minimum_amount>`_ project on GitHub.
119+
120+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "Sale Order Minimum Amount",
3+
"version": "16.0.1.0.0",
4+
"development_status": "Alpha",
5+
"summary": "Restrict confirmation of sales orders below a configured minimum total amount",
6+
"license": "AGPL-3",
7+
"category": "Sales",
8+
"author": "BizzAppDev Systems Pvt. Ltd., Odoo Community Association (OCA)",
9+
"website": "https://github.com/OCA/sale-workflow",
10+
"depends": ["sale_management"],
11+
"data": ["views/res_config_settings_views.xml"],
12+
"installable": True,
13+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import res_config_settings
2+
from . import res_company
3+
from . import sale_order
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from odoo import fields, models
2+
3+
4+
class ResCompany(models.Model):
5+
_inherit = "res.company"
6+
7+
sale_min_order_limit = fields.Float(
8+
string="Minimum Sales Order Amount",
9+
help=(
10+
"Sales users cannot confirm orders below this amount. "
11+
"Sales Managers are not restricted."
12+
),
13+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from odoo import fields, models
2+
3+
4+
class ResConfigSettings(models.TransientModel):
5+
_inherit = "res.config.settings"
6+
7+
sale_min_order_limit = fields.Float(
8+
string="Minimum Sales Order Amount",
9+
related="company_id.sale_min_order_limit",
10+
readonly=False,
11+
help=(
12+
"Sales users cannot confirm orders below this amount. "
13+
"Sales Managers are not restricted."
14+
),
15+
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from odoo import _, models
2+
from odoo.exceptions import UserError
3+
4+
5+
class SaleOrder(models.Model):
6+
_inherit = "sale.order"
7+
8+
def action_confirm(self):
9+
"""Inherited the method allow order confirmation only if amount exceeds
10+
company minimum or user is Sales Manager."""
11+
# Allow confirmation if user is Sales Manager
12+
if self.env.user.has_group("sales_team.group_sale_manager"):
13+
return super().action_confirm()
14+
# Otherwise, validate each order amount
15+
for order in self:
16+
sale_min_order_limit = order.company_id.sale_min_order_limit
17+
if order.amount_untaxed <= sale_min_order_limit:
18+
raise UserError(
19+
_(
20+
"Only sale orders over %(amount).2f %(currency)s can be confirmed.",
21+
amount=sale_min_order_limit,
22+
currency=order.currency_id.symbol,
23+
)
24+
)
25+
return super().action_confirm()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
To configure the minimum allowed amount for confirming sales orders:
2+
3+
#. Go to **Sales > Configuration > Settings**
4+
#. Find the field **Minimum Allowed Sales Order Amount**
5+
#. Enter the desired minimum amount (e.g., 100.00)
6+
#. Click **Save** to apply the changes
7+
#. Ensure the user has the **Salesperson (Normal User)** role:
8+
- Go to **Settings > Users**
9+
- Open the user form
10+
- In the **Sales** section, ensure the access level is set to **Salesperson**
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* `BizzAppDev Systems <https://www.bizzappdev.com>`_:
2+
3+
* Ruchir Shukla
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The development of this module has been financially supported by:
2+
3+
- Agent ERP GmbH

0 commit comments

Comments
 (0)