Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • 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 Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and 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
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Help

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How to override the get_lines method of the report_account_common class?

Odoberať

Get notified when there's activity on this post

This question has been flagged
override
1 Odpoveď
5609 Zobrazenia
Avatar
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
Avatar
Zrušiť
Avatar
Pascal Tremblay
Autor 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
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Create function problem Solved
override
Avatar
Avatar
2
jún 23
2944
Overriding method in a model Solved
override
Avatar
Avatar
1
jún 20
36150
How to override method 'create' on the non-inherited model
override
Avatar
Avatar
1
nov 17
3977
I overrote a method and it was not called
override
Avatar
Avatar
Avatar
2
aug 15
6159
How i can override the activity js file in odoo 14?
javascript override
Avatar
Avatar
1
aug 23
3784
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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