Odoo Help

3

1
14 Answers
3
Avatar

Zbik Poland

--Zbik--
12715
| 7 6 9
Łódź, Poland
--Zbik--


Zbik Poland
4/2/15, 1:51 PM

You inherit class account_invoice() like this:

class account_invoice(models.Model):
    _inherit = "account.invoice"
   @api.multi
   def amount_to_text(self, amount, currency='Euro'):
       return amount_to_text(amount, currency)

call in xml

<span t-esc="o.amount_to_text(o.amount_total, 'Euro')"/> 


2
Pravitha Qatar
1/11/17, 11:20 PM

 https://github.com/Pravithavarghese1/purchase_amount_to_text

inherit account_invoice():

from odoo.tools import amount_to_text_en

class AccountInvoice(models.Model):
_inherit = "account.invoice"
_description = "Invoice"

    @api.multi
def amount_to_text(self, amount, currency):
    convert_amount_in_words = amount_to_text_en.amount_to_text(amount, lang='en', currency='')
        convert_amount_in_words = convert_amount_in_words.replace(' and Zero Cent', ' Only ')  
        return convert_amount_in_words


In xml:

<span t-esc="o.amount_to_text(o.amount_total, o.currency_id)"/>
0
Herry prasetyo Indonesia
4/20/18, 4:05 AM

  Pravitha thank you very much 

0
Arafat Ali Malaysia
10/25/17, 2:36 AM

For Odoo 10, you can get this free here: https://www.maxibi.com/prints-amount-text-english-using-odoo-free-module/

0
bunny India
8/22/17, 7:37 AM
<span t-esc="o.amount_to_text(o.amount_total, 'INR')"/> 
0
Susana Castillo United States
1/11/17, 11:47 PM

Thanks for sharing. 

0
B.hind Belgium
6/23/16, 10:07 AM

hi ,

when i try this code , it isn't working , i have this error

i dont  know how to solve it

File "/opt/odoo/addons/recu_facture/facture.py", line 23, in amount_to_text
    return amount_to_text(amount,currency)
QWebException: ""global name 'amount_to_text' is not defined" while evaluating
"o.amount_to_text(o.amount_total,'Euro')"" while evaluating
"translate_doc(doc_id, doc_model, 'partner_id.lang','recu_facture.recufacture_document')"
1 Comment
Pravitha Qatar
1/12/17, 12:18 AM

import amount_to_text from tools.

"from odoo.tools import amount_to_text"

0
le_dilem Canada
8/6/15, 10:21 AM

Hi,

https://github.com/ledilem/Odoo

1 Comment
Budi Hartono Indonesia
8/8/15, 4:55 AM

Thanks, I'll take a look

0
Budi Hartono Indonesia
4/3/15, 11:33 AM

Hi zbik,

Thanks a lot for your reply.

I did what you told, and I got this error.

QWebException: ""'account.invoice' object has no attribute 'amount_to_text'" while evaluating
"o.amount_to_text(o.amount_total, 'Euro')"" while evaluating
"translate_doc(doc_id, doc_model, 'partner_id.lang', 'account.report_invoice_document')"

FYI, these are the files in my modules:

amount_text folder:

views\report_invoice.xml
__init__.py
__openerp__.py
account_invoice.py
In the account_invoice.py

from openerp.tools import amount_to_text
class account_invoice(models.Model):
    _inherit = "account.invoice"
   @api.multi
   def amount_to_text(self, amount, currency='Euro'):
       return amount_to_text(amount, currency)

__init__.py

import account_invoice

__openerp__.py

{
   "name": "Amount Text",
    "version": "1.0.0",
    "depends": ["base"],
    "author": "Budi Hartono",
    "category": "",
    "description": """
    Amount to text.
    """,
    "website": "http://www.recoremedia.com",
    "depends": ["base"],
    "data": ["views/report_invoice.xml"],
    "installable": True,
    "active": False,
    #    "certificate": "",
}

views\report_invoice.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <template id="report_invoice_document_inherit" inherit_id="account.report_invoice_document">
            <xpath expr="//div[@class='page']/div[@class='row mt32 mb32']" position="replace">
                <div class="row mt32 mb32">
                  <div class="col-xs-2" t-if="o.name">
                      <strong>Keterangan:</strong>
                      <p t-field="o.name"/>
                  </div>
                  <div class="col-xs-2" t-if="o.date_invoice">
                      <strong>Tanggal Invoice:</strong>
                      <p t-field="o.date_invoice"/>
                  </div>
                  <div class="col-xs-2" t-if="o.origin">
                      <strong>Asal:</strong>
                      <p t-field="o.origin"/>
                  </div>
                  <div class="col-xs-2" t-if="o.partner_id.ref">
                      <strong>Kode Customer:</strong>
                      <p t-field="o.partner_id.ref"/>
                  </div>
                  <div class="col-xs-2" t-if="o.reference">
                      <strong>Referensi:</strong>
                      <p t-field="o.reference"/>
                  </div>
              </div>
            </xpath>
            <xpath expr="//table[@class='table table-condensed']" position="after">
            <p>
                <strong>Amount in Text:</strong>                
                <span t-esc="o.amount_to_text(o.amount_total, 'Euro')"/> 
            </p>
            </xpath>
        </template>
    </data>
</openerp>

3 Comments
Zbik Poland
4/3/15, 1:33 PM

Try it: "depends": ["account", "report"]

Zbik Poland
4/3/15, 1:35 PM

... in __openerp__.py and ... update your module.

Budi Hartono Indonesia
4/4/15, 12:49 AM

Hi zbik, Thanks, now it's working. You saved my live :) Anyway, I still have to add some import directives in the account_invoice.py to avoid further error messages: from openerp import api from openerp import models, fields

Ask a Question
Writer
Keep Informed
2 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 E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now