summaryrefslogtreecommitdiff
path: root/addons/mrp/models/mrp_workorder.py
diff options
context:
space:
mode:
authorWilliam Henrotin <whe@odoo.com>2020-07-27 13:17:46 +0000
committerWilliam Henrotin <whe@odoo.com>2020-08-10 09:40:24 +0000
commit963ad5eada35f22cc074b4becf4e55ac5edad63b (patch)
tree14f24c1eed8ad745be411b87da834a6ed5e60f0e /addons/mrp/models/mrp_workorder.py
parent68f06c7accbc903981bbaa47fdc8024bb7229f11 (diff)
[FIX] mrp: keep duration ratio
Updating the quantity to produce on a production order will recompute the expected production duration. This can be counter productive on prototyping production when no BoM are given. The default expected batch duration is set to 60 minutes. Setting the actual production time then updating the quantity to produce will naively change the duration to 60 x the new quantity. This commit compute the duration pro rata in case of 'no BoM' production and recompute everything in case of BoM production. Task : 2278147
Diffstat (limited to 'addons/mrp/models/mrp_workorder.py')
-rw-r--r--addons/mrp/models/mrp_workorder.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py
index f100c361984..5ffb7ffc860 100644
--- a/addons/mrp/models/mrp_workorder.py
+++ b/addons/mrp/models/mrp_workorder.py
@@ -671,10 +671,15 @@ class MrpWorkorder(models.Model):
for wo in self:
wo.qty_remaining = float_round(wo.qty_production - wo.qty_produced, precision_rounding=wo.production_id.product_uom_id.rounding)
- def _get_duration_expected(self, alternative_workcenter=False):
+ def _get_duration_expected(self, alternative_workcenter=False, ratio=1):
self.ensure_one()
if not self.workcenter_id:
return False
+ if not self.operation_id:
+ 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
qty_production = self.production_id.product_uom_id._compute_quantity(self.qty_production, self.production_id.product_id.uom_id)
cycle_number = float_round(qty_production / self.workcenter_id.capacity, precision_digits=0, rounding_method='UP')
if alternative_workcenter: