Skip to content

Commit

Permalink
Merge pull request #58 from akretion/16-improve-consistency-invoice-l…
Browse files Browse the repository at this point in the history
…ine-subcontractor

[IMP] For subcontractor total qty on invoice line
  • Loading branch information
florian-dacosta authored Jan 16, 2025
2 parents 1861e12 + 0e135f2 commit f81e758
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 f81e758

Please sign in to comment.