I want to compare the record parent company with the parent of currently active company via record rule
<record model="ir.rule" id="purchase_requisition.purchase_requisition_comp_rule">
<field name="name">Purchase Requisition multi-company</field>
<field name="model_id" ref="purchase_requisition.model_purchase_requisition"/>
<field name="domain_force">[('company_id.parent_id','=',company_id.parent_id)]
</field>
</record>
But it seems like that the right company_id is an integer and how I can access its parent_id?
Related
In Odoo every partner has a parent_id field.
In my Odoo app I want to make that an user can only see their contacts (partners). That means that an user can only see those contacts in which they are the parent contact. I created the following record rule for this purpose, but it is not working, the user can see all contacts, whether they are the parent or not. What am I doing wrong?
<record model="ir.rule" id="portabilidad_client_record_rule">
<field name="name">See only His client</field>
<field name="model_id" ref="model_res_partner"/>
<field name="domain_force">[('parent_id.id','=',user.partner_id.id)]</field>
<field name="groups" eval="[(4, ref('portabilidad_store'))]"/>
</record>
When you go to configuration->users in odoo as administrator, you see two groups under the category administration: Settings and Access rights. Since one of these groups are selected from a combo box, it seems to me like these groups are mutually exclusive, that is that a user can't be a member of both groups.
I need to do exactly the same with two groups under a custom category which I have created with the following data file:
<record id="FVO" model="ir.module.category">
<field name="name"> FVO </field>
</record>
<record id="FVO_nuova" model="res.groups">
<field name="name">FVO - nuova vista</field>
<field name="category_id" ref="FVO"/>
</record>
<record id="FVO_vecchia" model="res.groups">
<field name="name">FVO - vecchia vista</field>
<field name="category_id" ref="FVO"/>
</record>
But in the users form, they appear as two check boxes, which means that the user could be member of both groups.
Now I've studied both of these groups, and it's category, inspecting also the tables in which they are stored, to try to find out which flag they have so that Settings and Access rights can't be applied to one user at the same time, but for the life of me, I can't find anything special nor in the record for the group, nor in the record for the category.
Is someone able to point out what I'm missing?
I don't know the meaning of vecchia vista and nuova vista so i cannot understand if they are cascade or not, if they are cascade (inherited) rights (like 'see_own_leads' and 'see_all_leads'), you should use
<field name="implied_ids" eval="[(4, ref('FVO_nuova'))]"/> in your FVO_vecchia group so odoo will understand the user should select one of your groups not both of them.
If your groups are not meant to be cascade, i should define 3 groups like this:
`
<record id="FVO_none" model="res.groups">
<field name="name">FVO - no access</field>
<field name="category_id" ref="FVO"/>
</record>
<record id="FVO_nuova" model="res.groups">
<field name="name">FVO - nuova vista</field>
<field name="implied_ids" eval="[(4, ref('FVO_none'))]"/>
<field name="category_id" ref="FVO"/>
</record>
<record id="FVO_vecchia" model="res.groups">
<field name="name">FVO - vecchia vista</field>
<field name="implied_ids" eval="[(4, ref('FVO_none'))]"/>
<field name="category_id" ref="FVO"/>
</record>
`
I am working with res.partner object in customer form view in sale module
category_id use many2many field in customer form view.
Based on the user I have to hide the create new category record in ODOO or OpenERP.
It is possible using options attribute.
Check this example:
<record id="view_customer_form_inherit" model="ir.ui.view">
<field name="name">view.customer.form.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name='category_id' position='attributes'>
<attribute name='options'>
{"no_create": 1, "no_create_edit": 1}
</attribute>
</field>
</field>
</record>
I know it is too late to answer but I hope it'll be helpful
.
For a company there can be different branches across the country. In Openerp,in CRM module Can i filter the Leads by Branches(here filter should be branch name) of that company.Thanks in advance.
My Code
lead.py
'branch_name':fields.selection([('Ahmedabad','Ahmedabad'),('Bangalore','Bangalore'),('Chennai','Chennai'),('Hyderabad','Hyderabad'),('Koltata','Koltata'),('Mumbai','Mumbai'),('NewDelhi','New Delhi'),('Pune','Pune')],'Branch'),
lead_view.xml
<record id="lead_view_crm_case_leads_filter" model="ir.ui.view">
<field name="name">CRM - Leads Search</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.view_crm_case_leads_filter" />
<field name="arch" type="xml">
<search string="Search Leads">
<field name="branch_name" filter_domain="[('branch_name','ilike',self)]"/>
</search>
</field>
</record>
added and new field branch in crm.lead. inherit search view added this field in filter
it will help you
I want to make field readonly based on group, and status. Like I have two groups:
Manager Group
User Group
If I give User Group to any user and then change Status to Done, then field will be readonly for this user.
Hope I was able to make it clear to understand. Thanks.
Create a functional field of type boolean. If the logged in user is under user group and state is done, then return true. Then in the view, specify attrs="{'readonly':[('boolean_field_name','=',True)]}"
OR
First create your form view. Then inherit the view also specify the groups. for example in sale order form view, i want to make the customer reference field readonly for group user when state is not in draft or sent.
<record id="view_order_form_cust_ref_readonly" model="ir.ui.view">
<field name="name">sale.order.form.readonly.cust</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="groups_id" eval="[(6, 0, [ref('base.group_user') ])]"/>
<field name="arch" type="xml">
<field name='client_order_ref'" position="attributes">
<attribute name="attrs">{'readonly':[('state','not in',['draft','sent'])]}</attribute>
</field>
</field>
</record>
you can apply access rule on field level in OpenERP, like in py
'name': fields.char('Name', size=128, required=True, select=True,
read=['base.group_user'] ),
And for status in xml:
<field name="name " attrs="{'readonly': [('state','=','done')]}"/>
There is another sweet way to achieve this. Create one functional field and in that check for group assigned to that user and do not store that field. In View use that field in attrs.
Let say in product you don't want to allow any user to modify Internal Reference if user does not belongs to Product Modify group.
Create one group.
<data noupdate="1" >
<record model="res.groups" id="group_product_modify">
<field name="name">Product Modify</field>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
</data>
Python file
class product_template(models.Model):
_inherit="product.template"
#api.one
def set_access_for_product(self):
self.able_to_modify_product = self.env['res.users'].has_group('product_extended_ecom_ept.group_product_modify')
able_to_modify_product = fields.Boolean(compute=set_access_for_product, string='Is user able to modify product?')
XMl file should be looking like,
<record model="ir.ui.view" id="product_template_update_internal_code_ept">
<field name="name">Product Template extension</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="model">product.template</field>
<field name="priority" eval="50" />
<field name="arch" type="xml">
<field name="default_code" position="before">
<field name="able_to_modify_product" invisible="1" />
</field>
<field name="default_code" position="attributes">
<attribute name="attrs">{'readonly' : [('able_to_modify_product','=',False)]}</attribute>
</field>
</field>
</record>
In case if you are using Odoo web client(GUI) instead of code then there is a bit unorthodox way to do it.
Just make a copy of the field which will contain same value as the original one(giving original field name in Related Field under Advanced Properties) and mark it as read-only.
Then you can hide original field from the users which cannot edit that field and hide the copy field from those who can edit by using groups attribute.