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

precision decimal

Subscribe

Get notified when there's activity on this post

This question has been flagged
decimalprintnumberodooV8
3455 Views
Avatar
kiyuubi
Hello
I use odoo V8 on windows 7
I would like to add a decimal precision on the print state, for example 20000.0 to 20,000.00.
I tried everything but I did not succeed
attached my code:

## -*- coding: utf-8 -*-

import time
from openerp.report import report_sxw
from openerp.osv import osv
from openerp import pooler
import locale

class etat104(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context=None):
super(etat104, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'_get_etat': self._get_etat,
'_get_year': self._get_year,
'_cpt': self._cpt
})

def _cpt(self, ss):
locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')
if ss < 0.0 :
cpt = (locale.format('%.2f', ss, True))
cpt = '(' + cpt + ')'
else:
cpt = (locale.format('%.2f', ss, True))
return cpt

def _get_year(self,form):
return self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form).name

def _get_etat(self,form):
nbr = 0
fiscalyear = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear_id'])
period_ids=self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id', '=', form['fiscalyear_id'])])

if period_ids:
self.cr.execute("SELECT MIN(date_start) AS date_start, MAX(date_stop) AS date_stop FROM account_period WHERE id = ANY(%s)", (period_ids,))
dates = self.cr.dictfetchall()
else:
dates = False
if dates:
if form['tri']==False :
query = "SELECT ai.partner_id as partner, SUM(aml.credit-aml.debit) as ht FROM account_invoice ai, account_move am,account_move_line aml, account_account aa where ai.state IN ('open','paid') "\
"AND ai.date_invoice >= '%s' AND ai.date_invoice <= '%s' AND ai.move_id=aml.move_id "\
"AND ai.move_id=am.id AND aml.account_id=aa.id AND aa.code like '%s' AND aa.code not like '%s' "\
"AND ai.type like '%s' GROUP BY partner" % (dates[0]['date_start'], dates[0]['date_stop'],'70%','706%','out_%')
else:
query = "SELECT ai.partner_id as partner,p.name as nom, SUM(aml.credit-aml.debit) as ht FROM account_invoice ai, account_move am,account_move_line aml, account_account aa, res_partner p where ai.state IN ('open','paid') "\
"AND ai.date_invoice >= '%s' AND ai.date_invoice <= '%s' AND ai.move_id=aml.move_id AND p.id=ai.partner_id "\
"AND ai.move_id=am.id AND aml.account_id=aa.id AND aa.code like '%s' AND aa.code not like '%s' "\
"AND ai.type like '%s' GROUP BY partner,nom ORDER BY nom" % (dates[0]['date_start'], dates[0]['date_stop'],'70%','706%','out_%')
# raise Warning(query)
# query = "SELECT ai.partner_id as partner, SUM(ai.amount_untaxed) as ht, SUM(ai.amount_tax) as tax ," \
# "CASE " \
# "WHEN type = 'out_refund' THEN SUM(ai.amount_untaxed) * -1 " \
# "WHEN type = 'out_invoice' THEN SUM(ai.amount_untaxed) " \
# "END ht," \
# "CASE " \
# "WHEN type = 'out_refund' THEN SUM(ai.amount_tax) * -1 " \
# "WHEN type = 'out_invoice' THEN SUM(ai.amount_tax) " \
# "END tax" \
# " FROM account_invoice ai WHERE ai.state IN ('open','paid') AND ai.date_invoice >= '%s' AND ai.date_invoice <= '%s'" \
# " AND ai.type like '%s' GROUP BY partner,ai.type ORDER BY partner" % (dates[0]['date_start'], dates[0]['date_stop'],'out_%')
# query3="SELECT ai.partner_id as partner, SUM(aml.debit) as ht FROM account_invoice ai,"\
# "account_move am,account_move_line aml, account_account aa where ai.state IN ('open','paid') "\
# "AND ai.date_invoice >= '2017-01-01' AND ai.move_id=aml.move_id "\
# "AND ai.move_id=am.id AND aml.account_id=aa.id GROUP BY partner"
res=[]
self.cr.execute(query)
datas = self.cr.dictfetchall()
obj_partner=self.pool.get('res.partner')
ref = ''
tht = ttax = 0.0
for dd in datas:
if dd['ht']==0.0:
continue
query="SELECT ai.partner_id as partner, SUM(aml.credit-aml.debit) as tax FROM account_invoice ai, account_move am,account_move_line aml, account_account aa where ai.state IN ('open','paid') "\
"AND ai.date_invoice >= '%s' AND ai.date_invoice <= '%s' and ai.move_id=aml.move_id "\
"and ai.move_id=am.id and aml.account_id=aa.id and aa.code = '445700' "\
"AND ai.type like '%s' AND ai.partner_id= '%s' GROUP BY partner" % (dates[0]['date_start'], dates[0]['date_stop'],'out_%',dd['partner'])
# raise Warning(query)
self.cr.execute(query)
datas2=self.cr.dictfetchall()
tax=0.0
# raise Warning(query)
for i in datas2:
tax=i['tax']
# raise Warning(query)
ttax+=tax
partner = obj_partner.read(self.cr, self.uid, dd['partner'], [])
ref = partner['name']
if form['reference'] == True:
if partner['ref'] :
ref= '[' + partner['ref'] + '] ' + partner['name']
else:
ref = partner['name']
p1=partner['street'] and partner['street'] or ''
p2=partner['city'] and partner['city'] or ''
rue = p1 +' '+ p2
tht += dd['ht']
nbr += 1
dicts={
'nbr': nbr,
'art' : partner['ai'],
'rc' : partner['rc'],
'nif' : partner['nif'],
'name': ref[0:20],
'rue' : rue[0:27],
'ht' : dd['ht'],
'tax' : tax,
'tht': tht,
'ttax': ttax
}
res.append(dicts)





# if len(data) > 0 :
# for dd in data:
# partner = obj_partner.read(self.cr, self.uid, dd['partner'], [])
# ref = partner['name']
# if form['reference'] == True:
# if partner['ref'] :
# ref= '[' + partner['ref'] + '] ' + partner['name']
# else:
# ref = partner['name']
# p1=partner['street'] and partner['street'] or ''
# p2=partner['city'] and partner['city'] or ''
# rue = p1 +' '+ p2
# tht += dd['ht']
# ttax += dd['tax']
# nbr += 1
# dicts={
# 'nbr': nbr,
# 'art' : partner['ai'],
# 'rc' : partner['rc'],
# 'nif' : partner['nif'],
# 'name': ref[0:20],
# 'rue' : rue[0:27],
# 'ht' : dd['ht'],
# 'tax' : dd['tax'],
# 'tht': tht,
# 'ttax': ttax
# }
# res.append(dicts)
# else:
# dicts={
# 'nbr' : 0,
# 'art' : '',
# 'rc' : '',
# 'nif' : '',
# 'name': '',
# 'rue' : '',
# 'ht' : 0.0,
# 'tax' : 0.0,
# 'tht' : 0.0,
# 'ttax': 0.0

# }
# res.append(dicts)

return res
###############################################################



report_sxw.report_sxw('report.l10n.dz.Etat-104', 'account.move.line', 'addons/l10n_dz_report/report/rmls/etat104.rml', parser=etat104, header=False)


# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:



0
Avatar
Discard
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
Invoice Report Multiple Journal Line Print Error Solved
print report odooV8
Avatar
Avatar
Avatar
3
Feb 19
4526
report attribute explanation (in print a report context)
print attributes odooV8
Avatar
0
May 17
8061
Multiple report on one button click
qweb print report odooV8
Avatar
Avatar
Avatar
Avatar
6
Jan 20
8873
Decimal view for Float odoo v8
decimal precision float odooV8
Avatar
0
Aug 17
4557
Is it possible to make a text-only report?
print reporting report odooV8
Avatar
0
Nov 15
3805
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