From 3a263e0e48c41cf5527fc7f462aa3ada7cdebc2e Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Tue, 7 Apr 2009 14:48:01 +0530 Subject: [PATCH 1/6] [FIX] Bug 309832 : Analytic account view corrected bzr revid: jvo@tinyerp.com-20090407091801-eode3zwbqvwp3aqk --- .../analytic_journal_billing_rate_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/analytic_journal_billing_rate/analytic_journal_billing_rate_view.xml b/addons/analytic_journal_billing_rate/analytic_journal_billing_rate_view.xml index 6653205c05f..3288ca9daf8 100644 --- a/addons/analytic_journal_billing_rate/analytic_journal_billing_rate_view.xml +++ b/addons/analytic_journal_billing_rate/analytic_journal_billing_rate_view.xml @@ -32,7 +32,7 @@ account.analytic.account.form account.analytic.account form - + From 7dc845ef116d5745dff4f95961e251c81dcad89f Mon Sep 17 00:00:00 2001 From: OnDemand Open Object User Date: Tue, 7 Apr 2009 10:16:26 +0000 Subject: [PATCH 2/6] [FIX] crm: fix mail formating bzr revid: odoo@saas-20090407101626-tnf07sl4nz2ahwc9 --- addons/crm/crm.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 2c6bed9bca2..55f116b626e 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -510,7 +510,7 @@ class crm_case(osv.osv): return True def format_body(self, body): - return tools.ustr((body or '').encode('ascii', 'replace')) + return (body or u'').encode('utf8', 'replace') def format_mail(self, case, body): data = { @@ -526,7 +526,7 @@ class crm_case(osv.osv): 'partner': (case.partner_id and case.partner_id.name) or '/', 'partner_email': (case.partner_address_id and case.partner_address_id.email) or '/', } - return self.format_body(body) % data + return self.format_body(body % data) def email_send(self, cr, uid, case, emails, body, context={}): body = self.format_mail(case, body) @@ -534,7 +534,10 @@ class crm_case(osv.osv): emailfrom = case.user_id.address_id.email else: emailfrom = case.section_id.reply_to - tools.email_send(emailfrom, emails, '['+str(case.id)+'] '+case.name, body, reply_to=case.section_id.reply_to, tinycrm=str(case.id)) + name = '[%d] %s' % (case.id, case.name.encode('utf8')) + reply_to = case.section_id.reply_to or False + if reply_to: reply_to = reply_to.encode('utf8') + tools.email_send(emailfrom, emails, name, body, reply_to=reply_to, tinycrm=str(case.id)) return True def __log(self, cr, uid, cases, keyword, context={}): if not self.pool.get('res.partner.event.type').check(cr, uid, 'crm_case_'+keyword): From b2ae2812e511f1f69b1823c086202b946b0d3c50 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 7 Apr 2009 14:00:13 +0200 Subject: [PATCH 3/6] [FIX] account: made the invoice date searchable bzr revid: christophe@tinyerp.com-20090407120013-x6bb6tacoj2u49vi --- addons/account/account_invoice_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 1410c9bc5ac..d16ea4dcbf6 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -121,7 +121,7 @@ - + From 86597698aa994e439adbb2af281cd3fdad58165a Mon Sep 17 00:00:00 2001 From: husen daudi Date: Tue, 7 Apr 2009 17:45:46 +0530 Subject: [PATCH 4/6] bugfixed for delete invoices Bug#356854 lp bug: https://launchpad.net/bugs/356854 fixed bzr revid: hda@hda-20090407121546-91otm4hgqpzz4dv8 --- addons/account/invoice.py | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 0bd58afe90a..e48863315a3 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -290,30 +290,15 @@ class account_invoice(osv.osv): } def unlink(self, cr, uid, ids, context=None): - for inv in self.browse(cr, uid, ids, context): - print inv.name, inv.amount_total - for line in inv.invoice_line: - print line.price_subtotal -# invoices = self.read(cr, uid, ids, ['state']) -# unlink_ids = [] -# for t in invoices: -# if t['state'] in ('draft', 'cancel'): -# unlink_ids.append(t['id']) -# else: -# raise osv.except_osv(_('Invalid action !'), _('Cannot delete invoice(s) that are already opened or paid !')) -# osv.osv.unlink(self, cr, uid, unlink_ids, context=context) -# return True - - #def unlink(self, cr, uid, ids, context=None): - # invoices = self.read(cr, uid, ids, ['state']) - # unlink_ids = [] - # for t in invoices: - # if t['state'] in ('draft', 'cancel'): - # unlink_ids.append(t['id']) - # else: - # raise osv.except_osv(_('Invalid action !'), _('Cannot delete invoice(s) that are already opened or paid !')) - # osv.osv.unlink(self, cr, uid, unlink_ids, context=context) - # return True + invoices = self.read(cr, uid, ids, ['state']) + unlink_ids = [] + for t in invoices: + if t['state'] in ('draft', 'cancel'): + unlink_ids.append(t['id']) + else: + raise osv.except_osv(_('Invalid action !'), _('Cannot delete invoice(s) that are already opened or paid !')) + osv.osv.unlink(self, cr, uid, unlink_ids, context=context) + return True # def get_invoice_address(self, cr, uid, ids): # res = self.pool.get('res.partner').address_get(cr, uid, [part], ['invoice']) From 5609c037cec86730b9e5a1a5591b2fa6c0b32b0c Mon Sep 17 00:00:00 2001 From: husen daudi Date: Wed, 8 Apr 2009 12:35:28 +0530 Subject: [PATCH 5/6] Bugfix for quantity onchange on sale.order.line bzr revid: hda@hda-20090408070528-0ukeu1apbqog4v2u --- addons/warning/warning.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/warning/warning.py b/addons/warning/warning.py index 9c315f4046f..d75bfb0275e 100644 --- a/addons/warning/warning.py +++ b/addons/warning/warning.py @@ -137,7 +137,7 @@ class sale_order_line(osv.osv): def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, - fiscal_position=False): + fiscal_position=False, flag=False): warning = {} if not product: return {'value': {'th_weight' : 0, 'product_packaging': False, @@ -152,7 +152,7 @@ class sale_order_line(osv.osv): message= product_info.sale_line_warn_msg result = super(sale_order_line, self).product_id_change( cr, uid, ids, pricelist, product, qty, uom, qty_uos, uos, name, partner_id, - lang, update_tax, date_order, packaging, fiscal_position) + lang, update_tax, date_order, packaging, fiscal_position, flag) if title and message: warning['title']=title[0] warning['message']=message From ca068d9e3b5eab077bc2bc79af3659b65b2c88ec Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Wed, 8 Apr 2009 20:05:50 +0530 Subject: [PATCH 6/6] Analytic chart of Accounts: according to context and period bzr revid: jvo@tinyerp.com-20090408143550-dj2zhfz3sc6c77o5 --- addons/account/account_analytic_line.py | 15 ++++ addons/account/project/project.py | 42 ++++++++-- addons/account/project/project_view.xml | 7 +- addons/account/project/wizard/__init__.py | 1 + .../wizard/wizard_account_analytic_line.py | 12 +-- .../wizard/wizard_analytic_account_chart.py | 79 +++++++++++++++++++ 6 files changed, 140 insertions(+), 16 deletions(-) create mode 100644 addons/account/project/wizard/wizard_analytic_account_chart.py diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index c880db50fc1..975069231ef 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -48,6 +48,21 @@ class account_analytic_line(osv.osv): 'date': lambda *a: time.strftime('%Y-%m-%d'), } _order = 'date' + + + def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None): + if context is None: + context = {} + + if context.get('from_date',False): + args.append(['date', '>=',context['from_date']]) + + if context.get('to_date',False): + args.append(['date','<=',context['to_date']]) + + return super(account_analytic_line, self).search(cr, uid, args, offset, limit, + order, context=context) + def _check_company(self, cr, uid, ids): lines = self.browse(cr, uid, ids) for l in lines: diff --git a/addons/account/project/project.py b/addons/account/project/project.py index 0f6f0319916..bcec9209d22 100644 --- a/addons/account/project/project.py +++ b/addons/account/project/project.py @@ -36,8 +36,15 @@ class account_analytic_account(osv.osv): def _credit_calc(self, cr, uid, ids, name, arg, context={}): acc_set = ",".join(map(str, ids)) - 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 l.amount<0 and a.id IN (%s) GROUP BY a.id" % acc_set) - r= dict(cr.fetchall()) + + 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)) + r = dict(cr.fetchall()) for i in ids: r.setdefault(i,0.0) return r @@ -45,18 +52,30 @@ class account_analytic_account(osv.osv): def _debit_calc(self, cr, uid, ids, name, arg, context={}): acc_set = ",".join(map(str, ids)) - 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 l.amount>0 and a.id IN (%s) GROUP BY a.id" % acc_set) + + 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)) r= dict(cr.fetchall()) for i in ids: r.setdefault(i,0.0) return r - - def _balance_calc(self, cr, uid, ids, name, arg, context={}): ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) acc_set = ",".join(map(str, ids2)) - 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 a.id IN (%s) GROUP BY a.id" % acc_set) + + 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 a.id IN (%s) GROUP BY a.id" % (where_date,acc_set)) res = {} for account_id, sum in cr.fetchall(): res[account_id] = sum @@ -86,9 +105,16 @@ class account_analytic_account(osv.osv): #XXX must convert into one uom ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) acc_set = ",".join(map(str, ids2)) + + 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.unit_amount), 0) \ FROM account_analytic_account a \ - LEFT JOIN account_analytic_line l ON (a.id = l.account_id) \ + LEFT JOIN account_analytic_line l ON (a.id = l.account_id ' + where_date + ') \ WHERE a.id IN ('+acc_set+') GROUP BY a.id') res = {} for account_id, sum in cr.fetchall(): @@ -168,7 +194,7 @@ class account_analytic_account(osv.osv): _order = 'parent_id desc,code' _constraints = [ - (check_recursion, 'Error! You can not create recursive account.', ['parent_id']) + (check_recursion, 'Error! You can not create recursive analytic accounts.', ['parent_id']) ] def create(self, cr, uid, vals, context=None): diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index a417f14eca6..02842c47333 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -94,8 +94,11 @@ action="action_account_analytic_account_tree2" id="account_analytic_def_chart" parent="account_analytic_def_account"/> - - + + + + + New Analytic Account account.analytic.account diff --git a/addons/account/project/wizard/__init__.py b/addons/account/project/wizard/__init__.py index b4558079faa..c539b899fba 100644 --- a/addons/account/project/wizard/__init__.py +++ b/addons/account/project/wizard/__init__.py @@ -27,6 +27,7 @@ import wizard_account_analytic_cost_ledger_report import wizard_account_analytic_cost_ledger_for_journal_report import wizard_account_analytic_analytic_check import wizard_account_analytic_line +import wizard_analytic_account_chart # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/wizard/wizard_account_analytic_line.py b/addons/account/project/wizard/wizard_account_analytic_line.py index db90e00f3b6..8a6774617b6 100644 --- a/addons/account/project/wizard/wizard_account_analytic_line.py +++ b/addons/account/project/wizard/wizard_account_analytic_line.py @@ -26,15 +26,15 @@ import time from tools.translate import _ def _action_open_window(self, cr, uid, data, context): - domain=[] - from_date= data['form']['from_date'] - to_date=data['form']['to_date'] + domain = [] + from_date = data['form']['from_date'] + to_date = data['form']['to_date'] if from_date and to_date: - domain=[('date','>=',from_date),('date','<=',to_date)] + domain = [('date','>=',from_date),('date','<=',to_date)] elif from_date: - domain=[('date','>=',from_date)] + domain = [('date','>=',from_date)] elif to_date: - domain=[('date','<=',to_date)] + domain = [('date','<=',to_date)] return { 'name': _('Analytic Entries'), 'view_type': 'form', diff --git a/addons/account/project/wizard/wizard_analytic_account_chart.py b/addons/account/project/wizard/wizard_analytic_account_chart.py new file mode 100644 index 00000000000..43a921c614e --- /dev/null +++ b/addons/account/project/wizard/wizard_analytic_account_chart.py @@ -0,0 +1,79 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +import wizard +import pooler + +class wizard_analytic_account_chart(wizard.interface): + _account_chart_arch = ''' +
+ + + + + +