Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

how to pass parameters using with_context ?

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
pythonodoo10
3 Risposte
22444 Visualizzazioni
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
Abbandona
Niyas Raphy (Walnut Software Solutions)

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

Shaffaf
Autore

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

Avatar
Sehrish
Risposta migliore

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
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
error ConfigParser.ParsingError: File contains parsing errors
python odoo10
Avatar
0
mar 21
7749
odoo/python invalidate_all() Risolto
python odoo10
Avatar
Avatar
Avatar
2
gen 19
8412
Function Python for Odoo 10
python odoo10
Avatar
Avatar
1
dic 18
3870
calculate expiration date from production date and duration
python odoo10
Avatar
Avatar
1
lug 18
8291
odoo10 error,i can't submit helpdesk ticket Ask Question in our own server
python odoo10
Avatar
Avatar
1
apr 18
4784
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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