mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[MIG] mrp_warehouse_calendar: Migration to 16.0
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
{
|
||||
"name": "MRP Warehouse Calendar",
|
||||
"summary": "Considers the warehouse calendars in manufacturing",
|
||||
"version": "15.0.1.0.1",
|
||||
"version": "16.0.1.0.0",
|
||||
"license": "LGPL-3",
|
||||
"website": "https://github.com/OCA/manufacture",
|
||||
"author": "ForgeFlow, Odoo Community Association (OCA)",
|
||||
|
||||
@@ -7,24 +7,26 @@ from odoo import api, models
|
||||
class MrpProduction(models.Model):
|
||||
_inherit = "mrp.production"
|
||||
|
||||
@api.onchange("date_planned_start", "product_id")
|
||||
def _onchange_date_planned_start(self):
|
||||
res = super(MrpProduction, self)._onchange_date_planned_start()
|
||||
if self.date_planned_start and not self.is_planned:
|
||||
@api.depends("company_id", "date_planned_start", "is_planned", "product_id")
|
||||
def _compute_date_planned_finished(self):
|
||||
res = super(MrpProduction, self)._compute_date_planned_finished()
|
||||
productions = self.filtered(lambda p: p.date_planned_start and not p.is_planned)
|
||||
for production in productions:
|
||||
warehouse = self.picking_type_id.warehouse_id
|
||||
if warehouse.calendar_id:
|
||||
if self.product_id.produce_delay:
|
||||
self.date_planned_finished = warehouse.calendar_id.plan_days(
|
||||
+1 * self.product_id.produce_delay + 1, self.date_planned_start
|
||||
if production.product_id.produce_delay:
|
||||
production.date_planned_finished = warehouse.calendar_id.plan_days(
|
||||
+1 * production.product_id.produce_delay + 1,
|
||||
production.date_planned_start,
|
||||
)
|
||||
if self.company_id.manufacturing_lead:
|
||||
self.date_planned_finished = warehouse.calendar_id.plan_days(
|
||||
+1 * self.company_id.manufacturing_lead + 1,
|
||||
self.date_planned_finished,
|
||||
if production.company_id.manufacturing_lead:
|
||||
production.date_planned_finished = warehouse.calendar_id.plan_days(
|
||||
+1 * production.company_id.manufacturing_lead + 1,
|
||||
production.date_planned_finished,
|
||||
)
|
||||
self.move_finished_ids = [
|
||||
(1, m.id, {"date": self.date_planned_finished})
|
||||
for m in self.move_finished_ids
|
||||
production.move_finished_ids = [
|
||||
(1, m.id, {"date": production.date_planned_finished})
|
||||
for m in production.move_finished_ids
|
||||
]
|
||||
return res
|
||||
|
||||
|
||||
@@ -119,11 +119,11 @@ class TestMrpWarehouseCalendar(TransactionCase):
|
||||
"product_qty": 1,
|
||||
"picking_type_id": self.env[
|
||||
"mrp.production"
|
||||
]._get_default_picking_type(),
|
||||
]._get_default_picking_type_id(self.company.id),
|
||||
}
|
||||
)
|
||||
mo.date_planned_start = "2097-01-04 09:00:00"
|
||||
mo._onchange_date_planned_start()
|
||||
mo._compute_date_planned_finished()
|
||||
date_plan_finished = fields.Date.to_date(mo.date_planned_finished)
|
||||
monday = fields.Date.to_date("2097-01-07 09:00:00")
|
||||
self.assertEqual(date_plan_finished, monday)
|
||||
|
||||
Reference in New Issue
Block a user