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'/>
Related
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>
I have two tree views, how can I merge it in one but still have the same number of lines because my problem is that I wanna separate a line into two as i didn't find a solution I created the two tree views, so if there is another way to separate the line without creating the two views is better.
<record model="ir.ui.view" id="medical_lab_cash_tree_id">
<field name="name">cash</field>
<field name="model">medical.lab.patient</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree>
<field name="patient_id"/>
<field name="Amount_in_date"/>
<field name="Amount_In"/>
<field name="type_In"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="medical_lab_cash_tree_id2">
<field name="name">cash2</field>
<field name="model">medical.lab.patient</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree>
<field name="patient_id"/>
<field name="Amount_in_date1"/>
<field name="Amount_In1"/>
<field name="type_In1"/>
</tree>
</field>
</record>
We can inherit original view and add as needed fields in tree view.
For example:
<record id="medical_lab_cash_tree_id_extend" model="ir.ui.view">
<field name="name">medical.lab.cash.tree</field>
<field name="model">medical.lab.patient</field>
<field name="inherit_id" ref="module_name.medical_lab_cash_tree_id"/>
<field name="arch" type="xml">
<field name="type_In" position="after">
<field name="Amount_in_date1"/>
<field name="Amount_In1"/>
<field name="type_In1"/>
</field>
</field>
</record>
EDIT: You can replace your whole tree with following style.
<record id="medical_lab_cash_tree_id_extend" model="ir.ui.view">
<field name="name">medical.lab.cash.tree</field>
<field name="model">medical.lab.patient</field>
<field name="inherit_id" ref="module_name.medical_lab_cash_tree_id"/>
<field name="arch" type="xml">
<xpath expr="/tree" position="replace">
<tree>
<!-- Place your new field list -->
</tree>
</xpath>
</field>
</record>
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.
I extended "hr.employee" class. (Inherited and gave the same name to the new one).
I defined two views (tree and form) and a menu:
<record model="ir.ui.view" id="my_employee_tree">
<field name="name">hr.employee.tree</field>
<field name="model">hr.employee</field>
<field name="arch" type="xml">
...
</field>
</record>
<record id="view_my_hr_employee_form" model="ir.ui.view">
<field name="name">hr.employee.form</field>
<field name="model">hr.employee</field>
<field name="arch" type="xml">
...
</field>
</record>
<record model="ir.actions.act_window" id="action_my_hr_employee_seq">
<field name="name">Angajati</field>
<field name="res_model">hr.employee</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_my_hr_employee_form"/>
</record>
<menuitem id="menu_project_hr_base" parent="menu_project_utcn_project_base_main" name="HR"/>
<menuitem action="action_my_hr_employee_seq" id="menu_action_employee_form" name ="Angajati" parent="menu_project_hr_base"/>
What I want to do is to get the original views from hr.employee view when i use the original module, and to get my defined views when i use my module.
As you can see, I have specified "view_id" reference to my form view, but how can i define a reference also to my tree view? And I want the tree view to be shown first, and form view as alternative. How can i specify this?
<field name="view_mode">tree,form</field>
seems not to work if i add reference to form view
You have to map your action with particular tree,form view.
Try this:
<record model="ir.actions.act_window" id="action_my_hr_employee_seq">
<field name="name">Angajati</field>
<field name="res_model">hr.employee</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.actions.act_window.view" id="act_hr_employee_tree_view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="your_tree_view_id"/>
<field name="act_window_id" ref="action_my_hr_employee_seq"/>
</record>
<record model="ir.actions.act_window.view" id="act_hr_employee_form_view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="your_form_view_id"/>
<field name="act_window_id" ref="action_my_hr_employee_seq"/>
</record>
I would like to create different 'kinds' of purchase order forms in OpenERP with different fields in each. Because of the inheritance model, I am assuming I can't inherit multiple children with disjoint fields. So I decided to create a superset child that had all the fields from all types of PO.
I then created different views, containing different fields from the inherited model.
But each of the views shows the same superset.
Please advise if I am doing this the right way or is there no other way but fields_view_get().
Thanks
Code:
class purchase_order_hash(osv.osv):
_name = 'purchase.order'
_inherit = 'purchase.order'
_columns={
'quality_code': fields....,
'rice_quality': fields....,
'packing_code': fields....,
'packing_type': fields....,
'late_payment': fields.float('Late Payment'),
'num_bags': fields.integer('Number of Bags'),
'unit_kg': fields.integer('Unit kg'),
'rate_': fields.float('Rate', digits=(16,2), help="Rate"),
'penalty_moisture': fields.float('Moisture Penalty', digits=(16,2), help="Percentage"),
'penalty_broken': fields.float('Broken Penalty', digits=(16,2), help="Percentage"),
'num_trucks': fields.integer('Number of Trucks'),
'test1': fields.integer('Test 1')
}
purchase_order_hash()
(views xml:)
<record id="purchase_order_hash_form" model="ir.ui.view">
<field name="name">purchase_order_hash_form</field>
<field name="model">purchase.order</field>
<field name="priority" eval="1" />
<field name="type">form</field>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field name="arch" type="xml">
<field name="origin" select="2" position="after">
<field name="quality_code"/>
<field name="rice_quality"/>
<field name="packing_code"/>
<field name="packing_type"/>
<field name="late_payment"/>
<field name="num_bags"/>
<field name="unit_kg"/>
<field name="rate_"/>
<field name="penalty_moisture"/>
<field name="penalty_broken"/>
<field name="num_trucks"/>
</field>
</field>
</record>
<record id="purchase_order_hash_form_test" model="ir.ui.view">
<field name="name">purchase_order_hash_form_test</field>
<field name="model">purchase.order</field>
<field name="priority" eval="2" />
<field name="type">form</field>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field name="arch" type="xml">
<field name="origin" select="2" position="after">
<field name="test1"/>
</field>
<field name="num_trucks" position="replace"/>
</field>
</record>
<record model="ir.actions.act_window" id="action_PO_hash">
<field name="name">action_PO_hash</field>
<field name="res_model">purchase.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="purchase_order_hash_form" />
</record>
<record model="ir.actions.act_window" id="action_PO_hash_test">
<field name="name">action_PO_hash_test</field>
<field name="res_model">purchase.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="purchase_order_hash_form_test" />
</record>
<menuitem id="menu_PO_hash" name="menu_PO_hash" action="action_PO_hash" parent="purchase.menu_procurement_management"/>
<menuitem id="menu_PO_hash_test" name="menu_PO_hash_test" action="action_PO_hash_test" parent="purchase.menu_procurement_management"/>
[Update Oct 16, 2012: view.xml - final working code:]
<record model="ir.actions.act_window" id="action_PO_hash">
<field name="name">action_PO_hash</field>
<field name="res_model">purchase.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
</record>
<record model="ir.actions.act_window" id="action_PO_hash_test">
<field name="name">action_PO_hash_test</field>
<field name="res_model">purchase.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
</record>
<record model="ir.actions.act_window.view" id="action_PO_hash_2">
<field name="sequence" eval="1"/>
<field name="view_mode">form</field>
<field name="view_id" ref="purchase_order_hash_form"/>
<field name="act_window_id" ref="action_PO_hash"/>
</record>
<record model="ir.actions.act_window.view" id="action_PO_hash_test_2">
<field name="sequence" eval="1"/>
<field name="view_mode">form</field>
<field name="view_id" ref="purchase_order_hash_form_test"/>
<field name="act_window_id" ref="action_PO_hash_test"/>
</record>
<menuitem id="menu_PO_hash" name="menu_PO_hash" action="action_PO_hash" parent="purchase.menu_procurement_management"/>
<menuitem id="menu_PO_hash_test" name="menu_PO_hash_test" action="action_PO_hash_test" parent="purchase.menu_procurement_management"/>
If you want to get different form for each action, then you have to create different forms without inheriting the view. Then for each form and tree view you newly create, please specify the window action. For example:
<record model="ir.actions.act_window.view" id="a_unique_name_as_id">
<field name="sequence" eval="2"/>
<field name="view_mode">form</field>
<field name="view_id" ref="your_view_ref_id"/><!--use ref="purchase_order_hash_form_test"-->
<field name="act_window_id" ref="your_action_reference_id"/><!--use ref='action_PO_hash_test'-->
</record>
To create different 'kinds' of purchase order forms you have to create different forms without inheriting them and provide reference of those forms in your action.
Write below tag in your action:
<field name="view_id" ref="id_of_your_form"/>
You can find so many examples in your addons.
To see example go to addons-6.1/account/account_view.xml: find with "view_id"