Some Changes in warning module

bzr revid: ruchakpatel@gmail.com-20081027055928-samavuvg9c36gxqm
This commit is contained in:
Rucha Patel 2008-10-27 11:29:28 +05:30
parent df9cd38b34
commit fe59ee430b
5 changed files with 17 additions and 146 deletions

View File

@ -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={}):

View File

@ -88,25 +88,12 @@
<field name="view_mode">form,graph</field>
<field name="view_id" ref="view_account_analytic_account_tree"/>
</record>
<menuitem
action="action_account_analytic_account_tree2"
id="account_analytic_def_chart"
<<<<<<< TREE
parent="account.account_analytic_def_account"/>
<!--
OVERRIDDEN BY NEW WIZARD
=======
parent="account_analytic_def_account"/>
>>>>>>> MERGE-SOURCE
<menuitem action="action_account_analytic_account_tree2" id="account_analytic_chart" parent="account.menu_finance_charts"/>
-->
<wizard id="action_analytic_account_chart" menu="False" model="account.analytic.account" name="account.analytic.line1" string="Analytic Chart of Accounts"/>
<menuitem type="wizard" icon="STOCK_INDENT" action="action_analytic_account_chart" id="account_analytic_chart" parent="account.menu_finance_charts" name="Analytic Account lines"/>
<record id="analytic_account_form" model="ir.actions.act_window">
<field name="name">New Analytic Account</field>
<field name="res_model">account.analytic.account</field>

View File

@ -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:

View File

@ -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 = '''<?xml version="1.0"?>
<form string="View Account Analytic Lines">
<separator string="Account Analytic Lines Analysis" colspan="4"/>
<field name="from_date"/>
<newline/>
<field name="to_date"/>
<newline/>
<label string=""/>
<label string="(Keep empty to open the current situation)" align="0.0" colspan="3"/>
</form>'''
form1_fields = {
'from_date': {
'string': 'From',
'type': 'date',
},
'to_date': {
'string': 'To',
'type': 'date',
},
}
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel','gtk-cancel'),('open', 'Open Entries','gtk-ok')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
account_analytic_line1('account.analytic.line1')

View File

@ -35,13 +35,13 @@ class res_partner(osv.osv):
_inherit = 'res.partner'
_columns = {
'sale_warn' : fields.boolean('Sale Order'),
'sale_warn_msg' : fields.char('Message for Sale Order', size=64),
'sale_warn_msg' : fields.text('Message for Sale Order'),
'purchase_warn' : fields.boolean('Purchase Order'),
'purchase_warn_msg' : fields.char('Message for Purchase Order', size=64),
'purchase_warn_msg' : fields.text('Message for Purchase Order'),
'picking_warn' : fields.boolean('Stock Picking'),
'picking_warn_msg' : fields.char('Message for Stock Picking', size=64),
'picking_warn_msg' : fields.text('Message for Stock Picking'),
'invoice_warn' : fields.boolean('Invoice'),
'invoice_warn_msg' : fields.char('Message for Invoice', size=64),
'invoice_warn_msg' : fields.text('Message for Invoice'),
}
res_partner()
@ -56,8 +56,10 @@ class sale_order(osv.osv):
message=False
partner = self.pool.get('res.partner').browse(cr, uid, part)
if partner.sale_warn:
title= "Message",
message=partner.sale_warn_msg
warning={
'title': "Message",
'message': partner.sale_warn_msg
}
result = super(sale_order, self).onchange_partner_id(cr, uid, ids, part)['value']
if result.get('warning',False):
@ -132,9 +134,9 @@ class product_product(osv.osv):
_inherit = 'product.product'
_columns = {
'sale_line_warn' : fields.boolean('Sale Order Line'),
'sale_line_warn_msg' : fields.char('Message for Sale Order Line', size=64),
'sale_line_warn_msg' : fields.text('Message for Sale Order Line'),
'purchase_line_warn' : fields.boolean('Purchase Order Line'),
'purchase_line_warn_msg' : fields.char('Message for Purchase Order Line', size=64),
'purchase_line_warn_msg' : fields.text('Message for Purchase Order Line'),
}
product_product()