Skip to content

Commit

Permalink
[IMP] For subcontractor total qty on invoice line
Browse files Browse the repository at this point in the history
To avoid quantity difference between invoice line and subcontractor, we copy the quantity from subcontractor to invoice line (if diff is really small), this way, we avoid amount differences between the invoice line and the subcontractor. On the other hand, we loose a bit of accurency between invoice line and timesheet line.
  • Loading branch information
florian-dacosta committed Jan 16, 2025
1 parent 1861e12 commit 0e135f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _compute_timesheet_qty(self):
record.product_uom_id
)
)
if abs(record.timesheet_qty - record.quantity) > 0.001:
if abs(record.timesheet_qty - record.quantity) > 0.002:
record.timesheet_error = "⏰ %s" % record.timesheet_qty

@api.depends(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,22 @@ def _get_invoice_line_vals_list(self, invoice, task_id, all_data):
line_vals = self._prepare_invoice_line(invoice, task, timesheet_lines)
# add subcontractors vals
subcontractor_vals = []
total_subcontractor_quantity = 0.0
for employee_id, line_ids in task_data.items():
val = self._prepare_subcontractor_work(employee_id, line_ids)
subcontractor_vals.append((0, 0, val))
total_subcontractor_quantity += val["quantity"]
if subcontractor_vals:
line_vals["subcontractor_work_ids"] = subcontractor_vals
line_vals["subcontracted"] = True
# To avoid rounding issues between invoice qty and subcontractor line
# quantities, we set the sum of subcontract on invoice line.
# As a security, we still check the difference is small...
if (
abs(line_vals.get("quantity", 0.0) - total_subcontractor_quantity)
< 0.005
):
line_vals["quantity"] = total_subcontractor_quantity

if not inv_line:
invoice_line_vals_list = [(0, 0, line_vals)]
Expand Down

0 comments on commit 0e135f2

Please sign in to comment.