Monday 26 December 2016

How Create Inherited Tree view

How Create Inherited Tree view

1) Create parent field and child field as below

class object_object(models.Model):
    _name = 'object.object'

    name = fields.Char('Name')
    parent_id = fields.Many2one('object.object','Parent Field')
    child_id = fields.One2many('object.object', 'parent_id', string='Child Field')

2) Create simple tree view and add field as 'field_parent' as below

<record id="inherited_tree_view_example" model="ir.ui.view">
            <field name="name">object.object.tree</field>
            <field name="model">object.object</field>
            <field name="field_parent">child_id</field>
            <field name="arch" type="xml">
                <tree string="String Name">
                    <field name="name"/>
                </tree>
                or
                <tree toolbar="True" string="String Name">
                    <field name="name"/>
                </tree>
            </field>
        </record>

3) Create simple action as below

        <record id="inherited_tree_view_action" model="ir.actions.act_window">
            <field name="name">Action Name</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">object.object</field>
            <field name="domain">[('parent_id','=',False)]</field>
            <field name="view_type">tree</field>
            <field name="view_id" ref="inherited_tree_view_example"/>
        </record>
4) Create simple menu as below

        <menuitem action="inherited_tree_view_action" id="menu_id"/>

Sunday 11 December 2016

Create Custom Header Footer

Create Custome Header Footer

Create Simple template For Header Footer as below

<template id="header_footer_id">
    <t t-if="o and 'company_id' in o">
        <t t-set="company" t-value="o.company_id"></t>
    </t>
    <t t-if="not o or not 'company_id' in o">
        <t t-set="company" t-value="res_company"></t>
    </t>

    <t t-call="modulename.header_id" />
    <t t-raw="0" />
    <t t-call="modulename.footer_id" />
</template>

Create Header

<template id="header_id">
    <div class="header">
        //Your Code
    </div>
</template>

Create Footer

<template id="footer_id">
<div class="footer">
    //Your Code
</div>
</template>

Create Report custome report or inherited report

<template id="your_report_id">
    <t t-foreach="docs" t-as="o">
   <t t-call="modulename.header_footer_id">
       <div class="page">
       //Your Code
       </div>
   </t>
</t>
</template>

Odoo 17 New Features

  Odoo 17 new Features 1) Duplicate  multiple records from List view. Please have look below screenshots first you need to select records th...