Hide fields in odoo9 openerp - odoo

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" />

Related

How to access logged in user's group in a view in Odoo?

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>

odoo 9 how to add relational field to pivot view?

I'm customizing Project's pivot view to show timesheet description along with task's name.
here is my code below but when I click pivot view it shows an error
<!-- Insert Project Issue Pivot Field -->
<record id="project_task_custom_pivot" model="ir.ui.view">
<field name="name">project.task.custom.pivot</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_project_task_pivot"/>
<field name="arch" type="xml">
<field name="stage_id" position="after">
<field name="name" type="row"/>
<field name="timesheet_ids" type="row"/>
</field>
</field>
</record>
Error below
assert groupby_def and groupby_def._classic_write, "Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True"
Edit
I re-defined the field "timesheet_ids" as #George Daramouskas mentioned.
timesheet_ids = fields.One2many('account.analytic.line', 'task_id', string="Timesheetss", store=True)
But It didn't work.
So I took a look at the source code in Odoo Source
The function "One2many" has no such a parameter.
I guess the Store=True is for only regular field not related field.
Is there any other solution for this?
Thanks
Create your field with the attribute store=True in the constructor so that the field is stored in the database.

What is the use of ir.ui.menu in OpenERP 7.0?

I am new to OpenERP and I wish to know about that what is model="ir.ui.menu" in OpenERP. Like this there are many other models also there.
For eg:
model="ir.ui.view"
model="ir.actions.act_window"
Can any one explain all this?
With the ir.ui.menu model you can create new menu items. You can use the menuitem tag, it is shortcut:
<record id="menu_human_readable_name" model="ir.ui.menu" >
<field name="name">Human readable name</field>
<field name="sequence" eval="10" />
<field name="action" ref="action_name" />
<field name="parent_id" ref="base.menu_custom" />
</record>
And you have a small explanation of the ir.actions.act_window model in the Odoo documentation. You can assign the id of this kind of action in the field action of the ir.ui.menu model
The most common action type, used to present visualisations of a model
through views: a window action defines a set of view types (and
possibly specific views) for a model (and possibly specific record of
the model).
<record id="action_human_readable_name_act_window" model="ir.actions.act_window">
<field name="type">ir.actions.act_window</field>
<field name="name">Human readable name</field>
<field name="res_model">model.name</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
<field name="target">current</field>
<field name="domain">[]</field>
<field name="context">{}</field>
<field name="search_view_id" ref="ir.ui.view" />
</record>
The ir.ui.view is used for the views where you show the field or tree list
You have more information in the Odoo Documentation:
Views define the way the records of a model are displayed. Each type
of view represents a mode of visualization (a list of records, a graph
of their aggregation, …). Views can either be requested generically
via their type (e.g. a list of partners) or specifically via their id.
For generic requests, the view with the correct type and the lowest
priority will be used (so the lowest-priority view of each type is the
default view for that type).
<record model="ir.ui.view" id="view_id">
<field name="name">view.name</field>
<field name="model">object_name</field>
<field name="priority" eval="16"/>
<field name="arch" type="xml">
<!-- view content: <form>, <tree>, <graph>, ... -->
[...]
<field name="field_name" />
[...]
</field>
</record>
Menus and Actions
Menus are records in the ir.ui.menu table. In order to create a new menu entry, you can directly create a record using the record tag.
<record id="menu_external_id" model="ir.ui.menu">
<field name="name">New Menu</field>
<field name="action" ref="action_external_id"/>
<field name="sequence" eval="<integer value>" />
<field name="parent_id" ref="parent_menu_external_id"/>
</record>
There is a shortcut by using the menuitem tag that you should use preferentially. It offers a flexible way to easily define the menu entry along with icons and other fields.
<menuitem id="menu_external_id"
name="New Menu"
action="action_external_id"
icon="ICON_NAME"
groups="groupname"
sequence="<integer value>"
parent="parent_menu_external_id"
/>
If you remove parent/parent_id from menu/menuitem then it becames top level menu.
Actions
action specifies the identifier of the attached action defined in the action table (ir.actions.act_window). This field is not mandatory : you can define menu elements without associating actions to them.
This is useful when defining custom icons for menu elements that will act as folders. This is how custom icons for “Projects” or “Human Resources” in OpenERP are defined).
The actions define the behavior of the system in response to the actions of the users ; login of a new user, double-click on an invoice, click on the action button, ...
There are different types of simple actions:
Window: Opening of a new window
Report: The printing of a report
- Custom Report: The personalized reports
- RML Report: The XSL:RML reports
Execute: The execution of a method on the server side
Group: Gather some actions in one group
The actions are used for the following events:
User connection.
The user clicks on a menu.
The user clicks on the icon ‘print’ or ‘action’.
<record id="action_external_id" model="ir.actions.act_window">
<field name="name">action.name</field>
<field name="view_id" ref="view_external_id" />
<field name="domain">[('field','operator','value')]</field>
<field name="context">{'key':value}</field>
<field name="res_model">Model Name</field>
<field name="view_type">form|tree</field>
<field name="view_mode">form,tree|tree,form|form|tree</field>
<field name="target">new/current</field>
</record>
I hope you will easily understand my explanation below:
"ir.ui.menu" is a model which is mapped as ir_ui_menu table of database that stores data of menus in Odoo (OpenERP). Every menu in Odoo (OpenERP) is inserted via xml file and stored in database. Also, "ir.ui.view" stores view data (such as form, tree, and search views) and "ir.actions.act_window" stores action data.
Conclusion: Mostly (not all), models inside OpenERP are manifestation of tables inside database.
http://useopenerp.com/v8/model/ir-ui-view#pagetop
https://www.odoo.com/documentation/8.0/reference/actions.html#window-actions-ir-actions-act-window
See the above references for detail.
hope this will help you.

Openerp remove a submenu

I want to hide/remove "Timesheet Activities" from the "Human Resource" module. I thought assigning it to a different group would do the trick but it doesn't seem to work.
This is what I have in my custom security.xml:
<record id="timesheet_activities" model="res.groups">
<field name="name">Timesheet Activities</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
You need to add group on menu Timesheet Activities
Go to Setting => Technical => User Interface => Menu items => and find out "Timesheet Activities" add it with new group created.
Create new group and add only Administrator to this group and assign that group to the any menus. So the only admin can see the menus for all other it will be hidden.
If you want to do it from backend then just overwrite the menu in your custom module and add the new group in that menu section
Create a group named like Hidden Items,
<record model="res.groups" id="group_invisible">
<field name="name">Hidden items</field>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
And add that menu into this group,
<record id="module_name.menuitem_name" model="ir.ui.menu">
<field name="groups_id" eval="[(6, False, [ref('module_name.group_invisible')])]"/>
</record>
Hope it will resolve your problem.
<delete model="ir.ui.menu" id="hr.your_menu_id"/>

set other account in accounting module

I am trying to set default account for some fields for that i write some code like
<!-- 1.Income account–311000 -->
<record forcecreate="True" id="property_account_income_product" model="ir.property">
<field name="name">property_account_income</field>
<field name="fields_id" search="[('model','=','product.template'),('name','=','property_account_income')]"/>
<field eval="'account.account,'+str(account_account_456)" name="value"/>
<field name="company_id" ref="base.main_company"/>
</record>
in account.account.template i write code like
<record model="account.account.template" id="account_account_456">
<field name="name">INCOME FROM SALES</field>
<field name="code">311000</field>
<field name="type">other</field>
<field name="user_type" ref="account.data_account_type_income"/>
<field name="reconcile" eval="False"/>
<field name="parent_id" ref="account_account_256"/>
</record>
but after update database it sets different account
i don't know why but correct account are not set
pleas help me
thanks...
Now i got exact Problem Firstly i put record in account.account.template this record is also automatically added into account.account and when i am trying to add record into ir.property search that Account into account.account.template take id and display record from account.account
so the problem is id mismatch in account.account and account.account.template
how to resolve this problem and sorry for English
This is because you must having multiple entries in model="ir.property" for field property_account_income_product for your company so when you try an see the values for the a/c you will find the first value get set on field as your record may be second in list, so it get not selected.