From fe59ee430bd9ed8532b43a300661634c19f4ce86 Mon Sep 17 00:00:00 2001 From: Rucha Patel Date: Mon, 27 Oct 2008 11:29:28 +0530 Subject: [PATCH] Some Changes in warning module bzr revid: ruchakpatel@gmail.com-20081027055928-samavuvg9c36gxqm --- addons/account/project/project.py | 48 ++--------- addons/account/project/project_view.xml | 13 --- addons/account/project/wizard/__init__.py | 1 - .../wizard/wizard_account_analytic_line1.py | 83 ------------------- addons/warning/warning.py | 18 ++-- 5 files changed, 17 insertions(+), 146 deletions(-) delete mode 100644 addons/account/project/wizard/wizard_account_analytic_line1.py diff --git a/addons/account/project/project.py b/addons/account/project/project.py index 60a1704bb2d..b4cc3468e5f 100644 --- a/addons/account/project/project.py +++ b/addons/account/project/project.py @@ -43,32 +43,17 @@ class account_analytic_account(osv.osv): _description = 'Analytic Accounts' def _credit_calc(self, cr, uid, ids, name, arg, context={}): - if 'date_start' in context and context['date_start']: - date_start = context['date_start'] - else: - date_start = time.strftime('%Y-01-01') - if 'date_stop' in context and context['date_stop']: - date_stop = context['date_stop'] - else: - date_stop = time.strftime('%Y-%m-%d') 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) AND (l.date BETWEEN '%s' and '%s') GROUP BY a.id" % (acc_set,date_start,date_stop)) + 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()) for i in ids: r.setdefault(i,0.0) return r def _debit_calc(self, cr, uid, ids, name, arg, context={}): - if 'date_start' in context and context['date_start']: - date_start = context['date_start'] - else: - date_start = time.strftime('%Y-01-01') - if 'date_stop' in context and context['date_stop']: - date_stop = context['date_stop'] - else: - date_stop = time.strftime('%Y-%m-%d') + 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) AND (l.date BETWEEN '%s' and '%s') GROUP BY a.id" % (acc_set,date_start,date_stop)) + 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()) for i in ids: r.setdefault(i,0.0) @@ -77,18 +62,9 @@ class account_analytic_account(osv.osv): def _balance_calc(self, cr, uid, ids, name, arg, context={}): - if 'date_start' in context and context['date_start']: - date_start = context['date_start'] - else: - date_start = time.strftime('%Y-01-01') - if 'date_stop' in context and context['date_stop']: - date_stop = context['date_stop'] - else: - date_stop = time.strftime('%Y-%m-%d') 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) AND (l.date BETWEEN '%s' and '%s') GROUP BY a.id" % (acc_set,date_start,date_stop)) -# 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.date BETWEEN '2008-10-01' AND '2008-10-03') GROUP BY a.id") + 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) res = {} for account_id, sum in cr.fetchall(): res[account_id] = sum @@ -115,21 +91,13 @@ class account_analytic_account(osv.osv): return dict([(i, res[i]) for i in ids ]) def _quantity_calc(self, cr, uid, ids, name, arg, context={}): -# XXX must convert into one uom - if 'date_start' in context and context['date_start']: - date_start = context['date_start'] - else: - date_start = time.strftime('%Y-01-01') - if 'date_stop' in context and context['date_stop']: - date_stop = context['date_stop'] - else: - date_stop = time.strftime('%Y-%m-%d') + #XXX must convert into one uom ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) acc_set = ",".join(map(str, ids2)) - cr.execute("SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \ + 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 a.id IN (%s) AND (l.date BETWEEN '%s' and '%s') GROUP BY a.id" % (acc_set,date_start,date_stop)) + WHERE a.id IN ('+acc_set+') GROUP BY a.id') res = {} for account_id, sum in cr.fetchall(): res[account_id] = sum @@ -139,8 +107,6 @@ class account_analytic_account(osv.osv): if child <> id: res.setdefault(id, 0.0) res[id] += res.get(child, 0.0) - if not id in res: - res.setdefault(id, 0.0) return dict([(i, res[i]) for i in ids]) def name_get(self, cr, uid, ids, context={}): diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index 11975d9a6b8..74ce6a354e9 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -88,25 +88,12 @@ form,graph - - - - - - - New Analytic Account account.analytic.account diff --git a/addons/account/project/wizard/__init__.py b/addons/account/project/wizard/__init__.py index 66cce97becb..477e5262a00 100644 --- a/addons/account/project/wizard/__init__.py +++ b/addons/account/project/wizard/__init__.py @@ -35,7 +35,6 @@ 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_account_analytic_line1 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/wizard/wizard_account_analytic_line1.py b/addons/account/project/wizard/wizard_account_analytic_line1.py deleted file mode 100644 index c8e0d3952e6..00000000000 --- a/addons/account/project/wizard/wizard_account_analytic_line1.py +++ /dev/null @@ -1,83 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved. -# -# $Id$ -# -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company -# -# 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 2 -# 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, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################## - -import wizard -import pooler -import time - -def _action_open_window(self, cr, uid, data, context): - domain=[] - cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('account.analytic.account.tree', 'tree')) - view_res = cr.fetchone() - return { - 'name': 'Analytic Entries', - 'view_type': 'tree', - "view_mode": 'tree,form', - 'res_model': 'account.analytic.account', - 'type': 'ir.actions.act_window', - 'view_id' : view_res, - 'domain' :[('parent_id','=',False)], - 'context':{'date_start':data['form']['from_date'],'date_stop':data['form']['to_date']}, - } - - -class account_analytic_line1(wizard.interface): - form1 = ''' -
- - - - - -