Logout when print Qweb report - odoo

How can I close the odoo session after printing a qweb report?
What I want is to close session after clicking Sample Report
<?xml version="1.0"?>
<odoo>
<record id="paperformat_euro_landscape"
model="report.paperformat">
<field name="name">European A4 Landscape</field>
<field name="default" eval="True" />
<field name="format">A4</field>
<field name="page_height">0</field>
<field name="page_width">0</field>
<field name="orientation">Landscape</field>
<field name="margin_top">35</field>
<field name="margin_bottom">15</field>
<field name="margin_left">7</field>
<field name="margin_right">7</field>
<field name="header_line" eval="False" />
<field name="header_spacing">35</field>
<field name="dpi">90</field>
</record>
<report id="action_mantto_task_report"
string="Sample Report"
model="rep.oper"
report_type="qweb-pdf"
name="repop_report.report_repop_task_template"
paperformat="paperformat_euro_landscape"
/>
</template>
</odoo>

Related

Format to xml view in odoo

I would like to give this structure to new fields that I add to this (inherited) view.
This is the xml code that I am using:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<record id="fleet_vehicule_l10n_new_form"
model="ir.ui.view">
<field name="name">fleet.vehicle.l10n.new.form</field>
<field name="model">fleet.vehicle</field>
<field name="inherit_id"
ref="fleet.fleet_vehicle_view_form" />
<field name="arch"
type="xml">
<field name="model_id"
position="after">
<group >
<field name="vehiculo_sat" />
</group>
</field>
<field name="description"
position="after">
<group string="MX EDI group">
<field name="transport_permit_no" />
<field name="transport_insurer" />
<field name="transport_insurance_policy" />
<field name="transport_perm_sct" />
<field name="vehicle_model" />
<field name="vehicle_config" />
<field name="vehicle_licence" />
<field name="trailer_ids" />
<field name="figure_ids" />
</group>
</field>
</field>
</record>
</data>
</odoo>
How can I achieve this? I understand that odoo uses bootstrap, but I don't know how to apply the classes in the xml of an inherited view.
Edit
I try this, but still not working:
<field name="description" position="after">
<!-- <field name="vehicle_licence" />
<field name="vehicle_model" /> -->
<group>
<field name="transport_permit_no" />
<field name="transport_insurer" />
<field name="transport_insurance_policy" />
<field name="transport_perm_sct" />
</group>
<field name="vehicle_config" />
<group>
<field name="trailer_ids" />
</group>
<group>
<field name="figure_ids" />
</group>
</field>
What am I doing wrong?
The description filed is inside a group, so adding two groups inside a group won't work like in the picture above.
You can add the group to sheet like following:
<xpath expr="//sheet" position="inside">
<group>
<group string="MX EDI group">
<field name="transport_permit_no"/>
<field name="transport_insurer"/>
<field name="transport_insurance_policy"/>
<field name="transport_perm_sct"/>
<field name="vehicle_model"/>
<field name="vehicle_config"/>
<field name="vehicle_licence"/>
</group>
<group string="Second Group">
</group>
</group>
<group>
<field name="trailer_ids"/>
<field name="figure_ids"/>
</group>
</xpath>
The default fleet vehicle form added six groups inside a group, so you can append the two groups inside that group
Example:
<xpath expr="//sheet/group" position="inside">
<group string="MX EDI group">
<field name="transport_permit_no"/>
<field name="transport_insurer"/>
<field name="transport_insurance_policy"/>
<field name="transport_perm_sct"/>
<field name="vehicle_model"/>
<field name="vehicle_config"/>
<field name="vehicle_licence"/>
</group>
<group string="Second Group">
</group>
</xpath>
<xpath expr="//sheet/group" position="after">
<group>
<field name="trailer_ids"/>
<field name="figure_ids"/>
</group>
</xpath>
The default col attribute value for group is 2

Odoo - How to update non updateable records by XML

I have created a few companies under res.company
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="True">
<record id="partner_my_company_hk" model="res.partner" context="{'default_is_company': True}">
<field name="name">My company HK</field>
<field name="company_id" eval="None"/>
<field name="customer" eval="False"/>
<field name="is_company" eval="True"/>
<field name="street"></field>
<field name="city"></field>
<field name="zip"></field>
<field name="phone"></field>
<field name="email">info#my_company.com</field>
<field name="website">www.my_company.com</field>
<field name="image" type="base64" file="base/static/img/res_company_logo.png"/>
</record>
<record id="partner_my_company_us" model="res.partner">
<field name="name">My company US</field>
<field name="company_id" eval="None"/>
<field name="customer" eval="False"/>
<field name="is_company" eval="True"/>
<field name="street"></field>
<field name="city"></field>
<field name="zip"></field>
<field name="phone"></field>
<field name="email">info#my_company.com</field>
<field name="website">www.my_company.com</field>
<field name="image" type="base64" file="base/static/img/res_company_logo.png"/>
</record>
<record id="company_my_company_hk" model="res.company">
<field name="name">My company HK</field>
<field name="partner_id" ref="partner_my_company_hk"/>
<field name="currency_id" ref="base.USD"/>
</record>
<record id="partner_my_company_hk" model="res.partner">
<field name="company_id" ref="company_my_company_hk"/>
</record>
<record id="company_my_company_us" model="res.company">
<field name="name">My company US</field>
<field name="partner_id" ref="partner_my_company_us"/>
<field name="currency_id" ref="base.USD"/>
</record>
<record id="partner_my_company_us" model="res.partner">
<field name="company_id" ref="company_my_company_us"/>
</record>
</data>
</odoo>
This is my original res_users.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<record id="base.user_admin" model="res.users">
<field name="groups_id" eval="[(4, ref('account.group_account_user'))]"/>
</record>
</data>
</odoo>
So I want to set those 2 newly created 2 companies into base.user_admin
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<record id="base.user_admin" model="res.users">
<field name="groups_id" eval="[(4, ref('account.group_account_user'))]"/>
<field name="company_id" ref="company_my_company_hk" />
<field name="company_ids" eval="[(4, ref('company_my_company_hk')),(4, ref('company_my_company_us'))]" />
</record>
</data>
</odoo>
And it is not working. But when I uninstall the module and reinstall it works.
Why? I cannot uninstall the module just to make it work in the future. What are the limitations and how to bypass the limits?
You can change the noupdate value on XML, change the desired fields and should take the change on noupdate back.
<!-- Allow updating on noupdate=True records -->
<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data">
<value
eval="[('module', '=', 'base'), ('name', '=', 'user_admin')]" />
</function>
<value eval="{'noupdate': False}" />
</function>
<record id="base.user_admin" model="res.users">
<!-- change fields here -->
</record>
<!-- Revoke noupdate change -->
<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data">
<value
eval="[('module', '=', 'base'), ('name', '=', 'user_admin')]" />
</function>
<value eval="{'noupdate': True}" />
</function>
External ID user_admin in base has been marked as noupdate.
And noupdate cannot be overridden.
Unless I run
UPDATE ir_model_data SET noupdate=False WHERE name = 'user_admin' and module='base';
Otherwise I won't be able to update it when I upgrade the module
More refined solution to #CZoellner 's solution is:
<function name="toggle_noupdate" model="ir.model.data" eval="['res.users', ref('base.user_admin')]"/>

Odoo 10 - ParseError:

Odoo 10 -
I am trying to create an attendance module for partners rather than employees. I am copying code from the Attendance Module included in Odoo but am stuck and getting ParseError. The problem seems to be the action="base.res_partner_kanban_view"/>
The error is below
ParseError: "ir.actions.view" while parsing
/opt/odoo/odoo10/odoo-10.0/customaddons/gym_attendance/views/gym_attendance_view.xml:93,
near
<menuitem id="menu_gym_attendance_view_members_kanban" name="Members" parent="menu_gym_attendance_manage_attendances" sequence="15" action="base.res_partner_kanban_view
Below is my XML
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- views -->
<record id="view_attendance_tree" model="ir.ui.view">
<field name="name">gym.attendance.tree</field>
<field name="model">gym.attendance</field>
<field name="arch" type="xml">
<tree string="Member attendances">
<field name="partner_id"/>
<field name="check_in"/>
<field name="check_out"/>
</tree>
</field>
</record>
<record id="gym_attendance_view_form" model="ir.ui.view">
<field name="name">gym.attendance.form</field>
<field name="model">gym.attendance</field>
<field name="arch" type="xml">
<form string="Member attendances">
<sheet>
<group>
<field name="partner_id"/>
<field name="check_in"/>
<field name="check_out"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="gym_attendance_view_filter" model="ir.ui.view">
<field name="name">gym_attendance_view_filter</field>
<field name="model">gym.attendance</field>
<field name="arch" type="xml">
<search string="Gym Attendance Search">
<field name="partner_id"/>
<!-- <field name="department_id"/> -->
<filter name="today" string="Today" domain="[('check_in', '>=', datetime.datetime.now().replace(hour=0, minute=0, second=0)),('check_in', '<=', datetime.datetime.now().replace(hour=23, minute=59, second=59))]" />
<filter string="Current Month" domain="[('check_in', '>=', datetime.datetime.now().strftime('%Y-%m-01'))]" />
<separator/>
<filter string="No Check Out" domain="[('check_out', '=', False)]" />
<separator/>
<filter string="My Attendances" domain="[('employee_id.user_id.id', '=', uid)]" />
<group expand="0" string="Group By">
<filter name="member" string="Member" context="{'group_by':'partner_id'}"/>
<separator/>
<filter name="groupby_name" string="Month" context="{'group_by':'check_in'}"/>
</group>
</search>
</field>
</record>
<record id="gym_attendance_action_my_attendances" model="ir.actions.client">
<field name="name">Attendance</field>
<field name="tag">gym_attendance_my_attendances</field>
<field name="target">main</field>
</record>
<!-- actions -->
<record id="gym_attendance_action" model="ir.actions.act_window">
<field name="name">Attendances</field>
<field name="res_model">gym.attendance</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{"search_default_today":1}</field>
<field name="search_view_id" ref="gym_attendance_view_filter" />
<field name="help" type="html">
<p>The attendance records of your members will be displayed here.</p>
<p>Please make sure you're using the correct filter if you expected to see any.</p>
</field>
</record>
<record id="gym_attendance_action_my_attendances" model="ir.actions.client">
<field name="name">Gym Attendance</field>
<field name="tag">gym_attendance_my_attendances</field>
<field name="target">main</field>
</record>
<menuitem id="menu_gym_attendance_root" name="Attendances" sequence="90" web_icon="gym_attendance,static/description/icon.png"/>
<menuitem id="menu_gym_attendance_my_attendances" name="Gym Attendances" parent="menu_gym_attendance_root" sequence="10" action="gym_attendance_action_my_attendances"/>
<menuitem id="menu_gym_attendance_manage_attendances" name="Manage Attendances" parent="menu_gym_attendance_root" sequence="20"/>
<menuitem id="menu_gym_attendance_view_attendances" name="Attendances" parent="menu_gym_attendance_manage_attendances" sequence="10" action="gym_attendance_action"/>
<menuitem id="menu_gym_attendance_view_members_kanban" name="Members" parent="menu_gym_attendance_manage_attendances" sequence="15" action="base.res_partner_kanban_view"/>
</odoo>
I think you trying to call id of kanban view of res.partner instead of the id of action. Either you have to find out the correct id for the action or create a new one and use.
Here is the example id for Customer base.action_partner_form which available in base/res/res_partner.xml
I hope it will help you.
Try with : gym_attendance_action,
you need to specify the action to your menu-item and this action will call your view.
Your action:
<field name="search_view_id" ref="gym_attendance_view_filter" />
Your menu-item:
<menuitem id="id_menu_item" name="NameOfYourView" parent="model.model"
action="turnover_filtered_view_action..." />

Odoo : make form fields show/hide based on dropdown

My custom module view looks like this
<odoo>
<data>
<record model="ir.ui.view" id="session_form_view">
<field name="name">item.form</field>
<field name="model">inventory.item</field>
<field name="arch" type="xml">
<form string="Items Form">
<sheet>
<group>
<field name="name"/>
<field name="code"/>
<field name="department"/>
<field name="state"/>
</group>
<group>
<field name="measurement" position="attributes">
<attribute name="attrs">{'invisible': [('state', '=', True)]}</attribute>
</field>
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="items_tree">
<field name="name">Item</field>
<field name="res_model">inventory.item</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<!-- <field name="context" eval="{'state':True}" /> -->
</record>
<menuitem id="main_openacademy_menu" name="Inventory"></menuitem>
<menuitem id="openacademy_menu" name="Store" parent="main_openacademy_menu"></menuitem>
<menuitem id="store_items_menu" name="Store items" parent="openacademy_menu" action="items_tree"/>
</data>
</odoo>
I have a simple model
I want to hide/show based on the department drop down. But some how for a lot of cases attrs is not working. I am begginer and using odoo 10.
Thanks

Customize dashboard in Odoo/Open ERP

Odoo/openerp 8 supports creating dashboard in which we can add multiple reports into it.
My question is: How can we inherit this dashboard to customize it?
For example, I want to add a button which helps clone the dashboard to another user.
It seems that this dashboard is not a usual FormView.
You can't inherit dashboards in Odoo 8.because dashboards is work like views container not usual view if you want to customize one .. just copy it's code and paste it in your module over again and customize what you need.
Try to make formview for yourself :-)
This is a good example:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.actions.act_window" id="act_centiro_stocks_tree_pendientes">
<field name="name">Centiro stock</field>
<field name="res_model">stock.picking</field>
<field name="view_type">tree</field> <!-- form -->
<field name="view_mode">tree</field>
<field name="domain">[('state', 'not in', ('assigned','done'))]</field>
</record>
<record model="ir.actions.act_window" id="act_centiro_stocks_tree_procesados">
<field name="name">Centiro stock</field>
<field name="res_model">stock.picking</field>
<field name="view_type">tree</field> <!-- form -->
<field name="view_mode">tree</field>
<field name="domain">[('state', 'in', ('assigned','done'))]</field>
</record>
<record model="ir.actions.act_window" id="act_centiro_stocks_graph">
<field name="name">Operaciones Centiro</field>
<field name="res_model">gc.operaciones.centiro</field>
<field name="view_type">form</field>
<field name="auto_refresh" eval="1" />
<field name="view_mode">kanban,form</field>
</record>
<record model="ir.ui.view" id="board_view_stock_centiro_form">
<field name="name">Stock Centiro</field>
<field name="model">board.board</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Centiro Stock Dashboard">
<hpaned>
<child1>
<action string="Estado almacén Centiro" name="%(act_centiro_stocks_graph)d" colspan="2" />
</child1>
<child2>
<action string="Pedidos pendientes" name="%(act_centiro_stocks_tree_pendientes)d" colspan="2" />
<action string="Pedidos sin ubicar" name="%(act_centiro_stocks_tree_procesados)d" colspan="2" />
</child2>
</hpaned>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="open_stock_centiro_board">
<field name="name">Stock Centiro Dashboard</field>
<field name="res_model">board.board</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="usage">menu</field>
<field name="view_id" ref="board_view_stock_centiro_form" />
</record>
<menuitem id="dashboard_menu" name="Dasboard custom module"
parent="cabecera_dashboard_custom_module" action="open_stock_centiro_board" />
</data>
Good luck