Skip to content

Commit 6974973

Browse files
committed
[FIX]stock_picking_state: domain for state_detail_id in tree view
1 parent 8db6174 commit 6974973

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

stock_picking_state/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
##############################################################################
2020
{
2121
"name": "Stock Picking State",
22-
"version": "18.0.1.0.0",
22+
"version": "18.0.1.1.0",
2323
"category": "Warehouse Management",
2424
"sequence": 14,
2525
"summary": "",

stock_picking_state/models/stock_picking.py

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# directory
44
##############################################################################
55
from odoo import api, fields, models
6+
from odoo.exceptions import ValidationError
67

78

89
class StockPicking(models.Model):
@@ -24,3 +25,11 @@ def change_state(self):
2425
if rec.state_detail_id and rec.state_detail_id in state_detail:
2526
continue
2627
rec.state_detail_id = state_detail and state_detail[0]
28+
29+
@api.constrains("state_detail_id")
30+
def change_state_detail_id(self):
31+
for rec in self:
32+
if rec.picking_type_id.code != rec.state_detail_id.picking_type or rec.state != rec.state_detail_id.state:
33+
raise ValidationError(
34+
f"You're selecting a state detail that doesn’t belong to this state: {rec.state} or picking type: {rec.picking_type_id.code}"
35+
)

stock_picking_state/views/stock_picking_views.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<field name="inherit_id" ref="stock.vpicktree"/>
77
<field name="arch" type="xml">
88
<field name="state" position="after">
9-
<field name="state_detail_id"/>
9+
<field name="state_detail_id" domain="[('state','=', state),'|',('picking_type','=', picking_type_code), ('picking_type','=', False)]"/>
1010
</field>
1111
</field>
1212
</record>

0 commit comments

Comments
 (0)