[IMP] sale_*: visible reinvoice policy rights
Impacted modules: sale, sale_timesheet, sale_expense The purpose of this commit is to remove harcoded list of xml ids that are not defined in the module 'sale'. This commit brings a new implementation of the feature (hiding re-invoice policy on product form view, depending of multiple user groups). The approach is more modular and easy to extend than the previous one. Therefore, this commit is completely technical and does not change any functionnal behavior. Task-1896095 closes odoo/odoo#28786
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -1015,8 +1015,8 @@
|
||||
<group string="Invoicing" name="invoicing" invisible="1">
|
||||
<field name="invoice_policy" widget="radio"/>
|
||||
<field name="service_type" widget="radio" invisible="True"/>
|
||||
<field name="hide_expense_policy" invisible="1"/>
|
||||
<field name="expense_policy" widget="radio" attrs="{'invisible': [('hide_expense_policy', '=', True)]}"/>
|
||||
<field name="visible_expense_policy" invisible="1"/>
|
||||
<field name="expense_policy" widget="radio" attrs="{'invisible': [('visible_expense_policy', '=', False)]}"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
from . import analytic
|
||||
from . import hr_expense
|
||||
from . import sale_order
|
||||
from . import product_template
|
||||
|
||||
@@ -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
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user