automated actions through xml files - odoo-14

I managed to make the system send a message as a notification when some expiration date is close
BUT
I created a server action and an automatic action both in the GUI
I'd like to use xml files to create such actions
Otherwise I have to remember to create them every time I create a new db
I found something but for Odoo 15, I'm on Odoo 14

The creation of server actions and automated actions from XML are same in Odoo 14.0 or 15.0 and you can check the Odoo 14.0 Documentation
Example for server action:
<record id="act_hr_employee_holiday_request" model="ir.actions.server">
<field name="name">Time off Analysis</field>
<field name="model_id" ref="hr_holidays.model_hr_leave_report"/>
<field name="binding_model_id" ref="hr.model_hr_employee"/>
<field name="state">code</field>
<field name="groups_id" eval="[(4, ref('base.group_user'))]"/>
<field name="code">
action = model.action_time_off_analysis()
</field>
</record>
Examples for automated action.

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>

How to display only my costumes (created ) modules in Odoo (OpenERP)

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.

Issue when converting odoo 9 code in to Odoo 10

I have a module developed for online payments. As Odoo 10 has released with a new API I have converted this in to the new API. But when I install / update my addon I have an xml parse error in my xml file.
ParseError: "File not found: payment_gateway/static/src/img/gateway_icon.png" while parsing file:///C:/Program%20Files%20(x86)/Odoo%2010.0e/server/odoo/addons/payment_gateway/data/payment_acquirer_data.xml:5, near
<record id="payment.payment_acquirer_gateway" model="payment.acquirer">
**<field name="name">gateway</field>**
<field name="image" type="base64" file="payment_gateway/static/src/img/gateway_icon.png"/>
<field name="provider">gateway</field>
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="gateway_acquirer_button"/>
<field name="environment">test</field>
<field name="pre_msg">
<p>You will be redirected to the website after clicking on the payment button.</p></field>
<field name="gateway_merchant_number">dummy</field>
</record>
Above code in a screenshot
Does anyone can point me the reason.
Thanks

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.

Creating a new group

I've made a custom module for the warehouse and now I want this module to be available to a new group.
This new group needs to inherit from the stock manager, so it has to have all the rights the stock manager has + access to this new module.
In my xml I defined:
<record id="group_stock_manager_editor" model="res.groups">
<field name="name">Manager Editor</field>
<field name="category_id" ref="base.module_category_warehouse_management"/>
<field name="implied_ids" eval="[(4, ref('group_stock_manager')), (4, ref('account.group_account_user'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
But this doesn't seem to work, how can I achieve this?
Solved it, the problem was that I wanted to inherit the rights from the group_stock_manager from a custom module, so instead of group_stock_manager it had to be stock.group_stock_manager