Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Can I have values of a function field in graph?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
1 Respondre
4648 Vistes
Avatar
Kuldeep Jadeja

I have a function field 'balance' for a Report named BalanceSheet and all other accounts which lie under it,and also for other type of reports.

 

The field 'balance' is not store(because we are doing a dynamic calculation, balance and total fields are not stored anywhere in the database)

 

So, is it possible to get the value of above mentioned field in Graph?

0
Avatar
Descartar
Avatar
Deepa Venkatesh
Best Answer

Yes it is possible... you can use it...

1
Avatar
Descartar
Kuldeep Jadeja
Autor

I am unable to get the value in the graph, can you explain how it is done?

Kuldeep Jadeja
Autor

My file merlin_account_report.py ============================== class merlin_account_financial_report(osv.osv): _name = "merlin.account.financial.report" _description = "Merlin Account Report" def _get_total(self, cr, uid, ids, context=None): for i in ids: #get the id of the current function of the employee of identifier "i" sql_req= """ SELECT f.id AS func_id FROM merlin.account.financial.report c LEFT JOIN res_partner_function f ON (f.id = c.function) WHERE (c.parent_id = %d) """ % (i,) cr.execute(sql_req) sql_res = cr.dictfetchone() if sql_res: #The employee has one associated contract res[i] = sql_res['func_id'] else: #res[i] must be set to False and not to None because of XML:RPC # "cannot marshal None unless allow_none is enabled" res[i] = False return res def _get_level(self, cr, uid, ids, field_name, arg, context=None): '''Returns a dictionary with key=the ID of a record and value = the level of this record in the tree structure.''' res = {} for report in self.browse(cr, uid, ids, context=context): level = 0 if report.parent_id: level = report.parent_id.level + 1 res[report.id] = level return res def _get_children_by_order(self, cr, uid, ids, context=None): '''returns a dictionary with the key= the ID of a record and value = all its children, computed recursively, and sorted by sequence. Ready for the printing''' res = [] for id in ids: res.append(id) ids2 = self.search(cr, uid, [('parent_id', '=', id)], order='sequence ASC', context=context) res += self._get_children_by_order(cr, uid, ids2, context=context) return res def _get_balance(self, cr, uid, ids, field_names, args, context=None): '''returns a dictionary with key=the ID of a record and value=the balance amount computed for this record. If the record is of type : 'accounts' : it's the sum of the linked accounts 'account_type' : it's the sum of leaf accoutns with such an account_type 'account_report' : it's the amount of the related report 'sum' : it's the sum of the children of this record (aka a 'view' record)''' account_obj = self.pool.get('account.account') res = {} for report in self.browse(cr, uid, ids, context=context): if report.id in res: continue res[report.id] = dict((fn, 0.0) for fn in field_names) if report.type == 'accounts': # it's the sum of the linked accounts for a in report.account_ids: for field in field_names: res[report.id][field] += getattr(a, field) elif report.type == 'account_type': # it's the sum the leaf accounts with such an account type report_types = [x.id for x in report.account_type_ids] account_ids = account_obj.search(cr, uid, [('user_type','in', report_types), ('type','!=','view')], context=context) for a in account_obj.browse(cr, uid, account_ids, context=context): for field in field_names: res[report.id][field] += getattr(a, field) elif report.type == 'code': try: dic = {} list1 = re.findall('[a-zA-Z]+' , report.amount_python_compute) myobj = self.pool.get('merlin.account.financial.report') ids3 = myobj.search(cr, uid, [('code','in',list1)]) res2 = self._get_balance(cr, uid, ids3, field_names, False, context=context) for val in res2: dic[myobj.browse(cr,uid,val).code] = res2[val]['balance'] cal_bal = eval(report.amount_python_compute) res[report.id]['balance'] = cal_bal except: raise osv.except_osv(_('Error!'), _('Wrong python condition defined for financial Statement %s (%s).')% (report.name, report.code)) elif report.type == 'account_report' and report.account_report_id: # it's the amount of the linked report res2 = self._get_balance(cr, uid, [report.account_report_id.id], field_names, False, context=context) for key, value in res2.items(): for field in field_names: res[report.id][field] += value[field] elif report.type == 'sum': # it's the sum of the children of this account.report res2 = self._get_balance(cr, uid, [rec.id for rec in report.children_ids], field_names, False, context=context) for key, value in res2.items(): for field in field_names: res[report.id][field] += value[field] return res _columns = { 'name': fields.char('Report Name', size=128, required=True, translate=True), 'parent_id': fields.many2one('merlin.account.financial.report', 'Parent'), 'children_ids': fields.one2many('merlin.account.financial.report', 'parent_id', 'Account Report'), 'sequence': fields.integer('Sequence'), 'balance': fields.function(_get_balance, 'Balance', multi='balance'), 'debit': fields.function(_get_balance, 'Debit', multi='balance'), 'credit': fields.function(_get_balance, 'Credit', multi="balance"), 'cmp_balance' :fields.float('Compare Balance'), 'level': fields.function(_get_level, string='Level', store=True, type='integer'), 'type': fields.selection([ ('sum','View'), ('accounts','Accounts'), ('account_type','Account Type'), ('account_report','Report Value'), ('code','Python Code') ],'Type'), 'account_ids': fields.many2many('account.account', 'account_account_financial_report', 'report_line_id', 'account_id', 'Accounts'), 'account_report_id': fields.many2one('merlin.account.financial.report', 'Report Value'), 'account_type_ids': fields.many2many('account.account.type', 'account_account_financial_report_type', 'report_id', 'account_type_id', 'Account Types'), 'amount_python_compute':fields.text('Python Code'), 'code':fields.char('Code', size=64, required=True ,help="The code of financial statement can be used as reference in computation of other rules. In that case, it is case sensitive."), 'total':fields.boolean('Total'), 'sign': fields.selection([(-1, 'Reverse balance sign'), (1, 'Preserve balance sign')], 'Sign on Reports', required=True, help='For accounts that are typically more debited than credited and that you would like to print as negative amounts in your reports, you should reverse the sign of the balance; e.g.: Expense account. The same applies for accounts that are typically more credited than debited and that you would like to print as positive amounts in your reports; e.g.: Income account.'), } _defaults = { 'type': 'sum', 'sign': 1, } merlin_account_financial_report() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: ---------------------------------------------------------------------------------------------------------- XML file =========== merlin.account.financial.report.form merlin.account.financial.report merlin.account.financial.report.tree merlin.account.financial.report merlin.account.financial.report.search merlin.account.financial.report Financial Reports ir.actions.act_window merlin.account.financial.report form tree,form merlin.account.financial.report.search merlin.account.financial.report merlin.account.report.hierarchy merlin.account.financial.report children_ids merlin.account.financial.report.graph merlin.account.financial.report graph Financial Reports Hierarchy merlin.account.financial.report tree tree,form,graph [('parent_id','=',False)] ------------------------------------------------------------------------------------ What changes are required to get the graph display the BAR chart representaion of fields 'balance' and 'total' ?

Kuldeep Jadeja
Autor

WHOA , I am sorry for above code, I didn't know it just pastes the text like this if I copy from my module, It's the 1st time you know as I'm a Beginner cum Learner of OpenERP as well as this form(Odoo). Can you just explain how can i display the 'balance' and 'total' fields in the Graph?

Deepa Venkatesh

sure, functional field can be added just like any other field... and also it will be shown in measures.... you can refer Invoice Analysis... in that functional fields are used....

Kuldeep Jadeja
Autor

Okay I am going to refer Invoice Analysis, but maybe I've looked it up and in it, function fields are defined with property(parameter) STORE=TRUE, which means it is being stored somewhere in the database. In my case, we don't store 'balance' field, that's why it makes it to display in graph a TOUGH NUT TO CRACK. ANy more suggestions...!

Deepa Venkatesh

Hmmmm... No idea which report you had check... Do check "account.invoice.report".. "user_currency_price_total" is a functional field which is not saved to db...

Kuldeep Jadeja
Autor

above said field is not used in Graph in the said module, so not useful for me though.

Kuldeep Jadeja
Autor

thanks for sharing related knowledge with a view to help.

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

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

Registrar-se
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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