Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

add custom function to _get_report_value

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
functionpythonvaluesreporting
2 Replies
10935 Rodiniai
Portretas
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
Portretas
Atmesti
Portretas
Cybrosys Techno Solutions Pvt.Ltd
Best Answer
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
Portretas
Atmesti
Portretas
BOUDEKAK MOHAMED
Autorius Best Answer

Thank you very much, great help thanks

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

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

Registracija
Related Posts Replies Rodiniai Veikla
How to call a function defined in python in a mako file?
function python reporting mako openerp7
Portretas
Portretas
3
rugp. 15
6638
OpenERP fields.function() explanation
function python xml
Portretas
1
gruod. 22
45921
Generate report from Python by given user and data range
python reporting odooV8
Portretas
Portretas
1
geg. 20
7054
Call a function on print menu option instead of qweb template Solved
function reporting odoo12.0
Portretas
Portretas
Portretas
3
gruod. 19
8219
Selection "report value" can not be set in accounting reports
accounting values reporting
Portretas
0
vas. 17
3194
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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