[FIX] mrp: fix planning by workcenter

Since https://github.com/odoo/odoo/commit/926c4d4769db1846d94e2ab5a3e9b02308b0b160
planning by workcenter no longer takes into account unavailabilities of
less than 1 day in month mode, leading to erroneous accumulations
because some calendar unavailabilities (for example from day 5:00 p.m.
to day+1 8:00 a.m.) are missing.
We return to the previous behavior by transmitting all the unavailabilities.

The planning by production no longer displays the unavailability of workcenters.

closes odoo/odoo#123898

Task: 3305266
X-original-commit: d7a803cfbed7aa28d0835f9db974802d4b6f77d1
Related: odoo/enterprise#42017
Signed-off-by: Steve Van Essche <svs@odoo.com>
Signed-off-by: Jean-Francois Aubert (ajf) <ajf@odoo.com>
This commit is contained in:
JF Aubert
2023-06-06 14:48:30 +02:00
parent 70f131626c
commit 65b06f3eff
2 changed files with 4 additions and 6 deletions
+1 -5
View File
@@ -573,15 +573,11 @@ class MrpWorkorder(models.Model):
workcenters = self.env['mrp.workcenter'].browse(workcenter_ids)
unavailability_mapping = workcenters._get_unavailability_intervals(start_datetime, end_datetime)
# Only notable interval (more than one case) is send to the front-end (avoid sending useless information)
cell_dt = (scale in ['day', 'week'] and timedelta(hours=1)) or (scale == 'month' and timedelta(days=1)) or timedelta(days=28)
def add_unavailability(row, workcenter_id=None):
if row.get('groupedBy') and row.get('groupedBy')[0] == 'workcenter_id' and row.get('resId'):
workcenter_id = row.get('resId')
if workcenter_id:
notable_intervals = filter(lambda interval: interval[1] - interval[0] >= cell_dt, unavailability_mapping[workcenter_id])
row['unavailabilities'] = [{'start': interval[0], 'stop': interval[1]} for interval in notable_intervals]
row['unavailabilities'] = [{'start': interval[0], 'stop': interval[1]} for interval in unavailability_mapping[workcenter_id]]
return {'workcenter_id': workcenter_id}
for row in rows:
+3 -1
View File
@@ -321,6 +321,7 @@
<record id="workcenter_line_gantt_production" model="ir.ui.view">
<field name="name">mrp.production.work.order.gantt.production</field>
<field name="model">mrp.workorder</field>
<field name="priority">20</field>
<field name="arch" type="xml">
<gantt class="o_mrp_workorder_gantt" date_stop="date_finished" date_start="date_start" string="Operations" default_group_by="production_id" create="0" delete="0"
progress="progress" plan="0"
@@ -328,7 +329,7 @@
decoration-success="state == 'done'"
decoration-warning="state == 'cancel' or (json_popover and 'text-warning' in json_popover)"
color="workcenter_id"
display_unavailability="1"
display_unavailability="0"
progress_bar="workcenter_id"
total_row="True"
js_class="mrp_workorder_gantt"
@@ -361,6 +362,7 @@
<record id="mrp_workorder_view_gantt" model="ir.ui.view">
<field name="name">mrp.workorder.view.gantt</field>
<field name="model">mrp.workorder</field>
<field name="priority">10</field>
<field name="arch" type="xml">
<gantt class="o_mrp_workorder_gantt" date_stop="date_finished" date_start="date_start" string="Operations" default_group_by="workcenter_id" create="0"
delete="0" sample="1"