I am working on odoo 15.
I would like to set access rights to all apps installed for particular group;
In my case ; I want to put internal user can read only for any apps installed ..
I create a custom module with following :
custom_module>security>ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
I know I should list all models, with its group & access rights
but what I can do if I would like to access all current apps installed and featured once ? to give it access rights for particular group ..
First you have to create that new user group if its a new one:
<record id="office_technology_group" model="res.groups">
<field name="name">Office technology</field>
<field name="comment">Office Technology Permission Group.</field>
<field name="category_id" ref="ng_office_technology.module_category_ng_office_technology"/>
</record>
<record model="ir.module.category" id="module_category_ng_office_technology">
<field name="name">Office Technology</field>
<field name="description">The Office technology Applilcation</field>
<field name="sequence">20</field>
</record>
Ref: Creating New Groups in Odoo
Then ypu have to write on that security CSV like that:
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
model_name_office_technology_group,model_name_office_technology_group,module_name.model_model_name,module_name.office_technology_group,1,1,1,1
Real example:
Model: res_partner
Base model: Base
Custom module (Where you create user groups etc.): custom_module res_partner_office_technology_group,res_partner_office_technology_group,base.model_res_partner,custom_module.office_technology_group,1,1,1,1
Finally you have to add file on manifest.py
https://www.odoo.com/documentation/15.0/es/developer/reference/backend/module.html
Related
I want to show a field read-only for all users of group named Manager (having read and update rights for that model). They must not be able to update a field called 'x_name'.
I am using odoo web client (Gui) and don't have access of xml file. I am only able to use the GUI so please suggest a solution for working this out through GUI.
Go to Settings -> User Interface -> Views and create a view, give it the following contents:
<record id="give_an_id" model="ir.ui.view">
<field name="name">give_a_name</field>
<field name="model">your.model</field>
<field name="inherit_id" ref="module.the_id_of_the_view_that_field_is_on" />
<field name="groups_id" eval="[(6, 0, [ref('module.the_id_of_the_group_for_which_you_want_the_field_hidden') ])]" />
<field name="arch" type="xml">
<field name="x_name" position="attributes">
<attribute name="readonly">1</attribute>
</field>
</field>
</record>
So what happens here is that the above view gets activated only when the user belongs in groups_id more here.
You can achieve it by inheriting a view, also you can create a new inherited view from the GUI and add group id for that view.
Enable Debug mode.
Go to Settings > Technical > Views > Create new view
Add All the field like which view you want to inherit, view type
Add Group name inside the Access rights
Inside the architecture add :
<field name="your_field_name" position="attributes">
<attribute name="readonly">1</attribute>
</field>
I would like to show only my custom module in Odoo interface, without displaying other Odoo Modules.
I have tried to assign my module to the user ( in user settings interface) and hidde other modules to him. But when the user login he see only the Web module, without the other modules.
For example:
I Odoo menu you can see the names of modules like : Sales, Calender ...etc
My goal is to hidde all module to users, and display only my module ( my costum module)
Any help please ... Thank you
Inherit action for module list and add a domain
Try below code:
<record id="open_module_tree" model="ir.actions.act_window">
<field name="name">Apps</field>
<field name="res_model">ir.module.module</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="domain">[('name,'=','your_module_name')]</field>
<field name="context">{'search_default_app':1}</field>
<field name="search_view_id" ref="view_module_filter"/>
<field name="help" type="html">
<p><b>No module found!</b></p>
<p>You should try other search criteria.</p>
</field>
</record>
Hope it will help you.
I want hide fields for user in odoo 9. For example, hide Deadline in Project > Task module.
Only administrator can see this fields.
Any solution how create group etc. hide_only_admin_see and in field add this line.
<field name="date_deadline" groups="hide_only_admin_see" />
I'm find in source groups="base.group_no_one", groups="base.group_user"
but don't understand is it possible create my own group, when add to fiels that only Manager can see this...
Here is my solution:
https://postimg.org/image/rvxi74f51/
https://postimg.org/image/b87h1dlhv/
https://postimg.org/image/5mzst1wtz/
ID from file add to field etc: groups="export.res_groups_84"
On odoo 8, you forbid access to a field to all users (except configuration permissions) in that way:
<field name="date_deadline" position="attributes">
<attribute name="groups">base.group_system</attribute>
</field>
To create new group of permissions,
on odoo 8, you can create record for new category like:
<record model="ir.module.category" id="xxx">
<field name="name">Name of new category of permissions</field>
<field name="sequence">200</field>
</record>
You can create new records for groups permission on res_groups:
<record model="res.groups" id="hide_only_admin_see">
<field name="category_id" ref="XXXX"/>
<field name="name">Usuario</field>
</record>
On category_id you must write the ir_module_category you are creating / overridiing.
After this, you have to create a line on your ir.model.access.csv to give correct permissions to the model you want, something like:
"access_project.issue","project_issue access","model_project_issue","hide_only_admin_see",1,0,0,0
Finally, go to the line and override like:
<field name="date_deadline" groups="your_custom_module.hide_only_admin_see" />
I have Leads and all my leads have emails set. Now I have sent emails to leads with "Mass Mailings" from "Marketing". But now when I click on my lead I do not see any link between the Lead (email) to emails I have sent with "Mass Mailings".
Is there a way to make a link between Lead (email) to email I have sent?
The information about sent emails is available trough the model mail.mail.statistics. In this model you have everything you need. The following fields may be of interest for your task:
model - as emails may be related to any Odoo model, this field tells you to which model was related the email. You are interested in records with crm.lead in this field
res_id - the id of the corresponding model instance. In your case this fields links you to the id of your lead.
mail_mail_id_int - the id of the objects of type email.email - the emails themselves
etc.
You can use this to create a list of emails related to a lead and show them in the crm lead form.
To do that, create a new Odoo module, extend the crm.lead object adding a One2many relation to the mail.mail.statistics model and extend the crm.lead view to show this new field.
For instance, in a file called models/lead.py in this new module, put the following:
from openerp import models, fields
class crm_lead(models.Model):
_inherit = 'crm.lead'
emails = fields.One2many(comodel_name='mail.mail.statistics',
inverse_name='res_id',
domain=[('model', '=', 'crm.lead')])
crm_lead()
Respectively, to extend the view, create a file views/lead_view.xml like this:
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="mail_crm_stats.crm_lead_form">
<field name="name">mail_crm_stats.crm_lead.form</field>
<field name="model">crm.lead</field>
<field name="type">form</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page[#string='Extra Info']"
position="after">
<page string="Emails sent">
<group name="emails">
<div>
<field name="emails" nolabel="1"
class="oe_inline"/>
</div>
</group>
</page>
</xpath>
</field>
</record>
</data>
</openerp>
Now you should see additional tab 'EMails sent' in your lead form. Of course, this is just and example and the module may be improved to show better information about the sent emails. As the case is interesting I may commit soon a new version in the github repository I created for the purpose..
You can download the entire module and test it from my github repository like this:
git clone https://github.com/andreiboyanov/odoo-mails_crm_stats mails_crm_stats
In V8 there is a fields between leads and Marketing Campaign See in any Lead > Extra Info (tab) > Marketing, You can manually add your campaign to that, but if you need to automatically sync then you need to create a new module for that, but just for now you can manually put entry.You can view various modules on here.
I have created a new module in openerp now I want to give security for the module for that I have created a folder named "security" inside my module folder and created a xml file and ir.model.access.csv file in it.My aim is I want to create two roles for my module one is manager and other is user.
for that I have added the below code in the xml file
<record id="group_mat_mgmt_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="base.module_category_mat_mgmt"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="group_mat_mgmt_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="base.module_category_mat_mgmt"/>
<field name="implied_ids" eval="[(4, ref('group_mat_mgmt_user'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
At the view part I have added like this
<menuitem name="Materials Management" id="menu_mat_mgmt_root"
groups="group_mat_mgmt_manager,group_mat_mgmt_user"
sequence="80"/>
then the permission given at the csv but i got an error like this
File
"C:\OpenErp\openerp\openobject-server\openerp\addons\base\ir\ir_model.py",
line 850, in _get_id raise ValueError('No such external ID
currently defined in the system: %s.%s' % (module, xml_id)) alueError:
No such external ID currently defined in the system:
mat_mgmt.group_mat_mgmt_manager
It looks like you did not add files in openerp.py in well sequence. Are you getting this error from CSV file or from View.xml file ?
You need to check openerp.py file. You may be assign first ir.model.access.csv/module_view.xml and after that, module_security.xml in 'data' attribute. So It will go first checking ir.model.access.csv/module_view.xml and it will not find that group, that you created in security.xml and that will be load after loading ir.model.access.csv/module_view.xml files. You can check it and you need to pass first security.xml and after that, ir.model.access.csv/module_view.xml files in openerp.py.
You can also check by assigning group like this : module_name.GROUP_XML_ID wherever you did assign/use those groups.