Browse Source

July 05: [FIX] Bug Fixed 'manufacturing_timesheet'

17.0
Cybrosys Technologies 6 days ago
parent
commit
8e3136b365
  1. 2
      manufacturing_timesheet/__manifest__.py
  2. 7
      manufacturing_timesheet/doc/RELEASE_NOTES.md
  3. 68
      manufacturing_timesheet/models/mrp_workorder.py

2
manufacturing_timesheet/__manifest__.py

@ -21,7 +21,7 @@
################################################################################ ################################################################################
{ {
'name': 'Manufacturing (MRP) Timesheet', 'name': 'Manufacturing (MRP) Timesheet',
'version': '17.0.1.0.0', 'version': '17.0.1.0.1',
'category': 'Manufacturing,Project', 'category': 'Manufacturing,Project',
'summary': 'Timesheet for manufacturing.', 'summary': 'Timesheet for manufacturing.',
'description': """ This module will help you to create timesheet for 'description': """ This module will help you to create timesheet for

7
manufacturing_timesheet/doc/RELEASE_NOTES.md

@ -8,4 +8,9 @@
#### 08.11.2024 #### 08.11.2024
#### Version 17.0.1.0.0 #### Version 17.0.1.0.0
#### Updated #### Updated
- Updated the code for adding the value to allocated hours while creating a project task in the MRP work order. Also updated it in index. - Updated the code for adding the value to allocated hours while creating a project task in the MRP work order. Also updated it in index.
#### 04.07.2025
#### Version 17.0.1.0.1
#### FIX
- Fixed the singleton error that occurred when clicking the 'Produce All' button.

68
manufacturing_timesheet/models/mrp_workorder.py

@ -168,35 +168,43 @@ class MrpWorkorder(models.Model):
""" """
res = super(MrpWorkorder, self).button_finish() res = super(MrpWorkorder, self).button_finish()
allocated_hours = int(self.duration_expected) for workorder in self:
allocated_minutes = int( allocated_hours = int(workorder.duration_expected)
(self.duration_expected - allocated_hours) * 60) allocated_minutes = int((workorder.duration_expected - allocated_hours) * 60)
allocated_time_str = f"{allocated_hours:02d}:{allocated_minutes:02d}" allocated_time_str = f"{allocated_hours:02d}:{allocated_minutes:02d}"
allocated_minutes_str, allocated_seconds_str = allocated_time_str.split( allocated_minutes_str, allocated_seconds_str = allocated_time_str.split(":")
":")
allocated_minutes = int(allocated_minutes_str) allocated_minutes = int(allocated_minutes_str)
allocated_seconds = int(allocated_minutes_str) allocated_seconds = int(allocated_seconds_str)
total_allocated_hours = (
allocated_minutes + allocated_seconds / 60) / 60 total_allocated_hours = (allocated_minutes + allocated_seconds / 60) / 60
project = self.env['project.project'].search(
[('name', '=', ("MO: {}".format(self.production_id.name)))]) project = self.env['project.project'].search([
task_id = project.task_ids.search([('name', '=', ( ('name', '=', f"MO: {workorder.production_id.name}")
"{} in {} for {} on {}".format(self.name, self.workcenter_id.name, ], limit=1)
self.product_id.display_name, task_id = project.task_ids.search([
str(self.date_start))))]) ('name', '=', f"{workorder.name} in {workorder.workcenter_id.name} "
task_id.write({ f"for {workorder.product_id.display_name} on {workorder.date_start}")
'allocated_hours': total_allocated_hours ], limit=1)
})
timesheet = task_id.mapped('timesheet_ids') task_id.write({
hours = int(self.duration) 'allocated_hours': total_allocated_hours
minutes = int((self.duration - hours) * 60)
time_str = f"{hours:02d}:{minutes:02d}"
minutes_str, seconds_str = time_str.split(":")
minutes = int(minutes_str)
seconds = int(seconds_str)
total_hours = (minutes + seconds / 60) / 60
for rec in timesheet:
rec.write({
'unit_amount': total_hours,
}) })
timesheet = task_id.mapped('timesheet_ids')
hours = int(workorder.duration)
minutes = int((workorder.duration - hours) * 60)
time_str = f"{hours:02d}:{minutes:02d}"
minutes_str, seconds_str = time_str.split(":")
minutes = int(minutes_str)
seconds = int(seconds_str)
total_hours = (minutes + seconds / 60) / 60
for rec in timesheet:
rec.write({
'unit_amount': total_hours,
})
return res return res

Loading…
Cancel
Save