Skip to Content
Menu
This question has been flagged
1 Reply
2752 Views

for my work some bom are public and some of them only the manager can see them.that why i add a new field as checkbox to the bom called type if the bom is no checked all users can see it but if it's checked only manager can see it

the problem is that the hide is done for all the users and if i make the permission of access as condition all users also see it as if the line of security is not seen

my python file is

from odoo import api, fields, models, _



class hide(models.Model):   

    _inherit='mrp.bom'

    

    joker=fields.Boolean('type') 

my xml file is

<?xml version="1.0"?>

<odoo>

     <record id="view_mrp_form_inherit" model="ir.ui.view">

        <field name="name">mrp.bom.form.inherit</field>

        <field name="model">mrp.bom</field>

        <field name="inherit_id" ref="mrp.mrp_bom_form_view"/>

        <field name="arch" type="xml">

                

              

        

                 <data>

              <field name="product_id" position="after">

                <field name="joker"/>

              </field>

          </data>

              

                 

         </field>

    </record>

    <record id="view_mrp_tree_inherit" model="ir.ui.view">

        <field name="name">mrp.bom.tree.inherit</field>

        <field name="model">mrp.bom</field>

        <field name="inherit_id" ref="mrp.mrp_bom_tree_view"/>

        <field name="arch" type="xml">

            <data>

                  <field name="product_id" position="after">

                    <field name="joker"/>

                  </field>

            </data>         

         </field>

    </record>


    <record id="action_hide" model="ir.actions.act_window">

        <field name="name">hide</field>

        <field name="res_model">mrp.bom</field>

        <field name="view_type">form</field>

        <field name="view_mode">tree,form</field>

        <field name="groups_id" eval="[(4,ref('mrp.group_mrp_user'))]"/>

        <field name="domain">[ ('joker', '=', False)]

        </field>

    </record>

 

    

    <menuitem id="mrp.menu_mrp_bom_form_action"

            action="action_hide"

            parent="mrp.menu_mrp_bom"

            sequence="99"/>

   

            

    

     

</odoo>

Avatar
Discard
Best Answer

Hi,

you have to override search method of odoo.

In that you have to check that logged in user have manager access right then you have to display all records of bom and

if user have User access right in manufacturing then you have to display  joker= false record.

hope this will help you. 

Avatar
Discard