diff --git a/addons/account/account.py b/addons/account/account.py index a55428c8612..3ca1b53b91b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -654,7 +654,8 @@ class account_journal_period(osv.osv): 'period_id': fields.many2one('account.period', 'Period', required=True, ondelete="cascade"), 'icon': fields.function(_icon_get, method=True, string='Icon', type='string'), 'active': fields.boolean('Active', required=True), - 'state': fields.selection([('draft','Draft'), ('printed','Printed'), ('done','Done')], 'Status', required=True, readonly=True) + 'state': fields.selection([('draft','Draft'), ('printed','Printed'), ('done','Done')], 'Status', required=True, readonly=True), + 'fiscalyear_id': fields.related('period_id', 'fiscalyear_id', string='Fiscal Year', type='many2one', relation='account.fiscalyear'), } def _check(self, cr, uid, ids, context={}): @@ -1550,7 +1551,7 @@ class account_model_line(osv.osv): 'ref': fields.char('Ref.', size=16), - 'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optionnal other currency."), + 'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency."), 'currency_id': fields.many2one('res.currency', 'Currency'), 'partner_id': fields.many2one('res.partner', 'Partner Ref.'), @@ -2285,7 +2286,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): for tax in position.tax_ids: vals_tax = { 'tax_src_id' : tax_template_ref[tax.tax_src_id.id], - 'tax_dest_id' : tax_template_ref[tax.tax_dest_id.id], + 'tax_dest_id' : tax.tax_dest_id and tax_template_ref[tax.tax_dest_id.id] or False, 'position_id' : new_fp, } obj_tax_fp.create(cr, uid, vals_tax) diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index 975069231ef..aff75a80192 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -84,7 +84,7 @@ class account_analytic_line(osv.osv): a = prod.categ_id.property_account_expense_categ.id if not a: raise osv.except_osv(_('Error !'), - _('There is no expense account define ' \ + _('There is no expense account defined ' \ 'for this product: "%s" (id:%d)') % \ (prod.name, prod.id,)) amount = unit_amount * uom_obj._compute_price(cr, uid, diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index d16ea4dcbf6..9715598eb9c 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -170,8 +170,8 @@ - - + + @@ -257,8 +257,8 @@ - - + + diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 128ad3e24b9..a6b4556a373 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -40,16 +40,22 @@ class account_move_line(osv.osv): else: fiscalyear_clause = '%s' % context['fiscalyear'] state=context.get('state',False) - where_move_state='' + where_move_state = '' + where_move_lines_by_date = '' + + if context.get('date_from', False) and context.get('date_to', False): + where_move_lines_by_date = " AND " +obj+".move_id in ( select id from account_move where date >= '" +context['date_from']+"' AND date <= '"+context['date_to']+"')" + if state: if state.lower() not in ['all']: where_move_state= " AND "+obj+".move_id in (select id from account_move where account_move.state = '"+state+"')" - + + if context.get('periods', False): ids = ','.join([str(x) for x in context['periods']]) - return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s" % (fiscalyear_clause, ids,where_move_state) + return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids,where_move_state,where_move_lines_by_date) else: - return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s)" % (fiscalyear_clause,where_move_state) + return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s %s)" % (fiscalyear_clause,where_move_state,where_move_lines_by_date) def default_get(self, cr, uid, fields, context={}): data = self._default_get(cr, uid, fields, context) @@ -342,8 +348,8 @@ class account_move_line(osv.osv): 'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=1), 'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=2), 'reconcile_partial_id': fields.many2one('account.move.reconcile', 'Partial Reconcile', readonly=True, ondelete='set null', select=2), - 'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optionnal other currency if it is a multi-currency entry."), - 'currency_id': fields.many2one('res.currency', 'Currency', help="The optionnal other currency if it is a multi-currency entry."), + 'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry."), + 'currency_id': fields.many2one('res.currency', 'Currency', help="The optional other currency if it is a multi-currency entry."), 'period_id': fields.many2one('account.period', 'Period', required=True, select=2), 'journal_id': fields.many2one('account.journal', 'Journal', required=True, select=1), diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 2a4116ce472..ebb0c4ff0cd 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1038,7 +1038,8 @@ tree - + + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index e48863315a3..b15d2884078 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -357,11 +357,16 @@ class account_invoice(osv.osv): pt_obj= self.pool.get('account.payment.term') if not date_invoice : date_invoice = time.strftime('%Y-%m-%d') - pterm_list= pt_obj.compute(cr, uid, payment_term_id, value=1, date_ref=date_invoice) + + pterm_list = pt_obj.compute(cr, uid, payment_term_id, value=1, date_ref=date_invoice) + if pterm_list: pterm_list = [line[0] for line in pterm_list] pterm_list.sort() res= {'value':{'date_due': pterm_list[-1]}} + else: + raise osv.except_osv(_('Data Insufficient !'), _('The Payment Term of Supplier does not have Payment Term Lines(Computation) defined !')) + return res def onchange_invoice_line(self, cr, uid, ids, lines): @@ -491,7 +496,6 @@ class account_invoice(osv.osv): company_currency = inv.company_id.currency_id.id # create the analytical lines line_ids = self.read(cr, uid, [inv.id], ['invoice_line'])[0]['invoice_line'] - ils = self.pool.get('account.invoice.line').read(cr, uid, line_ids) # one move line per invoice line iml = self._get_analytic_lines(cr, uid, inv.id) # check if taxes are all computed @@ -897,17 +901,18 @@ account_invoice() class account_invoice_line(osv.osv): def _amount_line(self, cr, uid, ids, prop, unknow_none,unknow_dict): - res = {} - cur_obj=self.pool.get('res.currency') - for line in self.browse(cr, uid, ids): - if line.invoice_id: - res[line.id] = line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0) - cur = line.invoice_id.currency_id - res[line.id] = cur_obj.round(cr, uid, cur, res[line.id]) - else: - res[line.id] = round(line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0),2) - return res - + res = {} + cur_obj=self.pool.get('res.currency') + for line in self.browse(cr, uid, ids): + if line.invoice_id: + res[line.id] = line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0) + cur = line.invoice_id.currency_id + res[line.id] = cur_obj.round(cr, uid, cur, res[line.id]) + else: + res[line.id] = round(line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0),2) + return res + + def _price_unit_default(self, cr, uid, context=None): if context is None: context = {} @@ -1098,9 +1103,23 @@ class account_invoice_tax(osv.osv): 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', help="The tax basis of the tax declaration."), 'tax_amount': fields.float('Tax Code Amount', digits=(16,2)), } - def base_change(self, cr, uid, ids, base): + def base_change(self, cr, uid, ids, base,currency_id=False,company_id=False,date_invoice=False): + cur_obj = self.pool.get('res.currency') + company_obj = self.pool.get('res.company') + company_currency=False + if company_id: + company_currency=company_obj.browse(cr,uid,company_id).id + if currency_id and company_currency: + base=cur_obj.compute(cr, uid, currency_id, company_currency, base, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'base_amount':base}} - def amount_change(self, cr, uid, ids, amount): + def amount_change(self, cr, uid, ids, amount,currency_id=False,company_id=False,date_invoice=False): + cur_obj = self.pool.get('res.currency') + company_obj = self.pool.get('res.company') + company_currency=False + if company_id: + company_currency=company_obj.browse(cr,uid,company_id).id + if currency_id and company_currency: + amount=cur_obj.compute(cr, uid, currency_id, company_currency, amount, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'tax_amount':amount}} _order = 'sequence' _defaults = { diff --git a/addons/account/project/report/analytic_journal.rml b/addons/account/project/report/analytic_journal.rml index 96383420a1f..d7570aa8943 100644 --- a/addons/account/project/report/analytic_journal.rml +++ b/addons/account/project/report/analytic_journal.rml @@ -98,8 +98,8 @@ [[ move.name ]] [[ move.account_id.code ]] - [[ move.account_id.name ]] - [[ formatLang(move.debit-move.credit) ]] + diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index 7c98f32089a..1ced4a117b9 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -60,55 +60,26 @@ class account_balance(report_sxw.rml_parse): 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)) - res=self.cr.fetchall() + res = self.cr.fetchall() + len_res = len(res) for r in res: - if (r == res[res.__len__()-1]): + if (r == res[len_res-1]): result+=r[0]+". " else: result+=r[0]+", " + else: + fy_obj = self.pool.get('account.fiscalyear').browse(self.cr,self.uid,form['fiscalyear']) + res = fy_obj.period_ids + len_res = len(res) + for r in res: + if r == res[len_res-1]: + result+=r.name+". " + else: + result+=r.name+", " + return str(result and result[:-1]) or '' - def transform_both_into_date_array(self,data): - if not data['periods'][0][2] : - periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) - else: - periods_id = data['periods'][0][2] - date_array = [] - for period_id in periods_id: - period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) - date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop) - - period_start_date = date_array[0] - date_start_date = data['date_from'] - period_stop_date = date_array[-1] - date_stop_date = data['date_to'] - - if period_start_date 0 or res['debit'] > 0 or res['balance'] > 0 : result_acc.append(res) @@ -175,51 +154,18 @@ class account_balance(report_sxw.rml_parse): result_acc.append(res) else: result_acc.append(res) - if account.child_id: - acc_id = [acc.id for acc in account.child_id] - lst_string = '' - lst_string = '\'' + '\',\''.join(map(str,acc_id)) + '\'' - self.cr.execute("select code,id from account_account where id IN (%s)"%(lst_string)) - a_id = self.cr.fetchall() - a_id.sort() - ids2 = [x[1] for x in a_id] - - result_acc += self.lines(form, ids2, done, level+1) - +# if account.child_id: +# acc_id = [acc.id for acc in account.child_id] +# lst_string = '' +# lst_string = '\'' + '\',\''.join(map(str,acc_id)) + '\'' +# self.cr.execute("select code,id from account_account where id IN (%s)"%(lst_string)) +# a_id = self.cr.fetchall() +# a_id.sort() +# ids2 = [x[1] for x in a_id] +# +# result_acc += self.lines(form, ids2, done, level+1) return result_acc - - def date_range(self,start,end): - start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d"))) - end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d"))) - full_str_date = [] - # - r = (end+datetime.timedelta(days=1)-start).days - # - date_array = [start+datetime.timedelta(days=i) for i in range(r)] - for date in date_array: - full_str_date.append(str(date)) - return full_str_date - - # - def transform_period_into_date_array(self,form): - ## Get All Period Date - if not form['periods'][0][2] : - periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',form['fiscalyear'])]) - else: - periods_id = form['periods'][0][2] - date_array = [] - for period_id in periods_id: - period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) - date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop) - - self.date_lst = date_array - self.date_lst.sort() - - def transform_date_into_date_array(self,form): - return_array = self.date_range(form['date_from'],form['date_to']) - self.date_lst = return_array - self.date_lst.sort() - + 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 c268c643537..447aa7a5cb8 100644 --- a/addons/account/report/aged_trial_balance.py +++ b/addons/account/report/aged_trial_balance.py @@ -61,7 +61,7 @@ class aged_trial_report(rml_parse.rml_parse): 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,account_move_reconcile AS recon " \ + "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 ))) " \ diff --git a/addons/account/report/general_ledger.rml b/addons/account/report/general_ledger.rml index 09c071f4d6e..ed2d3dae324 100644 --- a/addons/account/report/general_ledger.rml +++ b/addons/account/report/general_ledger.rml @@ -41,7 +41,7 @@ - + @@ -90,7 +90,7 @@ - + [[ repeatIn(objects, 'a') ]] [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] Date @@ -102,10 +102,11 @@ Crebit Balance - - - [[ repeatIn(objects, 'a') ]] - [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] + +
+ [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] + @@ -115,28 +116,30 @@ [[formatLang(sum_credit_account(o, data['form'])) ]] [[formatLang(sum_solde_account(o, data['form'])) ]] - - [[ repeatIn(lines(o, data['form']), 'line') ]] - - - [[ formatLang(line['date'],date=True) ]] - [[ line['partner'] or '']] - [[ line['ref'] or '']] - [[ line['move'] or '']] - [[ line['name'] or '' ]] - [[ formatLang(line['debit']) ]] - [[ formatLang(line['credit']) ]] - [[ formatLang(line['progress']) ]] - - - - - - - - - - + + + + + + + + + + + + [[ repeatIn(lines(o, data['form']), 'line') ]] [[ formatLang(line['date'],date=True) ]] + [[ line['partner'] or '']] + [[ line['ref'] or '']] + [[ line['move'] or '']] + [[ line['name'] or '' ]] + [[ formatLang(line['debit']) ]] + [[ formatLang(line['credit']) ]] + [[ formatLang(line['progress']) ]] + + +
+ + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] @@ -150,10 +153,11 @@ Balance Currency - - - [[ repeatIn(objects, 'a') ]] - [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] + +
+ [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] + @@ -164,29 +168,30 @@ [[formatLang(sum_solde_account(o, data['form'])) ]] [[ formatLang(sum_currency_amount_account(a, data['form'])) ]] - - [[ repeatIn(lines(o, data['form']), 'line') ]] - - - [[ formatLang(line['date'],date=True) ]] - [[ line['partner'] or '' ]] - [[ line['ref'] or '']] - [[ line['move'] or '' ]] - [[ line['name'] or '' ]] - [[ formatLang(line['debit']) ]] - [[ formatLang(line['credit']) ]] - [[ formatLang(line['progress']) ]] - [[ formatLang(line['amount_currency'] or 0.00) ]] [[ line['currency_code'] or '']] - - - - - - - - - - + + + + + + + + + + + + + [[ repeatIn(lines(o, data['form']), 'line') ]] [[ formatLang(line['date'],date=True) ]] + [[ line['partner'] or '' ]] + [[ line['ref'] or '']] + [[ line['move'] or '' ]] + [[ line['name'] or '' ]] + [[ formatLang(line['debit']) ]] + [[ formatLang(line['credit']) ]] + [[ formatLang(line['progress']) ]] + [[ formatLang(line['amount_currency'] or 0.00) ]] [[ line['currency_code'] or '']] + + +
diff --git a/addons/account/report/general_ledger_landscape.rml b/addons/account/report/general_ledger_landscape.rml index c7f955516bb..424c0e3a3f3 100644 --- a/addons/account/report/general_ledger_landscape.rml +++ b/addons/account/report/general_ledger_landscape.rml @@ -2,7 +2,7 @@ - - - - - + - - - - - @@ -91,63 +82,11 @@ - [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] + + [[ repeatIn(objects, 'a') ]] + + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] - Date - JNRL - Partner - Ref - Mvt - Entry Label - Counterpart - Debit - Credit - Balance - Currency - - - - [[ repeatIn(objects, 'a') ]] - [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - - - - - [[ o.code ]] [[ o.name ]] - - [[ formatLang(sum_debit_account(o, data['form'])) ]] - [[ formatLang(sum_credit_account(o, data['form'])) ]] - [[ formatLang(sum_solde_account(o, data['form'])) ]] - [[ formatLang(sum_currency_amount_account(o, data['form'])) ]] - - - [[ repeatIn(lines(o, data['form']), 'line') ]] - - - - [[ formatLang(line['date'],date=True) ]] - [[ line['code'] ]] - [[ line['partner'] ]] - [[ line['ref'] ]] - [[ line['move'] ]] - [[ line['name'] ]] - [[ strip_name(line['line_corresp'],55) ]] - [[ formatLang(line['debit']) ]] - [[ formatLang(line['credit']) ]] - [[ formatLang(line['progress']) ]] - [[ formatLang(line['amount_currency'] or 0.00)]] [[ line['currency_code'] ]] - - - - - - - - - - - [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] - Date JNRL Partner @@ -158,43 +97,112 @@ Debit Credit Balance - + Currency + + + +
+ + [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] + + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] + + + + + [[ o.code ]] [[ o.name ]] + + [[ formatLang(sum_debit_account(o, data['form'])) ]] + [[ formatLang(sum_credit_account(o, data['form'])) ]] + [[ formatLang(sum_solde_account(o, data['form'])) ]] + [[ formatLang(sum_currency_amount_account(o, data['form'])) ]] + + + + + + + + + + + + + + + + [[ repeatIn(lines(o, data['form']), 'line') ]] [[ formatLang(line['date'],date=True) ]] + [[ line['code'] ]] + [[ line['partner'] ]] + [[ line['ref'] ]] + [[ line['move'] ]] + [[ line['name'] ]] + [[ strip_name(line['line_corresp'],15) ]] + [[ formatLang(line['debit']) ]] + [[ formatLang(line['credit']) ]] + [[ formatLang(line['progress']) ]] + [[ formatLang(line['amount_currency'] or 0.00)]] [[ line['currency_code'] ]] + + + +
+ + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] + + Date + JNRL + Partner + Ref + Mvt + Entry Label + Counterpart + Debit + Credit + Balance + + + +
+ + [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - - [[ repeatIn(objects, 'a') ]] - [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - - - - [[ o.code ]] [[ o.name ]] - - [[ formatLang(sum_debit_account(o, data['form']))]] - [[formatLang(sum_credit_account(o, data['form']))]] - [[formatLang(sum_solde_account(o, data['form'])) ]] - - - [[ repeatIn(lines(o, data['form']), 'line') ]] - + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] + + + - - [[ formatLang(line['date'],date=True) ]] - [[ line['code'] ]] - [[ line['partner'] ]] - [[ line['ref'] ]] - [[ line['move'] ]] - [[ line['name'] ]] - [[ strip_name(line['line_corresp'],55) ]] - [[ formatLang(line['debit']) ]] - [[ formatLang(line['credit']) ]] - [[ formatLang(line['progress']) ]] - + [[ o.code ]] [[ o.name ]] + + [[ formatLang(sum_debit_account(o, data['form']))]] + [[formatLang(sum_credit_account(o, data['form']))]] + [[formatLang(sum_solde_account(o, data['form'])) ]] + - + + + + + + + + + + - - - - - + + [[ repeatIn(lines(o, data['form']), 'line') ]][[ formatLang(line['date'],date=True) ]] + [[ line['code'] ]] + [[ line['partner'] ]] + [[ line['ref'] ]] + [[ line['move'] ]] + [[ line['name'] ]] + [[ strip_name(line['line_corresp'],15) ]] + [[ formatLang(line['debit']) ]] + [[ formatLang(line['credit']) ]] + [[ formatLang(line['progress']) ]] + + + +
\ No newline at end of file diff --git a/addons/account/report/partner_balance.py b/addons/account/report/partner_balance.py old mode 100644 new mode 100755 index 852e3cb127f..6c1eb0f7534 --- a/addons/account/report/partner_balance.py +++ b/addons/account/report/partner_balance.py @@ -169,18 +169,12 @@ class partner_balance(report_sxw.rml_parse): self.transform_both_into_date_array(data) - - -# if data['form']['fiscalyear']: -# print"data['form']['fiscalyear']=True" -# self.transform_period_into_date_array(data) -# else: -# print"data['form']['fiscalyear']=False" -# self.transform_date_into_date_array(data) ## self.date_lst_string ='' if 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') # @@ -207,43 +201,6 @@ class partner_balance(report_sxw.rml_parse): account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') full_account = [] result_tmp = 0.0 - - # - # - # - if self.date_lst and data['form']['soldeinit'] : - - - self.cr.execute( - "SELECT p.ref, p.name,l.account_id,ac.name as account_name,ac.code as code , sum(debit) as debit, sum(credit) as credit, " \ - "CASE WHEN sum(debit) > sum(credit) " \ - "THEN sum(debit) - sum(credit) " \ - "ELSE 0 " \ - "END AS sdebit, " \ - "CASE WHEN sum(debit) < sum(credit) " \ - "THEN sum(credit) - sum(debit) " \ - "ELSE 0 " \ - "END AS scredit, " \ - "(SELECT sum(debit-credit) " \ - "FROM account_move_line l " \ - "WHERE partner_id = p.id " \ - "AND date < %s " \ - "AND blocked = TRUE AND l.reconcile_id IS NULL " \ - ") 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 + " " \ - "AND l.date < %s AND l.reconcile_id IS NULL " \ - "GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \ - "ORDER BY l.account_id,p.name", - (self.date_lst[0],self.date_lst[0])) - res = self.cr.dictfetchall() - - for r in res: - full_account.append(r) - # - # - # if self.date_lst_string: self.cr.execute( "SELECT p.ref,l.account_id,ac.name as account_name,ac.code as code ,p.name, sum(debit) as debit, sum(credit) as credit, " \ @@ -317,23 +274,6 @@ class partner_balance(report_sxw.rml_parse): # else: if cleanarray[i]['account_id'] <> cleanarray[i-1]['account_id']: - ## -# new_tot = {} -# new_tot['ref'] = 'Total' -# new_tot['name'] = cleanarray[i-1]['account_name'] -# new_tot['code'] = cleanarray[i-1]['code'] -# -# new_tot['debit'] = tot_debit -# new_tot['credit'] = tot_credit -# new_tot['scredit'] = tot_scredit -# new_tot['sdebit'] = tot_sdebit -# new_tot['enlitige'] = tot_enlitige -# new_tot['balance'] = float(tot_sdebit) - float(tot_scredit) -# new_tot['type'] = 3 -# ## -# completearray.append(new_tot) - - new_header['debit'] = tot_debit new_header['credit'] = tot_credit @@ -415,19 +355,6 @@ class partner_balance(report_sxw.rml_parse): return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') result_tmp = 0.0 - # - # - if self.date_lst and data['form']['soldeinit'] : - self.cr.execute( - "SELECT sum(debit) " \ - "FROM account_move_line AS l " \ - "WHERE l.account_id IN (" + self.account_ids + ") " \ - "AND l.reconcile_id IS NULL " \ - "AND date < %s ", - (self.date_lst[0],)) - result_tmp = float(self.cr.fetchone()[0] or 0.0) - # - # temp_res = 0.0 if self.date_lst_string: self.cr.execute( @@ -446,19 +373,6 @@ class partner_balance(report_sxw.rml_parse): account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') result_tmp = 0.0 - # - # - if self.date_lst and data['form']['soldeinit'] : - self.cr.execute( - "SELECT sum(credit) " \ - "FROM account_move_line AS l " \ - "WHERE l.account_id IN (" + self.account_ids + ") " \ - "AND l.reconcile_id IS NULL " \ - "AND l.date < %s " , - (self.date_lst[0],)) - result_tmp = float(self.cr.fetchone()[0] or 0.0) - # - # temp_res = 0.0 if self.date_lst_string: self.cr.execute( @@ -476,21 +390,6 @@ class partner_balance(report_sxw.rml_parse): return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') result_tmp = 0.0 - - # - # - if self.date_lst and data['form']['soldeinit'] : - self.cr.execute( - "SELECT sum(debit-credit) " \ - "FROM account_move_line AS l " \ - "WHERE l.account_id IN (" + self.account_ids + ") " \ - "AND l.reconcile_id IS NULL " \ - "AND l.date < %s " \ - "AND l.blocked=TRUE " , - (self.date_lst[0],)) - result_tmp = float(self.cr.fetchone()[0] or 0.0) - # - # temp_res = 0.0 if self.date_lst_string: self.cr.execute( @@ -509,28 +408,6 @@ class partner_balance(report_sxw.rml_parse): return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') result_tmp = 0.0 - - # - # - if self.date_lst and data['form']['soldeinit'] : - self.cr.execute( - "SELECT CASE WHEN sum(debit) > sum(credit) " \ - "THEN sum(debit) - sum(credit) " \ - "ELSE 0 " \ - "END " \ - "FROM account_move_line AS l " \ - "WHERE l.account_id IN (" + self.account_ids + ") " \ - "AND l.date < %s " \ - "AND l.reconcile_id IS NULL " \ - "GROUP BY l.partner_id", - (self.date_lst[0],)) - - if self.cr.fetchone() != None: - result_tmp = float(self.cr.fetchone()[0]) - else: - result_tmp = 0.0 - # - # a = 0.0 if self.date_lst_string: self.cr.execute( @@ -558,27 +435,6 @@ class partner_balance(report_sxw.rml_parse): account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') result_tmp = 0.0 - # - # - if self.date_lst and data['form']['soldeinit'] : - self.cr.execute( - "SELECT CASE WHEN sum(debit) < sum(credit) " \ - "THEN sum(credit) - sum(debit) " \ - "ELSE 0 " \ - "END " \ - "FROM account_move_line AS l " \ - "WHERE l.account_id IN (" + self.account_ids + ") " \ - "AND l.date <= %s " \ - "AND l.reconcile_id IS NULL " \ - "GROUP BY l.partner_id", - (self.date_lst[0],)) - - if self.cr.fetchone() != None: - result_tmp = float(self.cr.fetchone()[0]) or 0.0 - else: - result_tmp = 0.0 - # - # a = 0.0 if self.date_lst_string: self.cr.execute( @@ -591,10 +447,10 @@ class partner_balance(report_sxw.rml_parse): "AND l.date IN (" + self.date_lst_string + ") " \ "GROUP BY l.partner_id") a = self.cr.fetchone()[0] or 0.0 - + if self.cr.fetchone() != None: result_tmp = result_tmp + (a or 0.0) - + else: result_tmp = 0.0 @@ -617,4 +473,5 @@ class partner_balance(report_sxw.rml_parse): report_sxw.report_sxw('report.account.partner.balance', 'res.partner', 'account/report/partner_balance.rml',parser=partner_balance, header=False) + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/wizard_account_balance_report.py b/addons/account/wizard/wizard_account_balance_report.py index 1679fcb52bb..d8282ad440f 100644 --- a/addons/account/wizard/wizard_account_balance_report.py +++ b/addons/account/wizard/wizard_account_balance_report.py @@ -87,10 +87,10 @@ 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') - periods_obj=pooler.get_pool(cr.dbname).get('account.period') +# periods_obj=pooler.get_pool(cr.dbname).get('account.period') data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid) - data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) - data['form']['fiscalyear'] = False +# data['form']['periods'] = periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) +# data['form']['fiscalyear'] = False data['form']['display_account']='bal_all' return data['form'] @@ -98,9 +98,9 @@ class wizard_report(wizard.interface): if data['form']['state'] == 'bydate': self._check_date(cr, uid, data, context) - data['form']['fiscalyear'] = 0 - else : - data['form']['fiscalyear'] = 1 +# data['form']['fiscalyear'] = 0 +# else : +# data['form']['fiscalyear'] = 1 return data['form'] def _check_path(self, cr, uid, data, context): diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py index 7cd560e7b44..68e69941b5c 100644 --- a/addons/account/wizard/wizard_fiscalyear_close.py +++ b/addons/account/wizard/wizard_fiscalyear_close.py @@ -178,7 +178,8 @@ def _data_save(self, cr, uid, data, context): 'WHERE account_id = %s ' \ 'AND ' + query_line + ' ' \ 'ORDER BY id ' \ - 'LIMIT %s OFFSET %s', (account.id,fy_id, limit, offset)) + 'LIMIT %s OFFSET %s', (account.id, limit, offset)) + result = cr.dictfetchall() if not result: break diff --git a/addons/account/wizard/wizard_refund.py b/addons/account/wizard/wizard_refund.py index b4c8cdd7897..39d92b58a35 100644 --- a/addons/account/wizard/wizard_refund.py +++ b/addons/account/wizard/wizard_refund.py @@ -69,35 +69,31 @@ class wiz_refund(wizard.interface): if form['period'] : period = form['period'] else: - period = inv.period_id.id + period = inv.period_id and inv.period_id.id or False if form['date'] : date = form['date'] if not form['period'] : - try : - #we try in multy company mode + cr.execute("select name from ir_model_fields where model='account.period' and name='company_id'") + result_query = cr.fetchone() + if result_query: + #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 - ) - - ) - except : - #we try in mono company mode + )) + 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'], - ) - - ) + )) res = cr.fetchone() if res: period = res[0] - - else: date = inv.date_invoice @@ -105,6 +101,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 diff --git a/addons/account_analytic_plans/wizard/wizard_crossovered_analytic.py b/addons/account_analytic_plans/wizard/wizard_crossovered_analytic.py index 9b9adad9e25..483e9d54893 100644 --- a/addons/account_analytic_plans/wizard/wizard_crossovered_analytic.py +++ b/addons/account_analytic_plans/wizard/wizard_crossovered_analytic.py @@ -60,7 +60,7 @@ class wizard_crossovered_analytic(wizard.interface): break if flag: - raise wizard.except_wizard(_('User Error'),_("There are no Analytic lines related to Account '%s'" % name)) + raise wizard.except_wizard(_('User Error'),_('There are no Analytic lines related to Account %s' % name)) return {} states = { diff --git a/addons/account_budget/crossovered_budget.py b/addons/account_budget/crossovered_budget.py index 4cf09bc962a..3a41bdfe654 100644 --- a/addons/account_budget/crossovered_budget.py +++ b/addons/account_budget/crossovered_budget.py @@ -163,6 +163,7 @@ class crossovered_budget_lines(osv.osv): acc_ids = [x.id for x in line.general_budget_id.account_ids] if not acc_ids: raise osv.except_osv(_('Error!'),_("The General Budget '%s' has no Accounts!") % str(line.general_budget_id.name)) + date_to = line.date_to date_from = line.date_from if context.has_key('wizard_date_from'): diff --git a/addons/account_budget/report/analytic_account_budget_report.rml b/addons/account_budget/report/analytic_account_budget_report.rml index 8f15f8a8ecd..99a095f336e 100644 --- a/addons/account_budget/report/analytic_account_budget_report.rml +++ b/addons/account_budget/report/analytic_account_budget_report.rml @@ -1,8 +1,8 @@ -