mirror of
https://github.com/bringout/oca-mrp.git
synced 2026-04-26 08:52:05 +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 product_template
|
||||
from . import mrp_production
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
# Copyright 2023 Camptocamp SA (https://www.camptocamp.com).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class MrpProduction(models.Model):
|
||||
_inherit = "mrp.production"
|
||||
|
||||
def _cal_price(self, consumed_moves):
|
||||
# OVERRIDE to use the theoretical duration of the workcenter
|
||||
# This will overwrite the real duration of the workcenter, but that's ok for now
|
||||
should_overwrite_duration = (
|
||||
self.product_id.mrp_workcenter_cost == "theoretical"
|
||||
and not any(t.cost_already_recorded for t in self.workorder_ids.time_ids)
|
||||
)
|
||||
duration_by_workorder = {}
|
||||
if should_overwrite_duration:
|
||||
workorders = self.workorder_ids.filtered("duration_expected")
|
||||
for workorder in workorders:
|
||||
duration_by_workorder[workorder.id] = workorder.duration
|
||||
workorder.duration = workorder.duration_expected
|
||||
res = super()._cal_price(consumed_moves)
|
||||
# Restore the durations set by users
|
||||
if should_overwrite_duration:
|
||||
for workorder in workorders:
|
||||
workorder.duration = duration_by_workorder[workorder.id]
|
||||
return res
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# Copyright 2023 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = "product.template"
|
||||
|
||||
mrp_workcenter_cost = fields.Selection(
|
||||
selection=[("theoretical", "Theoretical"), ("effective", "Effective")],
|
||||
string="Workcenter Cost Duration",
|
||||
help="Controls how to compute the workcenter cost for manufactured products.\n"
|
||||
"* Theoretical: The cost is computed based on the theoretical duration of the "
|
||||
"workcenter.\n"
|
||||
"* Effective: The cost is computed based on the real duration of the workcenter.",
|
||||
default="effective",
|
||||
required=True,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue