diff --git a/manufacturing_timesheet/__manifest__.py b/manufacturing_timesheet/__manifest__.py index f04458284..216fc9c86 100644 --- a/manufacturing_timesheet/__manifest__.py +++ b/manufacturing_timesheet/__manifest__.py @@ -21,7 +21,7 @@ ################################################################################ { 'name': 'Manufacturing (MRP) Timesheet', - 'version': '18.0.1.0.0', + 'version': '18.0.1.0.1', 'category': 'Manufacturing,Project', 'summary': 'Timesheet for manufacturing.', 'description': """ This module will help you to create timesheet for diff --git a/manufacturing_timesheet/doc/RELEASE_NOTES.md b/manufacturing_timesheet/doc/RELEASE_NOTES.md index 325e4cf79..f6d8f8a91 100644 --- a/manufacturing_timesheet/doc/RELEASE_NOTES.md +++ b/manufacturing_timesheet/doc/RELEASE_NOTES.md @@ -4,3 +4,8 @@ #### Version 18.0.1.0.0 #### ADD - Initial Commit for Manufacturing (MRP) Timesheet + +#### 04.07.2025 +#### Version 18.0.1.0.1 +#### FIX +- Fixed the singleton error that occurred when clicking the 'Produce All' button. \ No newline at end of file diff --git a/manufacturing_timesheet/models/mrp_workorder.py b/manufacturing_timesheet/models/mrp_workorder.py index aec36cb12..83e507ea7 100644 --- a/manufacturing_timesheet/models/mrp_workorder.py +++ b/manufacturing_timesheet/models/mrp_workorder.py @@ -140,20 +140,28 @@ class MrpWorkorder(models.Model): Boolean: Returns true """ res = super(MrpWorkorder, self).button_finish() - project = self.env['project.project'].search( - [('name', '=', ("MO: {}".format(self.production_id.name)))]) - task_id = project.task_ids.search([('name', '=', ( - "{} in {} for {} on {}".format(self.name, self.workcenter_id.name, - self.product_id.display_name, - str(self.date_start))))]) - task_id.write({ - 'allocated_hours': self.duration_expected - }) - timesheet = task_id.mapped('timesheet_ids') - for rec in timesheet: - rec.write({ - 'unit_amount': self.duration, + + for workorder in self: + project = self.env['project.project'].search([ + ('name', '=', f"MO: {workorder.production_id.name}") + ], limit=1) + + task = project.task_ids.search([ + ('name', '=', ( + f"{workorder.name} in {workorder.workcenter_id.name} for " + f"{workorder.product_id.display_name} on {str(workorder.date_start)}" + )) + ], limit=1) + + task.write({ + 'allocated_hours': workorder.duration_expected }) + + for rec in task.timesheet_ids: + rec.write({ + 'unit_amount': workorder.duration, + }) + return res @api.depends('employee_id')