[IMP] sale_timesheet: remove pricing_type in create SO wizard

Since the pricing_type in the project is a compute non-stored field and
the user edits no longer this field. The condition on this field is not
valid.

This commit removes this related field in the
'project.create.sale.order.line' wizard and change the condition using
this field to keep the initial behaviour.

task-2442683

closes odoo/odoo#66181
This commit is contained in:
Xavier BOL (xbo)
2021-04-16 10:35:47 +02:00
committed by Yannick Tivisse
parent aa7e906034
commit af188dfb44
2 changed files with 6 additions and 14 deletions
@@ -41,12 +41,6 @@ class ProjectCreateSalesOrder(models.TransientModel):
'product_id': default_product.id,
'price_unit': default_product.lst_price
}) for e in employee_from_timesheet]
else:
result['line_ids'] = [
(0, 0, {
'product_id': p.id,
'price_unit': p.lst_price
}) for p in project.task_ids.timesheet_product_id]
return result
project_id = fields.Many2one('project.project', "Project", domain=[('sale_line_id', '=', False)], help="Project for which we are creating a sales order", required=True)
@@ -54,7 +48,6 @@ class ProjectCreateSalesOrder(models.TransientModel):
partner_id = fields.Many2one('res.partner', string="Customer", required=True, help="Customer of the sales order")
commercial_partner_id = fields.Many2one(related='partner_id.commercial_partner_id')
pricing_type = fields.Selection(related="project_id.pricing_type")
sale_order_id = fields.Many2one(
'sale.order', string="Sales Order",
domain="['|', '|', ('partner_id', '=', partner_id), ('partner_id', 'child_of', commercial_partner_id), ('partner_id', 'parent_of', partner_id)]")
@@ -89,7 +82,7 @@ class ProjectCreateSalesOrder(models.TransientModel):
if not self.line_ids:
raise UserError(_("At least one line should be filled."))
if self.pricing_type == 'employee_rate':
if self.line_ids.employee_id:
# all employee having timesheet should be in the wizard map
timesheet_employees = self.env['account.analytic.line'].search([('task_id', 'in', self.project_id.tasks.ids)]).mapped('employee_id')
map_employees = self.line_ids.mapped('employee_id')
@@ -138,9 +131,9 @@ class ProjectCreateSalesOrder(models.TransientModel):
return sale_order
def _make_billable(self, sale_order):
if self.pricing_type == 'fixed_rate':
if not self.line_ids.employee_id: # Then we configure the project with pricing type is equal to project rate
self._make_billable_at_project_rate(sale_order)
else:
else: # Then we configure the project with pricing type is equal to employee rate
self._make_billable_at_employee_rate(sale_order)
def _make_billable_at_project_rate(self, sale_order):
@@ -11,13 +11,12 @@
<field name="project_id" readonly="1"/>
<field name="company_id" invisible="1"/>
<field name="partner_id" domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]"/>
<field name="pricing_type" invisible="1"/>
</group>
</group>
<group attrs="{'invisible': [('pricing_type', '!=', 'employee_rate')]}">
<field name="line_ids" nolabel="1" attrs="{'required': [('pricing_type', '=', 'employee_rate')]}">
<group>
<field name="line_ids" nolabel="1">
<tree editable="bottom">
<field name="employee_id" options="{'no_create_edit': True, 'no_create': True}" attrs="{'column_invisible': [('parent.pricing_type', '=', 'fixed_rate')], 'required': [('parent.pricing_type', '=', 'employee_rate')]}"/>
<field name="employee_id" options="{'no_create_edit': True, 'no_create': True}"/>
<field name="product_id" options="{'no_create_edit': True, 'no_create': True}"/>
<field name="price_unit" widget='monetary' options="{'currency_field': 'currency_id', 'field_digits': True}"/>
<field name="currency_id" invisible="1"/>