Skip to content
Snippets Groups Projects
Commit 5edfd748 authored by althaf shaik's avatar althaf shaik
Browse files

[FIX] mrp: create workorder without workcenter

When user not seleted 'work center' and only selecting 'Scheduled Start Date'
and 'Scheduled End Date' while creating  'work_order' in 'mrp_production',
this traceback raises.

To reproduce the issue:
1. Install 'mrp'
2. Activate 'Work Orders' in configuration/settings
3. Go to menuitem/operation and create 'Manufacturing Orders'
4. Select any product and add a line in Work Orders
5. Give values to 'Scheduled Start Date' and 'Scheduled End Date' only.

Error: A traceback appears:"ValueError: Expected singleton: resource.calendar()"

On '_calculate_duration_expected' method resource_calendar_id value
is getting from 'workcenter_id'.
https://github.com/odoo/odoo/blob/36459d26f1adb92f92d52ce05329e8ad3e95dd91/addons/mrp/models/mrp_workorder.py#L399-L404


Therefore in the above use case, when triggering the onchnage method,
because of resource_calender is dependend on 'workcenter' and when workcenter
is not selected it will lead to the above traceback.

Sentry-4244804815

closes odoo/odoo#124813

Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent cbca63d7
Branches
Tags
No related merge requests found
......@@ -393,7 +393,7 @@ class MrpWorkorder(models.Model):
@api.onchange('date_planned_finished')
def _onchange_date_planned_finished(self):
if self.date_planned_start and self.date_planned_finished:
if self.date_planned_start and self.date_planned_finished and self.workcenter_id:
self.duration_expected = self._calculate_duration_expected()
def _calculate_duration_expected(self, date_planned_start=False, date_planned_finished=False):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment