diff options
| author | Laurent Stukkens (LTU) <ltu@odoo.com> | 2021-04-23 16:06:23 +0000 |
|---|---|---|
| committer | Laurent Stukkens (LTU) <ltu@odoo.com> | 2021-04-29 12:05:28 +0000 |
| commit | 2480e9593808126ade2537cc2ae40b85080ba441 (patch) | |
| tree | 752e062a27a8457be8c3709adf94dce6906159bb /addons | |
| parent | f964b761eae32016e36dd9d39cc2c35fc2270eba (diff) | |
[FIX] sale_timesheet: prevent multicompany issue on SOL
Steps to reproduce:
- Create an SO for a prepaid service in company A and confirm it
- Create a project and a task in company B and select the customer linked to the SO you previously created
- Unselect company A from the multi-company widget; only display the records from company B
- Timesheet on the task you previously created
Observed behavior:
- The SOL set by default belongs to company A, thus generating an access right error when trying to timesheet on the task
Expected behavior:
- The SOL set by default should belong to the same company as the task
task-2515259
closes odoo/odoo#69783
Related: odoo/enterprise#17921
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/sale_project/models/product.py | 2 | ||||
| -rw-r--r-- | addons/sale_project/models/project.py | 2 | ||||
| -rw-r--r-- | addons/sale_timesheet/models/product.py | 4 | ||||
| -rw-r--r-- | addons/sale_timesheet/models/project.py | 2 |
4 files changed, 6 insertions, 4 deletions
diff --git a/addons/sale_project/models/product.py b/addons/sale_project/models/product.py index e4f6318684b..b86b0d71657 100644 --- a/addons/sale_project/models/product.py +++ b/addons/sale_project/models/product.py @@ -20,9 +20,11 @@ class ProductTemplate(models.Model): creating a new project based on the selected template.") project_id = fields.Many2one( 'project.project', 'Project', company_dependent=True, + domain="[('company_id', '=', current_company_id)]", help='Select a billable project on which tasks can be created. This setting must be set for each company.') project_template_id = fields.Many2one( 'project.project', 'Project Template', company_dependent=True, copy=True, + domain="[('company_id', '=', current_company_id)]", help='Select a billable project to be the skeleton of the new created project when selling the current product. Its stages and tasks will be duplicated.') @api.constrains('project_id', 'project_template_id') diff --git a/addons/sale_project/models/project.py b/addons/sale_project/models/project.py index db4c8f43773..c6b43ddbb9d 100644 --- a/addons/sale_project/models/project.py +++ b/addons/sale_project/models/project.py @@ -35,7 +35,7 @@ class ProjectTask(models.Model): sale_order_id = fields.Many2one('sale.order', 'Sales Order', help="Sales order to which the task is linked.") sale_line_id = fields.Many2one( - 'sale.order.line', 'Sales Order Item', domain="[('is_service', '=', True), ('order_partner_id', 'child_of', commercial_partner_id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done']), ('order_id', '=?', project_sale_order_id)]", + 'sale.order.line', 'Sales Order Item', domain="[('company_id', '=', company_id), ('is_service', '=', True), ('order_partner_id', 'child_of', commercial_partner_id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done']), ('order_id', '=?', project_sale_order_id)]", compute='_compute_sale_line', store=True, readonly=False, copy=False, 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.") diff --git a/addons/sale_timesheet/models/product.py b/addons/sale_timesheet/models/product.py index 04b02b34ddd..0c54ef8486c 100644 --- a/addons/sale_timesheet/models/product.py +++ b/addons/sale_timesheet/models/product.py @@ -19,8 +19,8 @@ class ProductTemplate(models.Model): ('timesheet', 'Timesheets on project (one fare per SO/Project)'), ], ondelete={'timesheet': 'set default'}) # override domain - project_id = fields.Many2one(domain="[('allow_billable', '=', True), ('bill_type', '=', 'customer_task'), ('allow_timesheets', 'in', [service_policy == 'delivered_timesheet' or '', True])]") - project_template_id = fields.Many2one(domain="[('allow_billable', '=', True), ('bill_type', '=', 'customer_project'), ('allow_timesheets', 'in', [service_policy == 'delivered_timesheet' or '', True])]") + project_id = fields.Many2one(domain="[('company_id', '=', current_company_id), ('allow_billable', '=', True), ('bill_type', '=', 'customer_task'), ('allow_timesheets', 'in', [service_policy == 'delivered_timesheet' or '', True])]") + project_template_id = fields.Many2one(domain="[('company_id', '=', current_company_id), ('allow_billable', '=', True), ('bill_type', '=', 'customer_project'), ('allow_timesheets', 'in', [service_policy == 'delivered_timesheet' or '', True])]") def _default_visible_expense_policy(self): visibility = self.user_has_groups('project.group_project_user') diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py index f3f9bdeb423..8c1183051e9 100644 --- a/addons/sale_timesheet/models/project.py +++ b/addons/sale_timesheet/models/project.py @@ -349,7 +349,7 @@ class ProjectTask(models.Model): self.ensure_one() if not self.commercial_partner_id or not self.allow_billable: return False - domain = [('is_service', '=', True), ('order_partner_id', 'child_of', self.commercial_partner_id.id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done'])] + domain = [('company_id', '=', self.company_id.id), ('is_service', '=', True), ('order_partner_id', 'child_of', self.commercial_partner_id.id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done'])] if self.project_id.bill_type == 'customer_project' and self.project_sale_order_id: domain.append(('order_id', '=?', self.project_sale_order_id.id)) sale_lines = self.env['sale.order.line'].search(domain) |
