Skip to Content
Menu
This question has been flagged

I'm using odoo 11
and I'm trying to create a module to show amount in letters (alpha) on quotes and invoices.

Module structure: 

Main folder 
- __init__.py (calling for : from . import models)

- models (folder)

-- models/__init__.py (code : import account_invoice)

-- models/account_invoice.py 

class AccountInvoice(models.Model):

    _inherit = "account.invoice"

    @api.multi

    @api.depends('amount_total')

    def get_amount_letter(self):

        amount = convertion.trad(self.amount_total,self.currency_id.name)

        return amount

-- models/convertion.py (functions)


and a view : report_views.xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>
	<data>
		<template id="report_invoice_document" inherit_id="account.report_invoice_document">
			<xpath expr="//div[@class='page']/p[position()=last()]" position="after">
				<p>
        			<strong>Arrêter la facture à la somme de:</strong>
        			<span t-esc="o.get_amount_letter()"/>
    			</p>
			</xpath>
		</template>
	</data>
</odoo>


I got the error :

Error to render compiling AST
AttributeError: 'account.invoice' object has no attribute 'get_amount_letter'
Template: account.report_invoice_document_with_payments
Path: /templates/t/t/div/p[4]/span
Node: <span t-esc="o.get_amount_letter()"/>
Avatar
Discard

Hello,

Seems like your account_invoice.py (models/__init__.py (code : import account_invoice)) is not loading properly .can you please recheck by importing in like this way.

from . import account_invoice

Thanks,

Dipak

Author

Hi Dipak,

Thank you for your answer, but I did already tried this and nothing happend !

When I remove the o. in "o.get_amount_letter()" the error changed to attribute can not be callable, even if I tried to print a string value it give a blank space !

I tried to declare the variable on int file but nothing happend always blank space ?

Related Posts Replies Views Activity
1
Nov 19
3223
0
Feb 19
2892
1
Sep 18
8282
2
Mar 18
6943
1
Mar 18
4043