This question has been flagged
1 Reply
3579 Views

Hi all,

I want to add a date filter to a Qweb report.My requirement is to mail a report which only has  "create_date" is equal to "yesterday".



My code looks like the below.

<?xml version="1.0"?>
<t t-name="crm.lead.future_report_walkin">
            <t t-call="web.html_container">
                  
                  <t t-call="web.external_layout">
                    
                        <table class="table table-bordered">
                          
                          <!-- Start of Row -->
                          <div class="row bg-primary">
                            <div class="col-2" style="border: 1px solid black;">Name</div>
                            <div class="col-2" style="border: 1px solid black;">Mobile</div>
                            <div class="col-2" style="border: 1px solid black;">Counselor</div>
                            <div class="col-2" style="border: 1px solid black;">Course</div>
                            <!--<div class="col-2">Father's Name</div>-->
                            <div class="col-2" style="border: 1px solid black;">City</div>
                            <div class="col-2" style="border: 1px solid black;">WalkIn Date</div>
                          </div>
                          
                          <t t-foreach="docs" t-as="o">
                            <div class="row">
                              <!-- Report Row Content -->
                              <div class="col-2" style="border: 1px solid black;">
                              <t t-esc="o.name"></t>
                              </div>
                              <div class="col-2" style="border: 1px solid black;">
                              <t t-esc="o.mobile"></t>
                              </div>
                              <div class="col-2" style="border: 1px solid black;">
                              <t t-esc="o.user_id.name"></t>
                              </div>
                              
                              <!--<div class="col-2">
                              <t t-esc="o.x_father_name"></t>
                              </div>-->
                              <div class="col-2" style="border: 1px solid black;">
                              <t t-esc="o.city"></t>
                              </div>
                              
                            </div>
                          </t>
                        </table>
                        
                    </t>
            </t>
        </t>

Now this is downloding all data present in list view.

If it is not possible by adding filter to Qweb then what will its procedure to download specific date wise data.Please answer.



Avatar
Discard
Best Answer

Hello Soudhankhi Dalai,

There are multiple ways to do this filter.

Options 1: filter docs 


x.create_date.strftime('%Y-%m-%d') == (datetime.date.today() - relativedelta(days=1)).strftime('%Y-%m-%d'))" t-as="doc">

Option 2:  add t-if condition to compare record date in div tag

doc.create_date.strftime('%Y-%m-%d') == (datetime.date.today() - relativedelta(days=1)).strftime('%Y-%m-%d')">


Option 3: you can call method from xml to python like doc.your_method_name to filter records

Avatar
Discard

There are multiple ways to do this filter.

Options 1: filter docs

<t t-foreach="docs.filtered(lambda x: x.create_date.strftime('%Y-%m-%d') == (datetime.date.today() - relativedelta(days=1)).strftime('%Y-%m-%d'))" t-as="doc">

Option 2: add t-if condition to compare record date in div tag

<div class="row" t-if="doc.create_date.strftime('%Y-%m-%d') == (datetime.date.today() - relativedelta(days=1)).strftime('%Y-%m-%d')">

Option 3: you can call method from xml to python like doc.your_method_name to filter records