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
    Real Estate
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Consulting
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • 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

How to override the get_lines method of the report_account_common class?

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
override
1 Atsakyti
5560 Rodiniai
Portretas
Pascal Tremblay

Hello there,

I'm trying to override the get_lines method of the report_account_common class.

It is really not easy to override this method.

What is the trick?


For the moment, I have this code in my custom module. I get no error, but override do nothing.

from openerp.addons.account.report.account_financial_report import report_account_common

class report_account_common_pt(report_account_common):

def __init__(self, cr, uid, name, context):

super(report_account_common_pt, self).__init__(cr, uid, name, context=context)

self.localcontext.update({

'report': 'report_account_common_pt',

})

def get_lines(self, data):

lines = []

account_obj = self.pool.get('account.account')

currency_obj = self.pool.get('res.currency')

ids2 = self.pool.get('account.financial.report')._get_children_by_order(self.cr, self.uid, [data['form']['account_report_id'][0]], context=data['form']['used_context'])

for report in self.pool.get('account.financial.report').browse(self.cr, self.uid, ids2, context=data['form']['used_context']):

vals = {

'name': report.name,

'balance': report.balance * report.sign or 0.0,

'type': 'report',

'level': bool(report.style_overwrite) and report.style_overwrite or report.level,

'account_type': report.type =='sum' and 'view' or False, #used to underline the financial report balances

}

if data['form']['debit_credit']:

vals['debit'] = report.debit

vals['credit'] = report.credit

if data['form']['enable_filter']:

vals['balance_cmp'] = self.pool.get('account.financial.report').browse(self.cr, self.uid, report.id, context=data['form']['comparison_context']).balance * report.sign or 0.0

lines.append(vals)

account_ids = []

if report.display_detail == 'no_detail':

#the rest of the loop is used to display the details of the financial report, so it's not needed here.

continue

if report.type == 'accounts' and report.account_ids:

account_ids = account_obj._get_children_and_consol(self.cr, self.uid, [x.id for x in report.account_ids])

elif report.type == 'account_type' and report.account_type_ids:

account_ids = account_obj.search(self.cr, self.uid, [('user_type','in', [x.id for x in report.account_type_ids])], order='code')

if account_ids:

for account in account_obj.browse(self.cr, self.uid, account_ids, context=data['form']['used_context']):

#if there are accounts to display, we add them to the lines with a level equals to their level in

#the COA + 1 (to avoid having them with a too low level that would conflicts with the level of data

#financial reports for Assets, liabilities...)

if report.display_detail == 'detail_flat' and account.type == 'view':

continue

flag = False

vals = {

'name': account.code + ' ' + account.name,

'balance': account.balance != 0 and account.balance * report.sign or account.balance,

'type': 'account',

'level': report.display_detail == 'detail_with_hierarchy' and min(account.level + 1,6) or 6, #account.level + 1

'account_type': account.type,

}

if data['form']['debit_credit']:

vals['debit'] = account.debit

vals['credit'] = account.credit

if not currency_obj.is_zero(self.cr, self.uid, account.company_id.currency_id, vals['balance']):

flag = True

if data['form']['enable_filter']:

vals['balance_cmp'] = account_obj.browse(self.cr, self.uid, account.id, context=data['form']['comparison_context']).balance * report.sign or 0.0

if not currency_obj.is_zero(self.cr, self.uid, account.company_id.currency_id, vals['balance_cmp']):

flag = True

if flag:

lines.append(vals)

return lines

class report_financial_pt(osv.AbstractModel):

_name = 'report.report_lapagept.report_financial_pt'

_inherit = 'report.abstract_report'

_template = 'account.report_financial'

_wrapped_report_class = report_account_common_pt



0
Portretas
Atmesti
Portretas
Pascal Tremblay
Autorius Best Answer

Oh yeah! I got it!


from openerp.addons.account.report.account_financial_report import report_account_common

class report_account_common_pt(report_account_common):

def __init__(self, cr, uid, name, context):

super(report_account_common_pt, self).__init__(cr, uid, name, context=context)

self.localcontext.update({

'report': 'report_account_common_pt',

})

def get_lines(self, data):

lines = []

account_obj = self.pool.get('account.account')

currency_obj = self.pool.get('res.currency')

ids2 = self.pool.get('account.financial.report')._get_children_by_order(self.cr, self.uid, [data['form']['account_report_id'][0]], context=data['form']['used_context'])

for report in self.pool.get('account.financial.report').browse(self.cr, self.uid, ids2, context=data['form']['used_context']):

vals = {

'name': report.name,

'balance': report.balance * report.sign or 0.0,

'type': 'report',

'level': bool(report.style_overwrite) and report.style_overwrite or report.level,

'account_type': report.type =='sum' and 'view' or False, #used to underline the financial report balances

}

if data['form']['debit_credit']:

vals['debit'] = report.debit

vals['credit'] = report.credit

if data['form']['enable_filter']:

vals['balance_cmp'] = self.pool.get('account.financial.report').browse(self.cr, self.uid, report.id, context=data['form']['comparison_context']).balance * report.sign or 0.0

lines.append(vals)

account_ids = []

if report.display_detail == 'no_detail':

#the rest of the loop is used to display the details of the financial report, so it's not needed here.

continue

if report.type == 'accounts' and report.account_ids:

account_ids = account_obj._get_children_and_consol(self.cr, self.uid, [x.id for x in report.account_ids])

elif report.type == 'account_type' and report.account_type_ids:

account_ids = account_obj.search(self.cr, self.uid, [('user_type','in', [x.id for x in report.account_type_ids])], order='code')

if account_ids:

for account in account_obj.browse(self.cr, self.uid, account_ids, context=data['form']['used_context']):

#if there are accounts to display, we add them to the lines with a level equals to their level in

#the COA + 1 (to avoid having them with a too low level that would conflicts with the level of data

#financial reports for Assets, liabilities...)

if report.display_detail == 'detail_flat' and account.type == 'view':

continue

flag = False

vals = {

'name': account.code + ' ' + account.name,

'balance': account.balance != 0 and account.balance * report.sign or account.balance,

'type': 'account',

'level': report.display_detail == 'detail_with_hierarchy' and min(account.level + 1,6) or 6, #account.level + 1

'account_type': account.type,

}

if data['form']['debit_credit']:

vals['debit'] = account.debit

vals['credit'] = account.credit

if not currency_obj.is_zero(self.cr, self.uid, account.company_id.currency_id, vals['balance']):

flag = True

if data['form']['enable_filter']:

vals['balance_cmp'] = account_obj.browse(self.cr, self.uid, account.id, context=data['form']['comparison_context']).balance * report.sign or 0.0

if not currency_obj.is_zero(self.cr, self.uid, account.company_id.currency_id, vals['balance_cmp']):

flag = True

if flag:

lines.append(vals)

return lines

class report_financial_pt(osv.AbstractModel):

_name = 'report.account.report_financial'

_inherit = 'report.abstract_report'

_template = 'account.report_financial'

_wrapped_report_class = report_account_common_pt

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
Create function problem Solved
override
Portretas
Portretas
2
birž. 23
2925
Overriding method in a model Solved
override
Portretas
Portretas
1
birž. 20
36103
How to override method 'create' on the non-inherited model
override
Portretas
Portretas
1
lapkr. 17
3931
I overrote a method and it was not called
override
Portretas
Portretas
Portretas
2
rugp. 15
6119
How i can override the activity js file in odoo 14?
javascript override
Portretas
Portretas
1
rugp. 23
3760
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