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

Float, comma as decimal separator and trailing 0

Subscribe

Get notified when there's activity on this post

This question has been flagged
reports
1 Reply
15356 Views
Avatar
aydunno

I created a simple report with float numbers which are calculated beforehand in this simple method:


def onchange_value(self, cr, uid, ids, c1 = 0.0, c2 = 0.00, c3 = 0.0, c4 = 0.0, c5 = 0.0, c6 = 0.0, c7 = 0.0, c8 = 0.0, c9 = 0.0, c10 = 0.0, context = None):

cx = (c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9) * 1.19

c10 = round(cx, 2)

return {'value': { 'c10': c10 }}


the numbers aredeclared in this manner:

'c1': fields.float(string="Betrag 1"),

'c2': fields.float(string="Betrag 2"),

'c3': fields.float(string="Betrag 3"),


and added to the report in this manner: 

<div class="col-xs-2"> <p t-field="o.c1" /> </div>   

<div class="col-xs-2"> <p t-field="o.c2" /> </div>

<div class="col-xs-2"> <p t-field="o.c3" /> </div>


What I try to do and actually have no idea how, is:

Having a comma as a decimal sepataor instead of the dot and the trailing zero need to be displayed.

Any help is much appreciated.

0
Avatar
Discard
Avatar
Axel Mendoza
Best Answer

For change the decmal separator you can do it in your specific lang on the menu /Settings/Translations/Languages, there is a field called Decimal Separator specifically for that matter

For change the trailing zeros you need to do it directly on the float field by defining the decimal precision like:

Old Api

'rounding': fields.float('Rounding Factor', digits=(12,2)),

New Api

rounding = fields.Float('Rounding Factor', digits=(12,2))

Where (12,2) is the number of digits before and after the decimal separator

2
Avatar
Discard
aydunno
Author

you agaibn, thanks!!!!! guess I have to mention you in the credits now :P I will try this out tomorrow. any idea for the trailing zero? My last idea was to modify the downloaded pdf by an external script.

Axel Mendoza

The answer is updated to include the trailing zeros part

aydunno
Author

got it! remarks on the solution: when trying to accomplish this by changing anything in the code, the leading zero where never displayed, unless using

in stead of field vauel in the report's definition. I solved it by doing both changes in the seetings. 1. the languages settings you pointed out. importatn here is to also change the value of the thousands separator. 2. under settings > technical > database structure > decimal accuracy, create a new entry whith your modules name and the number of digits that should follow the separator. in this way, comma and trainiling zeros are displayed everywhere correctly, especially in the reports.
aydunno
Author

one part is not displayed: using t-esc="'%.2f'%(o.c2)" instead of t-field value

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
Related Posts Replies Views Activity
Code for page number in Body of Pdf report
reports
Avatar
Avatar
Avatar
2
Oct 25
3339
How to increase the width of a column on odoo quotation PDF?
reports
Avatar
Avatar
1
Oct 25
1132
Odoo Online (SaaS 18.4 Enterprise) – How to modify invoice report header without affecting other reports but keep default table content
reports
Avatar
Avatar
1
Aug 25
1800
Odoo .SH V17 how do I migrate a report from staging to production?
reports
Avatar
Avatar
1
Apr 25
2443
List of Sales in a Report
reports
Avatar
Avatar
1
Jul 24
2785
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