I need to show Tree view instead of Form view after i inherit CRM Module to my Custom Module in Openerp - odoo

I had successfully inherited the CRM module into my custom module.I'm able to view the Form view but i need to show Tree view first.When i click Lead button in the main menu i'm able to show the form view (like in img1), but i need to show the tree view(like in img 2)
img 1
img 2
lead_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_lead_tree" model="ir.ui.view">
<field name="name">bala.lead</field>
<field name="model">bala.lead</field>
<field name="arch" type="xml">
<tree string="Leads">
<field name="contact_name"/>
<field name="lead_source"/>
<field name="lead_status"/>
</tree>
</field>
</record>
<!-- ========================This is Form layout===============================-->
<record id="crm_case_form_view_leads_extended" model="ir.ui.view">
<field name="name">CRM - Leads Form</field>
<field name="model">bala.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads" />
<field name="arch" type="xml">
<field name="email_from" postion="replace"/>
<field name="contact_name" position="replace"/>
<label for="contact_name" position="replace">
<br/>
</label>
<xpath expr="//label[#for='street']" position="before">
<field name="contact_name"/>
</xpath>
<xpath expr="//label[#for='section_id']" position="before">
<field name="lead_source"/>
<field name="lead_status"/>
</xpath>
<field name="function" position="replace"/>
<field name="partner_name" position="replace"/>
<field name="priority" position="replace"/>
<field name="categ_ids" position="replace"/>
<field name="partner_id" position="replace"/>
</field>
</record>
<!-- ===========================Action layout=========================== -->
<record id="new_lead" model="ir.actions.act_window">
<field name="name">Leads</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">bala.lead</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_lead_tree"/>
</record>
<!-- ===========================Menu Settings=========================== -->
<menuitem name ="Lead" id = "menu_lis_lab" />
<menuitem name="Leads" id="sub_lead" parent="menu_lis_lab" />
<menuitem name="Create Lead" id="create_lead" parent="sub_lead" action="new_lead"/>
</data>
</openerp>
then on click of any lead i'm getting img 3 (invalid view)and on click on Create button img 4 is being displyed , but i need to get img1
img 3
img 4

Add tree view to your xml file, and you can add more fields in this according to requirement,
<record id="view_lead_tree" model="ir.ui.view">
<field name="name">bala.lead</field>
<field name="model">bala.lead</field>
<field name="arch" type="xml">
<tree string="Leads">
<field name="contact_name"/>
<field name="lead_source"/>
<field name="lead_status"/>
</tree>
</field>
</record>
update your act_window
<record id="new_lead" model="ir.actions.act_window">
<field name="name">Lead</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">bala.lead</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_lead_tree"/>
</record>
Hope this will help you.

Related

Odoo How to add a editable tree view inside a new page?

I want to display the fields as editable in tree view inside a new tab in the sale.order? My code does not make any errors, but shows the fields in form view rather than tree view. How to correct it?
.xml
<record model="ir.ui.view" id="contract_custom">
<field name="name">sale.order.custom.form.inherited</field>
<field name="model">sale.order</field>
<field name="type">tree</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//page[#string='Other Information']" position="after">
<page string="Salesman Commission">
<tree editable="bottom">
<group>
<field name="user_select"/>
<field name="sales_value" on_change="on_change_commission(sales_value,sale_percent)"/>
<field name="sale_percent" on_change="on_change_commission(sales_value,sale_percent)"/>
<field name="sale_commission"/>
</group>
</tree>
</page>
</xpath>
</field>
</record>
Here is a possible solution
<record model="ir.ui.view" id="contract_custom">
<field name="name">sale.order.custom.form.inherited</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//page[#string='Other Information']" position="after">
<page string="Salesman Commission">
<field name="field_name"> <!-- field you want to show as tree -->
<tree editable="bottom">
<field name="user_select"/>
<field name="sales_value" on_change="on_change_commission(sales_value,sale_percent)"/>
<field name="sale_percent" on_change="on_change_commission(sales_value,sale_percent)"/>
<field name="sale_commission"/>
</tree>
</field>
</page>
</xpath>
</field>
</record>

inheriting the inherit view in xml

In 'product.template' I need to add two fields for that I written one view in xml file but the problem is 'inherit_id' of 'accounts' is inheriting from 'product.product_template_form_view'.so how should I use inherit_id in my file.
I tried with below code but it was showing error please help me
account.product_view.xml code:
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.template.form.inherit</field>
<field name="model">product.template</field>
<field name="priority">5</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<page string="Sales" position="after">
<page string="Accounting" groups="account.group_account_invoice">
<group>
<label for="categ_id" string="Internal Category"/>
<div><field name="categ_id" colspan="3" nolabel="1"/></div>
</group>
<group name="properties">
<group>
<field name="property_account_income" domain="[('type','=','other')]" groups="account.group_account_user"/>
<field name="taxes_id" colspan="2" widget="many2many_tags" required="1"/>
</group>
<group>
<field name="property_account_expense" domain="[('type','=','other')]" groups="account.group_account_user"/>
<field name="supplier_taxes_id" colspan="2" widget="many2many_tags" required="1"/>
</group>
</group>
</page>
</page>
</field>
</record>
mycode:
<record model="ir.ui.view" id="gst_account_view_inherit">
<field name="name">gst_account_view_add_form_inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="account.product_template_form_view"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field/page/page/group/group/field[#name='taxes_id']" position="after">
<field name="cgst_id"/>
</xpath>
</data>
</field>
</record>
I need to add my 'cgst_id' field under 'taxes_id' field.
You don't need to give full path.
Try with these code:
<field name="taxes_id" position="after">
<field name="cgst_id"/>
</field>

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

Group by field name

I want to do Group by by City but this possibility doesn't shows up. where is my mistake? there is field city in python file and it's showing up in tree view but not really in Group by
<openerp>
<data>
<record id="vpicktree" model="ir.ui.view">
<field name="name">Picking tree city</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.vpicktree"/>
<field name="arch" type="xml">
<field name="location_dest_id" position="after">
<field name="city"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="stock_picking_filter_city_search">
<field name="name">stock.picking.tree.filter_search</field>
<field name="model">stock.picking</field>
<field name="arch" type="xml">
<search string="City">
<filter name="city" string="City" context="{'group_by':'city'}"/>
</search>
</field>
</record>
<record id="action_picking_tree_city" model="ir.actions.act_window">
<field name="name">City</field>
<field name="res_model">stock.picking</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,kanban,calendar</field>
<field name="domain"></field>
<field name="context">{ 'group_by':'city' }</field>
<field name="search_view_id" ref="stock.view_picking_internal_search"/>
</record>
</data>
</openerp>
The group by must be in search view not on the action setion as you did, so you have to edit your search view:
<record model="ir.ui.view" id="stock_picking_filter_city_search">
<field name="name">stock.picking.tree.filter_search</field>
<field name="model">stock.picking</field>
<field name="arch" type="xml">
<search string="City">
<filter name="city" string="City" context="{'group_by':'city'}"/>
<group expand="0" string="Grouper par">
<filter string="City" icon="terp-personal" domain="[]" context="{'group_by':'city'}"/>
</group>
</search>
</field>
</record>

Create two graph view for one model openerp

I want Create two graph view for one model openerp, I like to define Two menu for each one display a graph view,
exemple one content graph by country the ather by gender
You need to create two graph view in xml.
<record id="country_graph_id" model="ir.ui.view">
<field name="name">country.graph</field>
<field name="model">your.model</field>
<field name="arch" type="xml">
<graph string="By Country" type="bar">
<field name="your fields"/>
<field name="your_field2"/>
</graph>
</field>
</record>
<record id="country_gender_id" model="ir.ui.view">
<field name="name">gender.graph</field>
<field name="model">your.model</field>
<field name="arch" type="xml">
<graph string="By Gender" type="bar">
<field name="your_field3"/>
<field name="your_field4"/>
</graph>
</field>
</record>
after that, you need to create two actions and two menus like,
<record id="action_for_country_graph" model="ir.actions.act_window">
<field name="name">By Country</field>
<field name="res_model">your.model</field>
<field name="view_type">form</field>
<field name="view_mode">graph</field>
<field name="view_id" ref="country_graph_id"/>
</record>
<record id="action_for_gender_graph" model="ir.actions.act_window">
<field name="name">By gender</field>
<field name="res_model">your.model</field>
<field name="view_type">form</field>
<field name="view_mode">graph</field>
<field name="view_id" ref="gender_graph_id"/>
</record>
<menuitem action="action_for_country_graph" id="menu_country_graph_id"
sequence="1" name='Country Graph' parent='parent.menu'/>
<menuitem action="action_for_gender_graph" id="menu_gender_graph_id"
sequence="2" name='Gender Graph' parent='parent.menu'/>