How to group or nest a tree view by a field in Odoo? - odoo-8

I want to create a nested tree view grouping by fields like the following image.
I did not find any source code within Odoo. How to do it?

When you create a search view with a group_by you can see the lines like that
<record id="view_account_invoice_filter" model="ir.ui.view">
<field name="name">account.invoice.select</field>
<field name="model">account.invoice</field>
<field name="arch" type="xml">
<search string="Search Invoice">
<filter string="Period" context="{'group_by':'period_id'}"/>
</search>
</field>
</record>
You must select it in the search view

Related

How to add "Group By" to Tree View in Odoo V11?

I am new in odoo.
I have a tree view , i want to show it by default with grouped by according to my stage_id.
Any one help me.
Thanks
<field name="name">dmr.search.view</field>
<field name="model">model.name</field>
<field name="arch" type="xml">
<search string="DMR">
<filter name="group_customer_id" string="Customer" icon="terp-partner" context="{'group_by':'field_name'}"/>
</search>
</field>
After adding search record, you need to add search_view_id in action.
For Ex :-
In action
<field name="search_view_id" ref="dmr_search_view"/>
I hope it works for you

How to apply Many2many field filter in search view for odoo 10

i have a many2many field and i want to apply domain in search view. But i'm getting following error while filtering "Uncaught Error: Failed to evaluate search criterions: ".
My xml code is here:
<record id="view_partner_fare_well_ser_search_master" model="ir.ui.view">
<field name="name">Farewell Room Search</field>
<field name="model">fare.well.room.ser</field>
<field name="arch" type="xml">
<search string="Farewell Room">
<group string="Order By">
<filter string="Farewell Room" context="{'group_by':'room'}" help="Farewell Room"/>
</group>
<field name="single_room_show"/>
<filter string="Farewell Room" domain="[('id','in',single_room_show and single_room_show[0] and
single_room_show[0][2] or False)]"
name="my_farewell_room_filter"/>
</search>
</field>
</record>[![enter image description here][1]][1]

add many2one field in inherited view

I want to display my Many2one field.
I inherited from the hr_timesheet_sheet.sheet model like this:
class list_activity_sheet(models.Model):
_inherit = 'hr_timesheet_sheet.sheet'
activity_id = fields.Many2one('list_activity_sheet.activity')
class List_activity(models.Model):
_name='list_activity_sheet.activity'
name= fields.Char('Description',required=True)
And for the View:
<openerp>
<data>
<record id="List_activity_form" model="ir.ui.view">
<field name="name">hr_timesheet_sheet.sheet.form.inherit</field>
<field name="model">hr_timesheet_sheet.sheet</field>
<field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page[#string='Details']/field/tree/field[#name='name']" position="after">
<field name="activity_id"></field>
</xpath>
</field>
</record>
</data>
When i install my addon , i got that message:
field activity_id doesn't exist in the view.
Does anyone know how to solve that?
You're working on the wrong model. If i understand your view definition correctly, you want to choose an activity on the sheet lines.
You have to inherit hr.analytic.timesheet for that instead of hr_timesheet_sheet.sheet. In Odoo 9+ you have to inherit account.analytic.line, because hr.analytic.timesheet was kicked out.

how to add fields in inherited notebook/page/field

I have inherited 'sales order' from 'sales' module.
I need to add two extra fields inside 'Order Lines' tab.
.py
class SalesOrderInherit(models.Model):
_inherit = "sale.order"
type = fields.Selection([('appointment', 'Appointment'), ('walkin', 'Walk-In')], string="Type")
I need to add type field inside 'Order Lines' tab.
Which table should i inherit?
How to write to add above field.
Got Solution
<record id="inherit_sale_order_line" model="ir.ui.view">
<field name="name">inherit.sale.order.line.form.view</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="priority" eval="50" />
<field name="arch" type="xml">
<xpath expr="//field[#name='order_line']/tree/field[2]" position="after">
<field name="type"/>
</xpath>
</field>
</record>

inheritance view and adding fields

i have candidat model inherit the hr.emplyee model
i want to display the form view of hr.employee and add fields of my child model candidat
class hr_candidat(models.Model):
_name='hr_recrutement.candidat'
_inherit='hr.employee'
_description="Informations du Candidats"
situation=fields.Selection(string="Situation",selection=[('Nouveau','Nouveau'),('RDV Thechnique','RDV Technique'),('Annulation','Annulationn')])
.
.
.
<record id="hr_recrutement_candidat_form" model="ir.ui.view">
<field name="name">Candidat</field>
<field name="model">hr_recrutement.candidat</field>
<field name="arch" type="xml">
<form string="Candidat">
<sheet>
<group>
<field name="situation" />
.
.
</group>
</sheet>
</form>
</field>
</record>
I dont know how to display fields of hr.employee + my fields of candidat in view
Just we should set the below code from the view xml file and also
add the depended module as hr in your openerp.py and set the view xml file path as well.
Add below code in your .py file
class hr_employee(models.Model):
_inherit='hr.employee'
_description="Informations du Candidats"
situation=fields.Selection(string="Situation",selection=[('Nouveau','Nouveau'),('RDV Thechnique','RDV Technique'),('Annulation','Annulationn')])
Add below code in your .xml file
<record id="hr_recrutement_caindidat_form" model="ir.ui.view">
<field name="name">Candidat</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form" />
<field name="arch" type="xml">
<xpath expr="field[#name='work_location']" position="after">
<field name="situation" />
</xpath>
</field>
</record>
Hear We have to set the position of your element based on xpath using before,after,inside,replace Attributes of xpath tag.
I hope my answer may helpful for you :)

Resources