Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

how to pass parameters using with_context ?

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
pythonodoo10
3 Antworten
22455 Ansichten
Avatar
Shaffaf

I have a print_excel method which is used to create an excel file for general ledger. I have generated all the data but there is some issue while passing data into the query. I couldn't fix the bug please someone helps me out.


account_report_general_ledger.py

def print_excel(self):

filename= 'GeneralLedger.xls'

ctx = self.env.context

data = self.get_data_for_xls()

sortby = data['form']['sortby']

init_balance = data['form']['initial_balance']

date_from = data['form']['date_from']

date_to = data['form']['date_to']

od_move_lines = self.get_move_line_ids()

od_move_lines = self.env['account.move.line'].browse(od_move_lines)

search_cond = ''' '''

if od_move_lines:

search_cond = search_cond + ''' and l.id in %s '''

if data['form'].get('journal_ids', False):

codes = [journal.code for journal in self.env['account.journal'].search([('id', 'in', data['form']['journal_ids'])])]

self.model = self.env.context.get('active_model')

accounts = self.env['account.account'].browse(ctx.get('active_id')) if self.model == 'account.account' else self.env['account.account'].search([])

display_account = data['form']['display_account']

ctx = {'dt_cont':{'date_from':date_from,'date_to':date_to}}

movelines = self.env['report.account.report_generalledger'].with_context(ctx)._get_account_move_entry( accounts, init_balance, sortby, display_account,od_move_lines,search_cond) ##ISSUE

account_general_ledger.py

def _get_account_move_entry(self, accounts, init_balance, sortby, display_account,od_move_lines,search_cond):

"""

:param:

accounts: the recordset of accounts

init_balance: boolean value of initial_balance

sortby: sorting by date or partner and journal

display_account: type of account(receivable, payable and both)

Returns a dictionary of accounts with following key and value {

'code': account code,

'name': account name,

'debit': sum of total debit amount,

'credit': sum of total credit amount,

'balance': total balance,

'amount_currency': sum of amount_currency,

'move_lines': list of move line

}

"""

cr = self.env.cr

context=self.env.context

MoveLine = self.env['account.move.line']

move_lines = dict(map(lambda x: (x, []), accounts.ids))

# Prepare initial sql query and Get the initial move lines

if init_balance:

init_tables, init_where_clause, init_where_params = MoveLine.with_context(date_from=self.env.context.get('date_from'), date_to=False, initial_bal=True)._query_get()

init_wheres = [""]

if init_where_clause.strip():

init_wheres.append(init_where_clause.strip())

init_filters = " AND ".join(init_wheres)

filters = init_filters.replace('account_move_line__move_id', 'm').replace('account_move_line', 'l')

sql = ("""SELECT 0 AS lid, cc.name AS cost_center, l.account_id AS account_id, '' AS ldate, '' AS lcode, NULL AS amount_currency, '' AS lref, 'Initial Balance' AS lname, COALESCE(SUM(l.debit),0.0) AS debit, COALESCE(SUM(l.credit),0.0) AS credit, COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance, '' AS lpartner_id,\

'' AS move_name, '' AS mmove_id, '' AS currency_code,\

NULL AS currency_id,\

'' AS invoice_id, '' AS invoice_type, '' AS invoice_number,\

'' AS partner_name\

FROM account_move_line l\

LEFT JOIN account_move m ON (l.move_id=m.id)\

LEFT JOIN orchid_account_cost_center cc ON (l.orchid_cc_id=cc.id)\

LEFT JOIN res_currency c ON (l.currency_id=c.id)\

LEFT JOIN res_partner p ON (l.partner_id=p.id)\

LEFT JOIN account_invoice i ON (m.id =i.move_id)\

JOIN account_journal j ON (l.journal_id=j.id)\

WHERE l.account_id IN %s """ + search_cond + filters + ' GROUP BY l.account_id,l.partner_id,cc.name')

params = ()

print "where params>>>>>>>>>>>>>>>>>>>>>>>",init_where_params #####NO VALUES

if od_move_lines:

params = (tuple(accounts.ids),tuple(od_move_lines.ids),) + tuple(init_where_params)

else:

params = (tuple(accounts.ids),) + tuple(init_where_params)

cr.execute(sql, params)

for row in cr.dictfetchall():

if move_lines[row['account_id']]:

move_lines[row['account_id']][0]['credit'] = move_lines[row['account_id']][0]['credit'] + row['credit']

move_lines[row['account_id']][0]['debit'] = move_lines[row['account_id']][0]['debit'] + row['debit']

move_lines[row['account_id']][0]['balance'] = move_lines[row['account_id']][0]['balance'] + row['balance']

else:

move_lines[row.pop('account_id')].append(row)

sql_sort = 'l.date, l.move_id'

if sortby == 'sort_journal_partner':

sql_sort = 'j.code, p.name, l.move_id'


 

0
Avatar
Verwerfen
Niyas Raphy (Walnut Software Solutions)

I think it will be better if you can post the issue / error message along with the question

Shaffaf
Autor

There was no error and the issue was i am getting 2 different initial balance values in pdf and excel.

Avatar
Sehrish
Beste Antwort

I don't know what you are looking for but try this may be its helpful to you.

return self.with_context({'signal':'call_from_desination', 'current_object':self})

0
Avatar
Verwerfen
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
error ConfigParser.ParsingError: File contains parsing errors
python odoo10
Avatar
0
März 21
7751
odoo/python invalidate_all() Gelöst
python odoo10
Avatar
Avatar
Avatar
2
Jan. 19
8413
Function Python for Odoo 10
python odoo10
Avatar
Avatar
1
Dez. 18
3875
calculate expiration date from production date and duration
python odoo10
Avatar
Avatar
1
Juli 18
8292
odoo10 error,i can't submit helpdesk ticket Ask Question in our own server
python odoo10
Avatar
Avatar
1
Apr. 18
4787
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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