[MOV] sale_timesheet: move the timesheet_product_id field in mappings

Before this commit, the timesheet_product_id field in
project.sale.line.employee.map model is defined but never used.

This commit moves the definition of this field in the industry_fsm_sale
module to use this field in that module.

task-2376382

closes odoo/odoo#66157
This commit is contained in:
Xavier BOL (xbo)
2021-03-17 14:57:33 +01:00
parent 167655e2ce
commit 5236dff955
@@ -12,13 +12,6 @@ class ProjectProductEmployeeMap(models.Model):
employee_id = fields.Many2one('hr.employee', "Employee", required=True)
sale_line_id = fields.Many2one('sale.order.line', "Sale Order Item", compute="_compute_sale_line_id", store=True, readonly=False, required=True, domain=[('is_service', '=', True)])
company_id = fields.Many2one('res.company', string='Company', related='project_id.company_id')
timesheet_product_id = fields.Many2one(
'product.product', string='Service',
domain="""[
('type', '=', 'service'),
('invoice_policy', '=', 'delivery'),
('service_type', '=', 'timesheet'),
'|', ('company_id', '=', False), ('company_id', '=', company_id)]""")
price_unit = fields.Float("Unit Price", compute='_compute_price_unit', store=True, readonly=True)
currency_id = fields.Many2one('res.currency', string="Currency", compute='_compute_price_unit', store=True, readonly=False)
@@ -30,26 +23,16 @@ class ProjectProductEmployeeMap(models.Model):
def _compute_sale_line_id(self):
self.filtered(lambda map_entry: not map_entry.project_id.sale_order_id and map_entry.sale_line_id).update({'sale_line_id': None})
@api.depends('sale_line_id', 'sale_line_id.price_unit', 'timesheet_product_id')
@api.depends('sale_line_id', 'sale_line_id.price_unit')
def _compute_price_unit(self):
for line in self:
if line.sale_line_id:
line.price_unit = line.sale_line_id.price_unit
line.currency_id = line.sale_line_id.currency_id
elif line.timesheet_product_id:
line.price_unit = line.timesheet_product_id.lst_price
line.currency_id = line.timesheet_product_id.currency_id
else:
line.price_unit = 0
line.currency_id = False
@api.onchange('timesheet_product_id')
def _onchange_timesheet_product_id(self):
if self.timesheet_product_id:
self.price_unit = self.timesheet_product_id.lst_price
else:
self.price_unit = 0.0
@api.model
def create(self, values):
res = super(ProjectProductEmployeeMap, self).create(values)