Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kanban view in OpenERP

Tags:

kanban

openerp

How do I create a kanban view in OpenERP?

The developer book doesn't seem to have any information on the new kanban view, and I didn't see anything useful in the OpenERP forum.

like image 477
Pinakin Nayi Avatar asked Apr 04 '12 05:04

Pinakin Nayi


3 Answers

Here is sample code showing how to develop a kanban view in OpenERP.

For the kanban view you have to prepare 2 files: (1)xml file and (2) css file. The CSS file is used for the formating of the kanban view.

<record model="ir.ui.view" id="resource_kanban_view">
    <field name="name">any name of ur  model</field>
    <field name="model">object.name</field>
    <field name="type">kanban</field>
    <field name="arch" type="xml">
        <kanban>
            <templates>
                <t t-name="kanban-box">
                    <div class="oe_resource_vignette">
                        <div class="oe_resource_image">
                            <a type="edit"><img t-att-src="kanban_image('object.name', 'photo', record.id.value)" class="oe_resource_picture"/></a>
                        </div>
                        <div class="oe_resource_details">
                            <ul>
<!--Here you have to write the object's field name which you want to display in kanban view -->
                               <li><field name="name"/></li>
                               <li><field name="author"/></li>
                               <li><field name="description"/></li>
                               <li><field name="available_copy"/> </li>                                   
                             </ul>
                        </div>
                    </div>                       
                </t>
            </templates>
        </kanban>
    </field>
</record>
like image 116
ParaMeterz Avatar answered Jan 02 '23 02:01

ParaMeterz


Their is Doc on this, KANBAN view is created based on QWEB technology, developed by OF itself, you can see the the whole lib QWEB lib and under Doc Section you can see how you can define the qWeb QWEB Template, Now if you understand it then all you just need to do is out your web template under tag in view declaration, where other systex is same as generic view declaration :

   <record model="ir.ui.view" id="view_external_id">
        <field name="name">View Name</field>
        <field name="model">openerp.modelfield>
        <field name="type">kanban</field>
        <field name="arch" type="xml"> 
             <kanban>
                <field name="color"/>
                <!--list of field to be loaded -->
                <field name="list_price"/>
                <templates>
                     <!--Your Qweb based template goes here, each record will be wrapped in template so you can arrange field veyr easily in box -->
                </templates>
            </kanban>
        </field>
    </record>

Hope this will help you.

Regards

like image 21
ifixthat Avatar answered Jan 02 '23 02:01

ifixthat


I can't see any documentation for it yet, so the best you can do is look for examples in the addons project. Search all the XML files for <kanban>. Here's an example from the stock module:

    <record model="ir.ui.view" id="product.product_kanban_view">
        <field name="name">Product Kanban</field>
        <field name="model">product.product</field>
        <field name="type">kanban</field>
        <field name="arch" type="xml">
            <kanban>
                <field name="color"/>
                <field name="type"/>
                <field name="product_image"/>
                <field name="list_price"/>
                <templates>
                    <t t-name="kanban-box">
                        <div class="oe_product_vignette">
                            <div class="oe_product_img">
                            <a type="edit"><img t-att-src="kanban_image('product.product', 'product_image', record.id.value)" class="oe_product_photo"/></a>
                            </div>
                            <div class="oe_product_desc">
                                <h4><a type="edit"><field name="name"></field></a></h4>
                                <ul>
                                    <li t-if="record.type.raw_value != 'service'">Stock on hand: <field name="qty_available"/> <field name="uom_id"/></li>
                                    <li t-if="record.type.raw_value != 'service'">Stock available: <field name="virtual_available"/> <field name="uom_id"/></li>
                                    <li>Price: <field name="lst_price"></field></li>
                                    <li>Cost: <field name="standard_price"></field></li>
                                </ul>
                            </div>
                        </div>
                        <script>
                            $('.oe_product_photo').load(function() { if($(this).width() > $(this).height()) { $(this).addClass('oe_product_photo_wide') } });
                        </script>
                        <div></div>
                    </t>
                </templates>
            </kanban>
        </field>
    </record>
like image 45
Don Kirkby Avatar answered Jan 02 '23 00:01

Don Kirkby