1
votes

I have a field named items that i have defined as a Many2many field

item_ids = fields.Many2many('ics.itemdetails',string="Add items")

The model ics.itemdetails has the following fields

itm_nams = fields.Many2one('product.template',string="Name")
weight = fields.Char(string="Weight")

I want the user to select a product from product.template entries and fill the other field, for each product they add. Also a second user cannot select an entry from the previous entries. The problem is that a second user can select a previously entered entry. Am i doing it the right way? How do i prevent previous entries being shown for a second user?. I am using odoo 12.

1
Do you mean that if the product was selected by user1, then user2 can not select it?Terrence Poe
@TerrencePoe user1 and user2 can select the same item from product.template. An entry by user1 including itemdetails cannot be seen by user2.p.ry
what you need is One2many not many2many.Charif DZ
@EasyOdoo , Oops!..It was that easy!..p.ry

1 Answers

1
votes

you can use ir.rule for setting accesses of record.

<record id="normal_user_rule" model="ir.rule">
    <field name="name">User can see its own records</field>
    <field name="model_id" ref="model_name/>
    <field name="domain_force">[('user_id','=',user.id)]</field>
    <field name='perm_create' eval='True'/>
    <field name='perm_read' eval='True'/>
    <field name='perm_unlink' eval='True'/>
    <field name='perm_write' eval='True'/>
</record>