Skip to content

Commit d799214

Browse files
[MIG] mrp_warehouse_calendar: Migration to 16.0
1 parent 686e31d commit d799214

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

mrp_warehouse_calendar/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "MRP Warehouse Calendar",
66
"summary": "Considers the warehouse calendars in manufacturing",
7-
"version": "15.0.1.0.1",
7+
"version": "16.0.1.0.0",
88
"license": "LGPL-3",
99
"website": "https://github.com/OCA/manufacture",
1010
"author": "ForgeFlow, Odoo Community Association (OCA)",

mrp_warehouse_calendar/models/mrp_production.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,30 @@
77
class MrpProduction(models.Model):
88
_inherit = "mrp.production"
99

10-
@api.onchange("date_planned_start", "product_id")
11-
def _onchange_date_planned_start(self):
12-
res = super(MrpProduction, self)._onchange_date_planned_start()
13-
if self.date_planned_start and not self.is_planned:
10+
@api.depends("company_id", "date_planned_start", "is_planned", "product_id")
11+
def _compute_date_planned_finished(self):
12+
res = super(MrpProduction, self)._compute_date_planned_finished()
13+
productions = self.filtered(lambda p: p.date_planned_start and not p.is_planned)
14+
for production in productions:
1415
warehouse = self.picking_type_id.warehouse_id
1516
if warehouse.calendar_id:
16-
if self.product_id.produce_delay:
17-
self.date_planned_finished = warehouse.calendar_id.plan_days(
18-
+1 * self.product_id.produce_delay + 1, self.date_planned_start
17+
if production.product_id.produce_delay:
18+
production.date_planned_finished = (
19+
warehouse.calendar_id.plan_days(
20+
+1 * production.product_id.produce_delay + 1,
21+
production.date_planned_start,
22+
)
1923
)
20-
if self.company_id.manufacturing_lead:
21-
self.date_planned_finished = warehouse.calendar_id.plan_days(
22-
+1 * self.company_id.manufacturing_lead + 1,
23-
self.date_planned_finished,
24+
if production.company_id.manufacturing_lead:
25+
production.date_planned_finished = (
26+
warehouse.calendar_id.plan_days(
27+
+1 * production.company_id.manufacturing_lead + 1,
28+
production.date_planned_finished,
29+
)
2430
)
25-
self.move_finished_ids = [
26-
(1, m.id, {"date": self.date_planned_finished})
27-
for m in self.move_finished_ids
31+
production.move_finished_ids = [
32+
(1, m.id, {"date": production.date_planned_finished})
33+
for m in production.move_finished_ids
2834
]
2935
return res
3036

mrp_warehouse_calendar/tests/test_mrp_warehouse_calendar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ def test_onchange_date_planned(self):
119119
"product_qty": 1,
120120
"picking_type_id": self.env[
121121
"mrp.production"
122-
]._get_default_picking_type(),
122+
]._get_default_picking_type_id(self.company.id),
123123
}
124124
)
125125
mo.date_planned_start = "2097-01-04 09:00:00"
126-
mo._onchange_date_planned_start()
126+
mo._compute_date_planned_finished()
127127
date_plan_finished = fields.Date.to_date(mo.date_planned_finished)
128128
monday = fields.Date.to_date("2097-01-07 09:00:00")
129129
self.assertEqual(date_plan_finished, monday)

0 commit comments

Comments
 (0)