[IMP] sale_{project,timesheet}: set SOL in project even if no partner set
Before this commit, when the user configures his project and wants to set a default SOL, he must first define the customer of the project before setting the SOL. Same process for the SOL in employee mappings. This commit allows the user to choose a SOL as default SOL or the one in the employee mappings in his project even if no customer is defined into it. task-2442683 closes #66181
This commit is contained in:
committed by
Yannick Tivisse
parent
3444e37e17
commit
6463755f15
@@ -13,7 +13,7 @@ class Project(models.Model):
|
||||
sale_line_id = fields.Many2one(
|
||||
'sale.order.line', 'Sales Order Item', copy=False,
|
||||
compute="_compute_sale_line_id", store=True, readonly=False,
|
||||
domain="[('is_service', '=', True), ('is_expense', '=', False), ('state', 'in', ['sale', 'done']), ('order_partner_id', '=', partner_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]",
|
||||
domain="[('is_service', '=', True), ('is_expense', '=', False), ('state', 'in', ['sale', 'done']), ('order_partner_id', '=?', partner_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]",
|
||||
help="Sales order item to which the project is linked. Link the timesheet entry to the sales order item defined on the project. "
|
||||
"Only applies on tasks without sale order item defined, and if the employee is not in the 'Employee/Sales Order Item Mapping' of the project.")
|
||||
sale_order_id = fields.Many2one(string='Sales Order', related='sale_line_id.order_id', help="Sales order to which the project is linked.")
|
||||
|
||||
@@ -92,10 +92,14 @@ class AccountAnalyticLine(models.Model):
|
||||
if self.project_id.sale_line_id:
|
||||
return self.project_id.sale_line_id
|
||||
if self.task_id.allow_billable and self.task_id.sale_line_id:
|
||||
if self.task_id.pricing_type in ('task_rate', 'fixed_rate') or self.task_id.partner_id != self.project_id.partner_id:
|
||||
if self.task_id.pricing_type in ('task_rate', 'fixed_rate'):
|
||||
return self.task_id.sale_line_id
|
||||
else: # then pricing_type = 'employee_rate'
|
||||
map_entry = self.project_id.sale_line_employee_ids.filtered(lambda map_entry: map_entry.employee_id == self.employee_id)
|
||||
map_entry = self.project_id.sale_line_employee_ids.filtered(
|
||||
lambda map_entry:
|
||||
map_entry.employee_id == self.employee_id
|
||||
and map_entry.sale_line_id.order_partner_id.commercial_partner_id == self.task_id.commercial_partner_id
|
||||
)
|
||||
if map_entry:
|
||||
return map_entry.sale_line_id
|
||||
return self.task_id.sale_line_id
|
||||
|
||||
@@ -15,7 +15,7 @@ class ProjectProductEmployeeMap(models.Model):
|
||||
('is_service', '=', True),
|
||||
('is_expense', '=', False),
|
||||
('state', 'in', ['sale', 'done']),
|
||||
('order_partner_id', '=', partner_id),
|
||||
('order_partner_id', '=?', partner_id),
|
||||
'|', ('company_id', '=', False), ('company_id', '=', company_id)]""")
|
||||
company_id = fields.Many2one('res.company', string='Company', related='project_id.company_id')
|
||||
partner_id = fields.Many2one(related='project_id.partner_id')
|
||||
|
||||
Reference in New Issue
Block a user