Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

add custom function to _get_report_value

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
functionpythonvaluesreporting
2 Răspunsuri
10945 Vizualizări
Imagine profil
BOUDEKAK MOHAMED

Amm using odoo 12 and have a custom python function that have one parametre and i want to call it in my report using _get_report_value,  here is my model 



from odoo import  models,api

class ReportInvoiceWithoutPayment(models.AbstractModel):
_name = 'report.account.report_invoice'
_description = 'Account report without payment lines'

def chiffreen(self, num):

muz = (' ', 'Onze', 'Douze', 'Treize',
'Quatorze', 'Quinze', 'Seize', 'Dix-Sept', 'Dix-Huit', 'Dix-Neuf')

to_19_fr = ('Zéro', 'Un', 'Deux', 'Trois', 'Quatre', 'Cinq', 'Six',
'Sept', 'Huit', 'Neuf', 'Dix', 'Onze', 'Douze', 'Treize',
'Quatorze', 'Quinze', 'Seize', 'Dix-Sept', 'Dix-Huit', 'Dix-Neuf')
tens_fr = (
'Vingt', 'Trente', 'Quarante', 'Cinquante', 'Soixante', 'Soixante-Dix', 'Quatre-Vingt', 'Quatre-Vingt Dix')
denom_fr = ('',
'Mille', 'Million(s)', 'Milliards', 'Billions', 'Quadrillions',
'Quintillion', 'Sextillion', 'Septillion', 'Octillion', 'Nonillion',
'Décillion', 'Undecillion', 'Duodecillion', 'Tredecillion', 'Quattuordecillion',
'Sexdecillion', 'Septendecillion', 'Octodecillion', 'Icosillion', 'Vigintillion')

def _convert_nn_fr(val):
""" convertion des valeurs < 100 en Français
"""
if val < 20:
return to_19_fr[val]
for (dcap, dval) in ((k, 20 + (10 * v)) for (v, k) in enumerate(tens_fr)):
if dval + 10 > val:
if val % 10:
if (val > 70 and val <= 79):
dcap = 'Soixante'
return dcap + '-' + muz[val % 10]

if (val > 90 and val <= 99):
dcap = 'Quatre-vingt'
return dcap + '-' + muz[val % 10]
else:
return dcap + '-' + to_19_fr[val % 10]

return dcap

def _convert_nnn_fr(val):
""" convert a value < 1000 to french

special cased because it is the level that kicks
off the < 100 special case. The rest are more general. This also allows you to
get strings in the form of 'forty-five hundred' if called directly.
"""
word = ''
(mod, rem) = (val % 100, val // 100)
b = val // 100
if rem > 0:
if b == 1:
word = 'Cent'
else:
word = to_19_fr[rem] + ' Cent'
if mod > 0:
word += ' '
if mod > 0:
word += _convert_nn_fr(mod)
return word

def french_number(val):
if val < 100:
return _convert_nn_fr(val)
if val < 1000:
return _convert_nnn_fr(val)
for (didx, dval) in ((v - 1, 1000 ** v) for v in range(len(denom_fr))):
if dval > val:
mod = 1000 ** didx
l = val // mod
r = val - (l * mod)
if (l == 1) and (denom_fr[didx] == 'Mille'):
ret = denom_fr[didx]
else:
ret = _convert_nnn_fr(l) + ' ' + denom_fr[didx]
if r > 0:
ret = ret + ' ' + french_number(r)
return ret

def amount_to_text_fr(number):
import math
number = '%.2f' % number
units_name = ' '
list = str(number).split('.')
muzamil = (french_number(abs(int(list[0]))))
start_word = muzamil
end_word = ''
# french_number(int(list[1]))
cents_number = int(list[1])
cents_name = (cents_number > 1) and ' Francs' or ' Franc'
final_result = start_word + ' ' + units_name + ' ' + end_word + ' ' + cents_name
return final_result

def IntOuDouble(num):
double = True if type(num) == float else False
if double == True:
number = str(num)
premier = number.split('.')[0]
deuxieme = number.split('.')[1]
# print(premier)
# print(deuxieme)
premier = amount_to_text_fr(int(premier))
deuxieme = amount_to_text_fr(int(deuxieme))
premier = premier[:len(premier) - 6]
deuxieme = deuxieme[:len(deuxieme) - 6] + 'Dinare Algerien'
# print(premier)
# print(deuxieme)
if deuxieme == 'Zéro Dinare Algerien':
res = premier + 'Dinare Algerien'
else:
res = premier + 'virgule ' + deuxieme
resultat = ''
for rec in res.split():
resultat = resultat + ' ' + rec
res = resultat
return res
else:
return amount_to_text_fr(num)

return IntOuDouble(num)

@api.model
def _get_report_values(self, docids, data=None):
docs=self.env['account.invoice'].browse(docids)
return {
'doc_ids': docids,
'doc_model': 'account.invoice',
'docs':docs ,
'chiffreen':self.chiffreen(docs.amount_total),
'report_type': data.get('report_type') if data else '',

}
1
Imagine profil
Abandonează
Imagine profil
Cybrosys Techno Solutions Pvt.Ltd
Cel mai bun răspuns
Hi,
If you want to call a python function with parameters, you can try this way.
return {
'doc_ids': docids,
'doc_model': 'account.invoice',
'docs':docs ,
'chiffreen':self.chiffreen,
'report_type': data.get('report_type') if data else '', }
then the function call from the template.
<t t-set="chiffreen"
t-value="chiffreen(docs.amount_total)"/>
now you will get the return value of the function in chiffreen. you can use the variable in your reports.
regards,
5
Imagine profil
Abandonează
Imagine profil
BOUDEKAK MOHAMED
Autor Cel mai bun răspuns

Thank you very much, great help thanks

0
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
How to call a function defined in python in a mako file?
function python reporting mako openerp7
Imagine profil
Imagine profil
3
aug. 15
6640
OpenERP fields.function() explanation
function python xml
Imagine profil
1
dec. 22
45926
Generate report from Python by given user and data range
python reporting odooV8
Imagine profil
Imagine profil
1
mai 20
7059
Call a function on print menu option instead of qweb template Rezolvat
function reporting odoo12.0
Imagine profil
Imagine profil
Imagine profil
3
dec. 19
8226
Selection "report value" can not be set in accounting reports
accounting values reporting
Imagine profil
0
feb. 17
3198
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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