Odoo : show amount in letters in Invoices PDF reports

In some countries like Madagascar, invoices must states the total amount in letters additionally to the numbers. This basic need is unfortunately difficult to get with the current version of Odoo online (Odoo online v16-sass-1). I had to edit the Invoice report template manually to add the amount in letters.

This tutorial is is long and painful so hang tight!

There are 3 steps to do it in a (kind of) future proof way

  1. Duplicate the main invoice template and add the magic code
  2. Duplicate the specific report view and make it point to the new invoice template
  3. Duplicate the report entry and make it point to the specific report view

Step 1. Duplicate the invoice template in Odoo

  • Activate debug mode and goto General Setting > Menu Technical > User Interface > Views
    You can browse this url (change your-adress.com with yours) : https://your-adress.com/web?debug=1&reload=true#action=29&model=ir.ui.view&view_type=list&cids=1&menu_id=45
  • Search for the view named report_invoice_document, clic on it to edit, but do not change this view as it’s a default view and would not be updated automatically if changed. The Odoo update process do not overwrite your changes.
  • Instead clic on the button Action > Duplicate (on the top right) and name your new View a little bit differently for example : report_invoice_document_letters
  • Then add this code to add the amount in letter is this one :
    <span>
    Arrêtée la présente facture à la somme de <span t-out="o.currency_id.amount_to_text(o.amount_total)"/>.
    </span>

    This code use the Currency object of the current invoice to format the total amount using the partner language. If you want another language, you’ll be able to change it in the second part of this tutorial
    You can put the code where it makes sense to you. If you’re stranger to HTML then you’re in trouble ?. I recommend that you put this code just after the </table> below the total_tax widget. Feel free to let me know in comments if the previous doesn’t make sentence to you.
  • Save your duplicated View and record its database id. The Id of your view is a number and visible in the current url of your browser just after the id=  
  • Add an external id to your new template. To do so, go to General Setting > Menu Technical > Sequence and Identifiers > External Identifiers
    Or go to : https://nivo.odoo.com/web?debug=1&reload=true#action=21&model=ir.model.data&view_type=list&cids=1&menu_id=37
  • Clic on the New button on the top left and fil the following information
    • Module : mycompany  (of course, put your company name or any module name you want)
    • External Id : report_invoice_document_letters (the name of the template you previously created)
    • Model : ir.ui.view  (this is to say that we’re pointing to a view)
    • Record Id : The id of the view you created previously (I asked you to note it somewhere, remember ? 😉 )

Step 2. Duplicate the report view in Odoo

  • Activate debug mode and goto General Setting > Menu Technical > User Interface > Views
    You can browse this url (change your-adress.com with yours) : https://your-adress.com/web?debug=1&reload=true#action=29&model=ir.ui.view&view_type=list&cids=1&menu_id=45
  • For tweaking the Invoices with payment report, search for the view named  report_invoice_with_payments, clic on it to edit, but do not change this view as it’s a default view and would not be updated automatically if changed
  • Instead clic on the button Action > Duplicate (on the top right) and name your new View a little bit differently for example : report_invoice_with_payments_letters
  • Then change the code t-call=”account.report_invoice_document” to t-call=”mycompany.report_invoice_document_letters”
    Note that mycompany should be the module name you chose in the previous step
  • Save your duplicated View and note its database id. The Id of your view is a number and visible in the current url of your browser just after the id=  
  • Add an external id to your new template. To do so, go to General Setting > Menu Technical > Sequence and Identifiers > External Identifiers
    Or go to : https://nivo.odoo.com/web?debug=1&reload=true#action=21&model=ir.model.data&view_type=list&cids=1&menu_id=37
  • Clic on the New button on the top left and fil the following information
    • Module : mycompany  (of course, put your company name or any module name you want)
    • External Id : report_invoice_with_payments_letters (the name of the template you previously created)
    • Model : ir.ui.view  (this is to say that we’re pointing to a view)
    • Record Id : The id of the view you created previously (I asked you to note it somewhere, remember ? 😉 You’re not crazy, it’s the second time you do this but with a slightly different id)

Don’t quit now. You’re only one step ahead of success 🙂

Step 3. Duplicate the report entry

  • Activate debug mode and goto General Setting > Menu Technical > Actions >
    Report 
    You can browse this url (change your-adress.com with yours) : https://nivo.odoo.com/web?debug=1&reload=true#action=6&model=ir.actions.report&view_type=list&menu_id=4&cids=1
  • Search for report_invoice_with_payments, you should get a row named Invoices using the model repot_invoice_with_payments. Clic on it to edit, but do not change this report as it’s a default item and would not be updated automatically if changed
  • Instead clic on the button Action > Duplicate (on the top right) and name your new Report a little bit differently for example : Invoices with letters
  • Then change the report this way :
    • Model : account.move  (do not change it)
    • Report name : mycompany.report_invoice_with_payments_letters (the module and the name you chose in the previous step)
  • Save your duplicated report
  • Clic on the smart button Add to “Print” menu on the top right of the screen

Done ! You have a new invoice report which shows the amounts in letters.
If you have more questions, feel free to contact at manitra [at] manitra [dot] net .

Tips

Do not even try to do this with Odoo Studio. I wasted 3 days of my life trying. Odoo Studio tries to use xpath with loosely identified elements to update the report. You will most likely fail to do what you want and will pollute your instance with lot of randomly named elements.

Tips2

Did you actually manage to follow this very long tutorial ? Or where did you get stuck ?.
Let me know if I wrote some mistakes somewhere, I’ll gladly correct it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.