[IMP] mrp: Add setup/cleanup time to Workcenter Specific Capacities
- Add columns setup/cleanup time to Specific Capatities of Workcenter - Take into account these 2 fields when compute expected duration in WO task-2925474 Part-of: odoo/odoo#97588
This commit is contained in:
@@ -292,6 +292,15 @@ class MrpWorkcenter(models.Model):
|
||||
product_capacity = self.capacity_ids.filtered(lambda capacity: capacity.product_id == product)
|
||||
return product_capacity.capacity if product_capacity else self.default_capacity
|
||||
|
||||
def _get_expected_duration(self, product_id):
|
||||
"""Compute the expected duration when using this work-center
|
||||
Always include workcenter startup time and clean-up time.
|
||||
In case there are specific capacities defined in the workcenter
|
||||
that matches the product we are producing. Add the extra-time.
|
||||
"""
|
||||
capacity = self.capacity_ids.filtered(lambda p: p.product_id == product_id)
|
||||
return self.time_start + self.time_stop + (capacity.time_start + capacity.time_stop if capacity else 0.0)
|
||||
|
||||
|
||||
class WorkcenterTag(models.Model):
|
||||
_name = 'mrp.workcenter.tag'
|
||||
@@ -421,6 +430,8 @@ class MrpWorkCenterCapacity(models.Model):
|
||||
product_id = fields.Many2one('product.product', string='Product', required=True)
|
||||
product_uom_id = fields.Many2one('uom.uom', string='Product UoM', related='product_id.uom_id')
|
||||
capacity = fields.Float('Capacity', default=1.0, help="Number of pieces that can be produced in parallel for this product.")
|
||||
time_start = fields.Float('Setup Time (minutes)', help="Time in minutes for the setup.")
|
||||
time_stop = fields.Float('Cleanup Time (minutes)', help="Time in minutes for the cleaning.")
|
||||
|
||||
_sql_constraints = [
|
||||
('positive_capacity', 'CHECK(capacity > 0)', 'Capacity should be a positive number.'),
|
||||
|
||||
@@ -745,7 +745,7 @@ class MrpWorkorder(models.Model):
|
||||
duration_expected_working = (self.duration_expected - self.workcenter_id.time_start - self.workcenter_id.time_stop) * self.workcenter_id.time_efficiency / 100.0
|
||||
if duration_expected_working < 0:
|
||||
duration_expected_working = 0
|
||||
return self.workcenter_id.time_start + self.workcenter_id.time_stop + duration_expected_working * ratio * 100.0 / self.workcenter_id.time_efficiency
|
||||
return self.workcenter_id._get_expected_duration(self.product_id) + duration_expected_working * ratio * 100.0 / self.workcenter_id.time_efficiency
|
||||
qty_production = self.production_id.product_uom_id._compute_quantity(self.qty_production, self.production_id.product_id.uom_id)
|
||||
capacity = self.workcenter_id._get_capacity(self.product_id)
|
||||
cycle_number = float_round(qty_production / capacity, precision_digits=0, rounding_method='UP')
|
||||
@@ -756,9 +756,9 @@ class MrpWorkorder(models.Model):
|
||||
duration_expected_working = 0
|
||||
capacity = alternative_workcenter._get_capacity(self.product_id)
|
||||
alternative_wc_cycle_nb = float_round(qty_production / capacity, precision_digits=0, rounding_method='UP')
|
||||
return alternative_workcenter.time_start + alternative_workcenter.time_stop + alternative_wc_cycle_nb * duration_expected_working * 100.0 / alternative_workcenter.time_efficiency
|
||||
return alternative_workcenter._get_expected_duration(self.product_id) + alternative_wc_cycle_nb * duration_expected_working * 100.0 / alternative_workcenter.time_efficiency
|
||||
time_cycle = self.operation_id.time_cycle
|
||||
return self.workcenter_id.time_start + self.workcenter_id.time_stop + cycle_number * time_cycle * 100.0 / self.workcenter_id.time_efficiency
|
||||
return self.workcenter_id._get_expected_duration(self.product_id) + cycle_number * time_cycle * 100.0 / self.workcenter_id.time_efficiency
|
||||
|
||||
def _get_conflicted_workorder_ids(self):
|
||||
"""Get conlicted workorder(s) with self.
|
||||
|
||||
@@ -393,6 +393,8 @@
|
||||
<field name="product_id"/>
|
||||
<field name="product_uom_id" groups="uom.group_uom"/>
|
||||
<field name="capacity"/>
|
||||
<field name="time_start" optional="hide"/>
|
||||
<field name="time_stop" optional="hide"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
||||
Reference in New Issue
Block a user