Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Conversion of amount to text in openerp...

Subscribe

Get notified when there's activity on this post

This question has been flagged
3 Replies
20560 Views
Avatar
Ashmsh.M

in order to convert the amount to text in the sales order

I add the following lines in the sale/report/sale_order.py

from openerp.tools import amount_to_text
from openerp.tools import amount_to_text_en

'amount_to_text_en': amount_to_text_en, In the code

Then in the corresponding rml file i add [[str(amount_to_text(o.amount_total,"Ruppes"))]]

And in report.sxw also added this line. [[str(amount_to_text(o.amount_total,"Ruppes"))]]

But it will not generate any change in the printable report..

By looking on the openerp-server log file below mentioned warning displayed..

openerp.tools.safe_eval: Cannot eval 'str(amount_to_text(o.amount_total,"Ruppes"))'

Traceback (most recent call last): File "/opt/openerp/server/openerp/tools/safe_eval.py", line 241, in safe_eval return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict) File "", line 1, in <module> NameError: name 'amount_to_text' is not defined

How can be make amount to text in openerp v7.0

0
Avatar
Discard
Avatar
Dasadiya Chaitanya
Best Answer

Another Way just need to install the num2word python library and use it in as your  .py file

from num2words import num2words

use it in Qweb report py file

    def __init__(self, cr, uid, name, context):
        super(supplair_invoice, self).__init__(cr, uid, name, context)
        self.localcontext.update({
            'time': time,
            'num2words':num2word,
            'get_contact_chield':self.get_contact_chield,
        })

and use in your view xml file as report file

<span t-esc="str(num2words(o.amount_total)).upper()"  />

 

2
Avatar
Discard
Avatar
Prakash
Best Answer

Add amount_to_text in init method also

For Example in the sale/report/sale_order.py

from openerp.tools import amount_to_text
from openerp.tools import amount_to_text_en

class order(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(order, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time, 
            'show_discount':self._show_discount,
            'amount_to_text': amount_to_text,
            'amount_to_text_en': amount_to_text_en
        })

Then in the corresponding rml file add

 [[str(amount_to_text(o.amount_total,"Ruppes"))]]

And Restart the server

4
Avatar
Discard
Ashmsh.M
Author

ok.. Gives words in report. Through inheritance I make new module by refering the this. http://help.openerp.com/question/10504/detailed-procedure-to-do-the-number-to-text-conversion/ Inheriting the sale order. Write onchange function for amount_total field ,but now updating the values . it appears to zero in total

Prakash

on_change function shows output Rupees in word in the form. To show only in reports the above code updated

Ashmsh.M
Author

By using your code display in our report.. but in the salesorder form not display the words..

Prakash

To display in the form follows the steps: http://help.openerp.com/question/10504/detailed-procedure-to-do-the-number-to-text-conversion/ 1) make sure to create field data type char or text 2) To define on_change method in xml file amount field 3) Restart the server and update the module 4) result will be generate after change the amount fields

Ashmsh.M
Author

hello prakash i will post my .py file and xml file. please check. During onchange my amount_total field became "Zero" . Will u please check the code and help me to find the solution..

Avatar
Ashmsh.M
Author Best Answer
from openerp.osv import fields, osv
from tools.translate import _
from openerp.tools import amount_to_text_en
from openerp.tools.amount_to_text_en import amount_to_text 

class sale_order(osv.osv):
  _inherit = 'sale.order'
  _description = "Sales Order"
  def _amount_in_words(self, cr, uid, ids, field_name, arg, context=None):
    cur_obj = self.pool.get('res.currency')
    res = {}
    for order in self.browse(cr, uid, ids, context=context):
        taxed = untaxed = 0.0
        res[order.id] = {
            'amount_words': '0.0',
                        }
        val = val1 = 0.0
        cur = order.pricelist_id.currency_id
        for line in order.order_line:
            val1 += line.price_subtotal
            val += self._amount_line_tax(cr, uid, line, context=context)
        taxed = cur_obj.round(cr, uid, cur, val)
        untaxed = cur_obj.round(cr, uid, cur, val1)
        res[order.id] = amount_to_text_en.amount_to_text(float(taxed + untaxed))
    return res

  _columns = {
              'amount_words': fields.function(_amount_in_words, string='In Words', type="char", store=True, help="The amount in words"),

             }  

sale_order()

In XML file..

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
  <data> 
    <record model="ir.ui.view" id='view_report_order_form' >
      <field name="name">sale.order.form1</field>
      <field name="model">sale.order</field>
      <field name="inherit_id" ref="sale.view_order_form"/>
      <field name="arch" type="xml">
       <!-- <form string="Sales Order" version="7.0"> -->
          <field name="amount_total" position="after">
            <field name="amount_words"/> 
          </field>
        <!-- </form>-->
       </field>
    </record>

<record model="ir.actions.act_window" id="action_orders">
<field name="name">Salereport1</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>

</record>

</data> </openerp>

3
Avatar
Discard
Prakash

In xml file onchange should be amount float change the code <field name="text_amount" on_change="onchange_amount_total(amount_total)"/> into <field name="amount_total" on_change="onchange_amount_total(amount_total)"/

Ashmsh.M
Author

hi prakash Issue partially solved . See the updated post above.. I commented the line <form string="Invoice" version="7.0"> and its closing tags. Now amount appears in Euro and Cent , is it possible to make it to indian format..

Prakash

Updated the link http://help.openerp.com/question/37135/how-to-convert-amount-to-letters-in-indian-format/

Ashmsh.M
Author

thanks prakash.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now