Skip to Content
Menu
This question has been flagged
2310 Views

Based on card in template how to filter the contents in the ListTree View in odoo12 community

My template is:-

<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <template id="sale_filter_notify" name="sale.filter.notify">
        <div class="row">
            <t t-set="obj" t-value="request.env['sale.order']"/>
            <div class ="col-5">
                <div class="row">
                    <div class ='col'>
                       
                        <div class="card text-white bg-primary">
                            <div class="card-body">
                                <div class="stat-widget-one">
                                    <div class="stat-content dib">
                                        <div class="stat-text">Quotation</div>
                                        <div class='stat-digit'>
                                            <t t-esc="obj.get_state_count('draft')"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class ='col'>
                        <div class="card text-white bg-primary">
                            <div class="card-body">
                                <div class="stat-widget-one">
                                    <div class="stat-content dib">
                                        <div class="stat-text">Quotation Sent</div>
                                        <div class='stat-digit'>
                                            <t t-esc="obj.get_state_count('sent')"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div> 
                    </div>
                    <div class ='col'>
                        <div class="card text-white bg-primary">
                            <div class="card-body">
                                <div class="stat-widget-one">
                                    <div class="stat-content dib">
                                        <div class="stat-text">Sale Order</div>
                                        <div class='stat-digit'>
                                            <t t-esc="obj.get_state_count('sale')"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class ='col'>
                        <div class="card text-white bg-primary">
                            <div class="card-body">
                                <div class="stat-widget-one">
                                    <div class="stat-content dib">
                                        <div class="stat-text">Cancel</div>
                                        <div class='stat-digit'>
                                            <t t-esc="obj.get_state_count('cancel')"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>                 
    </template>
</odoo>

My model is:-

# -*- coding: utf-8 -*-

from odoo import models, fields, api, _
from odoo.http import request


#Model of sale-order
class SaleOrder(models.Model):
    _inherit = 'sale.order'
   
    @api.multi
    def get_state_count(self,states):
        count = len(self.env['sale.order'].search([('state','=',states)]).ids)
        print("\n\n\n\n",count)
        return count   

Controller is:-# -*- coding: utf-8 -*-

from odoo import http
from odoo.http import request
from odoo.addons.sale.controllers.onboarding import OnboardingController  # Import the class


# Inherit sales on-boarding
class CustomOnboardingController(OnboardingController):  

    @http.route('/sales/sale_quotation_onboarding_panel', auth='user', type='json')
    def sale_quotation_onboarding(self):

        company = request.env.user.company_id
        
        return {
            'html': request.env.ref('sale_filters.sale_filter_notify').render({
                'company': company,
                'state': company.get_and_update_sale_quotation_onboarding_state()
            })
        }


I have card Quotation,Quotion sent,Sale Order,Cancel in header of List tree view in sale..

on clicking it how to filter the contens in List tree view..

Please help..

Thanks in Advance...

Avatar
Discard