Skip to content

Commit 22bdf26

Browse files
committed
[MIG] maintenance_stock: Migration to 14.0
1 parent b6a5612 commit 22bdf26

10 files changed

+195
-213
lines changed

maintenance_stock/__manifest__.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@
55
"summary": "Links maintenance requests to stock",
66
"author": "Odoo Community Association (OCA), Solvos",
77
"license": "AGPL-3",
8-
"version": "13.0.1.0.0",
8+
"version": "14.0.1.0.0",
99
"category": "Warehouse",
1010
"website": "https://github.com/OCA/maintenance",
11-
"depends": ["base_maintenance", "stock",],
11+
"depends": [
12+
"base_maintenance",
13+
"stock",
14+
],
1215
"data": [
1316
"views/maintenance_equipment_views.xml",
1417
"views/maintenance_request_views.xml",
1518
"views/stock_move_views.xml",
1619
"views/stock_move_line_views.xml",
1720
"views/stock_picking_views.xml",
1821
],
19-
"demo": ["data/demo_maintenance_stock.xml",],
22+
"demo": [
23+
"data/demo_maintenance_stock.xml",
24+
],
2025
"post_init_hook": "post_init_hook",
2126
"installable": True,
2227
}
+135-132
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,150 @@
11
<?xml version="1.0" encoding="utf-8" ?>
2-
<odoo>
3-
<data noupdate="1">
2+
<odoo noupdate="1">
3+
<record id="location_inventory" model="stock.location">
4+
<field name="name">Inventory adjustment</field>
5+
<field name="usage">inventory</field>
46

5-
<record id="stock_warehouse_maintenance" model="stock.warehouse">
6-
<field name="name">Maintenance Warehouse</field>
7-
<field name="partner_id" ref="stock.res_partner_address_41" />
8-
<field name="code">Main</field>
9-
</record>
7+
</record>
8+
<record id="stock_warehouse_maintenance" model="stock.warehouse">
9+
<field name="name">Maintenance Warehouse</field>
10+
<field name="partner_id" ref="stock.res_partner_address_41" />
11+
<field name="code">Main</field>
12+
<field name="reception_steps">one_step</field>
13+
<field name="delivery_steps">ship_only</field>
14+
</record>
1015

11-
<function model="ir.model.data" name="_update_xmlids">
12-
<value
13-
model="base"
14-
eval="[{
15-
'xml_id': 'maintenance_stock.main_picking_type_cons',
16-
'record': obj().env.ref('maintenance_stock.stock_warehouse_maintenance').cons_type_id,
17-
'noupdate': True,
18-
}, {
19-
'xml_id': 'maintenance_stock.main_location_stock',
20-
'record': obj().env.ref('maintenance_stock.stock_warehouse_maintenance').lot_stock_id,
21-
'noupdate': True,
22-
}, {
23-
'xml_id': 'maintenance_stock.main_location_cons',
24-
'record': obj().env.ref('maintenance_stock.stock_warehouse_maintenance').wh_cons_loc_id,
25-
'noupdate': True,
26-
}]"
27-
/>
28-
</function>
16+
<function model="ir.model.data" name="_update_xmlids">
17+
<value
18+
model="base"
19+
eval="[{
20+
'xml_id': 'maintenance_stock.main_picking_type_cons',
21+
'record': obj().env.ref('maintenance_stock.stock_warehouse_maintenance').cons_type_id,
22+
'noupdate': True,
23+
}, {
24+
'xml_id': 'maintenance_stock.main_location_stock',
25+
'record': obj().env.ref('maintenance_stock.stock_warehouse_maintenance').lot_stock_id,
26+
'noupdate': True,
27+
}, {
28+
'xml_id': 'maintenance_stock.main_location_cons',
29+
'record': obj().env.ref('maintenance_stock.stock_warehouse_maintenance').wh_cons_loc_id,
30+
'noupdate': True,
31+
}]"
32+
/>
33+
</function>
2934

30-
<record id="product_toner" model="product.product">
31-
<field name="default_code">TON_1234</field>
32-
<field name="name">Toner</field>
33-
<field name="type">product</field>
34-
<field name="categ_id" ref="product.product_category_5" />
35-
<field name="lst_price">100.0</field>
36-
<field name="standard_price">70.0</field>
37-
<field name="uom_id" ref="uom.product_uom_unit" />
38-
<field name="uom_po_id" ref="uom.product_uom_unit" />
39-
<field
40-
name="image"
41-
type="base64"
42-
file="maintenance_stock/static/img/toner.png"
43-
/>
44-
</record>
35+
<record id="product_toner" model="product.product">
36+
<field name="default_code">TON_1234</field>
37+
<field name="name">Toner</field>
38+
<field name="type">product</field>
39+
<field name="categ_id" ref="product.product_category_5" />
40+
<field name="lst_price">100.0</field>
41+
<field name="standard_price">70.0</field>
42+
<field name="uom_id" ref="uom.product_uom_unit" />
43+
<field name="uom_po_id" ref="uom.product_uom_unit" />
44+
<field
45+
name="image_1920"
46+
type="base64"
47+
file="maintenance_stock/static/img/toner.png"
48+
/>
4549

46-
<record id="stock_inventory_toner" model="stock.inventory">
47-
<field name="name">Inventory for Toner</field>
48-
<field
49-
name="product_ids"
50-
eval="[(4, ref('maintenance_stock.product_toner'))]"
51-
/>
52-
</record>
50+
</record>
5351

54-
<record id="stock_inventory_toner_line" model="stock.inventory.line">
55-
<field name="product_id" ref="maintenance_stock.product_toner" />
56-
<field name="product_uom_id" ref="uom.product_uom_unit" />
57-
<field name="inventory_id" ref="maintenance_stock.stock_inventory_toner" />
58-
<field name="product_qty">50.0</field>
59-
<field name="location_id" ref="maintenance_stock.main_location_stock" />
60-
</record>
52+
<record id="stock_inventory_toner" model="stock.inventory">
53+
<field name="name">Inventory for Toner</field>
54+
<field
55+
name="product_ids"
56+
eval="[(6,0,[ref('maintenance_stock.product_toner'),])]"
57+
/>
6158

62-
<function model="stock.inventory" name="_action_start">
63-
<function
64-
eval="[[('state','=','draft'),('id', '=', ref('maintenance_stock.stock_inventory_toner'))]]"
65-
model="stock.inventory"
66-
name="search"
67-
/>
68-
</function>
59+
</record>
6960

70-
<function model="stock.inventory" name="action_validate">
71-
<function
72-
eval="[[('state','=','confirm'),('id', '=', ref('maintenance_stock.stock_inventory_toner'))]]"
73-
model="stock.inventory"
74-
name="search"
75-
/>
76-
</function>
61+
<record id="stock_inventory_toner_line" model="stock.inventory.line">
62+
<field name="product_id" ref="maintenance_stock.product_toner" />
63+
<field name="product_uom_id" ref="uom.product_uom_unit" />
64+
<field name="inventory_id" ref="maintenance_stock.stock_inventory_toner" />
65+
<field name="product_qty">50.0</field>
66+
<field name="location_id" ref="maintenance_stock.main_location_stock" />
67+
</record>
68+
<function name="action_start" model="stock.inventory">
69+
<function
70+
eval="[[('id', '=', ref('maintenance_stock.stock_inventory_toner'))]]"
71+
model="stock.inventory"
72+
name="search"
73+
/>
74+
</function>
75+
<function model="stock.inventory" name="action_validate">
76+
<function
77+
eval="[[('state','in', ['draft', 'confirm']),('id', '=', ref('maintenance_stock.stock_inventory_toner'))]]"
78+
model="stock.inventory"
79+
name="search"
80+
/>
81+
</function>
7782

78-
<record id="maintenance.equipment_printer1" model="maintenance.equipment">
79-
<field name="allow_consumptions" eval="True" />
80-
<field
81-
name="default_consumption_warehouse_id"
82-
ref="maintenance_stock.stock_warehouse_maintenance"
83-
/>
84-
</record>
83+
<record id="maintenance.equipment_printer1" model="maintenance.equipment">
84+
<field name="allow_consumptions" eval="True" />
85+
<field
86+
name="default_consumption_warehouse_id"
87+
ref="maintenance_stock.stock_warehouse_maintenance"
88+
/>
8589

86-
<record id="m_request_1" model="maintenance.request">
87-
<field name="name">Change toner</field>
88-
<field name="user_id" ref="base.user_demo" />
89-
<field name="owner_user_id" ref="base.user_admin" />
90-
<field name="equipment_id" ref="maintenance.equipment_printer1" />
91-
<field name="color">7</field>
92-
<field name="stage_id" ref="maintenance.stage_1" />
93-
<field
94-
name="maintenance_team_id"
95-
ref="maintenance.equipment_team_maintenance"
96-
/>
97-
</record>
90+
</record>
9891

99-
<record id="consuption_picking_m_request_1" model="stock.picking">
100-
<field
101-
name="picking_type_id"
102-
ref="maintenance_stock.main_picking_type_cons"
103-
/>
104-
<field name="date" eval="DateTime.today() - timedelta(days=15)" />
105-
<field name="location_id" ref="maintenance_stock.main_location_stock" />
106-
<field name="location_dest_id" ref="maintenance_stock.main_location_cons" />
107-
<field name="maintenance_request_id" ref="maintenance_stock.m_request_1" />
108-
<field
109-
name="move_lines"
110-
model="stock.move"
111-
eval="[(0, 0, {
112-
'name': obj().env.ref('maintenance_stock.product_toner').name,
113-
'product_id': ref('maintenance_stock.product_toner'),
114-
'product_uom': ref('uom.product_uom_unit'),
115-
'product_uom_qty': 1.0,
116-
'picking_type_id': ref('maintenance_stock.main_picking_type_cons'),
117-
'location_id': ref('maintenance_stock.main_location_stock'),
118-
'location_dest_id': ref('maintenance_stock.main_location_cons'),
119-
'move_line_ids': [(0, 0, {
120-
'product_id': ref('maintenance_stock.product_toner'),
121-
'qty_done': 1,
122-
'product_uom_id': ref('uom.product_uom_unit'),
123-
'location_id': ref('maintenance_stock.main_location_stock'),
124-
'location_dest_id': ref('maintenance_stock.main_location_cons'),
125-
})],
126-
})]"
127-
/>
128-
</record>
92+
<record id="m_request_1" model="maintenance.request">
93+
<field name="name">Change toner</field>
94+
<field name="user_id" ref="base.user_demo" />
95+
<field name="owner_user_id" ref="base.user_admin" />
96+
<field name="equipment_id" ref="maintenance.equipment_printer1" />
97+
<field name="color">7</field>
98+
<field name="stage_id" ref="maintenance.stage_1" />
12999

130-
<function model="stock.picking" name="action_confirm">
131-
<value
132-
model="stock.picking"
133-
eval="[
134-
obj().env.ref('maintenance_stock.consuption_picking_m_request_1').id]"
135-
/>
136-
</function>
100+
</record>
101+
<record model="stock.quant" id="stock_quant_toner">
102+
<field name="product_id" ref="maintenance_stock.product_toner" />
103+
<field name="location_id" ref="maintenance_stock.main_location_stock" />
104+
<field name="quantity">1.0</field>
105+
</record>
106+
<record id="consuption_picking_m_request_1" model="stock.picking">
107+
<field name="picking_type_id" ref="maintenance_stock.main_picking_type_cons" />
108+
<field name="date" eval="DateTime.today() - timedelta(days=15)" />
109+
<field name="location_id" ref="maintenance_stock.main_location_stock" />
110+
<field name="location_dest_id" ref="maintenance_stock.main_location_cons" />
111+
<field name="maintenance_request_id" ref="maintenance_stock.m_request_1" />
137112

138-
<function model="stock.picking" name="action_done">
139-
<value
140-
model="stock.picking"
141-
eval="[
142-
obj().env.ref('maintenance_stock.consuption_picking_m_request_1').id]"
143-
/>
144-
</function>
113+
<field
114+
name="move_lines"
115+
model="stock.move"
116+
eval="[(0, 0, {
117+
'name': obj().env.ref('maintenance_stock.product_toner').name,
118+
'product_id': ref('maintenance_stock.product_toner'),
119+
'product_uom': ref('uom.product_uom_unit'),
120+
'product_uom_qty': 1.0,
121+
'picking_type_id': ref('maintenance_stock.main_picking_type_cons'),
122+
'location_id': ref('maintenance_stock.main_location_stock'),
123+
'location_dest_id': ref('maintenance_stock.main_location_cons'),
145124
146-
</data>
125+
})]"
126+
/>
127+
</record>
128+
129+
<function model="stock.picking" name="action_confirm">
130+
<value
131+
model="stock.picking"
132+
eval="[
133+
obj().env.ref('maintenance_stock.consuption_picking_m_request_1').id]"
134+
/>
135+
</function>
136+
<function model="stock.picking" name="action_assign">
137+
<value
138+
model="stock.picking"
139+
eval="[
140+
obj().env.ref('maintenance_stock.consuption_picking_m_request_1').id]"
141+
/>
142+
</function>
143+
<function model="stock.picking" name="button_validate">
144+
<value
145+
model="stock.picking"
146+
eval="[
147+
obj().env.ref('maintenance_stock.consuption_picking_m_request_1').id]"
148+
/>
149+
</function>
147150
</odoo>

maintenance_stock/models/maintenance_equipment.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
class MaintenanceEquipment(models.Model):
77
_inherit = "maintenance.equipment"
88

9-
stock_picking_ids = fields.One2many(
10-
comodel_name="stock.picking",
11-
inverse_name="maintenance_equipment_id",
12-
groups="stock.group_stock_user",
13-
)
149
allow_consumptions = fields.Boolean(
1510
groups="stock.group_stock_user",
1611
)
@@ -27,7 +22,9 @@ def _onchange_allow_consumptions(self):
2722

2823
def action_view_stock_picking_ids(self):
2924
self.ensure_one()
30-
action = self.env.ref("stock.action_picking_tree_all").read()[0]
25+
action = self.env["ir.actions.act_window"]._for_xml_id(
26+
"stock.action_picking_tree_all"
27+
)
3128
action["domain"] = [("maintenance_equipment_id", "=", self.id)]
3229
action["context"] = {
3330
"show_maintenance_request_id": True,
@@ -36,13 +33,17 @@ def action_view_stock_picking_ids(self):
3633

3734
def action_view_stock_move_ids(self):
3835
self.ensure_one()
39-
action = self.env.ref("stock.stock_move_action").read()[0]
36+
action = self.env["ir.actions.act_window"]._for_xml_id(
37+
"stock.stock_move_action"
38+
)
4039
action["domain"] = [("maintenance_equipment_id", "=", self.id)]
4140
return action
4241

4342
def action_view_stock_move_line_ids(self):
4443
self.ensure_one()
45-
action = self.env.ref("stock.stock_move_line_action").read()[0]
44+
action = self.env["ir.actions.act_window"]._for_xml_id(
45+
"stock.stock_move_line_action"
46+
)
4647
action["domain"] = [("maintenance_equipment_id", "=", self.id)]
4748

4849
# TODO Grouping by destination allows separating consumptions

maintenance_stock/models/maintenance_request.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ class MaintenanceRequest(models.Model):
2424

2525
def action_view_stock_picking_ids(self):
2626
self.ensure_one()
27-
action = self.env.ref("stock.stock_picking_action_picking_type").read()[0]
27+
action = self.env["ir.actions.act_window"]._for_xml_id(
28+
"stock.stock_picking_action_picking_type"
29+
)
2830
action["domain"] = [("maintenance_request_id", "=", self.id)]
2931
action["context"] = {
3032
"default_picking_type_id": self.default_consumption_warehouse_id.cons_type_id.id,
@@ -34,13 +36,17 @@ def action_view_stock_picking_ids(self):
3436

3537
def action_view_stock_move_ids(self):
3638
self.ensure_one()
37-
action = self.env.ref("stock.stock_move_action").read()[0]
39+
action = self.env["ir.actions.act_window"]._for_xml_id(
40+
"stock.stock_move_action"
41+
)
3842
action["domain"] = [("maintenance_request_id", "=", self.id)]
3943
return action
4044

4145
def action_view_stock_move_line_ids(self):
4246
self.ensure_one()
43-
action = self.env.ref("stock.stock_move_line_action").read()[0]
47+
action = self.env["ir.actions.act_window"]._for_xml_id(
48+
"stock.stock_move_line_action"
49+
)
4450
action["domain"] = [("maintenance_request_id", "=", self.id)]
4551

4652
# TODO Grouping by destination allows separating consumptions

0 commit comments

Comments
 (0)