Browse Source

July 05: [FIX] Bug Fixed 'manufacturing_timesheet'

17.0
Cybrosys Technologies 5 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',
'version': '17.0.1.0.0',
'version': '17.0.1.0.1',
'category': 'Manufacturing,Project',
'summary': 'Timesheet for manufacturing.',
'description': """ This module will help you to create timesheet for

7
manufacturing_timesheet/doc/RELEASE_NOTES.md

@ -8,4 +8,9 @@
#### 08.11.2024
#### Version 17.0.1.0.0
#### 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()
allocated_hours = int(self.duration_expected)
allocated_minutes = int(
(self.duration_expected - allocated_hours) * 60)
allocated_time_str = f"{allocated_hours:02d}:{allocated_minutes:02d}"
allocated_minutes_str, allocated_seconds_str = allocated_time_str.split(
":")
allocated_minutes = int(allocated_minutes_str)
allocated_seconds = int(allocated_minutes_str)
total_allocated_hours = (
allocated_minutes + allocated_seconds / 60) / 60
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': total_allocated_hours
})
timesheet = task_id.mapped('timesheet_ids')
hours = int(self.duration)
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,
for workorder in self:
allocated_hours = int(workorder.duration_expected)
allocated_minutes = int((workorder.duration_expected - allocated_hours) * 60)
allocated_time_str = f"{allocated_hours:02d}:{allocated_minutes:02d}"
allocated_minutes_str, allocated_seconds_str = allocated_time_str.split(":")
allocated_minutes = int(allocated_minutes_str)
allocated_seconds = int(allocated_seconds_str)
total_allocated_hours = (allocated_minutes + allocated_seconds / 60) / 60
project = self.env['project.project'].search([
('name', '=', f"MO: {workorder.production_id.name}")
], limit=1)
task_id = project.task_ids.search([
('name', '=', f"{workorder.name} in {workorder.workcenter_id.name} "
f"for {workorder.product_id.display_name} on {workorder.date_start}")
], limit=1)
task_id.write({
'allocated_hours': total_allocated_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

Loading…
Cancel
Save