Skip to content

Commit dd8c313

Browse files
committed
[IMP] sale_order_lot_selection: add lot wizard
Implement wizard for adding lots to sale orders with following features: - Select existing sale order or create new one - Add multiple lots with quantities - Validate available quantities - Restrict creation of new records Task: 4470
1 parent e963926 commit dd8c313

20 files changed

Lines changed: 643 additions & 41 deletions

sale_order_lot_selection/README.rst

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,62 @@ This selected lot number will be the one delivered to the Customer.
3636
.. contents::
3737
:local:
3838

39+
Use Cases / Context
40+
===================
41+
42+
Sometimes companies need to create quotations with precise lot/serial number
43+
specifications before confirming orders, such as used equipment with unique serial
44+
numbers or specific inventory lots.
45+
46+
This is particularly important in several business scenarios:
47+
48+
* In industries where product traceability is critical and customers need specific
49+
serial numbers (electronics, automotive parts, medical devices)
50+
* When dealing with batches that vary in quality or characteristics, where
51+
customers require products from specific production runs
52+
* In regulated industries where lot traceability is mandatory for compliance
53+
purposes
54+
55+
For example:
56+
57+
* A machinery reseller needs to quote specific used equipment with known serial
58+
numbers
59+
* An electronics distributor must sell particular serial-numbered items for
60+
warranty tracking
61+
* A car parts supplier needs to specify exact serial numbers for rare components
62+
63+
Configuration
64+
=============
65+
66+
If you want to allow users to generate sales quotas directly from the stock.lots tree view:
67+
68+
* Go to Inventory > Configuration > Settings
69+
* Under Operations section select the "Allow to generate sales quotations from stock lots" check box
70+
3971
Usage
4072
=====
4173

42-
- Create/edit a product and set traceability by 'By Lots' option.
43-
- Create a new lot number and assign product.
44-
- Update quantity for that product and assign lot number.
45-
- Go to Sales > Orders > Quotations.
46-
- Create a new quotation and add recently above configured product.
47-
- Select lot number and confirm it.
48-
- Delivery order will reserve the lot when available
74+
There are two ways to add Lots to a Sale Order:
75+
76+
1. From Sale Order:
77+
78+
- Create/edit a product and set traceability by 'By Lots' option
79+
- Create a new lot number and assign product
80+
- Update quantity for that product and assign lot number
81+
- Go to Sales > Orders > Quotations
82+
- Create a new quotation and add recently above configured product
83+
- Select lot number and confirm it
84+
- Delivery order will reserve the lot when available
85+
86+
2. From Lots/Serial Numbers:
87+
88+
- Go to "Sales > Products > Lots/Serial Numbers"
89+
- Select Serial Numbers you would like to add to quotation
90+
- Click action > Create quotation
91+
- In the action wizard:
92+
93+
* To add to existing order: Select a Quotation/Sales order and click "Add"
94+
* To create new order: Click "New" to create quotation with selected lots
4995

5096
Known issues / Roadmap
5197
======================
@@ -84,6 +130,10 @@ Contributors
84130
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
85131
* François Honoré <francois.honore@acsone.eu>
86132
* Florian da Costa <florian.dacosta@akretion.com>
133+
* `Cetmix <https://cetmix.com>`_:
134+
135+
* George Smirnov
136+
* Anatol Mikheev
87137

88138
Maintainers
89139
~~~~~~~~~~~
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
# Copyright (C) 2025 Cetmix OÜ
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
14
from . import models
5+
from . import wizards

sale_order_lot_selection/__manifest__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (C) 2025 Cetmix OÜ
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
14
{
25
"name": "Sale Order Lot Selection",
36
"version": "16.0.1.0.1",
@@ -6,7 +9,13 @@
69
"website": "https://github.com/OCA/sale-workflow",
710
"license": "AGPL-3",
811
"depends": ["sale_stock", "stock_restrict_lot"],
9-
"data": ["view/sale_view.xml"],
12+
"data": [
13+
"security/ir.model.access.csv",
14+
"view/sale_view.xml",
15+
"view/lot_view.xml",
16+
"view/res_config_settings.xml",
17+
"wizards/stock_lot_add_to_sale_order.xml",
18+
],
1019
"demo": ["demo/sale_demo.xml"],
1120
"maintainers": ["bodedra"],
1221
"installable": True,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1+
# Copyright (C) 2025 Cetmix OÜ
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
14
from . import sale_order_line
5+
from . import res_config_settings
6+
from . import stock_lot
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (C) 2025 Cetmix OÜ
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class ResConfigSettings(models.TransientModel):
8+
_inherit = "res.config.settings"
9+
10+
allow_generate_so_from_lots = fields.Boolean(
11+
string="Allow Generate SO from Lots",
12+
config_parameter="sale_order_lot_selection.allow_generate_from_lots",
13+
default=False,
14+
)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright (C) 2025 Cetmix OÜ
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import _, models
5+
from odoo.exceptions import AccessError
6+
7+
8+
class StockLot(models.Model):
9+
_inherit = "stock.lot"
10+
11+
def action_add_to_sale_order(self):
12+
"""Open the wizard to add lots to a sale order."""
13+
self.ensure_one()
14+
return self.action_generate_sale_order()
15+
16+
def action_generate_sale_order(self):
17+
"""Open wizard to generate sale order from lots."""
18+
if (
19+
not self.env["ir.config_parameter"]
20+
.sudo()
21+
.get_param("sale_order_lot_selection.allow_generate_from_lots")
22+
):
23+
raise AccessError(_("You are not allowed to generate Sale Order from Lot."))
24+
25+
wizard = self.env["stock.lot.sale.order.wizard"].create(
26+
{
27+
"line_ids": [
28+
(
29+
0,
30+
0,
31+
{
32+
"lot_id": lot.id,
33+
"quantity": lot.product_qty,
34+
},
35+
)
36+
for lot in self
37+
]
38+
}
39+
)
40+
41+
return {
42+
"name": _("Add Lot to Sale Order"),
43+
"type": "ir.actions.act_window",
44+
"res_model": "stock.lot.sale.order.wizard",
45+
"view_mode": "form",
46+
"res_id": wizard.id,
47+
"target": "new",
48+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
If you want to allow users to generate sales quotas directly from the stock.lots tree view:
2+
3+
* Go to Inventory > Configuration > Settings
4+
* Under Operations section select the "Allow to generate sales quotations from stock lots" check box
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Sometimes companies need to create quotations with precise lot/serial number
2+
specifications before confirming orders, such as used equipment with unique serial
3+
numbers or specific inventory lots.
4+
5+
This is particularly important in several business scenarios:
6+
7+
* In industries where product traceability is critical and customers need specific
8+
serial numbers (electronics, automotive parts, medical devices)
9+
* When dealing with batches that vary in quality or characteristics, where
10+
customers require products from specific production runs
11+
* In regulated industries where lot traceability is mandatory for compliance
12+
purposes
13+
14+
For example:
15+
16+
* A machinery reseller needs to quote specific used equipment with known serial
17+
numbers
18+
* An electronics distributor must sell particular serial-numbered items for
19+
warranty tracking
20+
* A car parts supplier needs to specify exact serial numbers for rare components

sale_order_lot_selection/readme/CONTRIBUTORS.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
55
* François Honoré <francois.honore@acsone.eu>
66
* Florian da Costa <florian.dacosta@akretion.com>
7+
* `Cetmix <https://cetmix.com>`_:
8+
9+
* George Smirnov
10+
* Anatol Mikheev
Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
- Create/edit a product and set traceability by 'By Lots' option.
2-
- Create a new lot number and assign product.
3-
- Update quantity for that product and assign lot number.
4-
- Go to Sales > Orders > Quotations.
5-
- Create a new quotation and add recently above configured product.
6-
- Select lot number and confirm it.
7-
- Delivery order will reserve the lot when available
1+
There are two ways to add Lots to a Sale Order:
2+
3+
1. From Sale Order:
4+
5+
- Create/edit a product and set traceability by 'By Lots' option
6+
- Create a new lot number and assign product
7+
- Update quantity for that product and assign lot number
8+
- Go to Sales > Orders > Quotations
9+
- Create a new quotation and add recently above configured product
10+
- Select lot number and confirm it
11+
- Delivery order will reserve the lot when available
12+
13+
2. From Lots/Serial Numbers:
14+
15+
- Go to "Sales > Products > Lots/Serial Numbers"
16+
- Select Serial Numbers you would like to add to quotation
17+
- Click action > Create quotation
18+
- In the action wizard:
19+
20+
* To add to existing order: Select a Quotation/Sales order and click "Add"
21+
* To create new order: Click "New" to create quotation with selected lots

0 commit comments

Comments
 (0)