Odoo Help

0

0
1 Answer
0
Dasadiya Chaitanya
7/12/19, 6:50 AM


I have also fixed the issue from my end after tried a lot more attempts

If any one will face the same issue in your future development so that they can also able to fix it quickly.

Create a method into specific model  : (cheque.cheque model) 

def get_invoice_details(self, invoice_ids,cheque):
    vals,container,result,val=[],[],[],1
    invoice_no=''
    for line in invoice_ids:
        desc=''
        if line.is_vendor:
            invoice_no=line.vendor_reference
        else:
            invoice_no=line.number

        pay_amt=line.payment_ids.filtered(lambda m: m.cheque_issued_id.id ==cheque.id).amount or 0.00
        for l in line.invoice_line_ids:
            desc+=str(l.product_id.default_code)+',' or ''
        vals.append({
            'date':str(line.date_invoice),
            'invoice_no':invoice_no,
            'inv_amt':str(line.amount_total),
            'description':desc,
            'pay_amt':float(pay_amt)
        })
        invoice_no=''
    for l in vals:
        if val<=len(vals):
            container.append(l)
        if val % 9 == 0:
            result.append({'section':9,'vals':container})
            container=[]
        val+=1
    if container:
        result.append({'section':4,'vals':container})
    return result

In this method I have set section key with its value into result of list for dictionary where we are using the same section to making the page break perfectly

Call the same method and iterate it into Qweb Template
<t t-foreach="o.get_invoice_details(o.invoice_ids,o)" t-as="line" >
                <div class="page">
                    <div class="col-xs-12">
                                <table style="width:100%">
                                    <thead>
                                        <tr>
                                            <th>Invoice Date</th>
                                            <th>Invoice # </th>
                                            <th>Invoice Amt</th>
                                            <th>Description  </th>
                                            <th style="text-align:right">Payment Amt</th>
                                        </tr>
                                    </thead>
                                    <t t-foreach="line.get('vals')" t-as="inv">
                                    <tbody class="sale_tbody">
                                        <tr>
                                            <td>
                                                <span t-esc="inv.get('date')" />
                                            </td>
                                            <td>                                                
                                                <span t-esc="inv.get('invoice_no')" />
                                            </td>
                                            <td>
                                                <span t-esc="o.decimal_formated_amount(float(inv.get('inv_amt',0.00)))" />
                                            </td>

                                            <td>
                                                <span t-esc="inv.get('description')" />
                                            </td>
                                            <td style="text-align:right">
                                                <span t-esc="o.decimal_formated_amount2(float(inv.get('pay_amt',0.00)))" />                                             

                                       </td>
                                        </tr>               
                                    </tbody>
                                    </t>
                                </table>
                        </div>
                      <span t-if="line.get('section') % 9 == 0" style="page-break-after: always;">
                      </span>
                </div>

As per the business logic of get_invoice_details() method which is return the data in list form and then we can user the same and render it into the XML template.

Odoo will manage the page break automatically when the condition will satisfy over the XML template system will automatically bifurcate the page according to source code.

I hope my answer may helpful for you :)






















































Ask a Question
Keep Informed
1 follower(s)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now