Thursday, March 25, 2021
1 change · master
Enhancements to existing features
Field service projects can now bill work using employee-specific rates, so timesheets from different workers generate the right sales order lines automatically. This reduces manual workarounds, improves invoicing accuracy, and clarifies how task sales order changes affect related timesheets.
Original PR description
Purpose ====== Currently, the user can configure his field service project to be billed at an employee rate but it just won't work. The rates configured for each employee on the project are not taken…
Purpose
======
Currently, the user can configure his field service project to be billed at an employee rate but it just won't work. The rates configured for each employee on the project are not taken into account when the task is marked as done. As a consequence, the only workaround to support this kind of use-case is to create 1 task per employee with a different rate (or to add service products on the task). Those solutions are far from being ideal. We should give more flexibility.
## Details
- Add employee rate for fsm projects, now the employee mappings list is visible for fsm projects and when the user adds an employee mapping, then the pricing type of this project is computed to set it on employee rate. Moreover, in the employee mapping for fsm projects, an employee is not linked to a SOL like a basic project, he is linked to a service product.
- Generate SOLs in SO of the task for employee rate when the user marks as done the task. For this generation, for each employee who timesheet on the task and in the employee mappings defined in the project, we take the product and the price unit on the mapping for these employees and we generate a SOL for each product and price unit. That is, if 2 employees are in the mapping with the same product but the price unit is different than 2 SOLs are generated on the SO for this case.
- Add a reutrn value on the _fsm_ensure_sale_order to return the SO as expected in the commentary of this method.
- Move the timesheet_product_id of employee mappings (`project.sale.line.employee.map` model) from sale_timesheet to industry_fsm_sale, because this field is only used for fsm projects.
- Update the materials product count for the stat button of products in the task to not count the service products based on the employee rate.
- Determine the correct SOL for each timesheet in a fsm task when the user changes the SOL of this fsm task which the pricing type of the project is employee rate.
- When the user wants to create a task on a existing project when a service product is added in a SO, the list of available projects in project_id field of product.template is filtered to have only the projects that satisfy this condition:
- allow_billable=True
- pricing_type='task_rate'
- allow_timesheets in [service_policy == 'delivered_timesheet' or '', True]
Thus, the fsm project with the pricing type is equal to 'employee_rate' does not satisfy this condition.
This condition has been changed to get this condition and then accept fsm projects with any pricing type:
- allow_billable=True
- pricing_type='task_rate' or is_fsm=True
- allow_timesheets in [service_policy == 'delivered_timesheet' or '', True]
task-2376382
Community PR: odoo/odoo#66157
Upgrade PR: odoo/upgrade#2160