diff --git a/addons/account/account.py b/addons/account/account.py index 449a58f136d..823d07df175 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2275,7 +2275,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_invoice_view.xml b/addons/account/account_invoice_view.xml index cd383da14d1..768d3c4be49 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/invoice.py b/addons/account/invoice.py index 9ce5f2ac40b..a48a91690c7 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -382,13 +382,14 @@ class account_invoice(osv.osv): 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): @@ -917,8 +918,14 @@ 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): - res[line.id] = round(line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0),2) + 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): @@ -1111,9 +1118,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/report/account_balance.py b/addons/account/report/account_balance.py index e74ad786365..4c0adb74786 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 - + @@ -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 172261c16be..1cc14b16261 --- 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 diff --git a/addons/account/wizard/wizard_account_balance_report.py b/addons/account/wizard/wizard_account_balance_report.py index 232d2a80475..ea779289e2e 100644 --- a/addons/account/wizard/wizard_account_balance_report.py +++ b/addons/account/wizard/wizard_account_balance_report.py @@ -86,10 +86,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'] @@ -97,9 +97,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_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 @@ -