0

I do not know why it's not recognizing the fields which I have created in python file.I am getiing error as QWebException: "amt_inv" while evaluating "line['amt_inv']"

This is my python file,

class account_move_line(models.Model):
    _inherit = "account.move.line"

    amt_inv=fields.Char('Invoice')
    amt_reinv=fields.Char('Refunded Invoice')

This is a small part of my xml file,

<tr t-foreach="lines(partner)" t-as="line">
    <td>
        <t t-if="line['credit']==0">
            <span t-esc="line['amt_inv']"/></t>                 
        <t t-if="line['credit']>0">
            <span t-esc="line['amt_reinv']"/></t>                                                                                                           
    </td> 
Kiran
  • 1,481
  • 6
  • 36
  • 66

1 Answers1

0

Basically in your case your function lines(partner) will not returned the values properly.so your line instance of lines function is not part of the key so that you are facing that problem.

First it much and more important things is that you have to check the proper logic which you were returned from your lines() function.

For Example :

I have mentioned over hear what the actually you are returned from the dictionary and how we are iterate over the loop using our Qweb View file.

def lines(o.partner_id):

    Your logic mentioned over hear for make a new the dictionary
    res={
        'amt_inv':2022,
        'amt-reinv':5244.20,
        'credit':0,  
    }
    return list(res)

<tr t-foreach="lines(partner)" t-as="line">
    <td>
        <t t-if="line['credit']==0">
            <span t-esc="line['amt_inv']"/></t>                 
        <t t-if="line['credit']>0">
            <span t-esc="line['amt_reinv']"/></t>                                                                                                           
    </td> 

hear you can access as line instance form the key of that value as amt_inv key.

please try to check again your lines function logic It will return the proper list of dictionary or not

I hope my answer may helpful for your :)

DASADIYA CHAITANYA
  • 2,850
  • 3
  • 18
  • 41