I made new security in the custom module, like this
<record model="ir.module.category" id="module_create">
<field name="name">Module Role</field>
<field name="description">User access level for this module</field>
<field name="sequence">5</field>
</record>
<record id="group_merc" model="res.groups">
<field name="name">Merc Access</field>
<field name="category_id" ref="mymodule.module_create"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
and i make another form views using class res.users like this
<page name="access_rights" string="Access Rights">
<field name="groups_id" widget="many2many_tags" options='{"no_create": True, "no_open": True}'/>
</page>
the field displays like this
can i remove the fields views and change of the form in groups_id by displaying the group names that I have created automatically without having to do a search first?
You can use many2many_checkboxes which will list all the groups and you can select without any searching required.
<field name="groups_id" widget="many2many_checkboxes" />
Related
I used ir.actions.server model for add an option in action menu item.
Main purpose for using this is to run python code from here.Here i don't want to return a tree or form view here , so i used this method.
I need to add an option only in vendor bills form, but the option is set both invoice and supplier form.
<record id="account_invoice_accrual_entries_vendor_bill_non_po_action" model="ir.actions.server">
<field name="name">Accrual Entries</field>
<field name="model_id" ref="model_account_invoice"/>
<field name="domain">[('type','in',('in_invoice'))]</field>
<field name="state">code</field>
<field name="code">
if records:
records.action_accrual_entries_vendor_bill()
</field>
</record>
<record id="account_invoice_accrual_entries_vendor_bill_non_po" model="ir.values">
<field name="model_id" ref="account.model_account_invoice"/>
<field name="name">Accrual Entries</field>
<field name="key2">client_action_multi</field>
<field name="key">action</field>
<field name="model">account.invoice</field>
<field name="value" eval="'ir.actions.server,' + str(ref('account_invoice_accrual_entries_vendor_bill_non_po_action'))" />
</record>
This is the code i try to add domain only for vendor bills. But the option visible in both vendor bills and customer invoice.
anyone knows what is the mistake in my code .??
I want to hide the edit and create button on the form view for a specific user I use this code but the button not showing at all
i just want to hide buttons just for only group
<record model="ir.ui.view" id="edit_button_message_">
<field name="name">edit.button.message.1</field>
<field name="model">person.message</field>
<field name="inherit_id" ref="view_parent_message_form"/>
<field name="groups_id" eval="[(6,0,[ref('person_access')])]"/>
<field name="arch" type="xml">
<xpath expr="/form[#string='form_view_string']" position="attributes">
<attribute name="create">false</attribute>
<attribute name="edit">false</attribute>
</xpath>
</field>
</record>
and i use this
<form string="form_view_string" edit="false" create="false" >
nothing happened , I use odoo v8
You better create a security access for that group to allow just read to that model, preventing the create, write and unlink actions and those buttons should disappear.
You could create it in xml as it will be only one, like:
<record id="person_message_access" model="ir.model.access">
<field name="name">edit.button.message.access</field>
<field name="model_id" ref="person.message"/>
<field name="group_id" ref="person_access"/>
<field name="perm_read" eval="1"/>
<field name="perm_create" eval="0"/>
<field name="perm_write" eval="0"/>
<field name="perm_unlink" eval="0"/>
</record>
or you could set it into a field ir.model.access.csv with content like:
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
person_message_access,edit.button.message.access,model_person_message,person_access,1,0,0,0
I have made some groups A,B,C,D through GUI in Odoo v10. These groups are shown as check-boxes on the user page.
I want that instead of these check-boxes a dropdown must be shown so that user can be assigned to only a single group i.e. a user can only be in one of the A,B,C,D groups.
How can i do this??
I've found something that will clear how drop-downs are made and how check boxes are made. This is through code not from GUI as i am still finding a solution for it.
So, drop-downs are made when each group in a category inherits some other group in same category in hierarchical manner.
So, when i wrote the following code, check-boxes were made.
<record id='group_category' model='ir.module.category'>
<field name='name'>Category name</field>
</record>
<record id="group_a" model="res.groups">
<field name="name">A</field>
<field name="category_id" ref="group_category"/>
</record>
<record id="group_b" model="res.groups">
<field name="name">B</field>
<field name="category_id" ref="group_category"/>
</record>
<record id="group_c" model="res.groups">
<field name="name">C</field>
<field name="category_id" ref="group_category"/>
</record>
But when i wrote the following code in which one group inherits the other in a hierarchical way, drop-down was made
<record id='group_category' model='ir.module.category'>
<field name='name'>Category name</field>
</record>
<record id="group_a" model="res.groups">
<field name="name">A</field>
<field name="category_id" ref="group_category"/>
</record>
<record id="group_b" model="res.groups">
<field name="name">B</field>
<field name="category_id" ref="group_category"/>
<field name="implied_ids" eval="[(4, ref('module_name.group_a'))]"/>
</record>
<record id="group_c" model="res.groups">
<field name="name">C</field>
<field name="category_id" ref="group_category"/>
<field name="implied_ids" eval="[(4, ref('module_name.group_b'))]"/>
</record>
so, this was the case when i did it. Still finding a way to do it through GUI.
First Create this below record through xml.
<record model="ir.module.category" id="abcd_category">
<field name="name">ABCD</field>
</record>
Then Create your groups with category_id.
<record id="group_a" model="res.groups">
<field name="name">A</field>
<field name="category_id" ref="abcd_category"/>
</record>
<record id="group_b" model="res.groups">
<field name="name">B</field>
<field name="category_id" ref="abcd_category"/>
</record>
......
......
Thats it.
Updates :
Add category in manifest.py
....
....
'category':'ABCD',
....
....
and select it from view into the Application in group formview.
You can override the view and specify a widget. You could try:
<field name="field_name" widget="selection"/>
or
<field name="field_name" widget="many2one"/>
I hope this help you!
I have a tree view with a many2many field require_weekday:
<record model="ir.ui.view"
id="sale_order_email_collection_form">
<field name="name">sale.order_email.collection.form</field>
<field name="model">sale.order_email.collection</field>
<field name="arch" type="xml">
<form string="Collection">
<group>
<field name="name"/>
</group>
<field name="emails">
<tree string="Lines" editable="bottom">
<field name="required_weekday"/>
</tree>
</field>
</form>
</field>
</record>
When I click the many2many field it's basically unusable with some blue text overlaying the tree view making it impossible to tell what's going on.
Is it possible to make it work decent?
You can use widget="many2many_tags" in xml.
for example :
<field name="fields_name" widget="many2many_tags"/>
You can use widget="one2many" in xml.
This will change many2many form view to one2many as you want.
For Example:
<field name="your_many2many_field" widget="one2many">
<tree string="your string" editable="top/bottom">
<field name="your_fields"/>#Define all your fields for tree view
</tree>
</field?
i have a model that defined a nomenclator, it have only one field :
'name': fields.char('Name',size = 50,required = True),
and its view is as follow:
<record model="ir.ui.view" id="view_df_t_r_m_resource_type_tree">
<field name="name">df.t.r.m.resource.type.tree</field>
<field name="model">df.t.r.m.resource.type</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Types" editable="bottom">
<field name="name" select = "1"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_df_t_r_m_resource_type_form">
<field name="res_model">df.t.r.m.resource.type</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
</record>
I use this view to create types of product, but when i make a many2one field that reference the nomencaltor mode in other view and press the "Search" options i cant select the item because the editable property defined in the original view mess with the behavior i want
So: any ideas about how i can define the "editable" property in diferents views
PD: I tried to use this:
<field name="type_id" >
<tree>
<field name="name"/>
</tree>
</field>
but i dont know how to specify the "editable" property