how to make condition to a specific groups - odoo

I want to add a condition to one group access to no open and no create_edit just for normal people, but when I use the code below the admin have no access to edit I give to him all access right to file security
<field name="name" domain="[('person_id', '=', person_id), ]"
options='{"no_open":True,"no_create_edit": True}' readonly="1"
/>

No way to get it done without Odoo core extension to provide that features or by overriding the method fields_view_get to dynamically change the view definition based on the user groups.

Related

How could I hide a field with a button in Odoo

Currently, I had a view form and there is some field that need to be hide or unhide by click a button.
I tried to use State, Boolean field but unable to achieve the result.
My question is could I do it on Odoo and how?
I used State and Boolean field and set by condition on field, however the result was not good.
When a user clicks a button, hidden field will appear back
Yes, you can do it.
Button action in odoo triggers write method before being executed.
You should be aware of this before implementing your logic and your domains in order to show/hide fields in XML Views.
Your need is to use invisible attribute applied to a domain inside your field.
invisible is normally static, but can be elasticised inside attrs attribute.
Another important thing is, field-based domains requires the field to be present in view in order to access it. A good practice is to make these fields invisible and put them on top of your view.
In your model:
show_fields = fields.Boolean(default=False)
field_to_show = fields.Char()
def show_fields_action(self):
for record in self: record.show_fields = True
In your view:
<field name="show_fields" invisible="1" />
<field name="field_to_show" attrs="{'domain': [('show_fields','=',True])}" />
<button name="show_fields_action" type="object" string="Show Fields" />
If your question UI/UX related, consider using notebooks instead.

Can't add items to Many2many in Odoo 12 EE

I defined a Many2many field for ir.attachemnt. The problem is i can' see the Add an item link to add the records.
*.py
attachment_ids = fields.Many2many('ir.attachment', string='Attachments')
*.xml
<notebook>
<page string='Attachments'>
<field name="attachment_ids"/>
</page>
</notebook>
I also tried this:
<field name="attachment_ids" widget="many2many" />
Any idea?
There is only two thing that make Odoo behave like this.
Your view is in edit mode but I think I'm seeing a place holder comments this means it's not the case
Your user is not allowed to create an ir.attachment which is more likely not the case
Your field is readonly.
If not one of this cases these is wired but if you didn't understand what happen you can force that link to appear by using embedded tree with create attribute set to true
<field..... >
<tree create='1'>
....
It'a a bug. If you have more many2many fields in the some class and for one of this you haven't right access rules, all the many2many fields are showed in readonly mode.

How to add domain filter in odoo search view?

I want to add a custom search filter like this :
when I apply a filter like this is doesn't work
<filter string="Societe" name="company_id" domain='[("company_id","like","")]'/>
in my case, I want the condition is what the user enters on the search input input
It doesn't work because you shoud apply it on the name field.
domain='[("company_id.name","like","")]'
Actually you just need to add the field company_id as extension to a search view or just add it in your own search view:
<field name="company_id" />
And that's it. Now while typing a search term, the search view should show the user multiple search options.

How does one link to other defined entities using their id?

When writing XML files I will occasionally need to reference another entity, such as a group, a category, or an action.
How can I accomplish this?
There are two different methods to do this, and which one you use depends on where you are in the record:
in the type="xml" or type="html" portions (such as tree and form views)
everywhere else
Inside the type=["xml" | "html"] portions you need to use %-interpolation:
<button string="..." name="%(fnx_pd.action_add_cleaning_order)d" type="action" />
<field name="item_id" domain="[('categ_id','=',%(fnx_pd.pd_cleaning)d)]" />
The thing you are linking to needs to be inside a %()d or %()s construct: %(module.id_name)d.
If not inside an xml or html segment, then you can use the OpenERP-provided ref() function to get the id:
<field name="value" eval="'ir.actions.server,' + str(ref('action_release'))"/>
<field name="context" eval="{'default_pos_categ_id': ref('point_of_sale.categ_others')}"/>
In both of the above methods, OpenERP will look up the actual value associated with the id given and substitute it into the record.

Accessing 'Modified By' field in a reusable workflow

I'm creating a reusable workflow in SharePoint designer 2010. I've created a custom content type with all the necessary fields that I'll be used in the workflow. But I'm not able to get the Modified By field (Editor) inside the workflow.
<FieldRef ID="{d31655d1-1d5b-4511-95a1-7a09e9b75bf2}" ReadOnly="TRUE" Name="Editor" DisplayName="Last Updated By" FromBaseType="TRUE" Required="FALSE" PITarget="" PrimaryPITarget="" PIAttribute="" PrimaryPIAttribute="" Aggregation="" Node="" />
I really doubt whether the ID is matching with the inbuilt editor field. How can I cross-verify this? Any ideas?
Not sure but do you really need to include it explicitly? Editor is part of base content type : Item, and down the hierarchy all other content types should be inheriting it without the need to explicitly include it.
Regards,
Nitin Rastogi