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

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

Related

Odoo's qweb groups_id

With Odoo's Qweb, i wanna apply a restriction into actions.
I wanna remove some contacts into list with 'is_b2c' is True.
<record id="action_contacts" model="ir.actions.act_window">
<field name="name">Contacts</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.partner</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="search_view_id" ref="base.view_res_partner_filter"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to add a contact in your contacts directory.
</p><p>
Odoo helps you easily track all activities related to
a customer: discussions, history of business opportunities,
documents, etc.
</p>
</field>
</record>
The restriction must be:
<record id="contacts.action_contacts" model="ir.actions.act_window">
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="domain">
[
('is_b2c','=', False) <!-- Get contacts with 'is_b2c' is False for -->
]
</field>
<!-- for this group name only -->
<field name="groups_id" eval="[(6,0,[ref('sales_team.group_sale_salesman')])]"/>
</record>
Thanks
Instead of adding a group on the action, create two separate menu items and also create two separate actions and then add groups on these menu items. On one of the actions add the domain to show only limit contacts.

how to hide Edit button for a specific group

I'm using Odoo version 11 and I want to hide Edit button for some groups in this case group attendance/manual attendance. How can I do it?
you can done this by creating a security file in your module 'ir.model.access.csv'
1.id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2.access_hr_attendance_manual_id,access_hr_attendance_manual,model_hr_attendance,hr_attendance.group_hr_attendance,1,0,0,0
<record id="inherit_attendance_view_form" model="ir.ui.view">
<field name="name">attendance.form</field>
<field name="model">attendance</field>
<field name="inherit_id" ref="attendance."/>
<field name="groups_id" eval="[(6, 0, [ref('base.group_system') ])]"/><tree edit=false/>
</record>

How to restrict/disable the form view, while click tree view of one2many field in Odoo

How to restrict/disable the form view, while click the tree view of one2many field in Odoo.
Use style:
<field name="your_o2m" style="pointer-events:none;" />
Try this on your field XML definition :
<field name="your_o2m" mode="tree" />
I think that no_open attribute set on the <tree> might work
<field name="o2m_field" widget="one2many" mode="tree">
<tree no_open="1">
<field name="name"/>
</tree>
</field>

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

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

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