diff --git a/addons/account/account.py b/addons/account/account.py index 3772a660de9..ddb90cc13cc 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -201,20 +201,19 @@ class account_account(osv.osv): } #get all the necessary accounts ids2 = self._get_children_and_consol(cr, uid, ids, context) - acc_set = ",".join(map(str, ids2)) #compute for each account the balance/debit/credit from the move lines accounts = {} if ids2: query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) - cr.execute(("SELECT l.account_id as id, " +\ + cr.execute("SELECT l.account_id as id, " +\ ' , '.join(map(lambda x: mapping[x], field_names)) + "FROM " \ "account_move_line l " \ "WHERE " \ - "l.account_id IN (%s) " \ + "l.account_id =ANY(%s) " \ "AND " + query + " " \ - "GROUP BY l.account_id") % (acc_set, )) + "GROUP BY l.account_id",(ids2,)) for res in cr.dictfetchall(): accounts[res['id']] = res @@ -334,7 +333,7 @@ class account_account(osv.osv): if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)): return False while(ids): - cr.execute('select distinct child_id from account_account_consol_rel where parent_id in ('+','.join(map(str, ids))+')') + cr.execute('select distinct child_id from account_account_consol_rel where parent_id =ANY(%s)',(ids,)) child_ids = filter(None, map(lambda x: x[0], cr.fetchall())) c_ids = child_ids if (p_id and (p_id in c_ids)) or (obj_self.id in c_ids): @@ -774,7 +773,7 @@ class account_move(osv.osv): def _amount_compute(self, cr, uid, ids, name, args, context, where =''): if not ids: return {} - cr.execute('select move_id,sum(debit) from account_move_line where move_id in ('+','.join(map(str,map(int, ids)))+') group by move_id') + cr.execute('select move_id,sum(debit) from account_move_line where move_id =ANY(%s) group by move_id',(ids,)) result = dict(cr.fetchall()) for id in ids: result.setdefault(id, 0.0) @@ -872,7 +871,7 @@ class account_move(osv.osv): if new_name: self.write(cr, uid, [move.id], {'name':new_name}) - cr.execute('update account_move set state=%s where id in ('+','.join(map(str, ids))+')', ('posted',)) + cr.execute('update account_move set state=%s where id =ANY(%s) ',('posted',ids,)) else: raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !')) return True @@ -885,7 +884,7 @@ class account_move(osv.osv): if not line.journal_id.update_posted: raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !\nYou should set the journal to allow cancelling entries if you want to do that.')) if len(ids): - cr.execute('update account_move set state=%s where id in ('+','.join(map(str, ids))+')', ('draft',)) + cr.execute('update account_move set state=%s where id =ANY(%s)',('draft',ids,)) return True def write(self, cr, uid, ids, vals, context={}): @@ -1155,23 +1154,22 @@ class account_tax_code(osv.osv): """ def _sum(self, cr, uid, ids, name, args, context, where =''): ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - acc_set = ",".join(map(str, ids2)) if context.get('based_on', 'invoices') == 'payments': cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \ FROM account_move_line AS line, \ account_move AS move \ LEFT JOIN account_invoice invoice ON \ (invoice.move_id = move.id) \ - WHERE line.tax_code_id in ('+acc_set+') '+where+' \ + WHERE line.tax_code_id =ANY(%s) '+where+' \ AND move.id = line.move_id \ AND ((invoice.state = \'paid\') \ OR (invoice.id IS NULL)) \ - GROUP BY line.tax_code_id') + GROUP BY line.tax_code_id',(ids2,)) else: cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \ FROM account_move_line AS line \ - WHERE line.tax_code_id in ('+acc_set+') '+where+' \ - GROUP BY line.tax_code_id') + WHERE line.tax_code_id =ANY(%s) '+where+' \ + GROUP BY line.tax_code_id',(ids2,)) res=dict(cr.fetchall()) for record in self.browse(cr, uid, ids, context): def _rec_get(record): @@ -1246,7 +1244,7 @@ class account_tax_code(osv.osv): def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): - cr.execute('select distinct parent_id from account_tax_code where id in ('+','.join(map(str, ids))+')') + cr.execute('select distinct parent_id from account_tax_code where id =ANY(%s)',(ids,)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False @@ -1858,7 +1856,7 @@ class account_account_template(osv.osv): def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): - cr.execute('select parent_id from account_account_template where id in ('+','.join(map(str, ids))+')') + cr.execute('select parent_id from account_account_template where id =ANY(%s)',(ids,)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False @@ -1978,7 +1976,7 @@ class account_tax_code_template(osv.osv): def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): - cr.execute('select distinct parent_id from account_tax_code_template where id in ('+','.join(map(str, ids))+')') + cr.execute('select distinct parent_id from account_tax_code_template where id =ANY(%s)',(ids,)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 8c3742d7f8d..2034583ed02 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -327,14 +327,14 @@ - + - - - - - + + + + + @@ -349,18 +349,6 @@ {'type':'out_invoice'} - - - Panding Invoice - account.invoice - form - tree,form,calendar,graph - - {'type':'out_invoice'} - [('state','=','draft')] - - - tree @@ -372,7 +360,7 @@ - + Customer Invoices diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 9b126658157..e5e16ee73cc 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -258,7 +258,7 @@ class account_move_line(osv.osv): cursor.execute('SELECT l.id, i.id ' \ 'FROM account_move_line l, account_invoice i ' \ 'WHERE l.move_id = i.move_id ' \ - 'AND l.id in (' + ','.join([str(x) for x in ids]) + ')') + 'AND l.id =ANY(%s)',(ids,)) invoice_ids = [] for line_id, invoice_id in cursor.fetchall(): res[line_id] = invoice_id @@ -553,8 +553,6 @@ class account_move_line(osv.osv): return True def reconcile(self, cr, uid, ids, type='auto', writeoff_acc_id=False, writeoff_period_id=False, writeoff_journal_id=False, context={}): - id_set = ','.join(map(str, ids)) - lines = self.browse(cr, uid, ids, context=context) unrec_lines = filter(lambda x: not x['reconcile_id'], lines) credit = debit = 0.0 @@ -579,10 +577,10 @@ class account_move_line(osv.osv): cr.execute('SELECT account_id, reconcile_id \ FROM account_move_line \ - WHERE id IN ('+id_set+') \ - GROUP BY account_id,reconcile_id') + WHERE id =ANY(%s) \ + GROUP BY account_id,reconcile_id',(ids,)) r = cr.fetchall() -#TODO: move this check to a constraint in the account_move_reconcile object + #TODO: move this check to a constraint in the account_move_reconcile object if (len(r) != 1) and not context.get('fy_closing', False): raise osv.except_osv(_('Error'), _('Entries are not of the same account or already reconciled ! ')) if not unrec_lines: diff --git a/addons/account/i18n/hu.po b/addons/account/i18n/hu.po index 629d46d10c3..21fbe4cf06d 100644 --- a/addons/account/i18n/hu.po +++ b/addons/account/i18n/hu.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 5.0.0\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-01-22 23:52+0000\n" -"Last-Translator: Balint (eSolve) \n" +"PO-Revision-Date: 2010-01-30 16:38+0000\n" +"Last-Translator: Dukai Gábor \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-01-24 04:50+0000\n" +"X-Launchpad-Export-Date: 2010-01-31 04:51+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account @@ -910,7 +910,7 @@ msgstr "" #. module: account #: wizard_field:account.open_closed_fiscalyear,init,fyear_id:0 msgid "Fiscal Year to Open" -msgstr "" +msgstr "Visszanyitandó üzleti év" #. module: account #: view:account.config.wizard:0 @@ -981,7 +981,7 @@ msgstr "" #: wizard_field:account.print.journal.report,init,period_id:0 #: field:account.subscription,period_nbr:0 msgid "Period" -msgstr "Időszak" +msgstr "Periódus" #. module: account #: rml:account.partner.balance:0 @@ -1172,7 +1172,7 @@ msgstr "" #. module: account #: wizard_view:account.fiscalyear.close.state,init:0 msgid "Are you sure you want to close the fiscal year ?" -msgstr "" +msgstr "Biztos benne, hogy le akarja zárni az üzleti évet?" #. module: account #: selection:account.move,type:0 @@ -1212,7 +1212,7 @@ msgstr "" #. module: account #: field:account.account,company_currency_id:0 msgid "Company Currency" -msgstr "" +msgstr "Cég pénzneme" #. module: account #: model:ir.model,name:account.model_account_fiscal_position_account_template @@ -1332,7 +1332,7 @@ msgstr "" #: selection:account.analytic.account,type:0 #: field:account.journal,view_id:0 msgid "View" -msgstr "" +msgstr "nézet" #. module: account #: selection:account.account.balance.report,checktype,display_account:0 @@ -1471,7 +1471,7 @@ msgstr "Kötelezettség összesen" #. module: account #: wizard_button:account.fiscalyear.close.state,init,close:0 msgid "Close states" -msgstr "" +msgstr "Állapotok zárása" #. module: account #: model:ir.model,name:account.model_wizard_company_setup @@ -1707,7 +1707,7 @@ msgstr "Visszanyitás" #. module: account #: wizard_view:account.fiscalyear.close,init:0 msgid "Are you sure you want to create entries?" -msgstr "" +msgstr "Biztos hogy létre akarja hozni ezeket a könyvelési tételeket?" #. module: account #: field:account.tax,include_base_amount:0 @@ -2071,7 +2071,7 @@ msgstr "" #. module: account #: wizard_field:account.fiscalyear.close,init,period_id:0 msgid "Opening Entries Period" -msgstr "" +msgstr "Nyitóegyenleg periódusa" #. module: account #: model:ir.actions.wizard,name:account.wizard_validate_account_moves @@ -2088,7 +2088,7 @@ msgstr "" #. module: account #: selection:account.aged.trial.balance,init,direction_selection:0 msgid "Past" -msgstr "" +msgstr "múlt" #. module: account #: field:account.analytic.account,company_currency_id:0 @@ -2193,7 +2193,7 @@ msgstr "Tételes" #: selection:account.account,type:0 #: selection:account.account.template,type:0 msgid "Consolidation" -msgstr "Konszolidáció" +msgstr "konszolidáció" #. module: account #: field:account.chart.template,account_root_id:0 @@ -2236,7 +2236,7 @@ msgstr "" #. module: account #: wizard_field:account.fiscalyear.close,init,journal_id:0 msgid "Opening Entries Journal" -msgstr "" +msgstr "Nyitóegyenleg naplója" #. module: account #: view:account.config.wizard:0 @@ -2711,7 +2711,7 @@ msgstr "Számla azonosító" #. module: account #: field:account.period,date_stop:0 msgid "End of Period" -msgstr "Időszak vége" +msgstr "Periódus vége" #. module: account #: wizard_button:populate_statement_from_inv,go,finish:0 @@ -2765,7 +2765,7 @@ msgstr "" #. module: account #: wizard_field:account.aged.trial.balance,init,direction_selection:0 msgid "Analysis Direction" -msgstr "" +msgstr "Elemzés iránya" #. module: account #: wizard_button:populate_statement_from_inv,init,go:0 @@ -3093,7 +3093,7 @@ msgstr "" #: selection:account.account.template,type:0 #: selection:account.aged.trial.balance,init,result_selection:0 msgid "Payable" -msgstr "" +msgstr "kötelezettségek" #. module: account #: rml:account.invoice:0 @@ -3110,7 +3110,7 @@ msgstr "" #: selection:account.account,type:0 #: selection:account.account.template,type:0 msgid "Others" -msgstr "" +msgstr "egyéb" #. module: account #: selection:account.automatic.reconcile,init,power:0 @@ -3250,7 +3250,7 @@ msgstr "" #: model:ir.actions.wizard,name:account.wizard_fiscalyear_close #: model:ir.ui.menu,name:account.menu_wizard_fy_close msgid "Generate Fiscal Year Opening Entries" -msgstr "" +msgstr "Nyitóegyenlegek készítése az üzleti évhez" #. module: account #: model:ir.actions.wizard,name:account.wizard_reconcile @@ -3277,7 +3277,7 @@ msgstr "Adónév" #. module: account #: wizard_view:account.fiscalyear.close.state,init:0 msgid " Close states of Fiscal year and periods" -msgstr "" +msgstr " Az üzleti év és a periódusok állapotainak zárása" #. module: account #: model:account.payment.term,name:account.account_payment_term @@ -3565,7 +3565,7 @@ msgstr "Naplókód" #: wizard_button:account.fiscalyear.close,init,close:0 #: view:account.model:0 msgid "Create entries" -msgstr "" +msgstr "Tételek létrehozása" #. module: account #: view:account.analytic.line:0 @@ -3780,7 +3780,7 @@ msgstr "" #: selection:account.account,type:0 #: selection:account.account.template,type:0 msgid "Closed" -msgstr "" +msgstr "lezárt" #. module: account #: model:process.node,name:account.process_node_paymententries0 @@ -3878,7 +3878,7 @@ msgstr "Maximális mennyiség" #. module: account #: field:account.period,name:0 msgid "Period Name" -msgstr "Időszak" +msgstr "Periódus" #. module: account #: help:account.analytic.journal,type:0 @@ -4294,7 +4294,7 @@ msgstr "" #: field:account.account,type:0 #: field:account.account.template,type:0 msgid "Internal Type" -msgstr "" +msgstr "Belső típus" #. module: account #: selection:account.automatic.reconcile,init,power:0 @@ -4333,7 +4333,7 @@ msgstr "Záró dátum" #: model:ir.actions.wizard,name:account.wizard_open_closed_fiscalyear #: model:ir.ui.menu,name:account.menu_wizard_open_closed_fy msgid "Cancel Opening Entries" -msgstr "" +msgstr "Nyitóegyenleg visszavonása" #. module: account #: model:process.transition,name:account.process_transition_invoicemanually0 @@ -4435,7 +4435,7 @@ msgstr "" #: view:account.fiscalyear:0 #: view:account.period:0 msgid "States" -msgstr "" +msgstr "Állapotok" #. module: account #: view:account.move:0 @@ -4560,7 +4560,7 @@ msgstr "" #. module: account #: wizard_field:account.aged.trial.balance,init,result_selection:0 msgid "Filter on Partners" -msgstr "" +msgstr "Partnerek szűrése" #. module: account #: field:account.tax,price_include:0 @@ -4772,7 +4772,7 @@ msgstr "" #: selection:account.account.template,type:0 #: selection:account.aged.trial.balance,init,result_selection:0 msgid "Receivable" -msgstr "" +msgstr "követelések" #. module: account #: model:ir.actions.report.xml,name:account.account_account_balance @@ -4909,12 +4909,12 @@ msgstr "Tételek" #. module: account #: field:account.period,date_start:0 msgid "Start of Period" -msgstr "" +msgstr "Periódus kezdete" #. module: account #: wizard_field:account.fiscalyear.close,init,report_name:0 msgid "Name of new entries" -msgstr "" +msgstr "Új tételek neve" #. module: account #: wizard_button:account_use_models,init_form,create:0 @@ -5252,7 +5252,7 @@ msgstr "" #. module: account #: wizard_view:account.period.close,init:0 msgid "Are you sure ?" -msgstr "" +msgstr "Biztos benne?" #. module: account #: rml:account.invoice:0 @@ -5320,7 +5320,7 @@ msgstr "" #. module: account #: selection:account.aged.trial.balance,init,result_selection:0 msgid "Receivable and Payable" -msgstr "" +msgstr "követelések és kötelezettségek" #. module: account #: rml:account.account.balance:0 @@ -5468,7 +5468,7 @@ msgstr "" #: view:account.move:0 #: view:account.move.line:0 msgid "General Information" -msgstr "" +msgstr "Általános adatok" #. module: account #: help:populate_statement_from_inv,init,journal_id:0 @@ -5566,7 +5566,7 @@ msgstr "" #: wizard_field:account.fiscalyear.close,init,fy_id:0 #: wizard_field:account.fiscalyear.close.state,init,fy_id:0 msgid "Fiscal Year to close" -msgstr "" +msgstr "Lezárandó üzleti év" #. module: account #: wizard_field:account.aged.trial.balance,init,date1:0 @@ -5670,7 +5670,7 @@ msgstr "Árbevétel számla" #. module: account #: field:account.period,special:0 msgid "Opening/Closing Period" -msgstr "" +msgstr "Nyitó/záró periódus" #. module: account #: rml:account.analytic.account.balance:0 @@ -5763,7 +5763,7 @@ msgstr "Pénzügyi év" #. module: account #: selection:account.aged.trial.balance,init,direction_selection:0 msgid "Future" -msgstr "" +msgstr "jövő" #. module: account #: help:account.account.balance.report,checktype,fiscalyear:0 @@ -5893,7 +5893,7 @@ msgstr "" #: wizard_field:account.fiscalyear.close.state,init,sure:0 #: wizard_field:account.period.close,init,sure:0 msgid "Check this box" -msgstr "" +msgstr "Jelölje meg ezt a négyzetet" #. module: account #: help:account.tax,price_include:0 diff --git a/addons/account/i18n/it.po b/addons/account/i18n/it.po index a677f708ff2..58ad4f5346d 100644 --- a/addons/account/i18n/it.po +++ b/addons/account/i18n/it.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 5.0.0\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-01-17 16:07+0000\n" -"Last-Translator: Davide Corio \n" +"PO-Revision-Date: 2010-01-29 14:02+0000\n" +"Last-Translator: Carlo \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-01-18 04:44+0000\n" +"X-Launchpad-Export-Date: 2010-01-30 04:39+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account @@ -299,7 +299,7 @@ msgstr "Fisso" #: model:ir.actions.report.xml,name:account.account_overdue #: view:res.company:0 msgid "Overdue Payments" -msgstr "" +msgstr "Ritardo Pagamenti" #. module: account #: wizard_view:account.account.balance.report,checktype:0 @@ -336,7 +336,7 @@ msgstr "Computazione del canone" #. module: account #: rml:account.central.journal:0 msgid "Account Num." -msgstr "" +msgstr "Conto n." #. module: account #: rml:account.analytic.account.analytic.check:0 @@ -475,7 +475,7 @@ msgstr "Riconciliazione bancaria" #. module: account #: rml:account.invoice:0 msgid "Disc.(%)" -msgstr "" +msgstr "Sconto (%)" #. module: account #: rml:account.general.ledger:0 @@ -497,6 +497,8 @@ msgid "" "Set if the amount of tax must be included in the base amount before " "computing the next taxes." msgstr "" +"Selezionare se l'importo della tassa debba essere incluso nell'importo base " +"prima di calcolare le prossime tasse" #. module: account #: model:ir.ui.menu,name:account.menu_finance_periodical_processing @@ -506,7 +508,7 @@ msgstr "Elaborazioni periodiche" #. module: account #: view:report.hr.timesheet.invoice.journal:0 msgid "Analytic Entries Stats" -msgstr "" +msgstr "Statistiche delle registrazioni analitiche" #. module: account #: model:ir.actions.act_window,name:account.action_account_tax_code_template_form @@ -528,7 +530,7 @@ msgstr "Pagamento Riconciliato" #. module: account #: wizard_field:account.chart,init,target_move:0 msgid "Target Moves" -msgstr "" +msgstr "Registrazioni:" #. module: account #: model:ir.actions.act_window,name:account.action_account_tax_template_form @@ -549,7 +551,7 @@ msgstr "Metodo riapertura conti" #. module: account #: field:account.tax.template,include_base_amount:0 msgid "Include in Base Amount" -msgstr "" +msgstr "Incluso nell'imponibile" #. module: account #: field:account.tax,ref_base_code_id:0 @@ -579,6 +581,9 @@ msgid "" "Number of days to add before computation of the day of month.If Date=15/01, " "Number of Days=22, Day of Month=-1, then the due date is 28/02." msgstr "" +"Numero di giorni da aggiungere prima della computazione del giorno del mese. " +"Se Data=15/01, Numero di giorni=22, Giorno del mese=-1, allora la scadenza " +"sarà 28/02." #. module: account #: model:ir.model,name:account.model_account_tax @@ -588,12 +593,12 @@ msgstr "account.tax" #. module: account #: rml:account.central.journal:0 msgid "Printing Date" -msgstr "" +msgstr "Stampa Data" #. module: account #: rml:account.general.ledger:0 msgid "Mvt" -msgstr "" +msgstr "Reg. n." #. module: account #: model:ir.actions.wizard,name:account.wizard_aged_trial_balance @@ -659,7 +664,7 @@ msgstr "" #. module: account #: help:account.fiscalyear,company_id:0 msgid "Keep empty if the fiscal year belongs to several companies." -msgstr "" +msgstr "Lasciare vuoto se l'anno fiscale appartiene a più aziende" #. module: account #: model:ir.ui.menu,name:account.menu_analytic_accounting @@ -669,7 +674,7 @@ msgstr "Contabilità Analitica" #. module: account #: rml:account.overdue:0 msgid "Sub-Total :" -msgstr "" +msgstr "Sub-totale" #. module: account #: field:account.analytic.account,line_ids:0 @@ -687,12 +692,12 @@ msgstr "Mese" #. module: account #: field:account.analytic.account,partner_id:0 msgid "Associated Partner" -msgstr "" +msgstr "Partner associato" #. module: account #: field:account.invoice,comment:0 msgid "Additional Information" -msgstr "" +msgstr "Informazioni Aggiuntive" #. module: account #: selection:account.invoice,type:0 diff --git a/addons/account/partner.py b/addons/account/partner.py index a3985ee68e9..215c4286315 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -90,20 +90,20 @@ class res_partner(osv.osv): _description = 'Partner' def _credit_debit_get(self, cr, uid, ids, field_names, arg, context): query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) - cr.execute(("""select + cr.execute("""select l.partner_id, a.type, sum(l.debit-l.credit) from account_move_line l left join account_account a on (l.account_id=a.id) where - a.type in ('receivable','payable') and - l.partner_id in (%s) and + a.type =ANY(%s) and + l.partner_id =ANY(%s) and l.reconcile_id is null and - """ % (','.join(map(str, ids)),))+query+""" + """+query+""" group by l.partner_id, a.type - """) + """,(['receivable','payable'],ids,)) tinvert = { 'credit': 'receivable', 'debit': 'payable' diff --git a/addons/account/project/project.py b/addons/account/project/project.py index e39e5b00d77..a381f587f8a 100644 --- a/addons/account/project/project.py +++ b/addons/account/project/project.py @@ -34,7 +34,6 @@ class account_analytic_account(osv.osv): _description = 'Analytic Accounts' def _credit_calc(self, cr, uid, ids, name, arg, context={}): - acc_set = ",".join(map(str, ids)) where_date = '' if context.get('from_date',False): @@ -42,7 +41,7 @@ class account_analytic_account(osv.osv): if context.get('to_date',False): where_date += " AND l.date <= '" + context['to_date'] + "'" - cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s) WHERE l.amount<0 and a.id IN (%s) GROUP BY a.id" % (where_date,acc_set)) + cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount<0 and a.id =ANY(%s) GROUP BY a.id",(ids,)) r = dict(cr.fetchall()) for i in ids: r.setdefault(i,0.0) @@ -50,15 +49,13 @@ class account_analytic_account(osv.osv): def _debit_calc(self, cr, uid, ids, name, arg, context={}): - acc_set = ",".join(map(str, ids)) - where_date = '' if context.get('from_date',False): where_date += " AND l.date >= '" + context['from_date'] + "'" if context.get('to_date',False): where_date += " AND l.date <= '" + context['to_date'] + "'" - cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s) WHERE l.amount>0 and a.id IN (%s) GROUP BY a.id" % (where_date,acc_set)) + cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount>0 and a.id =ANY(%s) GROUP BY a.id" ,(ids,)) r= dict(cr.fetchall()) for i in ids: r.setdefault(i,0.0) @@ -67,12 +64,9 @@ class account_analytic_account(osv.osv): def _balance_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - acc_set = ",".join(map(str, ids2)) - for i in ids: res.setdefault(i,0.0) - - if not acc_set: + if not ids2: return res where_date = '' @@ -81,12 +75,12 @@ class account_analytic_account(osv.osv): if context.get('to_date',False): where_date += " AND l.date <= '" + context['to_date'] + "'" - cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s) WHERE a.id IN (%s) GROUP BY a.id" % (where_date,acc_set)) + cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE a.id =ANY(%s) GROUP BY a.id",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = sum - cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id in (%s)" % acc_set) + cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id =ANY(%s)",(ids2,)) currency= dict(cr.fetchall()) @@ -131,7 +125,7 @@ class account_analytic_account(osv.osv): cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \ FROM account_analytic_account a \ LEFT JOIN account_analytic_line l ON (a.id = l.account_id ' + where_date + ') \ - WHERE a.id IN ('+acc_set+') GROUP BY a.id') + WHERE a.id =ANY(%s) GROUP BY a.id',(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = sum diff --git a/addons/account/project/report/analytic_balance.py b/addons/account/project/report/analytic_balance.py index ab4c5f87ac0..f7b909ae452 100644 --- a/addons/account/project/report/analytic_balance.py +++ b/addons/account/project/report/analytic_balance.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -47,7 +47,7 @@ class account_analytic_balance(report_sxw.rml_parse): self.empty_acc = False self.acc_data_dict = {}# maintains a relation with an account with its successors. self.acc_sum_list = []# maintains a list of all ids - + def get_children(self, ids): ids2 = [] read_data = self.pool.get('account.analytic.account').read(self.cr, self.uid, ids,['child_ids','code','complete_name','balance']) @@ -56,23 +56,23 @@ class account_analytic_balance(report_sxw.rml_parse): inculde_empty = True if (not self.empty_acc) and data['balance'] == 0.00: inculde_empty = False - if inculde_empty: + if inculde_empty: self.acc_ids.append(data['id']) self.read_data.append(data) if data['child_ids']: - res = self.get_children(data['child_ids']) - return True - - + res = self.get_children(data['child_ids']) + return True + + def _get_objects(self, empty_acc): if self.read_data: return self.read_data self.empty_acc = empty_acc self.read_data = [] self.get_children(self.ids) - + return self.read_data - + def _lines_g(self, account_id, date1, date2): account_analytic_obj = self.pool.get('account.analytic.account') ids = account_analytic_obj.search(self.cr, self.uid, @@ -86,7 +86,7 @@ class account_analytic_balance(report_sxw.rml_parse): GROUP BY aal.general_account_id, aa.name, aa.code, aal.code \ ORDER BY aal.code", (date1, date2)) res = self.cr.dictfetchall() - + for r in res: if r['balance'] > 0: r['debit'] = r['balance'] @@ -99,7 +99,7 @@ class account_analytic_balance(report_sxw.rml_parse): r['debit'] = 0.0 r['credit'] = 0.0 return res - + def _move_sum(self, account_id, date1, date2, option): if account_id not in self.acc_data_dict: account_analytic_obj = self.pool.get('account.analytic.account') @@ -107,24 +107,23 @@ class account_analytic_balance(report_sxw.rml_parse): self.acc_data_dict[account_id] = ids else: ids = self.acc_data_dict[account_id] - + if option == "credit" : self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \ - WHERE account_id in ("+ ','.join(map(str, ids)) +") \ - AND date>=%s AND date<=%s AND amount<0", - (date1, date2)) + WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", + (ids,date1, date2)) elif option == "debit" : self.cr.execute("SELECT sum(amount) FROM account_analytic_line \ - WHERE account_id in ("+ ','.join(map(str, ids)) +") \ + WHERE account_id =ANY(%s)\ AND date>=%s AND date<=%s AND amount>0", - (date1, date2)) + (ids,date1, date2)) elif option == "quantity" : self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \ - WHERE account_id in ("+ ','.join(map(str, ids)) +") \ + WHERE account_id =ANY(%s)\ AND date>=%s AND date<=%s", - (date1, date2)) + (ids,date1, date2)) return self.cr.fetchone()[0] or 0.0 - + # def _move_sum_debit(self, account_id, date1, date2): # account_analytic_obj = self.pool.get('account.analytic.account') @@ -147,12 +146,12 @@ class account_analytic_balance(report_sxw.rml_parse): # AND date>=%s AND date<=%s AND amount<0", # (date1, date2)) # return self.cr.fetchone()[0] or 0.0 -# +# def _move_sum_balance(self, account_id, date1, date2): - debit = self._move_sum(account_id, date1, date2, 'debit') + debit = self._move_sum(account_id, date1, date2, 'debit') credit = self._move_sum(account_id, date1, date2, 'credit') return (debit-credit) - + # def _move_sum_quantity(self, account_id, date1, date2): # account_analytic_obj = self.pool.get('account.analytic.account') # ids = account_analytic_obj.search(self.cr, self.uid, @@ -166,7 +165,6 @@ class account_analytic_balance(report_sxw.rml_parse): def _sum_all(self, accounts, date1, date2, option): ids = map(lambda x: x['id'], accounts) - if not len(ids): return 0.0 @@ -176,25 +174,21 @@ class account_analytic_balance(report_sxw.rml_parse): self.acc_sum_list = ids2 else: ids2 = self.acc_sum_list - if option == "debit" : self.cr.execute("SELECT sum(amount) FROM account_analytic_line \ - WHERE account_id IN ("+','.join(map(str, ids2))+") \ - AND date>=%s AND date<=%s AND amount>0", - (date1, date2)) + WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", + (ids,date1, date2,)) elif option == "credit" : self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \ - WHERE account_id IN ("+','.join(map(str, ids2))+") \ - AND date>=%s AND date<=%s AND amount<0", - (date1, date2)) + WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", + (ids,date1, date2,)) elif option == "quantity" : self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \ - WHERE account_id IN ("+','.join(map(str, ids2))+") \ - AND date>=%s AND date<=%s", - (date1, date2)) + WHERE account_id =ANY(%s)AND date>=%s AND date<=%s", + (ids,date1, date2,)) return self.cr.fetchone()[0] or 0.0 - + # def _sum_debit(self, accounts, date1, date2): # ids = map(lambda x: x['id'], accounts) # if not len(ids): @@ -208,7 +202,7 @@ class account_analytic_balance(report_sxw.rml_parse): # AND date>=%s AND date<=%s AND amount>0", # (date1, date2)) # return self.cr.fetchone()[0] or 0.0 -# +# # def _sum_credit(self, accounts, date1, date2): # ids = map(lambda x: x['id'], accounts) # if not len(ids): diff --git a/addons/account/project/report/analytic_check.py b/addons/account/project/report/analytic_check.py index a97f94757af..0469c3b6918 100644 --- a/addons/account/project/report/analytic_check.py +++ b/addons/account/project/report/analytic_check.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -43,7 +43,6 @@ class account_analytic_analytic_check(report_sxw.rml_parse): def _lines_p(self, date1, date2): res = [] acc_obj = self.pool.get('account.account') - # print"3333333acc_obj3333333",acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code','user_type']) for a in acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code']): self.cr.execute("SELECT sum(debit), sum(credit) \ diff --git a/addons/account/project/report/cost_ledger.py b/addons/account/project/report/cost_ledger.py index 1109549ace4..9163cd8e0d4 100644 --- a/addons/account/project/report/cost_ledger.py +++ b/addons/account/project/report/cost_ledger.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -85,7 +85,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): return self.cr.fetchone()[0] or 0.0 def _account_sum_balance(self, account_id, date1, date2): - debit = self._account_sum_debit(account_id, date1, date2) + debit = self._account_sum_debit(account_id, date1, date2) credit = self._account_sum_credit(account_id, date1, date2) return (debit-credit) @@ -93,7 +93,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): ids = map(lambda x: x.id, accounts) if not len(ids): return 0.0 - self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount>0", (date1, date2)) + self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", (ids, date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_credit(self, accounts, date1, date2): @@ -101,7 +101,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): if not len(ids): return 0.0 ids = map(lambda x: x.id, accounts) - self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount<0", (date1, date2)) + self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", (ids,date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_balance(self, accounts, date1, date2): diff --git a/addons/account/project/report/inverted_analytic_balance.py b/addons/account/project/report/inverted_analytic_balance.py index 7071062e08a..37f469d4ef8 100644 --- a/addons/account/project/report/inverted_analytic_balance.py +++ b/addons/account/project/report/inverted_analytic_balance.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -40,8 +40,8 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): ids = map(lambda x: x.id, accounts) self.cr.execute("SELECT aa.name AS name, aa.code AS code, sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aa.id AS id \ FROM account_analytic_line AS aal, account_account AS aa \ - WHERE (aal.general_account_id=aa.id) AND (aal.account_id IN ("+','.join(map(str, ids))+")) AND (date>=%s) AND (date<=%s) AND aa.active \ - GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id ORDER BY aal.code", (date1, date2)) + WHERE (aal.general_account_id=aa.id) AND (aal.account_id =ANY(%s)) AND (date>=%s) AND (date<=%s) AND aa.active \ + GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id ORDER BY aal.code", (ids,date1,date2,)) res = self.cr.dictfetchall() for r in res: @@ -60,8 +60,8 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): ids = map(lambda x: x.id, accounts) self.cr.execute("SELECT sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aaa.code AS code, aaa.name AS name, account_id \ FROM account_analytic_line AS aal, account_analytic_account AS aaa \ - WHERE aal.account_id=aaa.id AND aal.account_id IN ("+','.join(map(str, ids))+") AND aal.general_account_id=%s AND aal.date>=%s AND aal.date<=%s \ - GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name ORDER BY aal.account_id", (general_account_id, date1, date2)) + WHERE aal.account_id=aaa.id AND aal.account_id =ANY(%s) AND aal.general_account_id=%s AND aal.date>=%s AND aal.date<=%s \ + GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name ORDER BY aal.account_id", (ids,general_account_id, date1, date2,)) res = self.cr.dictfetchall() aaa_obj = self.pool.get('account.analytic.account') @@ -86,14 +86,14 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): ids = map(lambda x: x.id, accounts) self.cr.execute("SELECT sum(amount) \ FROM account_analytic_line \ - WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount>0", (date1, date2)) + WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", (ids,date1, date2,)) return self.cr.fetchone()[0] or 0.0 - + def _sum_credit(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) self.cr.execute("SELECT -sum(amount) \ FROM account_analytic_line \ - WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount<0", (date1, date2)) + WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", (ids,date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_balance(self, accounts, date1, date2): @@ -105,7 +105,7 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): ids = map(lambda x: x.id, accounts) self.cr.execute("SELECT sum(unit_amount) \ FROM account_analytic_line \ - WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s", (date1, date2)) + WHERE account_id =ANY(%s) AND date>=%s AND date<=%s", (ids,date1, date2,)) return self.cr.fetchone()[0] or 0.0 report_sxw.report_sxw('report.account.analytic.account.inverted.balance', 'account.analytic.account', 'addons/account/project/report/inverted_analytic_balance.rml',parser=account_inverted_analytic_balance, header=False) diff --git a/addons/account/project/report/quantity_cost_ledger.py b/addons/account/project/report/quantity_cost_ledger.py index 6d4b0579794..c841c2131ab 100644 --- a/addons/account/project/report/quantity_cost_ledger.py +++ b/addons/account/project/report/quantity_cost_ledger.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -52,10 +52,9 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): WHERE (aal.account_id=%s) AND (aal.date>=%s) \ AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \ AND aa.active \ - AND (aal.journal_id IN (" + - ','.join(map(str, journal_ids)) + ")) \ + AND (aal.journal_id =ANY(%s) ) \ GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", - (account_id, date1, date2)) + (account_id, date1, date2,journal_ids)) res = self.cr.dictfetchall() return res @@ -80,10 +79,9 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): account_analytic_journal AS aaj \ WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) \ AND (aal.date>=%s) AND (aal.date<=%s) \ - AND (aal.journal_id=aaj.id) AND (aaj.id IN (" + - ','.join(map(str, journal_ids)) + ")) \ - ORDER BY aal.date, aaj.code, aal.code", - (general_account_id, account_id, date1, date2)) + AND (aal.journal_id=aaj.id) AND (aaj.id =ANY(%s)) \ + ORDER BY aal.date, aaj.code, aal.code", + (general_account_id, account_id, date1, date2,journal_ids,)) res = self.cr.dictfetchall() return res @@ -98,9 +96,8 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): self.cr.execute("SELECT sum(unit_amount) \ FROM account_analytic_line \ WHERE account_id = %s AND date >= %s AND date <= %s \ - AND journal_id IN (" + - ','.join(map(str, journal_ids)) + ")", - (account_id, date1, date2)) + AND journal_id =ANY(%s)", + (account_id, date1, date2,journal_ids,)) return self.cr.fetchone()[0] or 0.0 def _sum_quantity(self, accounts, date1, date2, journals): @@ -110,18 +107,14 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): if not journals or not journals[0][2]: self.cr.execute("SELECT sum(unit_amount) \ FROM account_analytic_line \ - WHERE account_id IN (" + - ','.join(map(str, ids)) + ") AND date>=%s AND date<=%s", - (date1, date2)) + WHERE account_id =ANY(%s) AND date>=%s AND date<=%s", + (date1, date2,ids,)) else: journal_ids = journals[0][2] self.cr.execute("SELECT sum(unit_amount) \ FROM account_analytic_line \ - WHERE account_id IN (" + - ','.join(map(str, ids)) + ") AND date >= %s AND date <= %s \ - AND journal_id IN (" + - ','.join(map(str, journal_ids)) + ")", - (date1, date2)) + WHERE account_id =ANY(%s) AND date >= %s AND date <= %s \ + AND journal_id =ANY(%s)",(ids,date1, date2,journal_ids)) return self.cr.fetchone()[0] or 0.0 report_sxw.report_sxw('report.account.analytic.account.quantity_cost_ledger', diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index 5c846dae7e1..1a93c371d20 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -57,10 +57,10 @@ class account_balance(report_sxw.rml_parse): def get_periods(self, form): result='' if form.has_key('periods') and form['periods'][0][2]: - period_ids = ",".join([str(x) for x in form['periods'][0][2] if x]) - self.cr.execute("select name from account_period where id in (%s)" % (period_ids)) + period_ids = form['periods'][0][2] + self.cr.execute("select name from account_period where id =ANY(%s)" ,(period_ids)) res = self.cr.fetchall() - len_res = len(res) + len_res = len(res) for r in res: if (r == res[len_res-1]): result+=r[0]+". " @@ -75,10 +75,10 @@ class account_balance(report_sxw.rml_parse): result+=r.name+". " else: result+=r.name+", " - + return str(result and result[:-1]) or '' - + def lines(self, form, ids={}, done=None, level=1): if not ids: ids = self.ids @@ -98,7 +98,7 @@ class account_balance(report_sxw.rml_parse): ctx['periods'] = form['periods'][0][2] elif form['state']== 'bydate': ctx['date_from'] = form['date_from'] - ctx['date_to'] = form['date_to'] + ctx['date_to'] = form['date_to'] elif form['state'] == 'all' : ctx['periods'] = form['periods'][0][2] ctx['date_from'] = form['date_from'] @@ -165,7 +165,7 @@ class account_balance(report_sxw.rml_parse): # # result_acc += self.lines(form, ids2, done, level+1) return result_acc - + def _sum_credit(self): return self.sum_credit diff --git a/addons/account/report/aged_trial_balance.py b/addons/account/report/aged_trial_balance.py index 5d3f1ae777d..c13ea96ea50 100644 --- a/addons/account/report/aged_trial_balance.py +++ b/addons/account/report/aged_trial_balance.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -47,26 +47,26 @@ class aged_trial_report(rml_parse.rml_parse): def _get_lines(self, form): if (form['result_selection'] == 'customer' ): - self.ACCOUNT_TYPE = "('receivable')" + self.ACCOUNT_TYPE = ['receivable'] elif (form['result_selection'] == 'supplier'): - self.ACCOUNT_TYPE = "('payable')" + self.ACCOUNT_TYPE = ['payable'] else: - self.ACCOUNT_TYPE = "('payable','receivable')" + self.ACCOUNT_TYPE = ['payable','receivable'] res = [] account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') self.line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line', context={'fiscalyear': form['fiscalyear']}) - self.cr.execute("""SELECT DISTINCT res_partner.id AS id, - res_partner.name AS name - FROM res_partner,account_move_line AS line, account_account - WHERE (line.account_id=account_account.id) - AND ((reconcile_id IS NULL) - OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' ))) - AND (line.partner_id=res_partner.id) - AND (account_account.company_id = %s) - ORDER BY res_partner.name""" % (form['date1'],form['company_id'])) + self.cr.execute("""SELECT DISTINCT res_partner.id AS id, + res_partner.name AS name + FROM res_partner,account_move_line AS line, account_account + WHERE (line.account_id=account_account.id) + AND ((reconcile_id IS NULL) + OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) + AND (line.partner_id=res_partner.id) + AND (account_account.company_id = %s) + ORDER BY res_partner.name""" , (form['date1'],form['company_id'])) partners = self.cr.dictfetchall() ## mise a 0 du total for i in range(7): @@ -74,20 +74,20 @@ class aged_trial_report(rml_parse.rml_parse): # # Build a string like (1,2,3) for easy use in SQL query - partner_ids = '(' + ','.join( [str(x['id']) for x in partners] ) + ')' + partner_ids = [x['id'] for x in partners] # This dictionary will store the debit-credit for all partners, using partner_id as key. totals = {} - self.cr.execute("""SELECT partner_id, SUM(debit-credit) + self.cr.execute("""SELECT partner_id, SUM(debit-credit) FROM account_move_line AS line, account_account - WHERE (line.account_id = account_account.id) - AND (account_account.type IN %s) - AND (partner_id in %s) + WHERE (line.account_id = account_account.id) + AND (account_account.type =ANY(%s)) + AND (partner_id =ANY (%s)) AND ((reconcile_id IS NULL) - OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' ))) - AND (account_account.company_id = %s) - AND account_account.active - GROUP BY partner_id""" % (self.ACCOUNT_TYPE, partner_ids,form['date1'],form['company_id'])) + OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) + AND (account_account.company_id = %s) + AND account_account.active + GROUP BY partner_id""" , (self.ACCOUNT_TYPE, partner_ids,form['date1'],form['company_id'],)) t = self.cr.fetchall() for i in t: totals[i[0]] = i[1] @@ -95,17 +95,17 @@ class aged_trial_report(rml_parse.rml_parse): # This dictionary will store the future or past of all partners future_past = {} if form['direction_selection'] == 'future': - self.cr.execute("""SELECT partner_id, SUM(debit-credit) - FROM account_move_line AS line, account_account - WHERE (line.account_id=account_account.id) - AND (account_account.type IN %s) - AND (COALESCE(date_maturity,date) < '%s') - AND (partner_id in %s) + self.cr.execute("""SELECT partner_id, SUM(debit-credit) + FROM account_move_line AS line, account_account + WHERE (line.account_id=account_account.id) + AND (account_account.type =ANY (%s)) + AND (COALESCE(date_maturity,date) < %s) + AND (partner_id =ANY (%s)) AND ((reconcile_id IS NULL) - OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' ))) - AND (account_account.company_id = %s) - AND account_account.active - GROUP BY partner_id"""% (self.ACCOUNT_TYPE, form['date1'], partner_ids,form['date1'], form['company_id'])) + OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) + AND (account_account.company_id = %s) + AND account_account.active + GROUP BY partner_id""", (self.ACCOUNT_TYPE, form['date1'], partner_ids,form['date1'], form['company_id'],)) t = self.cr.fetchall() for i in t: future_past[i[0]] = i[1] @@ -113,14 +113,14 @@ class aged_trial_report(rml_parse.rml_parse): self.cr.execute("""SELECT partner_id, SUM(debit-credit) FROM account_move_line AS line, account_account WHERE (line.account_id=account_account.id) - AND (account_account.type IN %s) - AND (COALESCE(date_maturity,date) > '%s') - AND (partner_id in %s) + AND (account_account.type =ANY (%s)) + AND (COALESCE(date_maturity,date) > %s) + AND (partner_id =ANY (%s)) AND ((reconcile_id IS NULL) - OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' ))) + OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) AND (account_account.company_id = %s) AND account_account.active - GROUP BY partner_id""" % (self.ACCOUNT_TYPE, form['date1'], partner_ids, form['date1'], form['company_id'])) + GROUP BY partner_id""" , (self.ACCOUNT_TYPE, form['date1'], partner_ids, form['date1'], form['company_id'],)) t = self.cr.fetchall() for i in t: future_past[i[0]] = i[1] @@ -132,14 +132,14 @@ class aged_trial_report(rml_parse.rml_parse): self.cr.execute("""SELECT partner_id, SUM(debit-credit) FROM account_move_line AS line, account_account WHERE (line.account_id=account_account.id) - AND (account_account.type IN %s) - AND (COALESCE(date_maturity,date) BETWEEN '%s' AND '%s') - AND (partner_id in %s ) + AND (account_account.type =ANY (%s)) + AND (COALESCE(date_maturity,date) BETWEEN %s AND %s) + AND (partner_id =ANY (%s)) AND ((reconcile_id IS NULL) - OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > '%s' ))) + OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) AND (account_account.company_id = %s) AND account_account.active - GROUP BY partner_id""" % (self.ACCOUNT_TYPE, form[str(i)]['start'], form[str(i)]['stop'],partner_ids ,form['date1'] ,form['company_id'])) + GROUP BY partner_id""" , (self.ACCOUNT_TYPE, form[str(i)]['start'], form[str(i)]['stop'],partner_ids ,form['date1'] ,form['company_id'],)) t = self.cr.fetchall() d = {} diff --git a/addons/account/report/general_journal.py b/addons/account/report/general_journal.py index 6d21ff2f513..2da07e04cfd 100644 --- a/addons/account/report/general_journal.py +++ b/addons/account/report/general_journal.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -41,10 +41,10 @@ class journal_print(report_sxw.rml_parse): def set_context(self, objects, data, ids, report_type = None): super(journal_print, self).set_context(objects, data, ids, report_type) - self.cr.execute('select period_id, journal_id from account_journal_period where id in (' + ','.join([str(id) for id in ids]) + ')') + self.cr.execute('select period_id, journal_id from account_journal_period where id =ANY(%s)',(ids,)) res = self.cr.fetchall() - self.period_ids = ','.join([str(x[0]) for x in res]) - self.journal_ids = ','.join([str(x[1]) for x in res]) + self.period_ids = map(lambda x:x[0],res) + self.journal_ids = map(lambda x:x[1],res) # returns a list of period objs def periods(self, journal_period_objs): @@ -74,7 +74,7 @@ class journal_print(report_sxw.rml_parse): periods.append(data.period_id.id) for period in periods: period_data = self.pool.get('account.period').browse(self.cr, self.uid, period) - self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id in (' + ','.join(map(str, journal_id)) + ') and l.state<>\'draft\' group by j.id, j.code, j.name', (period,)) + self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id =ANY(%s) and l.state<>\'draft\' group by j.id, j.code, j.name', (period,journal_id,)) res = self.cr.dictfetchall() res[0].update({'period_name':period_data.name}) res[0].update({'pid':period}) @@ -82,45 +82,45 @@ class journal_print(report_sxw.rml_parse): return lines_data if not self.journal_ids: return [] - self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id in (' + self.journal_ids + ') and l.state<>\'draft\' group by j.id, j.code, j.name', (period_id,)) + self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id =ANY(%s) and l.state<>\'draft\' group by j.id, j.code, j.name', (period_id,self.journal_ids,)) res = self.cr.dictfetchall() return res def _sum_debit_period(self, period_id,journal_id=None): if type(journal_id)==type([]): - self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'', (period_id,)) + self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,journal_id,)) return self.cr.fetchone()[0] or 0.0 if not self.journal_ids: return 0.0 - self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,)) + self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,self.journal_ids,)) return self.cr.fetchone()[0] or 0.0 def _sum_credit_period(self, period_id,journal_id=None): if type(journal_id)==type([]): - self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'', (period_id,)) + self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,journal_id,)) return self.cr.fetchone()[0] or 0.0 if not self.journal_ids: return 0.0 - self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,)) + self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,self.journal_ids,)) return self.cr.fetchone()[0] or 0.0 def _sum_debit(self,period_id=None,journal_id=None): if type(period_id)==type([]): - self.cr.execute('select sum(debit) from account_move_line where period_id in (' + ','.join(map(str, period_id)) + ') and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'') + self.cr.execute('select sum(debit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(period_id,journal_id,)) return self.cr.fetchone()[0] or 0.0 if not self.journal_ids or not self.period_ids: return 0.0 - self.cr.execute('select sum(debit) from account_move_line where period_id in (' + self.period_ids + ') and journal_id in (' + self.journal_ids + ') and state<>\'draft\'') + self.cr.execute('select sum(debit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(self.period_ids,self.journal_ids,)) return self.cr.fetchone()[0] or 0.0 def _sum_credit(self,period_id=None,journal_id=None): if type(period_id)==type([]): - self.cr.execute('select sum(credit) from account_move_line where period_id in (' + ','.join(map(str, period_id)) + ') and journal_id in (' + ','.join(map(str, journal_id)) + ') and state<>\'draft\'') + self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(period_id,journal_id,)) return self.cr.fetchone()[0] or 0.0 if not self.journal_ids or not self.period_ids: return 0.0 - self.cr.execute('select sum(credit) from account_move_line where period_id in (' + self.period_ids + ') and journal_id in (' + self.journal_ids + ') and state<>\'draft\'') + self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(self.period_ids,self.journal_ids,)) return self.cr.fetchone()[0] or 0.0 report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml',parser=journal_print) report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml',parser=journal_print, header=False) diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index beb96f3cf24..5db2545d070 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -89,7 +89,7 @@ class general_ledger(rml_parse.rml_parse): # We have the account ID we will search all account move line from now until this time # We are in the case of we are on the top of the account move Line cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\ - where ac.id = mv.account_id and mv.move_id = ' + num_id_move +' and mv.account_id <> ' + account_id ) + where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' ,(num_id_move,account_id,)) res_mv = cr.dictfetchall() # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line if (len(res_mv) >=1): @@ -120,15 +120,11 @@ class general_ledger(rml_parse.rml_parse): ## This function will return the most aged date periods = form['periods'][0][2] if not periods: - sql = """ - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ - """ + self.cr.execute(""" + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""",(form['fiscalyear'],)) else: - periods_id = ','.join(map(str, periods)) - sql = """ - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) - """ - self.cr.execute(sql) + self.cr.execute(""" + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) res = self.cr.dictfetchall() borne_min = res[0]['start_date'] borne_max = res[0]['stop_date'] @@ -138,15 +134,11 @@ class general_ledger(rml_parse.rml_parse): elif form['state'] == 'all': periods = form['periods'][0][2] if not periods: - sql = """ - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ - """ + self.cr.execute(""" + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""",(form['fiscalyear'],)) else: - periods_id = ','.join(map(str, periods)) - sql = """ - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) - """ - self.cr.execute(sql) + self.cr.execute(""" + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) res = self.cr.dictfetchall() period_min = res[0]['start_date'] period_max = res[0]['stop_date'] @@ -230,8 +222,8 @@ class general_ledger(rml_parse.rml_parse): else: ## We will now compute solde initiaux for move in res: - SOLDEINIT = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l WHERE l.account_id = " + str(move.id) + " AND l.date < '" + self.borne_date['max_date'] + "'" + " AND l.date > '" + self.borne_date['min_date'] + "'" - self.cr.execute(SOLDEINIT) + self.cr.execute("""SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l \ + WHERE l.account_id = %s AND l.date < %s AND l.date > %s""",(move.id,self.borne_date['max_date'],self.borne_date['min_date'])) resultat = self.cr.dictfetchall() if resultat[0] : if resultat[0]['sum_debit'] == None: @@ -284,7 +276,7 @@ class general_ledger(rml_parse.rml_parse): for l in res: line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) l['move'] = line.move_id.name - self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id)) + self.cr.execute('Select id from account_invoice where move_id =%s',(line.move_id.id,)) tmpres = self.cr.dictfetchall() if len(tmpres) > 0 : inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) @@ -312,7 +304,7 @@ class general_ledger(rml_parse.rml_parse): self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND %s "%(account.id, self.query)) + "WHERE l.account_id = %s AND "+self.query,(account.id,)) ## Add solde init to the result # sum_debit = self.cr.fetchone()[0] or 0.0 @@ -326,7 +318,7 @@ class general_ledger(rml_parse.rml_parse): self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND %s "%(account.id,self.query)) + "WHERE l.account_id = %s AND "+ self.query,(account.id,)) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -340,7 +332,7 @@ class general_ledger(rml_parse.rml_parse): def _sum_solde_account(self, account, form): self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND %s"%(account.id,self.query)) + "WHERE l.account_id = %s AND "+ self.query,(account.id,)) sum_solde = self.cr.fetchone()[0] or 0.0 if form.get('soldeinit', False): sum_solde += account.init_debit - account.init_credit @@ -352,7 +344,7 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) + "WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,)) sum_debit = self.cr.fetchone()[0] or 0.0 return sum_debit @@ -361,7 +353,7 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) + "WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,)) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -372,14 +364,14 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) + "WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,)) sum_solde = self.cr.fetchone()[0] or 0.0 return sum_solde def _set_get_account_currency_code(self, account_id): self.cr.execute("SELECT c.code as code "\ "FROM res_currency c,account_account as ac "\ - "WHERE ac.id = %s AND ac.currency_id = c.id"%(account_id)) + "WHERE ac.id = %s AND ac.currency_id = c.id",(account_id,)) result = self.cr.fetchone() if result: self.account_currency = result[0] diff --git a/addons/account/report/general_ledger_landscape.py b/addons/account/report/general_ledger_landscape.py index c1f9a374145..c0d48ad6e0e 100644 --- a/addons/account/report/general_ledger_landscape.py +++ b/addons/account/report/general_ledger_landscape.py @@ -22,7 +22,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## @@ -83,14 +83,14 @@ class general_ledger_landscape(rml_parse.rml_parse): # # result[account_line.id] = ' ' - num_id_move = str(account_line.move_id.id) - num_id_line = str(account_line.id) - account_id = str(account_line.account_id.id) + num_id_move = account_line.move_id.id + num_id_line = account_line.id + account_id = account_line.account_id.id # search the basic account # We have the account ID we will search all account move line from now until this time # We are in the case of we are on the top of the account move Line cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\ - where ac.id = mv.account_id and mv.move_id = ' + num_id_move +' and mv.account_id <> ' + account_id ) + where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' , (num_id_move,account_id,)) res_mv = cr.dictfetchall() # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line if (len(res_mv) >=1): @@ -121,15 +121,12 @@ class general_ledger_landscape(rml_parse.rml_parse): ## This function will return the most aged date periods = form['periods'][0][2] if not periods: - sql = """ - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ - """ + self.cr.execute(""" + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""" ,(form['fiscalyear'],)) else: - periods_id = ','.join(map(str, periods)) - sql = """ - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) - """ - self.cr.execute(sql) + self.cr.execute(""" + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) + res = self.cr.dictfetchall() borne_min = res[0]['start_date'] borne_max = res[0]['stop_date'] @@ -139,15 +136,12 @@ class general_ledger_landscape(rml_parse.rml_parse): elif form['state'] == 'all': periods = form['periods'][0][2] if not periods: - sql = """ - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ - """ + self.cr.execute(""" + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = = %s""" ,(form['fiscalyear'],)) + else: - periods_id = ','.join(map(str, periods)) - sql = """ - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) - """ - self.cr.execute(sql) + self.cr.execute(""" + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) res = self.cr.dictfetchall() period_min = res[0]['start_date'] period_max = res[0]['stop_date'] @@ -178,8 +172,6 @@ class general_ledger_landscape(rml_parse.rml_parse): def get_children_accounts(self, account, form): - - print self.ids self.child_ids = self.pool.get('account.account').search(self.cr, self.uid, [('parent_id', 'child_of', self.ids)]) # @@ -233,8 +225,8 @@ class general_ledger_landscape(rml_parse.rml_parse): else: ## We will now compute solde initiaux for move in res: - SOLDEINIT = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l WHERE l.account_id = " + str(move.id) + " AND l.date < '" + self.borne_date['max_date'] + "'" + " AND l.date > '" + self.borne_date['min_date'] + "'" - self.cr.execute(SOLDEINIT) + self.cr.execute("""SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l \ + WHERE l.account_id = %s AND l.date < %s AND l.date > %s""",(move.id,self.borne_date['max_date'],self.borne_date['min_date'])) resultat = self.cr.dictfetchall() if resultat[0] : if resultat[0]['sum_debit'] == None: @@ -287,7 +279,7 @@ class general_ledger_landscape(rml_parse.rml_parse): for l in res: line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) l['move'] = line.move_id.name - self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id)) + self.cr.execute('Select id from account_invoice where move_id =%s',(line.move_id.id,)) tmpres = self.cr.dictfetchall() if len(tmpres) > 0 : inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) @@ -315,7 +307,7 @@ class general_ledger_landscape(rml_parse.rml_parse): self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND %s "%(account.id, self.query)) + "WHERE l.account_id = %s AND "+self.query,(account.id,)) ## Add solde init to the result # sum_debit = self.cr.fetchone()[0] or 0.0 @@ -329,7 +321,7 @@ class general_ledger_landscape(rml_parse.rml_parse): self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND %s "%(account.id,self.query)) + "WHERE l.account_id = %s AND "+self.query,(account.id,)) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -343,7 +335,7 @@ class general_ledger_landscape(rml_parse.rml_parse): def _sum_solde_account(self, account, form): self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND %s"%(account.id,self.query)) + "WHERE l.account_id = %s AND "+self.query,(account.id,)) sum_solde = self.cr.fetchone()[0] or 0.0 if form.get('soldeinit',False): sum_solde += account.init_debit - account.init_credit @@ -355,7 +347,7 @@ class general_ledger_landscape(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) + "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) sum_debit = self.cr.fetchone()[0] or 0.0 return sum_debit @@ -364,7 +356,7 @@ class general_ledger_landscape(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) + "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -375,14 +367,14 @@ class general_ledger_landscape(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) + "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) sum_solde = self.cr.fetchone()[0] or 0.0 return sum_solde def _set_get_account_currency_code(self, account_id): self.cr.execute("SELECT c.code as code "\ "FROM res_currency c,account_account as ac "\ - "WHERE ac.id = %s AND ac.currency_id = c.id"%(account_id)) + "WHERE ac.id = %s AND ac.currency_id = c.id",(account_id,)) result = self.cr.fetchone() if result: self.account_currency = result[0] diff --git a/addons/account/report/partner_balance.py b/addons/account/report/partner_balance.py index 2b52a0616f0..a5b746a0bde 100755 --- a/addons/account/report/partner_balance.py +++ b/addons/account/report/partner_balance.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -166,27 +166,26 @@ class partner_balance(report_sxw.rml_parse): ## self.date_lst_string ='' if self.date_lst: - self.date_lst_string = '\'' + '\',\''.join(map(str, self.date_lst)) + '\'' - + self.date_lst_string = '\'' + '\',\''.join(map(str, self.date_lst)) + '\'' ## Compute Code account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') # if (data['form']['result_selection'] == 'customer' ): - self.ACCOUNT_TYPE = "('receivable')" + self.ACCOUNT_TYPE = ['receivable'] elif (data['form']['result_selection'] == 'supplier'): - self.ACCOUNT_TYPE = "('payable')" + self.ACCOUNT_TYPE = ['payable'] else: - self.ACCOUNT_TYPE = "('payable','receivable')" + self.ACCOUNT_TYPE = ['payable','receivable'] # self.cr.execute("SELECT a.id " \ "FROM account_account a " \ "LEFT JOIN account_account_type t " \ "ON (a.type = t.code) " \ "WHERE a.company_id = %s " \ - "AND a.type IN " + self.ACCOUNT_TYPE + " " \ - "AND a.active", (data['form']['company_id'],)) - self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()]) + "AND a.type =ANY(%s) "\ + "AND a.active", (data['form']['company_id'],self.ACCOUNT_TYPE,)) + self.account_ids = [a for (a,) in self.cr.fetchall()] super(partner_balance, self).set_context(objects, data, ids, report_type) @@ -214,11 +213,11 @@ class partner_balance(report_sxw.rml_parse): ") AS enlitige " \ "FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \ "JOIN account_account ac ON (l.account_id = ac.id)" \ - "WHERE ac.type IN " + self.ACCOUNT_TYPE + " " \ + "WHERE ac.type =ANY(%s) " "AND l.date IN (" + self.date_lst_string + ") " \ - "AND ac.company_id = "+ str(data['form']['company_id']) +" " \ + "AND ac.company_id = %s" \ "GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \ - "ORDER BY l.account_id,p.name") + "ORDER BY l.account_id,p.name",(self.ACCOUNT_TYPE,data['form']['company_id'],)) res = self.cr.dictfetchall() for r in res: full_account.append(r) @@ -355,8 +354,8 @@ class partner_balance(report_sxw.rml_parse): self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ - "WHERE l.account_id IN (" + self.account_ids + ") " \ - "AND l.date IN (" + self.date_lst_string + ") " ) + "WHERE l.account_id =ANY(%s)" \ + "AND l.date IN (" + self.date_lst_string + ")" ,(self.account_ids,)) temp_res = float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res @@ -373,8 +372,8 @@ class partner_balance(report_sxw.rml_parse): self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ - "WHERE l.account_id IN (" + self.account_ids + ") " \ - "AND l.date IN (" + self.date_lst_string + ") " ) + "WHERE l.account_id =ANY(%s)" \ + "AND l.date IN (" + self.date_lst_string + ")" ,(self.account_ids,)) temp_res = float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res @@ -390,9 +389,9 @@ class partner_balance(report_sxw.rml_parse): self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ - "WHERE l.account_id IN (" + self.account_ids + ") " \ - "AND l.date IN (" + self.date_lst_string + ") " \ - "AND l.blocked=TRUE " ) + "WHERE l.account_id =ANY(%s)" \ + "AND l.date IN (" + self.date_lst_string + ")"\ + "AND l.blocked=TRUE " ,(self.account_ids,)) temp_res = float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res @@ -411,9 +410,9 @@ class partner_balance(report_sxw.rml_parse): "ELSE 0 " \ "END " \ "FROM account_move_line AS l " \ - "WHERE l.account_id IN (" + self.account_ids + ") " \ - "AND l.date IN (" + self.date_lst_string + ") " \ - "GROUP BY l.partner_id") + "WHERE l.account_id =ANY(%s)" \ + "AND l.date IN (" + self.date_lst_string + ")" \ + "GROUP BY l.partner_id",(self.account_ids,)) a = self.cr.fetchone()[0] if self.cr.fetchone() != None: @@ -438,9 +437,9 @@ class partner_balance(report_sxw.rml_parse): "ELSE 0 " \ "END " \ "FROM account_move_line AS l " \ - "WHERE l.account_id IN (" + self.account_ids + ") " \ - "AND l.date IN (" + self.date_lst_string + ") " \ - "GROUP BY l.partner_id") + "WHERE l.account_id =ANY(%s)" \ + "AND l.date IN (" + self.date_lst_string + ")" \ + "GROUP BY l.partner_id",(self.account_ids,)) a = self.cr.fetchone()[0] or 0.0 if self.cr.fetchone() != None: diff --git a/addons/account/report/tax_report.py b/addons/account/report/tax_report.py index ccc62a53de0..3910622ad68 100644 --- a/addons/account/report/tax_report.py +++ b/addons/account/report/tax_report.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -41,25 +41,25 @@ class tax_report(rml_parse.rml_parse): 'get_lines' : self._get_lines, }) - + def _get_lines(self, based_on,period_list,company_id=False, parent=False, level=0): res = self._get_codes(based_on,company_id,parent,level,period_list) - + if period_list[0][2] : res = self._add_codes(based_on,res,period_list) else : self.cr.execute ("select id from account_fiscalyear") fy = self.cr.fetchall() - self.cr.execute ("select id from account_period where fiscalyear_id = %d"%(fy[0][0])) + self.cr.execute ("select id from account_period where fiscalyear_id = %s",(fy[0][0],)) periods = self.cr.fetchall() for p in periods : period_list[0][2].append(p[0]) res = self._add_codes(based_on,res,period_list) - + i = 0 top_result = [] while i < len(res): - + res_dict = { 'code' : res[i][1].code, 'name' : res[i][1].name, 'debit' : 0, @@ -69,7 +69,7 @@ class tax_report(rml_parse.rml_parse): 'level' : res[i][0], 'pos' : 0 } - + top_result.append(res_dict) res_general = self._get_general(res[i][1].id,period_list,company_id,based_on) ind_general = 0 @@ -89,7 +89,6 @@ class tax_report(rml_parse.rml_parse): def _get_general(self, tax_code_id,period_list ,company_id, based_on): res=[] - period_sql_list = ','.join(map(str, period_list[0][2])) if based_on == 'payments': self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ SUM(line.debit) AS debit, \ @@ -108,11 +107,11 @@ class tax_report(rml_parse.rml_parse): AND line.account_id = account.id \ AND account.company_id = %s \ AND move.id = line.move_id \ - AND line.period_id IN ('+ period_sql_list +') \ + AND line.period_id =ANY(%s) \ AND ((invoice.state = %s) \ OR (invoice.id IS NULL)) \ GROUP BY account.id,account.name,account.code', ('draft',tax_code_id, - company_id, 'paid')) + company_id, period_list[0][2],'paid',)) else : self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ @@ -128,14 +127,14 @@ class tax_report(rml_parse.rml_parse): AND line.tax_code_id = %s \ AND line.account_id = account.id \ AND account.company_id = %s \ - AND line.period_id IN ('+ period_sql_list +') \ + AND line.period_id =ANY(%s)\ AND account.active \ GROUP BY account.id,account.name,account.code', ('draft',tax_code_id, - company_id)) + company_id,period_list[0][2],)) res = self.cr.dictfetchall() - + #AND line.period_id IN ('+ period_sql_list +') \ - + i = 0 while i= int(accounts[bcl_rup_ind]['level']) and bcl_rup_ind >= 0 ): tot_elem = copy.copy(accounts[bcl_rup_ind]) res_tot = { 'code' : accounts[bcl_rup_ind]['code'], @@ -202,21 +201,21 @@ class tax_report(rml_parse.rml_parse): 'level' : 0, 'pos' : 0 } - + if res_tot['type'] == 1: # on change le type pour afficher le total res_tot['type'] = 2 result_accounts.append(res_tot) bcl_current_level = accounts[bcl_rup_ind]['level'] bcl_rup_ind -= 1 - + old_level = account_elem['level'] result_accounts.append(account_elem) ind+=1 - - + + return result_accounts - + report_sxw.report_sxw('report.account.vat.declaration', 'account.tax.code', 'addons/account/report/tax_report.rml', parser=tax_report, header=False) diff --git a/addons/account/report/third_party_ledger.py b/addons/account/report/third_party_ledger.py index affd7881218..0ae5bf8ce1a 100644 --- a/addons/account/report/third_party_ledger.py +++ b/addons/account/report/third_party_ledger.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -142,7 +142,8 @@ class third_party_ledger(rml_parse.rml_parse): if (data['model'] == 'res.partner'): ## Si on imprime depuis les partenaires if ids: - PARTNER_REQUEST = "AND line.partner_id IN (" + ','.join(map(str, ids)) + ")" + #PARTNER_REQUEST = "AND line.partner_id IN (" + ','.join(map(str, ids)) + ")" + PARTNER_REQUEST = "AND line.partner_id =ANY(%s)" %ids # Transformation des date # # @@ -166,11 +167,11 @@ class third_party_ledger(rml_parse.rml_parse): # #new_ids = [id for (id,) in self.cr.fetchall()] if data['form']['result_selection'] == 'supplier': - self.ACCOUNT_TYPE = "('receivable')" + self.ACCOUNT_TYPE = ['receivable'] elif data['form']['result_selection'] == 'customer': - self.ACCOUNT_TYPE = "('payable')" + self.ACCOUNT_TYPE = ['payable'] elif data['form']['result_selection'] == 'all': - self.ACCOUNT_TYPE = "('payable','receivable')" + self.ACCOUNT_TYPE = ['payable','receivable'] self.cr.execute( "SELECT a.id " \ @@ -178,9 +179,9 @@ class third_party_ledger(rml_parse.rml_parse): "LEFT JOIN account_account_type t " \ "ON (a.type=t.code) " \ "WHERE a.company_id = %s " \ - 'AND a.type IN ' + self.ACCOUNT_TYPE + " " \ - "AND a.active", (data['form']['company_id'],)) - self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()]) + 'AND a.type =ANY(%s)' \ + "AND a.active", (data['form']['company_id'],self.ACCOUNT_TYPE,)) + self.account_ids = [a for (a,) in self.cr.fetchall()] account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') partner_to_use = [] @@ -195,11 +196,11 @@ class third_party_ledger(rml_parse.rml_parse): "AND line.date >= %s " \ "AND line.date <= %s " \ "AND line.reconcile_id IS NULL " \ - "AND line.account_id IN (" + self.account_ids + ") " \ + "AND line.account_id =ANY(%s)" \ " " + PARTNER_REQUEST + " " \ "AND account.company_id = %s " \ "AND account.active " , - (self.date_lst[0],self.date_lst[len(self.date_lst)-1],data['form']['company_id'])) + (self.date_lst[0],self.date_lst[len(self.date_lst)-1],self.account_ids,data['form']['company_id'],)) # else: # # self.cr.execute( @@ -220,7 +221,8 @@ class third_party_ledger(rml_parse.rml_parse): partner_to_use.append(res_line['partner_id']) new_ids = partner_to_use - self.partner_ids = ','.join(map(str, new_ids)) + #self.partner_ids = ','.join(map(str, new_ids)) + self.partner_ids = new_ids objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids) super(third_party_ledger, self).set_context(objects, data, new_ids, report_type) @@ -259,11 +261,11 @@ class third_party_ledger(rml_parse.rml_parse): "LEFT JOIN account_journal j " \ "ON (l.journal_id = j.id) " \ "WHERE l.partner_id = %s " \ - "AND l.account_id IN (" + self.account_ids + ") " \ - "AND l.date IN (" + self.date_lst_string + ") " \ + "AND l.account_id =ANY(%s)"\ + "AND l.date IN (" + self.date_lst_string + ")" " " + RECONCILE_TAG + " "\ "ORDER BY l.id", - (partner.id,)) + (partner.id,self.account_ids,)) res = self.cr.dictfetchall() sum = 0.0 for r in res: @@ -286,10 +288,10 @@ class third_party_ledger(rml_parse.rml_parse): "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id = %s " \ - "AND account_id IN (" + self.account_ids + ") " \ + "AND account_id =ANY(%s)" \ "AND reconcile_id IS NULL " \ "AND date < %s " , - (partner.id, self.date_lst[0],)) + (partner.id, self.account_ids,self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -301,10 +303,10 @@ class third_party_ledger(rml_parse.rml_parse): "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id = %s " \ - "AND account_id IN (" + self.account_ids + ") " \ + "AND account_id =ANY(%s)" \ " " + RECONCILE_TAG + " " \ - "AND date IN (" + self.date_lst_string + ") " , - (partner.id,)) + "AND date IN (" + self.date_lst_string + ")" , + (partner.id,self.account_ids,)) contemp = self.cr.fetchone() if contemp != None: @@ -325,10 +327,10 @@ class third_party_ledger(rml_parse.rml_parse): "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id=%s " \ - "AND account_id IN (" + self.account_ids + ") " \ + "AND account_id =ANY(%s)" \ "AND reconcile_id IS NULL " \ "AND date < %s " , - (partner.id,self.date_lst[0],)) + (partner.id,self.account_ids,self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -340,10 +342,10 @@ class third_party_ledger(rml_parse.rml_parse): "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id=%s " \ - "AND account_id IN (" + self.account_ids + ") " \ + "AND account_id =ANY(%s)" \ " " + RECONCILE_TAG + " " \ - "AND date IN (" + self.date_lst_string + ") " , - (partner.id,)) + "AND date IN (" + self.date_lst_string + ")", + (partner.id,self.account_ids,)) contemp = self.cr.fetchone() if contemp != None: @@ -365,11 +367,11 @@ class third_party_ledger(rml_parse.rml_parse): self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ - "WHERE partner_id IN (" + self.partner_ids + ") " \ - "AND account_id IN (" + self.account_ids + ") " \ + "WHERE partner_id =ANY(%s)" \ + "AND account_id =ANY(%s)" \ "AND reconcile_id IS NULL " \ "AND date < %s " , - (self.date_lst[0],)) + (self.partner_ids,self.account_ids,self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -380,12 +382,10 @@ class third_party_ledger(rml_parse.rml_parse): self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ - "WHERE partner_id IN (" + self.partner_ids + ") " \ - "AND account_id IN (" + self.account_ids + ") " \ + "WHERE partner_id =ANY(%s)" \ + "AND account_id =ANY(%s)" \ " " + RECONCILE_TAG + " " \ - "AND date IN (" + self.date_lst_string + ") " - ) - + "AND date IN (" + self.date_lst_string + ")",(self.partner_ids,self.account_ids,)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -408,11 +408,11 @@ class third_party_ledger(rml_parse.rml_parse): self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ - "WHERE partner_id IN (" + self.partner_ids + ") " \ - "AND account_id IN (" + self.account_ids + ") " \ + "WHERE partner_id =ANY(%s)" \ + "AND account_id =ANY(%s)" \ "AND reconcile_id IS NULL " \ "AND date < %s " , - (self.date_lst[0],)) + (self.partner_ids,self.account_ids,self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -423,11 +423,10 @@ class third_party_ledger(rml_parse.rml_parse): self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ - "WHERE partner_id IN (" + self.partner_ids + ") " \ - "AND account_id IN (" + self.account_ids + ") " \ + "WHERE partner_id =ANY(%s)" \ + "AND account_id =ANY(%s)" \ " " + RECONCILE_TAG + " " \ - "AND date IN (" + self.date_lst_string + ") " - ) + "AND date IN (" + self.date_lst_string + ")",(self.partner_ids,self.account_ids,)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 diff --git a/addons/account/sequence.py b/addons/account/sequence.py index 08e38dd14a4..498e997dc2b 100644 --- a/addons/account/sequence.py +++ b/addons/account/sequence.py @@ -37,13 +37,13 @@ class ir_sequence(osv.osv): _columns = { 'fiscal_ids' : fields.one2many('account.sequence.fiscalyear', 'sequence_main_id', 'Sequences') } - def get_id(self, cr, uid, sequence_id, test='id=%s', context={}): - cr.execute('select id from ir_sequence where '+test+' and active=%s', (sequence_id, True,)) + def get_id(self, cr, uid, sequence_id, test='id', context={}): + cr.execute('select id from ir_sequence where '+test+'=%s and active=%s', (sequence_id, True,)) res = cr.dictfetchone() if res: for line in self.browse(cr, uid, res['id'], context=context).fiscal_ids: if line.fiscalyear_id.id==context.get('fiscalyear_id', False): - return super(ir_sequence, self).get_id(cr, uid, line.sequence_id.id, test="id=%s", context=context) + return super(ir_sequence, self).get_id(cr, uid, line.sequence_id.id, test="id", context=context) return super(ir_sequence, self).get_id(cr, uid, sequence_id, test, context) ir_sequence() diff --git a/addons/account/wizard/wizard_account_balance_report.py b/addons/account/wizard/wizard_account_balance_report.py index 62485a9f21a..26538d06b4b 100644 --- a/addons/account/wizard/wizard_account_balance_report.py +++ b/addons/account/wizard/wizard_account_balance_report.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -102,7 +102,7 @@ class wizard_report(wizard.interface): # else : # data['form']['fiscalyear'] = 1 return data['form'] - + def _check_path(self, cr, uid, data, context): if data['model'] == 'account.account': return 'checktype' @@ -111,8 +111,8 @@ class wizard_report(wizard.interface): def _check_date(self, cr, uid, data, context): sql = """ - SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date_from']) - cr.execute(sql) + SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ + cr.execute(sql,(data['form']['date_from'],)) res = cr.dictfetchall() if res: if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']): diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py index 7e48f7c496c..42e35276802 100644 --- a/addons/account/wizard/wizard_fiscalyear_close.py +++ b/addons/account/wizard/wizard_fiscalyear_close.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -56,14 +56,12 @@ def _data_save(self, cr, uid, data, context): fy_id = data['form']['fy_id'] period_ids = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', fy_id)]) - fy_period_set = ','.join(map(str, period_ids)) periods_fy2 = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', data['form']['fy2_id'])]) - fy2_period_set = ','.join(map(str, periods_fy2)) period = pool.get('account.period').browse(cr, uid, data['form']['period_id'], context=context) new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'], context=context) old_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy_id'], context=context) - + new_journal = data['form']['journal_id'] new_journal = pool.get('account.journal').browse(cr, uid, new_journal, context=context) @@ -89,7 +87,7 @@ def _data_save(self, cr, uid, data, context): ids = map(lambda x: x[0], cr.fetchall()) for account in pool.get('account.account').browse(cr, uid, ids, context={'fiscalyear': fy_id}): - + accnt_type_data = account.user_type if not accnt_type_data: continue @@ -135,7 +133,7 @@ def _data_save(self, cr, uid, data, context): }) offset += limit - #We have also to consider all move_lines that were reconciled + #We have also to consider all move_lines that were reconciled #on another fiscal year, and report them too offset = 0 limit = 100 @@ -149,10 +147,10 @@ def _data_save(self, cr, uid, data, context): 'WHERE b.account_id = %s ' \ 'AND b.reconcile_id is NOT NULL ' \ 'AND a.reconcile_id = b.reconcile_id ' \ - 'AND b.period_id IN ('+fy_period_set+') ' \ - 'AND a.period_id IN ('+fy2_period_set+') ' \ + 'AND b.period_id =ANY(%s)'\ + 'AND a.period_id =ANY(%s)' \ 'ORDER BY id ' \ - 'LIMIT %s OFFSET %s', (account.id, limit, offset)) + 'LIMIT %s OFFSET %s', (account.id,period_ids,periods_fy2,limit, offset)) result = cr.dictfetchall() if not result: break @@ -180,7 +178,7 @@ def _data_save(self, cr, uid, data, context): 'AND ' + query_line + ' ' \ 'ORDER BY id ' \ 'LIMIT %s OFFSET %s', (account.id, limit, offset)) - + result = cr.dictfetchall() if not result: break @@ -210,7 +208,6 @@ def _data_save(self, cr, uid, data, context): cr.execute('UPDATE account_fiscalyear ' \ 'SET end_journal_period_id = %s ' \ 'WHERE id = %s', (ids[0], old_fyear.id)) - return {} class wiz_journal_close(wizard.interface): diff --git a/addons/account/wizard/wizard_general_ledger_report.py b/addons/account/wizard/wizard_general_ledger_report.py index ac8df1e1142..d5f8ac0fa98 100644 --- a/addons/account/wizard/wizard_general_ledger_report.py +++ b/addons/account/wizard/wizard_general_ledger_report.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -46,7 +46,7 @@ period_form = ''' - + @@ -65,10 +65,10 @@ period_form = ''' - - - - + + + + ''' period_fields = { @@ -103,10 +103,10 @@ def _check(self, cr, uid, data, context): return 'report' def _check_date(self, cr, uid, data, context): - + sql = """ - SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date_from']) - cr.execute(sql) + SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ + cr.execute(sql,(data['form']['date_from'],)) res = cr.dictfetchall() if res: if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']): @@ -116,14 +116,14 @@ def _check_date(self, cr, uid, data, context): else: raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year')) - + def _check_state(self, cr, uid, data, context): if data['form']['state'] == 'bydate': _check_date(self, cr, uid, data, context) # data['form']['fiscalyear'] = 0 # else : -# +# # data['form']['fiscalyear'] = 1 return data['form'] @@ -137,7 +137,7 @@ class wizard_report(wizard.interface): company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] data['form']['company_id'] = company_id fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear') - + data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid) #periods_obj=pooler.get_pool(cr.dbname).get('account.period') #data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) diff --git a/addons/account/wizard/wizard_open_closed_fiscalyear.py b/addons/account/wizard/wizard_open_closed_fiscalyear.py index f3c434b5f2d..cbc46316484 100644 --- a/addons/account/wizard/wizard_open_closed_fiscalyear.py +++ b/addons/account/wizard/wizard_open_closed_fiscalyear.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -43,7 +43,7 @@ def _remove_entries(self, cr, uid, data, context): period_journal = data_fyear.end_journal_period_id ids_move = pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)]) if ids_move: - cr.execute('delete from account_move where id in ('+','.join(map(str, ids_move))+')') + cr.execute('delete from account_move where id =ANY(%s)',(ids_move,)) #cr.execute('UPDATE account_journal_period ' \ # 'SET state = %s ' \ # 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)', @@ -60,17 +60,17 @@ class open_closed_fiscal(wizard.interface): 'init' : { 'actions' : [], 'result': { - 'type': 'form', + 'type': 'form', 'arch': form, - 'fields': fields, + 'fields': fields, 'state':[('end','Cancel'),('open','Open')] } }, 'open': { 'actions': [], 'result': { - 'type':'action', - 'action':_remove_entries, + 'type':'action', + 'action':_remove_entries, 'state':'end' }, }, diff --git a/addons/account/wizard/wizard_partner_balance_report.py b/addons/account/wizard/wizard_partner_balance_report.py index 142aeeb682c..f7b049a4f0f 100644 --- a/addons/account/wizard/wizard_partner_balance_report.py +++ b/addons/account/wizard/wizard_partner_balance_report.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -74,14 +74,14 @@ period_fields = { } class wizard_report(wizard.interface): - + def _get_defaults(self,cr,uid,data,context): user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context) if user.company_id: company_id = user.company_id.id else: company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] - + fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear') periods_obj=pooler.get_pool(cr.dbname).get('account.period') data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid) @@ -91,25 +91,24 @@ class wizard_report(wizard.interface): data['form']['fiscalyear'] = False data['form']['result_selection'] = 'all' return data['form'] - + def _check_state(self, cr, uid, data, context): - + if data['form']['state'] == 'bydate' : self._check_date(cr, uid, data, context) return data['form'] - + def _check_date(self, cr, uid, data, context): - sql = """ - SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date1']) - cr.execute(sql) + SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ + cr.execute(sql,(data['form']['date1'],)) res = cr.dictfetchall() if res: if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']): raise wizard.except_wizard(_('UserError'),_('Date to must be set between %s and %s') % (str(res[0]['date_start']), str(res[0]['date_stop']))) else: return 'report' - + else: raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year')) @@ -118,7 +117,7 @@ class wizard_report(wizard.interface): 'actions': [_get_defaults], 'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel','gtk-cancel'),('report','Print','gtk-print')]} }, - + 'report': { 'actions': [_check_state], 'result': {'type':'print', 'report':'account.partner.balance', 'state':'end'} diff --git a/addons/account/wizard/wizard_refund.py b/addons/account/wizard/wizard_refund.py index 2d603abe4a4..42526f3cc0a 100644 --- a/addons/account/wizard/wizard_refund.py +++ b/addons/account/wizard/wizard_refund.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -80,17 +80,14 @@ class wiz_refund(wizard.interface): #in multi company mode cr.execute("""SELECT id from account_period where date('%s') - between date_start AND date_stop and company_id = %s limit 1 """%( - form['date'], - pool.get('res.users').browse(cr,uid,uid).company_id.id - )) + between date_start AND date_stop and company_id = %s limit 1 """, + (form['date'],pool.get('res.users').browse(cr,uid,uid).company_id.id,)) else: #in mono company mode cr.execute("""SELECT id from account_period where date('%s') - between date_start AND date_stop limit 1 """%( - form['date'], - )) + between date_start AND date_stop limit 1 """, + (form['date'],)) res = cr.fetchone() if res: period = res[0] @@ -101,10 +98,10 @@ class wiz_refund(wizard.interface): description = form['description'] else: description = inv.name - + if not period: raise wizard.except_wizard(_('Data Insufficient !'), _('No Period found on Invoice!')) - + refund_id = pool.get('account.invoice').refund(cr, uid, [inv.id],date, period, description) refund = pool.get('account.invoice').browse(cr, uid, refund_id[0]) # we compute due date @@ -112,7 +109,7 @@ class wiz_refund(wizard.interface): pool.get('account.invoice').write(cr, uid, [refund.id],{'date_due':date,'check_total':inv.check_total}) # to make the taxes calculated pool.get('account.invoice').button_compute(cr, uid, refund_id) - + created_inv.append(refund_id[0]) #if inv is paid we unreconcile if mode in ('cancel','modify'): diff --git a/addons/account/wizard/wizard_third_party_ledger.py b/addons/account/wizard/wizard_third_party_ledger.py index 43186f309c8..c89f87fd8e0 100755 --- a/addons/account/wizard/wizard_third_party_ledger.py +++ b/addons/account/wizard/wizard_third_party_ledger.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -113,8 +113,8 @@ class wizard_report(wizard.interface): def _check_date(self, cr, uid, data, context): sql = """ - SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date1']) - cr.execute(sql) + SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ + cr.execute(sql,(data['form']['date1'])) res = cr.dictfetchall() if res: if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']): diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index 241ad071af1..549d6aa06e1 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,14 +15,14 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## import operator from osv import osv, fields from osv.orm import intersect -import tools.sql +import tools.sql from tools.translate import _ @@ -34,14 +34,13 @@ class account_analytic_account(osv.osv): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: - acc_set = ",".join(map(str, ids2)) cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id IN (%s) \ + where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type = 'sale' \ - group by account_analytic_line.account_id" % acc_set) + group by account_analytic_line.account_id" ,(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) for obj_id in ids: @@ -60,7 +59,6 @@ class account_analytic_account(osv.osv): ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: # Amount uninvoiced hours to invoice at sale price - acc_set = ",".join(map(str, ids2)) cr.execute("""SELECT account_analytic_account.id, \ COALESCE(sum (product_template.list_price * \ account_analytic_line.unit_amount * \ @@ -77,11 +75,11 @@ class account_analytic_account(osv.osv): on account_analytic_account.id = account_analytic_line.account_id \ JOIN hr_timesheet_invoice_factor \ on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ - WHERE account_analytic_account.id IN (%s) \ + WHERE account_analytic_account.id =ANY(%s) \ AND account_analytic_line.invoice_id is null \ AND account_analytic_line.to_invoice IS NOT NULL \ and account_analytic_journal.type in ('purchase','general') \ - GROUP BY account_analytic_account.id;"""%acc_set) + GROUP BY account_analytic_account.id;""",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) @@ -113,16 +111,15 @@ class account_analytic_account(osv.osv): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: - acc_set = ",".join(map(str, ids2)) cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id IN (%s) \ + where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type='general' \ and invoice_id is null \ AND to_invoice IS NOT NULL \ - GROUP BY account_analytic_line.account_id;"%acc_set) + GROUP BY account_analytic_line.account_id;",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) for obj_id in ids: @@ -139,14 +136,13 @@ class account_analytic_account(osv.osv): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: - acc_set = ",".join(map(str, ids2)) cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id IN (%s) \ + where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type='general' \ - GROUP BY account_analytic_line.account_id"%acc_set) + GROUP BY account_analytic_line.account_id",(ids2,)) ff = cr.fetchall() for account_id, sum in ff: res[account_id] = round(sum,2) @@ -164,14 +160,13 @@ class account_analytic_account(osv.osv): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: - acc_set = ",".join(map(str, ids2)) cr.execute("""select account_analytic_line.account_id,COALESCE(sum(amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id IN (%s) \ + where account_analytic_line.account_id =ANY(%s) \ and amount<0 \ - GROUP BY account_analytic_line.account_id"""%acc_set) + GROUP BY account_analytic_line.account_id""",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) for obj_id in ids: @@ -189,7 +184,6 @@ class account_analytic_account(osv.osv): res2 = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: - acc_set = ",".join(map(str, ids2)) cr.execute("""select account_analytic_line.account_id as account_id, \ COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \ - (account_analytic_line.unit_amount * pt.list_price \ @@ -205,10 +199,10 @@ class account_analytic_account(osv.osv): on (a.id=account_analytic_line.account_id) \ join hr_timesheet_invoice_factor hr \ on (hr.id=a.to_invoice) \ - where account_analytic_line.account_id IN (%s) \ + where account_analytic_line.account_id =ANY(%s) \ and a.to_invoice IS NOT NULL \ and account_analytic_journal.type in ('purchase','general') - GROUP BY account_analytic_line.account_id"""%acc_set) + GROUP BY account_analytic_line.account_id""",(ids2,)) for account_id, sum in cr.fetchall(): res2[account_id] = round(sum,2) @@ -230,12 +224,11 @@ class account_analytic_account(osv.osv): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: - acc_set = ",".join(map(str, ids2)) cr.execute("select account_analytic_line.account_id, max(date) \ from account_analytic_line \ - where account_id IN (%s) \ + where account_id =ANY(%s) \ and invoice_id is null \ - GROUP BY account_analytic_line.account_id" % acc_set) + GROUP BY account_analytic_line.account_id" ,(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = sum for obj_id in ids: @@ -252,15 +245,14 @@ class account_analytic_account(osv.osv): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: - acc_set = ",".join(map(str, ids2)) cr.execute ("select account_analytic_line.account_id, \ date(max(account_invoice.date_invoice)) \ from account_analytic_line \ join account_invoice \ on account_analytic_line.invoice_id = account_invoice.id \ - where account_analytic_line.account_id IN (%s) \ + where account_analytic_line.account_id =ANY(%s) \ and account_analytic_line.invoice_id is not null \ - GROUP BY account_analytic_line.account_id"%acc_set) + GROUP BY account_analytic_line.account_id",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = sum for obj_id in ids: @@ -277,12 +269,11 @@ class account_analytic_account(osv.osv): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: - acc_set = ",".join(map(str, ids2)) cr.execute("select account_analytic_line.account_id, max(date) \ from account_analytic_line \ - where account_id IN (%s) \ + where account_id =ANY(%s) \ and invoice_id is not null \ - GROUP BY account_analytic_line.account_id;"%acc_set) + GROUP BY account_analytic_line.account_id;",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = sum for obj_id in ids: @@ -373,8 +364,7 @@ class account_analytic_account(osv.osv): ids2 = self.search(cr, uid, [('parent_id', 'child_of', [id])]) if ids2: cr.execute('SELECT DISTINCT(month_id) FROM account_analytic_analysis_summary_month ' \ - 'WHERE account_id in (' + ','.join([str(x) for x in ids2]) + ') ' \ - 'AND unit_amount <> 0.0') + 'WHERE account_id =ANY(%s) AND unit_amount <> 0.0',(ids2,)) res[id] = [int(id * 1000000 + int(x[0])) for x in cr.fetchall()] else: res[id] = [] @@ -388,11 +378,10 @@ class account_analytic_account(osv.osv): ids2 = self.search(cr, uid, [('parent_id', 'child_of', [id])]) if ids2: cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \ - 'WHERE account_id in (' + ','.join([str(x) for x in ids2]) + ') ' \ - 'AND unit_amount <> 0.0') + 'WHERE account_id =ANY(%s) AND unit_amount <> 0.0',(ids2,)) res[id] = [int((id * max_user) + x[0]) for x in cr.fetchall()] else: - res[id] = [] + res[id] = [] return res _columns ={ @@ -432,13 +421,11 @@ class account_analytic_account_summary_user(osv.osv): account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] account_ids2 = account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)]) - user_set = ','.join([str(x) for x in user_ids]) if account_ids2: - acc_set = ','.join([str(x) for x in account_ids2]) cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ - 'WHERE account_id in (%s) ' \ - 'AND "user" in (%s) ' % (acc_set, user_set)) + 'WHERE account_id =ANY(%s) ' \ + 'AND "user" =ANY(%s)',(account_ids2, user_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: @@ -599,14 +586,11 @@ class account_analytic_account_summary_month(osv.osv): account_ids = [int(str(int(x))[:-6]) for x in ids] month_ids = [int(str(int(x))[-6:]) for x in ids] account_ids2 = account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)]) - month_set = ','.join([str(x) for x in month_ids]) if account_ids2: - acc_set = ','.join([str(x) for x in account_ids2]) cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_month ' \ - 'WHERE account_id in (%s) ' \ - 'AND month_id in (%s) ' % \ - (acc_set, month_set)) + 'WHERE account_id =ANY(%s) ' \ + 'AND month_id =ANY(%s) ',(account_ids2, month_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: diff --git a/addons/account_budget/crossovered_budget.py b/addons/account_budget/crossovered_budget.py index 6ac17d59863..0fdb10c89a6 100644 --- a/addons/account_budget/crossovered_budget.py +++ b/addons/account_budget/crossovered_budget.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -51,7 +51,7 @@ class account_budget_post(osv.osv): 'sequence': lambda *a: 1, 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.budget.post', context=c) } - _order = "sequence, name" + _order = "sequence, name" def spread(self, cr, uid, ids, fiscalyear_id=False, amount=0.0): dobj = self.pool.get('account.budget.post.dotation') @@ -76,8 +76,10 @@ class account_budget_post_dotation(osv.osv): total_days=strToDate(obj_period.date_stop) - strToDate(obj_period.date_start) budget_id=line.post_id and line.post_id.id or False - query="select id from crossovered_budget_lines where general_budget_id= '"+ str(budget_id) + "' AND (date_from >='" +obj_period.date_start +"' and date_from <= '"+obj_period.date_stop + "') OR (date_to >='" +obj_period.date_start +"' and date_to <= '"+obj_period.date_stop + "') OR (date_from <'" +obj_period.date_start +"' and date_to > '"+obj_period.date_stop + "')" - cr.execute(query) + query="select id from crossovered_budget_lines where \ + general_budget_id= %s AND (date_from >=%s and date_from <= %s ) \ + OR (date_to >=%s and date_to <= %s) OR (date_from < %s and date_to > %s)" + cr.execute(query,(budget_id,obj_period.date_start,obj_period.date_stop,obj_period.date_start,obj_period.date_stop,obj_period.date_start,obj_period.date_stop,)) res1=cr.fetchall() tot_planned=0.00 @@ -175,10 +177,9 @@ class crossovered_budget_lines(osv.osv): date_from = context['wizard_date_from'] if context.has_key('wizard_date_to'): date_to = context['wizard_date_to'] - - cr.execute("select sum(amount) from account_analytic_line where account_id=%%s and (date " - "between to_date(%%s,'yyyy-mm-dd') and to_date(%%s,'yyyy-mm-dd')) and " - "general_account_id in (%s)" % ",".join(map(str,acc_ids)), (line.analytic_account_id.id, date_from, date_to )) + cr.execute("select sum(amount) from account_analytic_line where account_id=%s and (date " + "between to_date(%s,'yyyy-mm-dd') and to_date(%s,'yyyy-mm-dd')) and " + "general_account_id=ANY(%s)", (line.analytic_account_id.id, date_from, date_to,acc_ids,)) result = cr.fetchone()[0] if result is None: result = 0.00 @@ -213,7 +214,7 @@ class crossovered_budget_lines(osv.osv): elapsed = min(strToDate(line.date_to),strToDate(date_to)) - max(strToDate(line.date_from),strToDate(date_from)) if strToDate(date_to) < strToDate(line.date_from): elapsed = strToDate(date_to) - strToDate(date_to) - + if total.days: theo_amt = float(elapsed.days/float(total.days))*line.planned_amount else: diff --git a/addons/account_budget/report/analytic_account_budget_report.py b/addons/account_budget/report/analytic_account_budget_report.py index 7be79fc64b5..07e8bb27d12 100644 --- a/addons/account_budget/report/analytic_account_budget_report.py +++ b/addons/account_budget/report/analytic_account_budget_report.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -65,13 +65,11 @@ class analytic_account_budget_report(report_sxw.rml_parse): if not b_line_ids: return [] - bd_lines_ids = ','.join([str(x) for x in b_line_ids]) - d_from=form['date_from'] d_to=form['date_to'] # bd_ids = ','.join([str(x) for x in budget_lines]) - self.cr.execute('select distinct(crossovered_budget_id) from crossovered_budget_lines where id in (%s)'%(bd_lines_ids)) + self.cr.execute('select distinct(crossovered_budget_id) from crossovered_budget_lines where id =ANY(%s)',(b_line_ids,)) budget_ids=self.cr.fetchall() context={'wizard_date_from':d_from,'wizard_date_to':d_to} diff --git a/addons/account_budget/report/crossovered_budget_report.py b/addons/account_budget/report/crossovered_budget_report.py index c7a95585aa2..54be05e8d72 100644 --- a/addons/account_budget/report/crossovered_budget_report.py +++ b/addons/account_budget/report/crossovered_budget_report.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -71,10 +71,8 @@ class budget_report(report_sxw.rml_parse): if not budget_ids: return [] - b_line_ids=','.join([str(x) for x in budget_ids]) - # bd_ids = ','.join([str(x) for x in budget_lines]) - self.cr.execute('select distinct(analytic_account_id) from crossovered_budget_lines where id in (%s)'%(b_line_ids)) + self.cr.execute('select distinct(analytic_account_id) from crossovered_budget_lines where id =ANY(%s)',(budget_ids,)) an_ids=self.cr.fetchall() context={'wizard_date_from':d_from,'wizard_date_to':d_to} diff --git a/addons/account_chart/i18n/it.po b/addons/account_chart/i18n/it.po index 0a18bba9493..265ed870a9b 100644 --- a/addons/account_chart/i18n/it.po +++ b/addons/account_chart/i18n/it.po @@ -7,16 +7,16 @@ msgstr "" "Project-Id-Version: OpenERP Server 5.0.0\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2009-09-08 13:46+0000\n" -"Last-Translator: Fabien (Open ERP) \n" +"PO-Revision-Date: 2010-01-29 07:09+0000\n" +"Last-Translator: Stefano Prenna \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2009-12-16 05:27+0000\n" +"X-Launchpad-Export-Date: 2010-01-30 04:40+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account_chart #: model:ir.module.module,description:account_chart.module_meta_information msgid "Remove minimal account chart" -msgstr "" +msgstr "Rimuovi il grafico del conto minimo" diff --git a/addons/account_payment/account_move_line.py b/addons/account_payment/account_move_line.py index 0c7f61928c3..07fbcbbb237 100644 --- a/addons/account_payment/account_move_line.py +++ b/addons/account_payment/account_move_line.py @@ -42,7 +42,7 @@ class account_move_line(osv.osv): WHERE move_line_id = ml.id AND po.state != 'cancel') as amount FROM account_move_line ml - WHERE id in (%s)""" % (",".join(map(str,map(int, ids))))) + WHERE id =ANY(%s)""" ,(ids,)) r=dict(cr.fetchall()) return r diff --git a/addons/account_payment/payment.py b/addons/account_payment/payment.py index b52576f5be7..8f68bdaf46f 100644 --- a/addons/account_payment/payment.py +++ b/addons/account_payment/payment.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -100,7 +100,7 @@ class payment_order(osv.osv): ('draft', 'Draft'), ('open','Confirmed'), ('cancel','Cancelled'), - ('done','Done')], 'State', select=True, + ('done','Done')], 'State', select=True, help='When an order is placed the state is \'Draft\'.\n Once the bank is confirmed the state is set to \'Confirmed\'.\n Then the order is paid the state is \'Done\'.'), 'line_ids': fields.one2many('payment.line','order_id','Payment lines',states={'done':[('readonly',True)]}), 'total': fields.function(_total, string="Total", method=True, @@ -225,8 +225,8 @@ class payment_line(osv.osv): from account_move_line ml inner join payment_line pl on (ml.id = pl.move_line_id) - where pl.id in (%s)"""% - (self.translate(name), ','.join(map(str, ids)))) + where pl.id =ANY(%s)""", + (self.translate(name),ids,)) res = dict(cr.fetchall()) if name == 'partner_id': diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index 0c6f605c0e2..1b1258b8630 100755 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -406,7 +406,7 @@ class account_voucher(osv.osv): def action_number(self, cr, uid, ids, *args): cr.execute('SELECT id, type, number, move_id, reference ' \ 'FROM account_voucher ' \ - 'WHERE id IN ('+','.join(map(str, ids))+')') + 'WHERE id =ANY(%s)',(ids,)) for (id, invtype, number, move_id, reference) in cr.fetchall(): if not number: number = self.pool.get('ir.sequence').get(cr, uid, invtype) @@ -417,13 +417,13 @@ class account_voucher(osv.osv): ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_voucher SET number=%s ' \ - 'WHERE id=%d', (number, id)) + 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ - 'WHERE move_id=%d AND (ref is null OR ref = \'\')', + 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ - 'WHERE account_move_line.move_id = %d ' \ + 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) return True diff --git a/addons/auction/auction.py b/addons/auction/auction.py index 4ae909240a3..2955d97b501 100644 --- a/addons/auction/auction.py +++ b/addons/auction/auction.py @@ -95,12 +95,12 @@ class auction_dates(osv.osv): RETURN: True """ # objects vendus mais non factures - cr.execute('select count(*) as c from auction_lots where auction_id in ('+','.join(map(str, ids))+') and state=%s and obj_price>0', ('draft',)) + cr.execute('select count(*) as c from auction_lots where auction_id =ANY(%s) and state=%s and obj_price>0', (ids,'draft',)) nbr = cr.fetchone()[0] ach_uids = {} - cr.execute('select id from auction_lots where auction_id in ('+','.join(map(str, ids))+') and state=%s and obj_price>0', ('draft',)) + cr.execute('select id from auction_lots where auction_id =ANY(%s) and state=%s and obj_price>0', (ids,'draft',)) r=self.pool.get('auction.lots').lots_invoice(cr, uid, [x[0] for x in cr.fetchall()],{},None) - cr.execute('select id from auction_lots where auction_id in ('+','.join(map(str, ids))+') and obj_price>0') + cr.execute('select id from auction_lots where auction_id =ANY(%s) and obj_price>0',(ids,)) ids2 = [x[0] for x in cr.fetchall()] # for auction in auction_ids: c=self.pool.get('auction.lots').seller_trans_create(cr, uid, ids2,{}) @@ -113,7 +113,7 @@ auction_dates() # Deposits #---------------------------------------------------------- def _inv_uniq(cr, ids): - cr.execute('select name from auction_deposit where id in ('+','.join(map(lambda x: str(x), ids))+')') + cr.execute('select name from auction_deposit where id =ANY(%s)',(ids,)) for datas in cr.fetchall(): cr.execute('select count(*) from auction_deposit where name=%s', (datas[0],)) if cr.fetchone()[0]>1: @@ -229,7 +229,7 @@ def _type_get(self, cr, uid,ids): # Lots #---------------------------------------------------------- def _inv_constraint(cr, ids): - cr.execute('select id, bord_vnd_id, lot_num from auction_lots where id in ('+','.join(map(lambda x: str(x), ids))+')') + cr.execute('select id, bord_vnd_id, lot_num from auction_lots where id =ANY(%s)', (ids,)) for datas in cr.fetchall(): cr.execute('select count(*) from auction_lots where bord_vnd_id=%s and lot_num=%s', (datas[1],datas[2])) if cr.fetchone()[0]>1: diff --git a/addons/auction/report/auction_total_rml.py b/addons/auction/report/auction_total_rml.py index ea6b6ad72ec..0e207db62bc 100644 --- a/addons/auction/report/auction_total_rml.py +++ b/addons/auction/report/auction_total_rml.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -54,7 +54,7 @@ class auction_total_rml(report_sxw.rml_parse): for lot_id in objects: auc_lot_ids.append(lot_id.id) self.total_obj=auc_lot_ids - self.cr.execute('select auction_id from auction_lots where id in ('+','.join(map(str,auc_lot_ids))+') group by auction_id') + self.cr.execute('select auction_id from auction_lots where id =ANY(%s) group by auction_id',(auc_lot_ids,)) auc_date_ids = self.cr.fetchall() auct_dat=[] for ad_id in auc_date_ids: @@ -64,52 +64,52 @@ class auction_total_rml(report_sxw.rml_parse): def sum_taxes(self,auction_id): - self.cr.execute("select count(1) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s group by auction_id ", (auction_id,)) + self.cr.execute("select count(1) from auction_lots where id =ANY(%s) and auction_id=%s group by auction_id ", (self.total_obj,auction_id,)) res = self.cr.fetchone() return res[0] def sold_item(self, object_id): - self.cr.execute("select count(1) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and state in ('unsold') ", (object_id,)) + self.cr.execute("select count(1) from auction_lots where id =ANY(%s) and auction_id=%s and state in ('unsold') ", (self.total_obj,object_id,)) res = self.cr.fetchone() return str(res[0]) def sum_buyer(self, auction_id): - self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and (ach_uid is not null or ach_login is not null) ", (auction_id,)) + self.cr.execute("select count(*) from auction_lots where id =ANY(%s) and auction_id=%s and (ach_uid is not null or ach_login is not null) ", (self.total_obj,auction_id,)) res = self.cr.fetchone() return str(res[0]) def sum_seller(self, auction_id): - self.cr.execute("select count(distinct bord_vnd_id) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s AND bord_vnd_id is not null ", (auction_id,)) + self.cr.execute("select count(distinct bord_vnd_id) from auction_lots where id =ANY(%s) and auction_id=%s AND bord_vnd_id is not null ", (self.total_obj,auction_id,)) res = self.cr.fetchone() return res[0] def sum_adj(self, auction_id): - self.cr.execute("select sum(obj_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s ", (auction_id,)) + self.cr.execute("select sum(obj_price) from auction_lots where id =ANY(%s) and auction_id=%s ", (self.total_obj,auction_id,)) res = self.cr.fetchone() return str(res[0]) def count_take(self, auction_id): - self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and ach_emp='True' ", (auction_id,)) + self.cr.execute("select count(*) from auction_lots where id =ANY(%s) and auction_id=%s and ach_emp='True' ", (self.total_obj,auction_id,)) res = self.cr.fetchone() return str(res[0]) def chek_paid(self, auction_id): - self.cr.execute("select count(1) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and ((paid_ach='T') or (is_ok='T')) ", (auction_id,)) + self.cr.execute("select count(1) from auction_lots where id =ANY(%s) and auction_id=%s and ((paid_ach='T') or (is_ok='T')) ", (self.total_obj,auction_id,)) res = self.cr.fetchone() return str(res[0]) def check_paid_seller(self,auction_id): - self.cr.execute("select sum(seller_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and paid_vnd != 'T' ", (auction_id,)) + self.cr.execute("select sum(seller_price) from auction_lots where id =ANY(%s) and auction_id=%s and paid_vnd != 'T' ", (self.total_obj,auction_id,)) res = self.cr.fetchone() return str(res[0]) or 0.0 def sum_credit(self,auction_id): - self.cr.execute("select sum(buyer_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s", (auction_id,)) + self.cr.execute("select sum(buyer_price) from auction_lots where id =ANY(%s) and auction_id=%s", (self.total_obj,auction_id,)) res = self.cr.fetchone() return str(res[0]) def sum_debit_buyer(self,auction_id): - self.cr.execute("select sum(buyer_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s", (auction_id,)) + self.cr.execute("select sum(buyer_price) from auction_lots where id =ANY(%s) and auction_id=%s", (self.total_obj,auction_id,)) res = self.cr.fetchone() return str(res[0] or 0) @@ -121,27 +121,27 @@ class auction_total_rml(report_sxw.rml_parse): def sum_credit_seller(self, object_id): - self.cr.execute("select sum(seller_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s", (object_id,)) + self.cr.execute("select sum(seller_price) from auction_lots where id =ANY(%s) and auction_id=%s", (self.total_obj,object_id,)) res = self.cr.fetchone() return str(res[0] or 0) def sum_minadj(self, auction_id): - self.cr.execute('select sum(lot_est1) from auction_lots where id in ('+','.join(map(str,self.total_obj))+') and auction_id=%s', (auction_id,)) + self.cr.execute('select sum(lot_est1) from auction_lots where id =ANY(%s) and auction_id=%s', (self.total_obj,auction_id,)) res = self.cr.fetchone() return str(res[0]) or 0 def sum_maxadj(self, auction_id): - self.cr.execute('select sum(lot_est2) from auction_lots where id in ('+','.join(map(str,self.total_obj))+') and auction_id=%s', (auction_id,)) + self.cr.execute('select sum(lot_est2) from auction_lots where id =ANY(%s) and auction_id=%s', (self.total_obj,auction_id,)) res = self.cr.fetchone() return str(res[0]) or 0 def sum_buyer_paid(self, auction_id): - self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and state = 'paid' ", (auction_id,)) + self.cr.execute("select count(*) from auction_lots where id =ANY(%s) and auction_id=%s and state = 'paid' ", (self.total_obj,auction_id,)) res = self.cr.fetchone() return str(res[0]) def count_comm(self, auction_id): - self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%s and obj_comm is not null ", (auction_id,)) + self.cr.execute("select count(*) from auction_lots where id =ANY(%s) and auction_id=%s and obj_comm is not null ", (self.total_obj,auction_id,)) res = self.cr.fetchone() return str(res[0]) diff --git a/addons/auction/report/buyer_list.py b/addons/auction/report/buyer_list.py index cb35640e8b6..06430efdc85 100644 --- a/addons/auction/report/buyer_list.py +++ b/addons/auction/report/buyer_list.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -49,7 +49,7 @@ class buyer_list(report_sxw.rml_parse): for lot_id in objects: auc_lot_ids.append(lot_id.id) self.auc_lot_ids=auc_lot_ids - self.cr.execute('select auction_id from auction_lots where id in ('+','.join(map(str,auc_lot_ids))+') group by auction_id') + self.cr.execute('select auction_id from auction_lots where id =ANY(%s) group by auction_id',(auc_lot_ids,)) auc_date_ids = self.cr.fetchall() auct_dat=[] for ad_id in auc_date_ids: @@ -70,7 +70,7 @@ class buyer_list(report_sxw.rml_parse): auc_date_ids = self.pool.get('auction.dates').search(self.cr,self.uid,([('name','like',obj['name'])])) # self.cr.execute('select ach_uid,count(1) as no_lot, sum(obj_price) as adj_price, sum(buyer_price)-sum(obj_price) as buyer_cost ,sum(buyer_price) as to_pay from auction_lots where id in ('+','.join(map(str,self.auc_lot_ids))+') and auction_id=%s and ach_uid is not null group by ach_uid ', (auc_date_ids[0],)) - self.cr.execute('select ach_login as ach_uid,count(1) as no_lot, sum(obj_price) as adj_price, sum(buyer_price)-sum(obj_price) as buyer_cost ,sum(buyer_price) as to_pay from auction_lots where id in ('+','.join(map(str,self.auc_lot_ids))+') and auction_id=%s and ach_login is not null group by ach_login order by ach_login', (auc_date_ids[0],)) + self.cr.execute('select ach_login as ach_uid,count(1) as no_lot, sum(obj_price) as adj_price, sum(buyer_price)-sum(obj_price) as buyer_cost ,sum(buyer_price) as to_pay from auction_lots where id =ANY(%s) and auction_id=%s and ach_login is not null group by ach_login order by ach_login', (self.auc_lot_ids,auc_date_ids[0],)) res = self.cr.dictfetchall() for r in res: # if r['ach_uid']: diff --git a/addons/auction/report/catalog2.py b/addons/auction/report/catalog2.py index 95a72889f97..3eb993c55ce 100644 --- a/addons/auction/report/catalog2.py +++ b/addons/auction/report/catalog2.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -125,8 +125,8 @@ class auction_catalog(report_rml): auction_ids = [] for test in ab: if test.has_key('auction_id'): - auction_ids.append(str(test['auction_id'][0])) - cr.execute('select * from auction_lots where auction_id in ('+ ','.join(auction_ids)+')') + auction_ids.append(test['auction_id'][0]) + cr.execute('select * from auction_lots where auction_id =ANY(%s)',(auction_ids,)) res = cr.dictfetchall() for cat in res: product =doc.createElement('product') diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 84d9a744fe8..da335fda91c 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -27,6 +27,7 @@ from tools.translate import _ import base64 import pooler import re +import tools import vobject # O-1 Optional and can come only once @@ -84,7 +85,7 @@ def get_attribute_mapping(cr, uid, calname, context={}): if not res.get('uid', None): res['uid'] = {} res['uid']['field'] = 'id' - res[attr]['type'] = "integer" + res['uid']['type'] = "integer" return res def map_data(cr, uid, obj): @@ -170,17 +171,23 @@ class CalDAV(object): self.__attribute__[name][type] = None return True - def parse_ics(self, cr, uid, child): + def parse_ics(self, cr, uid, child, cal_children=None, context=None): att_data = [] for cal_data in child.getChildren(): if cal_data.name.lower() == 'attendee': + ctx = context.copy() + if cal_children: + ctx.update({'model': cal_children[cal_data.name.lower()]}) attendee = self.pool.get('basic.calendar.attendee') - att_data.append(attendee.import_cal(cr, uid, cal_data)) + att_data.append(attendee.import_cal(cr, uid, cal_data, context=ctx)) self.ical_set(cal_data.name.lower(), att_data, 'value') continue if cal_data.name.lower() == 'valarm': alarm = self.pool.get('basic.calendar.alarm') - vals = alarm.import_cal(cr, uid, cal_data) + ctx = context.copy() + if cal_children: + ctx.update({'model': cal_children[cal_data.name.lower()]}) + vals = alarm.import_cal(cr, uid, cal_data, context=ctx) self.ical_set(cal_data.name.lower(), vals, 'value') continue if cal_data.name.lower() in self.__attribute__: @@ -190,9 +197,7 @@ class CalDAV(object): def create_ics(self, cr, uid, datas, name, ical, context=None): if not datas: - model = context.get('model', None) - war_str = "No data available" + (model and " for " + model) or "" - raise osv.except_osv(_('Warning !'), _(war_str)) + return for data in datas: vevent = ical.add(name) for field in self.__attribute__.keys(): @@ -212,7 +217,8 @@ class CalDAV(object): r_ids = map(lambda x: x[0], cr.fetchall()) if r_ids: rdata = self.pool.get(model).read(cr, uid, r_ids) - rcal = self.export_cal(cr, uid, rdata, context=context) + event_obj = self.pool.get('basic.calendar.event') + rcal = event_obj.export_cal(cr, uid, rdata, context=context) for revents in rcal.contents['vevent']: ical.contents['vevent'].append(revents) if data.get('recurrent_uid', None): @@ -225,12 +231,14 @@ class CalDAV(object): data[map_field], vevent, context=context) elif field == 'valarm' and data[map_field]: model = self.__attribute__[field].get('object', False) + ctx = context.copy() + ctx.update({'model': model}) alarm_obj = self.pool.get('basic.calendar.alarm') vevent = alarm_obj.export_cal(cr, uid, model, \ - data[map_field][0], vevent, context=context) + data[map_field][0], vevent, context=ctx) elif data[map_field]: if map_type in ("char", "text"): - vevent.add(field).value = str(data[map_field]) + vevent.add(field).value = tools.ustr(data[map_field]) elif map_type in ('datetime', 'date') and data[map_field]: if field in ('exdate'): vevent.add(field).value = [parser.parse(data[map_field])] @@ -239,12 +247,12 @@ class CalDAV(object): elif map_type == "timedelta": vevent.add(field).value = timedelta(hours=data[map_field]) elif map_type == "many2one": - vevent.add(field).value = data.get(map_field)[1] + vevent.add(field).value = tools.ustr(data.get(map_field)[1]) elif map_type in ("float", "integer"): vevent.add(field).value = str(data.get(map_field)) elif map_type == "selection": if not self.ical_get(field, 'mapping'): - vevent.add(field).value = (data[map_field]).upper() + vevent.add(field).value = (tools.ustr(data[map_field])).upper() else: for key1, val1 in self.ical_get(field, 'mapping').items(): if val1 == data[map_field]: @@ -291,7 +299,7 @@ class CalDAV(object): res = [] for child in parsedCal.getChildren(): if child.name.lower() in ('vevent', 'vtodo'): - vals = self.parse_ics(cr, uid, child) + vals = self.parse_ics(cr, uid, child, context=context) else: vals = {} continue @@ -329,21 +337,18 @@ class Calendar(CalDAV, osv.osv): } def export_cal(self, cr, uid, datas, vobj='vevent', context={}): - try: - cal = self.browse(cr, uid, datas[0]) - ical = vobject.iCalendar() - for line in cal.line_ids: - if line.name in ('alarm', 'attendee'): - continue - mod_obj = self.pool.get(line.object_id.model) - data_ids = mod_obj.search(cr, uid, eval(line.domain), context=context) - datas = mod_obj.read(cr, uid, data_ids, context=context) - context.update({'model': line.object_id.model}) - self.__attribute__ = get_attribute_mapping(cr, uid, line.name, context) - self.create_ics(cr, uid, datas, line.name, ical, context=context) - return ical.serialize() - except Exception, e: - raise osv.except_osv(('Error !'), (str(e))) + cal = self.browse(cr, uid, datas[0]) + ical = vobject.iCalendar() + for line in cal.line_ids: + if line.name in ('valarm', 'attendee'): + continue + mod_obj = self.pool.get(line.object_id.model) + data_ids = mod_obj.search(cr, uid, eval(line.domain), context=context) + datas = mod_obj.read(cr, uid, data_ids, context=context) + context.update({'model': line.object_id.model}) + self.__attribute__ = get_attribute_mapping(cr, uid, line.name, context) + self.create_ics(cr, uid, datas, line.name, ical, context=context) + return ical.serialize() def import_cal(self, cr, uid, content, data_id=None, context=None): ical_data = base64.decodestring(content) @@ -359,7 +364,7 @@ class Calendar(CalDAV, osv.osv): if child.name.lower() in cal_children: context.update({'model': cal_children[child.name.lower()]}) self.__attribute__ = get_attribute_mapping(cr, uid, child.name.lower(), context=context) - val = self.parse_ics(cr, uid, child) + val = self.parse_ics(cr, uid, child, cal_children=cal_children, context=context) obj = self.pool.get(cal_children[child.name.lower()]) if hasattr(obj, 'check_import'): obj.check_import(cr, uid, [val], context=context) @@ -374,7 +379,7 @@ class basic_calendar_line(osv.osv): _description = 'Calendar Lines' _columns = { 'name': fields.selection([('vevent', 'Event'), ('vtodo', 'TODO'), \ - ('alarm', 'Alarm'), \ + ('valarm', 'Alarm'), \ ('attendee', 'Attendee')], \ string="Type", size=64), 'object_id': fields.many2one('ir.model', 'Object'), @@ -423,6 +428,51 @@ class basic_calendar_fields(osv.osv): _defaults = { 'fn': lambda *a: 'field', } + + def check_line(self, cr, uid, vals, name, context=None): + f_obj = self.pool.get('ir.model.fields') + field = f_obj.browse(cr, uid, vals['field_id'], context=context) + relation = field.relation + line_obj = self.pool.get('basic.calendar.lines') + l_id = line_obj.search(cr, uid, [('name', '=', name)]) + if l_id: + line = line_obj.browse(cr, uid, l_id, context=context)[0] + line_rel = line.object_id.model + if (relation != 'NULL') and (not relation == line_rel): + raise osv.except_osv(_('Warning !'), _('Please provide proper configuration of "%s" in Calendar Lines' % (name))) + return True + + def create(self, cr, uid, vals, context={}): + cr.execute('select name from basic_calendar_attributes \ + where id=%s' % (vals.get('name'))) + name = cr.fetchone() + name = name[0] + if name in ('valarm', 'attendee'): + self.check_line(cr, uid, vals, name, context=context) + cr.execute("Select count(id) from basic_calendar_fields \ + where name=%s and type_id=%s" % (vals.get('name'), vals.get('type_id'))) + res = cr.fetchone() + if res: + if res[0] > 0: + raise osv.except_osv(_('Warning !'), _('Can not map same field more than once')) + return super(basic_calendar_fields, self).create(cr, uid, vals, context=context) + + def write(self, cr, uid, ids, vals, context=None): + if not vals: + return + for id in ids: + field = self.browse(cr, uid, id, context=context) + name = field.name.name + if name in ('valarm', 'attendee'): + self.check_line(cr, uid, vals, name, context=context) + qry = "Select count(id) from basic_calendar_fields \ + where name=%s and type_id=%s" % (field.name.id, field.type_id.id) + cr.execute(qry) + res = cr.fetchone() + if res: + if res[0] > 1: + raise osv.except_osv(_('Warning !'), _('Can not map same field more than once')) + return super(basic_calendar_fields, self).write(cr, uid, ids, vals, context) basic_calendar_fields() @@ -584,11 +634,14 @@ class Alarm(CalDAV, osv.osv_memory): trigger.value = delta # Compute other details - valarm.add('DESCRIPTION').value = alarm_data['name'] + valarm.add('DESCRIPTION').value = alarm_data['name'] or 'OpenERP' valarm.add('ACTION').value = alarm_data['action'] return vevent - def import_cal(self, cr, uid, ical_data): + def import_cal(self, cr, uid, ical_data, context=None): + ctx = context.copy() + ctx.update({'model': context.get('model', None)}) + self.__attribute__ = get_attribute_mapping(cr, uid, self._calname, ctx) for child in ical_data.getChildren(): if child.name.lower() == 'trigger': seconds = child.value.seconds @@ -638,7 +691,10 @@ class Attendee(CalDAV, osv.osv_memory): 'language': None, # Use: 0-1 Specify the language for text values in a property or property parameter. } - def import_cal(self, cr, uid, ical_data): + def import_cal(self, cr, uid, ical_data, context=None): + ctx = context.copy() + ctx.update({'model': context.get('model', None)}) + self.__attribute__ = get_attribute_mapping(cr, uid, self._calname, ctx) for para in ical_data.params: if para.lower() == 'cn': self.ical_set(para.lower(), ical_data.params[para][0]+':'+ \ @@ -652,7 +708,9 @@ class Attendee(CalDAV, osv.osv_memory): def export_cal(self, cr, uid, model, attendee_ids, vevent, context={}): attendee_object = self.pool.get(model) - self.__attribute__ = get_attribute_mapping(cr, uid, self._calname, context) + ctx = context.copy() + ctx.update({'model': model}) + self.__attribute__ = get_attribute_mapping(cr, uid, self._calname, ctx) for attendee in attendee_object.read(cr, uid, attendee_ids, []): attendee_add = vevent.add('attendee') cn_val = '' @@ -662,9 +720,10 @@ class Attendee(CalDAV, osv.osv_memory): attendee_add.params[a_key] = [str(attendee[a_val['field']])] elif a_val['type'] == 'boolean': attendee_add.params[a_key] = [str(attendee[a_val['field']])] - if a_val['field'] == 'cn': + if a_val['field'] == 'cn' and attendee[a_val['field']]: cn_val = [str(attendee[a_val['field']])] - attendee_add.params['CN'] = cn_val + if cn_val: + attendee_add.params['CN'] = cn_val return vevent Attendee() diff --git a/addons/base_calendar/base_calendar_view.xml b/addons/base_calendar/base_calendar_view.xml index 0165e483f53..f5b4a274a95 100644 --- a/addons/base_calendar/base_calendar_view.xml +++ b/addons/base_calendar/base_calendar_view.xml @@ -19,7 +19,7 @@ - +
diff --git a/addons/base_calendar/wizard/wizard_cal_subscribe.py b/addons/base_calendar/wizard/wizard_cal_subscribe.py index 8146e7bb1fa..709c61d0b25 100644 --- a/addons/base_calendar/wizard/wizard_cal_subscribe.py +++ b/addons/base_calendar/wizard/wizard_cal_subscribe.py @@ -66,13 +66,14 @@ class cal_event_subscribe_wizard(wizard.interface): model_obj = pooler.get_pool(cr.dbname).get(model) context.update({'url': data['form']['url_path'], 'model': data.get('model')}) - vals = model_obj.import_cal(cr, uid, base64.encodestring(caldata), context) + vals = model_obj.import_cal(cr, uid, base64.encodestring(caldata), \ + data['id'], context) if vals: cnt = vals['count'] return {} def _result_set(self, cr, uid, data, context=None): - return {'msg': 'Subscribed %s Event(s)' % cnt} + return {'msg': 'Import Sucessful.'} states = { 'init': { diff --git a/addons/base_contact/i18n/lv.po b/addons/base_contact/i18n/lv.po index 9afb9c5b56d..584612133cc 100644 --- a/addons/base_contact/i18n/lv.po +++ b/addons/base_contact/i18n/lv.po @@ -8,13 +8,13 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2009-10-08 08:06+0000\n" -"Last-Translator: Fabien (Open ERP) \n" +"PO-Revision-Date: 2010-01-31 20:05+0000\n" +"Last-Translator: Rinalds \n" "Language-Team: Latvian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2009-12-16 05:08+0000\n" +"X-Launchpad-Export-Date: 2010-02-01 04:45+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: base_contact @@ -195,7 +195,7 @@ msgstr "Kategorijas" #. module: base_contact #: field:res.partner.contact,function_id:0 msgid "Main Function" -msgstr "" +msgstr "Pamatfunkcija" #. module: base_contact #: model:process.transition,note:base_contact.process_transition_partnertoaddress0 diff --git a/addons/base_module_merge/i18n/sq.po b/addons/base_module_merge/i18n/sq.po index 8486fc65258..7cec4156152 100644 --- a/addons/base_module_merge/i18n/sq.po +++ b/addons/base_module_merge/i18n/sq.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-01-27 04:45+0000\n" +"X-Launchpad-Export-Date: 2010-01-29 04:53+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: base_module_merge diff --git a/addons/base_module_merge/i18n/vi.po b/addons/base_module_merge/i18n/vi.po index bb3cd1c2cd4..6b897955b51 100644 --- a/addons/base_module_merge/i18n/vi.po +++ b/addons/base_module_merge/i18n/vi.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-01-27 04:45+0000\n" +"X-Launchpad-Export-Date: 2010-01-29 04:53+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: base_module_merge diff --git a/addons/base_module_quality/speed_test/speed_test.py b/addons/base_module_quality/speed_test/speed_test.py index 92b73a1cafa..ab50afe1293 100644 --- a/addons/base_module_quality/speed_test/speed_test.py +++ b/addons/base_module_quality/speed_test/speed_test.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -45,8 +45,9 @@ This test checks the speed of the module. Note that at least 5 demo data is need # remove osv_memory class becaz it does not have demo data if obj_list: - cr.execute("select w.res_model from ir_actions_todo as t left join ir_act_window as w on t.action_id=w.id where w.res_model in ('%s')"% ("','".join(obj_list))) + cr.execute("select w.res_model from ir_actions_todo as t left join ir_act_window as w on t.action_id=w.id where w.res_model =ANY(%s)",(obj_list,)) res = cr.fetchall() + print res for remove_obj in res: if remove_obj and (remove_obj[0] in obj_list): obj_list.remove(remove_obj[0]) diff --git a/addons/base_setup/i18n/it.po b/addons/base_setup/i18n/it.po index 262a33abdf7..0f78558505a 100644 --- a/addons/base_setup/i18n/it.po +++ b/addons/base_setup/i18n/it.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 5.0.0\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2009-09-08 14:11+0000\n" -"Last-Translator: Fabien (Open ERP) \n" +"PO-Revision-Date: 2010-01-29 14:07+0000\n" +"Last-Translator: Carlo \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2009-12-16 05:10+0000\n" +"X-Launchpad-Export-Date: 2010-01-30 04:39+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: base_setup @@ -165,6 +165,9 @@ msgid "" "We suggest you to put bank information here:\n" "IBAN: BE74 1262 0121 6907 - SWIFT: CPDF BE71 - VAT: BE0477.472.701" msgstr "" +"Questa frase apparirà al fondo dei report.\n" +"Si possono inserire le coordinate bancarie qui:\n" +"IBAN: BE74 1262 0121 6907 - SWIFT: CPDF BE71 - VAT: BE0477.472.701" #. module: base_setup #: wizard_field:base_setup.base_setup,company,country_id:0 @@ -270,7 +273,7 @@ msgstr "Logo" #. module: base_setup #: model:ir.module.module,shortdesc:base_setup.module_meta_information msgid "Base Setup" -msgstr "" +msgstr "Configurazione di base" #. module: base_setup #: wizard_button:base_setup.base_setup,company,init:0 diff --git a/addons/board/board.py b/addons/board/board.py index 7ea9fa9f1dc..29e8a3310b4 100644 --- a/addons/board/board.py +++ b/addons/board/board.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -24,9 +24,9 @@ from osv import fields,osv class board_board(osv.osv): _name = 'board.board' - + def create_view(self, cr, uid, ids, context): - + board = self.pool.get('board.board').browse(cr, uid, ids, context) left = [] right = [] @@ -52,23 +52,22 @@ class board_board(osv.osv): """ % ('\n'.join(left), '\n'.join(right)) - + return arch def write(self, cr, uid, ids, vals, context={}): result = super(board_board, self).write(cr, uid, ids, vals, context) cr.commit() - + board = self.pool.get('board.board').browse(cr, uid, ids[0]) - + view = self.create_view(cr, uid, ids[0], context) id = board.view_id.id - - cr.execute("update ir_ui_view set arch='%s' where id=%s" % (view, id)) + cr.execute("update ir_ui_view set arch=%s where id=%s" , (view, id)) cr.commit() - + return result - + def create(self, cr, user, vals, context=None): if not 'name' in vals: return False @@ -84,31 +83,31 @@ class board_board(osv.osv): super(board_board, self).write(cr, user, [id], {'view_id': view_id}, context) return id - + def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = {} res = super(board_board, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu) - + vids = self.pool.get('ir.ui.view.custom').search(cr, user, [('user_id','=',user), ('ref_id','=',view_id)]) if vids: view_id = vids[0] arch = self.pool.get('ir.ui.view.custom').browse(cr, user, view_id) res['arch'] = arch.arch - + res['toolbar'] = {'print':[],'action':[],'relate':[]} return res - + _columns = { 'name': fields.char('Dashboard', size=64, required=True), 'view_id': fields.many2one('ir.ui.view', 'Board View'), 'line_ids': fields.one2many('board.board.line', 'board_id', 'Action Views') } - + # the following lines added to let the button on dashboard work. _defaults = { 'name': lambda *args: 'Dashboard' } - + board_board() class board_line(osv.osv): diff --git a/addons/board/i18n/it.po b/addons/board/i18n/it.po index a1bf5c5ecfc..80b1555039f 100644 --- a/addons/board/i18n/it.po +++ b/addons/board/i18n/it.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 5.0.0\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2009-09-08 12:29+0000\n" -"Last-Translator: Fabien (Open ERP) \n" +"PO-Revision-Date: 2010-01-29 14:08+0000\n" +"Last-Translator: Carlo \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2009-12-16 05:20+0000\n" +"X-Launchpad-Export-Date: 2010-01-30 04:40+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: board @@ -37,7 +37,7 @@ msgstr "Autore" #. module: board #: model:ir.module.module,shortdesc:board.module_meta_information msgid "Dashboard main module" -msgstr "" +msgstr "Modulo principale cruscotti" #. module: board #: view:board.note:0 @@ -53,7 +53,7 @@ msgstr "Larghezza" #. module: board #: constraint:ir.actions.act_window:0 msgid "Invalid model name in the action definition." -msgstr "" +msgstr "Nome del modulo non valido nella definizione dell'azione." #. module: board #: field:board.board.line,name:0 @@ -137,7 +137,7 @@ msgstr "Dashboard" #. module: board #: model:ir.module.module,description:board.module_meta_information msgid "Base module for all dashboards." -msgstr "" +msgstr "Modulo base per tutti i cruscotti." #. module: board #: field:board.board.line,position:0 diff --git a/addons/caldav/caldav.py b/addons/caldav/caldav.py index 34cc3fcf74f..5741f645b1e 100644 --- a/addons/caldav/caldav.py +++ b/addons/caldav/caldav.py @@ -215,6 +215,15 @@ request was delegated to"), def do_decline(self, cr, uid, ids, context=None, *args): self.write(cr, uid, ids, {'state': 'declined'}, context) + def create(self, cr, uid, vals, context={}): + if not vals.get("email") and vals.get("cn"): + cnval = vals.get("cn").split(':') + email = filter(lambda x:x.__contains__('@'), cnval) + vals['email'] = email[0] + vals['cn'] = vals.get("cn") + res = super(calendar_attendee, self).create(cr, uid, vals, context) + return res + calendar_attendee() class res_alarm(osv.osv): @@ -252,6 +261,9 @@ are both optional, but if one occurs, so MUST the other"""), model_obj = self.pool.get(model) for data in model_obj.browse(cr, uid, ids): basic_alarm = data.alarm_id + if not context.get('alarm_id'): + self.do_alarm_unlink(cr, uid, [data.id], model) + return True self.do_alarm_unlink(cr, uid, [data.id], model) if basic_alarm: vals = { @@ -297,7 +309,7 @@ res_alarm() class calendar_alarm(osv.osv): _name = 'calendar.alarm' _description = 'Event alarm information' - _inherits = {'res.alarm': "alarm_id"} + _inherit = 'res.alarm' __attribute__ = {} _columns = { @@ -616,6 +628,8 @@ rule or repeating pattern for anexception to a recurrence set"), def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): + if not context: + context = {} if isinstance(ids, (str, int, long)): select = [ids] else: @@ -626,9 +640,10 @@ rule or repeating pattern for anexception to a recurrence set"), if not id in new_ids: new_ids.append(id) res = super(calendar_event, self).write(cr, uid, new_ids, vals, context=context) - if vals.has_key('alarm_id'): + if vals.has_key('alarm_id') or vals.has_key('caldav_alarm_id'): alarm_obj = self.pool.get('res.alarm') - alarm_obj.do_alarm_create(cr, uid, new_ids, self._name, 'date') + context.update({'alarm_id': vals.get('alarm_id')}) + alarm_obj.do_alarm_create(cr, uid, new_ids, self._name, 'date', context=context) return res def browse(self, cr, uid, ids, context=None, list_class=None, fields_process={}): @@ -849,8 +864,7 @@ class virtual_report_spool(web_services.report_spool): new_ids = [] for id in ids: new_ids.append(caldav_id2real_id(id)) - datas['id'] = caldav_id2real_id(datas['id']) - super(virtual_report_spool, self).exp_report(db, uid, object, new_ids, datas, context) + datas['id'] = caldav_id2real_id(datas['id']) return super(virtual_report_spool, self).exp_report(db, uid, object, new_ids, datas, context) virtual_report_spool() diff --git a/addons/caldav/caldav_data.xml b/addons/caldav/caldav_data.xml index b909bf1dc82..295b05ba540 100644 --- a/addons/caldav/caldav_data.xml +++ b/addons/caldav/caldav_data.xml @@ -143,7 +143,7 @@
- alarm + valarm @@ -170,13 +170,6 @@ field - - - - - field - - @@ -198,13 +191,6 @@ field - - - - - field - - @@ -219,13 +205,6 @@ field - - - - - field - - @@ -284,13 +263,6 @@ - - - - - field - - @@ -298,13 +270,6 @@ field - - - - - field - - @@ -333,13 +298,6 @@ field - - - - - field - - @@ -347,13 +305,6 @@ field - - - - - field - - @@ -368,13 +319,6 @@ field - - - - - hours - - @@ -422,7 +366,7 @@ - + field @@ -450,7 +394,7 @@ - + field diff --git a/addons/caldav/caldav_view.xml b/addons/caldav/caldav_view.xml index 06050f03b5a..559c45485cc 100644 --- a/addons/caldav/caldav_view.xml +++ b/addons/caldav/caldav_view.xml @@ -260,5 +260,9 @@ new + + diff --git a/addons/crm/__terp__.py b/addons/crm/__terp__.py index d01f083c2d9..5ef83f99cbe 100644 --- a/addons/crm/__terp__.py +++ b/addons/crm/__terp__.py @@ -85,7 +85,7 @@ between mails and Open ERP.""", 'crm_helpdesk_menu.xml', #'crm_report.xml', 'security/crm_security.xml', - #'security/ir.model.access.csv', + 'security/ir.model.access.csv', 'process/crm_configuration_process.xml' ], diff --git a/addons/crm/crm.py b/addons/crm/crm.py index f1b4eab309b..ed4735a55e8 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -79,7 +79,7 @@ class crm_case_section(osv.osv): def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): - cr.execute('select distinct parent_id from crm_case_section where id in ('+','.join(map(str, ids))+')') + cr.execute('select distinct parent_id from crm_case_section where id =ANY(%s)',(ids,)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False @@ -908,8 +908,7 @@ class users(osv.osv): _description = "Users" _columns = { 'context_section_id': fields.selection(_section_get, 'Sales Section'), - } - + } users() diff --git a/addons/crm/crm_helpdesk_view.xml b/addons/crm/crm_helpdesk_view.xml index 112440cef68..af702600e28 100644 --- a/addons/crm/crm_helpdesk_view.xml +++ b/addons/crm/crm_helpdesk_view.xml @@ -26,8 +26,9 @@
- - + + + @@ -127,7 +128,7 @@ - +