Odoo-8 -- How can I add a button next to the "Create" button in the "Human Resources" -> "Employees" Kanban view? - odoo

Unfortunately I can't post pictures with a reputation lower than 10. 8-/
In a inherited view I want to add a button beside the red "Create" Button in the employees Kanban view. You can reach it over the menus "Human Resources"->"Employees".
I've searched for that button in the "hr_view.xml" file but couldn't find it so I assume that it isn't part of the view but it reacts on switching through the views (kanban to list to form view) so there must be a relation anywhere!?
But where is this relation defined?
Now I tried the following code out to add a simple action button which I wanted to place in the (new) "header" of the view:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_kanban_hr_employees_inherited" model="ir.ui.view">
<field name="name">HR - Employees Kanban extension</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.hr_kanban_view_employees" />
<field name="arch" type="xml">
<field name="name" position="before">
<header>
<button string="Calculate Employee Timeaccounts" name="button_calc_employee_timeaccounts" type="object"/>
</header>
</field>
</field>
</record>
</data>
</openerp>
The result is that every kanban vignette now has that (small) button with no text in it.
What I wanted to achieve was to only add one button at th top of the page and didn't want to add a button to every single kanban vignette.
Does anyone have suggestions for me? Where should I insert the button??
The nicest solution would be right beside the red "Create" button on top. But like I mentioned before I think this isn't part of the inheritable view.
Seeing forward for great solutions and thank you for reading!

Related

Change the name of a parent menu in odoo 16

Change the name of a parent menu in odoo 16
I put this code here because it doesn't work for me. I wanted to clarify that what I want is to change the name of a menu but through code, not through the odoo interface
<record id="hr_payroll.menu_hr_payroll_payslips" model="ir.ui.menu">
<field name="name">New name</field>
</record>
What I'm trying to do is to be able to change the name of a parent menu in odoo 16, but so far the only thing I've managed to do is change the name of a sub-menu. How can I change the name of a parent menu in odoo 16? Could you help me on that part please.
your text`
<record id="menu_hr_payroll_payslips_new" model="ir.ui.menu">
<field name="name">Nómina</field>
<field name="sequence">70</field>
<field name="parent_id"
ref="hr_payroll.menu_hr_payroll_employee_payslips_to_pay"/>
<field name="action" ref="hr_payroll.hr_payslip_action_view_to_pay"/>
</record>
I tried this code and it worked for me but only to change the name of a sub-menu, but what I want is to change the name of a parent menu in odoo16`

How to display my module in one of multiple website Odoo?

I have two websites in Odoo.
Site 1: www.A.com
Site 2: www.B.fr
I created a module but I would like it to be visible only in website 2. But when I install it, it appears in both sites. I must then change the views manually in Odoo so that my view is visible on site 2.
I tried to put "website_id: 'B' in manifest.py but it doesn't work.
Where should I report please? I searched but I can't find a solution ...
Thank you.
You can edit your view or template and test for the website id to add your content, for example:
<template id = "test" name="test" inherit_id="test.test_view" priority="16">
<t t-if="website.id == 1">
<!-- add or edit the content that you want-->
</t>
</template>
You can specify the value of website_id field when you define the view or set its value by inheriting an existing view.
You will need the external id of website2(website.website2) and the external id of an existing view in case you need to use inheritance.
Specify the value in the view definition:
<record id="MODEL_view_TYPE" model="ir.ui.view">
<field name="name">NAME</field>
<field name="model">MODEL</field>
<field name="website_id" ref="Website_External_Id"/>
<field name="arch" type="xml">
 
Inherit an existing view and specify the website_id field value:
<record id="VIEW_External_ID" model="ir.ui.view">
<field name="website_id" ref="Website_External_Id"/>
</record>

Custom module and creating groups in odoo 10

I'm working with odoo 10 on windows. I've created a new custom module now I want to add some menus of my costum modules to certains users.
I'm new to odoo so my question is can I do that by creating group, associate the menus to my group then add the users to the group (I trid that but it did not work, when I log in with the user I find nothing).
I've search on the web and I found that I need to creat my groups trough ir.model.access.csv (security folder) with this : id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_testmod_test,access_testmod_test,model_testmod_test,,1,1,1,1.
Unfourtunately, I did not quite understand how can I do that and what should I write in some fields.
So can someone please give me a good tutorial that I can use, with examples, witch shows me how to create diffrents groups and adde users to it and add also some of the menus of my custom module to it.
Thank you.
so I tried this code but it did not work with me maybe I did it wrong here what I did : I created a file securuty.xml in my security folder with contain the following
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<!-- Creating a Group Category -->
<record id="evaluation_subj" model="ir.module.category">
<field name="name">evaluation subjective</field>
<field name="sequence">1</field>
</record>
<!-- Adding a Group to the Group Category -->
<record id="group_eval_subj" model="res.groups">
<field name="name">Groupe Evaluation Subjective</field>
<field name="evaluation_subj" ref="evaluation subjective"/>
<!-- Adding Rights of existing Groups -->
<field name="implied_ids"
eval="[(4, ref('base.group_system')), (4,ref('base.group_sale_manager'))]"/>
</record>
</data>
</odoo>
Then in the file pnc_menus.xml (I have a file called pnc_menus.xml where I created all of my menus) I added the groups field to this menu:
<menuitem name="Parties Prenantes" id="pnc_evaluation_stakeholders"
action="pncevaluation_partieprenante" parent="pnc_documents" sequence="40" groups="base.group_system"/>
Then in csv file of my security folder I added this :
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
eval_group,groupe_evaluation,pnc_evaluation_stakeholders,group_eval_subj,1,1,1,1
When I updated my module I have an error saying "csv file could not be proccessed"
Creating group category and group
security/security.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<!-- Creating a Group Category -->
<record id="category_name" model="ir.module.category">
<field name="name">Name</field>
<field name="sequence">1</field>
</record>
<!-- Adding a Group to the Group Category -->
<record id="group_name" model="res.groups">
<field name="name">Group Name</field>
<field name="category_id" ref="category_name"/>
<!-- Adding Rights of existing Groups -->
<field name="implied_ids"
eval="[(4, ref('base.group_system')), (4,ref('base.group_sale_manager'))]"/>
</record>
</data>
</openerp>
Adding a group to an existing menu (base.group_system)
<menuitem name="Name" id="id_name" parent="module.menu_id" action="module.action_id"
groups="base.group_system"/>
security/ir.model.access.csv
Give your group access to your model
access_anything,classname,model_classname,group_id,1,1,1,1
for example (base. is added because model_ir_property is not from the own module)
access_ir_property1,ir_property,base.model_ir_property,your_new_group_id,1,1,1,1
Go to Settings->Groups, select your new group, press "Edit" and add users at page "Users".

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 always displays inherited view instead of original

Original views:
<record id='view_1' model='ir.ui.view'>
<field name="name">view.name</field>
<field name="model">my.object</field>
<field name="priority" eval="17"/>
<field name="type">form</field>
<field name="arch" type="xml">
...
</field>
</record>
inherited view from the original:
<record id='view_2' model='ir.ui.view'>
<field name="name">view.name</field>
<field name="model">my.object</field>
<field name="priority" eval="10"/>
<field name="inherit_id" ref="view_1"/>
<field name="type">form</field>
<field name="arch" type="xml">
...
</field>
</record>
So what happens is OpenERP always displays the inherited view ignoring the priority value. Is this expected behaviour, or there's something else I am missing?
If this is the expected behaviour, then please read further :-)
I have my.second.object with many2one field to my.object, and when I want to create my.object from this field, I want to open a bit different form view of my.object. I am trying to create a different view just for that purpose, but as you see it doesn't work so easily (or does it?).
Any help is appreciated.
Yes it is the expected behavior. The priority of a view only serves to select the main view to use when no specific view was requested. Inherited views are "patch views" that act like children of the view they inherit from, and may never be selected as "main views". They always apply on top of their parent view when that view is displayed.
If you want an alternative view for a certain model you should define a new stand-alone view that does not inherit from any other. If that view is meant to be used only in the context of the view of my.second.object, there are two common tricks to make OpenERP use it:
Define it inline in the form view of my.second.object, as a child of the <field> element. This may not work in all OpenERP clients depending on the version, and works best for declaring inline form views for o2m lines, normally.
Declare it as a stand-alone view with a low priority (e.g. 32) and put a magic context key in the many2one field of the my.second.object view that should use it. The magic key is in the form <view_type>_view_ref, and the value must be the XML ID of the desired view. This should work everywhere.
<!-- Example 1: inline form view -->
<form string="My second object">
<field name="my_object_id">
<form string="My object inline view">
<field name="name"/>
</form>
</field>
</form>
<!-- Example 2: explicitly ask for special view using magic key -->
<form string="My second object">
<field name="my_object_id" context="{'form_view_ref': 'module.my_object_form2'}"/>
</form>
For reference, have a look at this page of the OpenERP documentation that explains most of the options for making and using context-specific views.
NOTE: If you have used form_view_ref and from form view if you have
any button which is opening another form view of some other model then
it will give you error . It will try to open the same form view you
have passed in form_view_ref for another model also.
What "position" you defined in <field name="field_from_original_view">?
<record id='view_2' model='ir.ui.view'>
<field name="name">view.name</field>
<field name="model">my.object</field>
<field name="priority" eval="10"/>
<field name="inherit_id" ref="view_1"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="field_from_original_view" position="after" (or before)>
<field name="inherit1" />
<field name="inherit2" />
<field name="inherit3" />
</field>
</field>
</record>
There may not be a possibility to make an inherited form the standard form of your model so that it will be presented automatically.
BUT If you look at a specific task --> open an inherited form view for a one2many field e.g.; there is. Set the context variable 'form_view_ref' to 'MODULE.VIEW_ID'.
<field name="myOne2ManyField" context="{'form_view_ref': 'myModule.myInheritedView'}/>
Still works with Odoo 9.0.