mirror of
https://github.com/bringout/oca-mrp.git
synced 2026-04-26 19:12:01 +02:00
Initial commit: OCA Mrp packages (117 packages)
This commit is contained in:
commit
277e84fd7a
4403 changed files with 395154 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
from . import mrp_production
|
||||
from . import stock_rule
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
# Copyright 2018-19 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class MrpProduction(models.Model):
|
||||
_inherit = "mrp.production"
|
||||
|
||||
@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 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 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,
|
||||
)
|
||||
production.move_finished_ids = [
|
||||
(1, m.id, {"date": production.date_planned_finished})
|
||||
for m in production.move_finished_ids
|
||||
]
|
||||
return res
|
||||
|
||||
@api.returns("self", lambda value: value.id)
|
||||
def copy(self, default=None):
|
||||
mo = super().copy(default=default)
|
||||
dt_planned = mo.date_planned_start
|
||||
warehouse = mo.picking_type_id.warehouse_id
|
||||
if warehouse.calendar_id and mo.product_id.produce_delay:
|
||||
date_expected = warehouse.calendar_id.plan_days(
|
||||
+1 * self.product_id.produce_delay + 1, dt_planned
|
||||
)
|
||||
mo.date_planned_finished = date_expected
|
||||
return mo
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# Copyright 2018-19 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class StockRule(models.Model):
|
||||
_inherit = "stock.rule"
|
||||
|
||||
def _get_date_planned(self, product_id, company_id, values):
|
||||
date_planned = super()._get_date_planned(product_id, company_id, values)
|
||||
picking_type = self.picking_type_id or values["warehouse_id"].manu_type_id
|
||||
# We force the date planned to be at the beginning of the day.
|
||||
# So no work intervals are found in planned date.
|
||||
dt_planned = fields.Datetime.to_datetime(values["date_planned"]).replace(hour=0)
|
||||
warehouse = picking_type.warehouse_id
|
||||
if warehouse.calendar_id and product_id.produce_delay:
|
||||
lead_days = (
|
||||
values["company_id"].manufacturing_lead + product_id.produce_delay
|
||||
)
|
||||
date_expected = warehouse.calendar_id.plan_days(-1 * lead_days, dt_planned)
|
||||
date_planned = date_expected
|
||||
return date_planned
|
||||
Loading…
Add table
Add a link
Reference in a new issue