diff --git a/addons/sale/models/product_template.py b/addons/sale/models/product_template.py index 3f380d4b3b5..7e84b35ff85 100644 --- a/addons/sale/models/product_template.py +++ b/addons/sale/models/product_template.py @@ -23,8 +23,8 @@ class ProductTemplate(models.Model): default='no', help="Expenses and vendor bills can be re-invoiced to a customer." "With this option, a validated expense can be re-invoice to a customer at its cost or sales price.") + visible_expense_policy = fields.Boolean("Re-Invoice Policy visible", compute='_compute_visible_expense_policy') sales_count = fields.Float(compute='_compute_sales_count', string='Sold') - hide_expense_policy = fields.Boolean(compute='_compute_hide_expense_policy') invoice_policy = fields.Selection([ ('order', 'Ordered quantities'), ('delivery', 'Delivered quantities')], string='Invoicing Policy', @@ -34,10 +34,10 @@ class ProductTemplate(models.Model): @api.multi @api.depends('name') - def _compute_hide_expense_policy(self): - hide_expense_policy = self.user_has_groups('!analytic.group_analytic_accounting,!project.group_project_user,!hr_expense.group_hr_expense_user') - for template in self: - template.hide_expense_policy = hide_expense_policy + def _compute_visible_expense_policy(self): + visibility = self.user_has_groups('analytic.group_analytic_accounting') + for product_template in self: + product_template.visible_expense_policy = visibility @api.multi @api.depends('product_variant_ids.sales_count') diff --git a/addons/sale/views/sale_views.xml b/addons/sale/views/sale_views.xml index 3d44b907d73..3b6372a111e 100644 --- a/addons/sale/views/sale_views.xml +++ b/addons/sale/views/sale_views.xml @@ -1015,8 +1015,8 @@ - - + + diff --git a/addons/sale_expense/models/__init__.py b/addons/sale_expense/models/__init__.py index cf2318e7b88..2848316b086 100644 --- a/addons/sale_expense/models/__init__.py +++ b/addons/sale_expense/models/__init__.py @@ -4,3 +4,4 @@ from . import analytic from . import hr_expense from . import sale_order +from . import product_template diff --git a/addons/sale_expense/models/product_template.py b/addons/sale_expense/models/product_template.py new file mode 100644 index 00000000000..58089a8378d --- /dev/null +++ b/addons/sale_expense/models/product_template.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + @api.multi + def _compute_visible_expense_policy(self): + super(ProductTemplate, self)._compute_visible_expense_policy() + + visibility = self.user_has_groups('hr_expense.group_hr_expense_user') + for product_template in self: + if not product_template.visible_expense_policy: + product_template.visible_expense_policy = visibility diff --git a/addons/sale_timesheet/models/product.py b/addons/sale_timesheet/models/product.py index 1d269f1267a..4057b628ae7 100644 --- a/addons/sale_timesheet/models/product.py +++ b/addons/sale_timesheet/models/product.py @@ -30,6 +30,15 @@ class ProductTemplate(models.Model): 'project.project', 'Project Template', company_dependent=True, domain=[('billable_type', '=', 'no')], copy=True, help='Select a non billable project to be the skeleton of the new created project when selling the current product. Its stages and tasks will be duplicated.') + @api.multi + def _compute_visible_expense_policy(self): + super(ProductTemplate, self)._compute_visible_expense_policy() + + visibility = self.user_has_groups('project.group_project_user') + for product_template in self: + if not product_template.visible_expense_policy: + product_template.visible_expense_policy = visibility + @api.depends('invoice_policy', 'service_type') def _compute_service_policy(self): for product in self: