Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

How to override the get_lines method of the report_account_common class?

Odebírat

Get notified when there's activity on this post

This question has been flagged
override
1 Odpovědět
5594 Zobrazení
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šit
Avatar
Pascal Tremblay
Autor Nejlepší odpověď

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šit
Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Create function problem Vyřešeno
override
Avatar
Avatar
2
čvn 23
2938
Overriding method in a model Vyřešeno
override
Avatar
Avatar
1
čvn 20
36121
How to override method 'create' on the non-inherited model
override
Avatar
Avatar
1
lis 17
3957
I overrote a method and it was not called
override
Avatar
Avatar
Avatar
2
srp 15
6139
How i can override the activity js file in odoo 14?
javascript override
Avatar
Avatar
1
srp 23
3777
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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