Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
9561 Переглядів

I'm using Odoo version 12.0
I just want to display the specific product category assigned for a group.
For this, I have also created the Allowed Groups field in product category form.

Here are my models.py :

class ProductCategoryList(models.Model):
_inherit = 'product.category'

product_category_groups = fields.Many2many('res.groups', string="Allowed Groups")


my views.xml :

<record id="product_category_filter_groups" model="ir.ui.view">
<field name="name">product.category.filter.groups</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='first']" position="inside">
<field name="product_category_groups" widget="many2many_tags"/>
</xpath>
</field>
</record>

<record id="product_template_filter_category" model="ir.ui.view">
<field name="name">product.template.filter.category</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='categ_id']" position="attributes">
<attribute name="domain">[('product_category_groups','in', <WHAT SHOULD I WRITE HERE?>)]</attribute>
</xpath>
</field>
</record>


As in attribute if I mention any static value like 3 it gives me the only category assigned for the user(Administrator), but since I want it dynamic as the user which is logged in.

I looked up almost everywhere but nothing seems to work.
Can anyone help me out?

Аватар
Відмінити

Hope this odoo customization tips will help you: http://learnopenerp.blogspot.com

Автор

Hi Sehrish, that link didn't help me.

Найкраща відповідь

Hi,

For this purpose definitely, you have to use the concept of the record rules in Odoo:- https://www.odoo.com/documentation/12.0/reference/security.html


Please see this free module in the store for restricting the products for the user, you can make some alterations to this module and can be changed the same for the case of the product categories:- Product Restriction on Users

Thanks

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
черв. 24
2544
2
серп. 19
4397
1
черв. 19
2872
2
вер. 23
6862
4
трав. 25
49669