mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[FIX] stock_request_analytic: Adding the correct groups to the views to avoid permissions errors
This commit is contained in:
@@ -4,13 +4,14 @@
|
|||||||
from odoo import fields
|
from odoo import fields
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
from odoo.tests import Form
|
from odoo.tests import Form
|
||||||
|
from odoo.tests.common import users
|
||||||
|
|
||||||
from odoo.addons.stock_request.tests import test_stock_request
|
from odoo.addons.stock_request.tests import test_stock_request
|
||||||
|
|
||||||
|
|
||||||
class TestStockRequestAnalytic(test_stock_request.TestStockRequest):
|
class TestStockRequestAnalytic(test_stock_request.TestStockRequest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestStockRequestAnalytic, self).setUp()
|
super().setUp()
|
||||||
self.analytic_model = self.env["account.analytic.account"]
|
self.analytic_model = self.env["account.analytic.account"]
|
||||||
self.analytic = self.analytic_model.create({"name": "Pizza"})
|
self.analytic = self.analytic_model.create({"name": "Pizza"})
|
||||||
self.analytic2 = self.analytic_model.create(
|
self.analytic2 = self.analytic_model.create(
|
||||||
@@ -48,6 +49,14 @@ class TestStockRequestAnalytic(test_stock_request.TestStockRequest):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.pizza.route_ids = [(6, 0, self.demand_route.ids)]
|
self.pizza.route_ids = [(6, 0, self.demand_route.ids)]
|
||||||
|
self.stock_request_user.write(
|
||||||
|
{
|
||||||
|
"groups_id": [
|
||||||
|
(4, self.env.ref("analytic.group_analytic_accounting").id),
|
||||||
|
(4, self.env.ref("stock.group_stock_user").id),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def prepare_order_request_analytic(self, analytic, company, analytic_tags=None):
|
def prepare_order_request_analytic(self, analytic, company, analytic_tags=None):
|
||||||
expected_date = fields.Datetime.now()
|
expected_date = fields.Datetime.now()
|
||||||
@@ -150,6 +159,7 @@ class TestStockRequestAnalytic(test_stock_request.TestStockRequest):
|
|||||||
)
|
)
|
||||||
self.env["stock.request.order"].create(vals)
|
self.env["stock.request.order"].create(vals)
|
||||||
|
|
||||||
|
@users("stock_request_user")
|
||||||
def test_default_analytic(self):
|
def test_default_analytic(self):
|
||||||
"""
|
"""
|
||||||
Create request order with a default analytic
|
Create request order with a default analytic
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
<field name="name">analytic.order.form</field>
|
<field name="name">analytic.order.form</field>
|
||||||
<field name="model">account.analytic.account</field>
|
<field name="model">account.analytic.account</field>
|
||||||
<field name="inherit_id" ref="analytic.view_account_analytic_account_form" />
|
<field name="inherit_id" ref="analytic.view_account_analytic_account_form" />
|
||||||
|
<field
|
||||||
|
name="groups_id"
|
||||||
|
eval="[(4, ref('stock_request.group_stock_request_user'))]"
|
||||||
|
/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//div[@name='button_box']" position="inside">
|
<xpath expr="//div[@name='button_box']" position="inside">
|
||||||
<field name="stock_request_ids" invisible="1" />
|
<field name="stock_request_ids" invisible="1" />
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
<field name="name">stock.request.order.form - stock_request_analytic</field>
|
<field name="name">stock.request.order.form - stock_request_analytic</field>
|
||||||
<field name="model">stock.request.order</field>
|
<field name="model">stock.request.order</field>
|
||||||
<field name="inherit_id" ref="stock_request.stock_request_order_form" />
|
<field name="inherit_id" ref="stock_request.stock_request_order_form" />
|
||||||
|
<field
|
||||||
|
name="groups_id"
|
||||||
|
eval="[(4, ref('analytic.group_analytic_accounting')),(4, ref('analytic.group_analytic_tags'))]"
|
||||||
|
/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<div name="button_box" position="inside">
|
<div name="button_box" position="inside">
|
||||||
<field name="analytic_account_ids" invisible="1" />
|
<field name="analytic_account_ids" invisible="1" />
|
||||||
@@ -23,6 +27,7 @@
|
|||||||
name="analytic_count"
|
name="analytic_count"
|
||||||
widget="statinfo"
|
widget="statinfo"
|
||||||
string="Analytic Accounts"
|
string="Analytic Accounts"
|
||||||
|
groups="analytic.group_analytic_accounting"
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
@@ -38,6 +43,7 @@
|
|||||||
name="analytic_tag_count"
|
name="analytic_tag_count"
|
||||||
widget="statinfo"
|
widget="statinfo"
|
||||||
string="Analytic Tags"
|
string="Analytic Tags"
|
||||||
|
groups="analytic.group_analytic_tags"
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
<field name="name">stock.request.form</field>
|
<field name="name">stock.request.form</field>
|
||||||
<field name="model">stock.request</field>
|
<field name="model">stock.request</field>
|
||||||
<field name="inherit_id" ref="stock_request.view_stock_request_form" />
|
<field name="inherit_id" ref="stock_request.view_stock_request_form" />
|
||||||
|
<field
|
||||||
|
name="groups_id"
|
||||||
|
eval="[(4, ref('analytic.group_analytic_accounting')),(4, ref('analytic.group_analytic_tags'))]"
|
||||||
|
/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="procurement_group_id" position="after">
|
<field name="procurement_group_id" position="after">
|
||||||
<field
|
<field
|
||||||
|
|||||||
Reference in New Issue
Block a user