Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

How to change color on kanban view as per state in sale order model

By
Ankit H Gandhi(AHG)
on 1/1/15, 9:17 AM 2,326 views

Hello everyone,

How to change color on kanban view as per state in sale order model.and how to add new css in kanban view

0
subbarao
On 1/21/15, 4:18 AM

i thing it is usefull for you.

 

<kanban colors="grey:state=='state1';blue:state in ('state2','state3');black:state=='state4'">
                    <field name="name" string="Order Number"/>

                     .....................................

                    ......................................

 </kanban>

 

Hello subbarao, Thanks for replay but this code is not work

Ankit H Gandhi(AHG)
on 1/21/15, 5:23 AM
1

Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--
996
| 5 3 6
Rajkot, India
--Ankit H Gandhi(AHG)--

Learning Python..

Ankit H Gandhi(AHG)
On 1/8/15, 11:08 AM

Hello all,

Hope this code will be help

write this code in py file

from openerp.osv import osv, fields
import openerp.addons.decimal_precision as dp

class sale_order(osv.osv):
    _inherit = 'sale.order'
    
    def _check_color(self, cr, uid, ids, field_name, arg, context):
        res = {}
        for record in self.browse(cr, uid, ids, context):
            color = 0
            if record.state == u'draft':
                color=1
            if record.state == u'sent':
                color=2
            if record.state == u'cancel':
                color=3
            if record.state == u'waiting_date':
                color=4
            if record.state == u'progress':
                color=5
            if record.state == u'manual':
                color=6
            if record.state == u'shipping_except':
                color=7
            if record.state == u'invoice_except':
                color=8
            if record.state == u'done':
                color=9
            res[record.id] = color
        return res
    
    _columns = {
        'member_color':fields.function(_check_color,'Color',type="integer"),
    }
    
write this code in xml file

        <record model="ir.ui.view" id="view_order_kanban">
            <field name="name">view.order.kanban</field>
            <field name="model">sale.order</field>
            <field name="arch" type="xml">
                <kanban>
                    <field name="name" string="Order Number"/>
                    <field name="date_order"/>
                    <field name="partner_id"/>
                    <field name="user_id"/>
                    <field name="section_id"/>
                    <field name="amount_total" sum="Total Tax Included"/>
                    <field name="state"/>
                    <field name="member_color"/>
                    <templates>
                        <t t-name="kanban-box">
                            <div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.member_color.raw_value)} oe_kanban_card oe_kanban_stock_picking_type">
                                <div class="oe_dropdown_toggle oe_dropdown_kanban">
                                    <span class="oe_e">í</span>
                                    <ul class="oe_dropdown_menu">
                                        <t t-if="widget.view.is_action_enabled('edit')"><li><a type="edit">Edit...</a></li></t>
                                        <t t-if="widget.view.is_action_enabled('delete')"><li><a type="delete">Delete</a></li></t>
                                    </ul>
                                </div>
                                <div class="oe_kanban_vignette oe_semantic_html_override">
                                    <div class="oe_kanban_details">
                                        <h4 class="oe_partner_heading"><a type="open"><b>Order Number: </b><field name="name" string="Order Number"/></a></h4>
                                        <ul>
                                            <li><b>Date: </b><field name="date_order"/></li>
                                            <li><b>Customer: </b><field name="partner_id"/></li>
                                            <li><b>Salesperson: </b><field name="user_id"/></li>
                                            <li><b>Salesteam: </b><field name="section_id"/></li>
                                            <li><b>Total: </b><field name="amount_total" sum="Total Tax Included"/></li>
                                            <li><b>Status: </b><field name="state"/></li>
                                        </ul>
                                    </div>
                                </div>
                           </div>
                        </t> 
                    </templates>
                </kanban>
            </field> 
        </record>
        
        <record id="sale.action_orders" model="ir.actions.act_window">
            <field name="view_id" ref="view_order_kanban"/>
            <field name="view_mode">kanban,tree,form</field>
        </record>
if you find this answer helpful, please give me a thumbs up vote    
Regards,

Ankit H Gandhi

I got this error When I create a module as per your code .... 5 ERROR crm openerp.osv.orm: Can't find field 'section_id' in the following view parts composing the view of object model 'sale.order': * view.order.kanban

Odoo
on 1/13/15, 2:46 AM

Hello LIBU, Should be installed sale module.if not installed you will get this error. thanks for comment me..

Ankit H Gandhi(AHG)
on 1/13/15, 5:27 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 1/1/15, 9:17 AM
Seen: 2326 times
Last updated: 3/16/15, 8:10 AM