diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py
index 5ccfbdb23d8..b71e2daa447 100644
--- a/addons/base_calendar/base_calendar.py
+++ b/addons/base_calendar/base_calendar.py
@@ -673,9 +673,10 @@ true, it will allow you to hide the event alarm information without removing it.
new_res_alarm = res_alarm_obj.create(cr, uid, val, context=context)
else:
new_res_alarm = alarm_ids[0]
- cr.execute('Update %s set base_calendar_alarm_id=%s, alarm_id=%s \
- where id=%s' % (model_obj._table, \
- cal_alarm.id, new_res_alarm, data.id))
+ cr.execute('UPDATE %s ' % model_obj._table + \
+ ' SET base_calendar_alarm_id=%s, alarm_id=%s ' \
+ ' WHERE id=%s',
+ (cal_alarm.id, new_res_alarm, data.id))
self.do_alarm_unlink(cr, uid, [data.id], model)
if basic_alarm:
@@ -697,9 +698,10 @@ true, it will allow you to hide the event alarm information without removing it.
'user_id': uid
}
alarm_id = alarm_obj.create(cr, uid, vals)
- cr.execute('Update %s set base_calendar_alarm_id=%s, alarm_id=%s \
- where id=%s' % (model_obj._table, \
- alarm_id, basic_alarm.id, data.id))
+ cr.execute('UPDATE %s ' % model_obj._table + \
+ ' SET base_calendar_alarm_id=%s, alarm_id=%s '
+ ' WHERE id=%s', \
+ ( alarm_id, basic_alarm.id, data.id) )
return True
def do_alarm_unlink(self, cr, uid, ids, model, context=None):
@@ -722,7 +724,7 @@ true, it will allow you to hide the event alarm information without removing it.
if alarm_ids:
alarm_obj.unlink(cr, uid, alarm_ids)
cr.execute('Update %s set base_calendar_alarm_id=NULL, alarm_id=NULL\
- where id=%s' % (model_obj._table, datas.id))
+ where id=%%d' % model_obj._table,(datas.id,))
return True
res_alarm()
@@ -994,10 +996,10 @@ class calendar_event(osv.osv):
context = {}
cr.execute("UPDATE %s set freq='None',interval=0,count=0,end_date=Null,\
mo=False,tu=False,we=False,th=False,fr=False,sa=False,su=False,\
- day=0,select1='date',month_list=Null ,byday=Null where id=%s" % (self._table, id))
+ day=0,select1='date',month_list=Null ,byday=Null where id=%%s" % (self._table), (id,))
if not value:
- cr.execute("UPDATE %s set rrule_type='none' where id=%s" % (self._table, id))
+ cr.execute("UPDATE %s set rrule_type='none' where id=%%s" % self._table,(id,))
return True
val = {}
for part in value.split(';'):
@@ -1063,7 +1065,7 @@ class calendar_event(osv.osv):
'rule_type': rrule_type,
'id': id,
})
- cr.execute(qry % val)
+ cr.execute(qry, val) # Hopefully psycopg2 works with dicts. But, FIXME
return True
def _get_rulestring(self, cr, uid, ids, name, arg, context=None):
@@ -1081,7 +1083,7 @@ class calendar_event(osv.osv):
if datas.get('rrule_type'):
if datas.get('rrule_type') == 'none':
result[event] = False
- cr.execute("UPDATE %s set exrule=Null where id=%s" % (self._table, event))
+ cr.execute("UPDATE %s set exrule=Null where id=%%s" % self._table,( event,))
elif datas.get('rrule_type') == 'custom':
if datas.get('interval', 0) < 0:
raise osv.except_osv('Warning!', 'Interval can not be Negative')
@@ -1258,7 +1260,7 @@ true, it will allow you to hide the event alarm information without removing it.
if defaults.get('location'):
qry += ", location = '%(location)s'"
qry += "WHERE id = %s" % (event_id)
- cr.execute(qry %(defaults))
+ cr.execute(qry, defaults)
return True
@@ -1283,8 +1285,7 @@ true, it will allow you to hide the event alarm information without removing it.
if ids and (base_start_date or base_until_date):
cr.execute("select m.id, m.rrule, m.date, m.date_deadline, m.duration, \
m.exdate, m.exrule, m.recurrent_id, m.recurrent_uid from " + self._table + \
- " m where m.id in ("\
- + ','.join(map(lambda x: str(x), ids))+")")
+ " m where m.id = ANY(%s)", (ids,) )
count = 0
for data in cr.dictfetchall():
@@ -1683,10 +1684,8 @@ class calendar_todo(osv.osv):
@param context: A standard dictionary for contextual values
"""
- event = self.browse(cr, uid, id, context=context)
- cr.execute("UPDATE %s set date_start='%s' where id=%s" \
- % (self._table, value, id))
- return True
+ assert name == 'date'
+ return self.write(cr, uid, id, { 'date_start': value }, context=context)
_columns = {
'date': fields.function(_get_date, method=True, fnct_inv=_set_date, \
diff --git a/addons/base_calendar/wizard/base_calendar_invite_attendee.py b/addons/base_calendar/wizard/base_calendar_invite_attendee.py
index 98369962ab7..47f5681addf 100644
--- a/addons/base_calendar/wizard/base_calendar_invite_attendee.py
+++ b/addons/base_calendar/wizard/base_calendar_invite_attendee.py
@@ -159,8 +159,8 @@ send an Email to Invited Person')
if not partner_id:
return {'value': {'contact_ids': []}}
- cr.execute('select id from res_partner_address \
- where partner_id=%s' % (partner_id))
+ cr.execute('SELECT id FROM res_partner_address \
+ WHERE partner_id=%s', (partner_id,))
contacts = map(lambda x: x[0], cr.fetchall())
return {'value': {'contact_ids': contacts}}
diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py
index 88b0549a3de..bcc624d6a67 100644
--- a/addons/caldav/calendar.py
+++ b/addons/caldav/calendar.py
@@ -61,10 +61,10 @@ def uid2openobjectid(cr, uidval, oomodel, rdate):
model_obj = pooler.get_pool(cr.dbname).get(model)
if (not model == oomodel) or (not dbname == cr.dbname):
return (False, None)
- qry = 'select distinct(id) from %s' % model_obj._table
+ qry = 'SELECT DISTINCT(id) FROM %s' % model_obj._table
if rdate:
- qry += " where recurrent_id='%s'" % (rdate)
- cr.execute(qry)
+ qry += " WHERE recurrent_id=%s"
+ cr.execute(qry, (rdate,))
r_id = cr.fetchone()
if r_id:
return (id, r_id[0])
@@ -364,8 +364,8 @@ class CalDAV(object):
model_obj = self.pool.get(model)
r_ids = []
if model_obj._columns.get('recurrent_uid', None):
- cr.execute('select id from %s where recurrent_uid=%s'
- % (model_obj._table, data[map_field]))
+ cr.execute('SELECT id FROM %s WHERE recurrent_uid=%%s' % model_obj._table,
+ (data[map_field],))
r_ids = map(lambda x: x[0], cr.fetchall())
if r_ids:
r_datas = model_obj.read(cr, uid, r_ids, context=context)
@@ -715,8 +715,9 @@ class basic_calendar_line(osv.osv):
@param context: A standard dictionary for contextual values
"""
- cr.execute("Select count(id) from basic_calendar_lines \
- where name='%s' and calendar_id=%s" % (vals.get('name'), vals.get('calendar_id')))
+ cr.execute("SELECT COUNT(id) FROM basic_calendar_lines \
+ WHERE name='%s' AND calendar_id=%s",
+ (vals.get('name'), vals.get('calendar_id')))
res = cr.fetchone()
if res:
if res[0] > 0:
@@ -797,8 +798,8 @@ class basic_calendar_fields(osv.osv):
@param context: A standard dictionary for contextual values
"""
- cr.execute('select name from basic_calendar_attributes \
- where id=%s' % (vals.get('name')))
+ cr.execute('SELECT name FROM basic_calendar_attributes \
+ WHERE id=%s', (vals.get('name'),))
name = cr.fetchone()
name = name[0]
if name in ('valarm', 'attendee'):
diff --git a/addons/caldav/calendar_collection.py b/addons/caldav/calendar_collection.py
index 06e799b1686..8dd4ff053c9 100644
--- a/addons/caldav/calendar_collection.py
+++ b/addons/caldav/calendar_collection.py
@@ -34,11 +34,11 @@ class calendar_collection(osv.osv):
def _get_root_calendar_directory(self, cr, uid, context=None):
objid = self.pool.get('ir.model.data')
try:
- mid = objid._get_id(cr, uid, 'document', 'dir_calendars')
+ mid = objid._get_id(cr, uid, 'document', 'dir_calendars')
if not mid:
return False
- root_id = objid.read(cr, uid, mid, ['res_id'])['res_id']
- root_cal_dir = self.browse(cr, uid, root_id, context=context)
+ root_id = objid.read(cr, uid, mid, ['res_id'])['res_id']
+ root_cal_dir = self.browse(cr,uid, root_id, context=context)
return root_cal_dir.name
except Exception, e:
import netsvc
@@ -67,7 +67,7 @@ class calendar_collection(osv.osv):
], limit=1, context=context)
root_cal_dir = self._get_root_calendar_directory(cr, uid, context=context)
- if not calendar_ids:
+ if not calendar_ids:
return root_cal_dir
calendar_id = calendar_ids[0]
calendar = calendar_obj.browse(cr, uid, calendar_id,
diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml
index e303ceb3378..e9c4f9f37b2 100644
--- a/addons/mrp/mrp_demo.xml
+++ b/addons/mrp/mrp_demo.xml
@@ -232,14 +232,6 @@
phantom
-
- HDD Seagate
- 26
-
- 1.0
- normal
-
- Assembly Basic PC29
@@ -563,6 +555,14 @@
+
+ Default BOM for Shelf of 100cm
+ SHE100
+ 129
+
+
+ 1.0
+ Assembly Section
@@ -591,15 +591,6 @@
-
- Default BOM for Shelf of 100cm
- SHE100
- 129
-
-
- 1.0
-
-
131
@@ -647,15 +638,6 @@
phantom
-
- 141
-
-
-
- 1.0
- Rear panel SHE100
-
-
Assembly Section143
diff --git a/addons/mrp/report/workcenter_load.py b/addons/mrp/report/workcenter_load.py
index 15e94bd6f4c..922e460ab6d 100644
--- a/addons/mrp/report/workcenter_load.py
+++ b/addons/mrp/report/workcenter_load.py
@@ -22,9 +22,8 @@
from report.render import render
from report.interface import report_int
from pychart import *
-from mx.DateTime import *
import time
-from datetime import datetime
+from datetime import date, datetime, timedelta
from dateutil.relativedelta import relativedelta
from report.misc import choice_colors
@@ -55,8 +54,8 @@ class report_custom(report_int):
stop = start
if time_unit == 'month':
dates = {}
- a = Date(*map(int, start.split("-"))).year*12+Date(*map(int, start.split("-"))).month
- z = Date(*map(int, stop.split("-"))).year*12+Date(*map(int, stop.split("-"))).month+1
+ a = int(start.split("-")[0])*12 + int(start.split("-")[1])
+ z = int(stop.split("-")[0])*12 + int(stop.split("-")[1]) + 1
for i in range(a,z):
year = i/12
month = i%12
@@ -66,27 +65,31 @@ class report_custom(report_int):
months = {1:"January",2:"February",3:"March",4:"April",5:"May",6:"June",7:"July",8:"August",9:"September",10:"October",11:"November",12:"December"}
dates[i] = {
'name' :months[month],
- 'start':(datetime.date(year, month, 2) + relativedelta(day=1)).strftime('%Y-%m-%d'),
- 'stop' :(datetime.date(year, month, 2) + relativedelta(day=-1)).strftime('%Y-%m-%d'),
+ 'start':(datetime(year, month, 2) + relativedelta(day=1)).strftime('%Y-%m-%d'),
+ 'stop' :(datetime(year, month, 2) + relativedelta(day=31)).strftime('%Y-%m-%d'),
}
return dates
elif time_unit == 'week':
dates = {}
- a = Date(*map(int, start.split("-"))).iso_week[0]*52+Date(*map(int, start.split("-"))).iso_week[1]
- z = Date(*map(int, stop.split("-"))).iso_week[0]*52+Date(*map(int, stop.split("-"))).iso_week[1]
+ start_week = date(int(start.split("-")[0]),int(start.split("-")[1]),int(start.split("-")[2])).isocalendar()
+ end_week = date(int(stop.split("-")[0]),int(stop.split("-")[1]),int(stop.split("-")[2])).isocalendar()
+ a = int(start.split("-")[0])*52 + start_week[1]
+ z = int(stop.split("-")[0])*52 + end_week[1]
for i in range(a,z+1):
year = i/52
week = i%52
+ d = date(year, 1, 1)
+
dates[i] = {
'name' :"Week #%d" % week,
- 'start':ISO.WeekTime(year, week, 1).strftime('%Y-%m-%d'),
- 'stop' :ISO.WeekTime(year, week, 7).strftime('%Y-%m-%d'),
+ 'start':(d + timedelta(days=-d.weekday(), weeks=week)).strftime('%Y-%m-%d'),
+ 'stop' :(d + timedelta(days=6-d.weekday(), weeks=week)).strftime('%Y-%m-%d'),
}
return dates
else: # time_unit = day
dates = {}
- a = Date(*map(int, start.split("-")))
- z = Date(*map(int, stop.split("-")))
+ a = datetime(int(start.split("-")[0]),int(start.split("-")[1]),int(start.split("-")[2]))
+ z = datetime(int(stop.split("-")[0]),int(stop.split("-")[1]),int(stop.split("-")[2]))
i = a
while i <= z:
dates[map(int,i.strftime('%Y%m%d').split())[0]] = {
diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py
index 52a8a81cb49..3328f24a59f 100644
--- a/addons/mrp_operations/mrp_operations.py
+++ b/addons/mrp_operations/mrp_operations.py
@@ -21,10 +21,9 @@
from osv import fields
from osv import osv
-import datetime
import netsvc
import time
-from mx import DateTime
+from datetime import datetime
from tools.translate import _
#----------------------------------------------------------
@@ -75,7 +74,6 @@ class mrp_production_workcenter_line(osv.osv):
for op in ops:
res[op.id] = False
if op.date_planned:
- d = DateTime.strptime(op.date_planned,'%Y-%m-%d %H:%M:%S')
i = intervals[(op.date_planned, op.hour, op.workcenter_id.calendar_id.id)]
if i:
res[op.id] = i[-1][1].strftime('%Y-%m-%d %H:%M:%S')
@@ -176,8 +174,8 @@ class mrp_production_workcenter_line(osv.osv):
date_now = time.strftime('%Y-%m-%d %H:%M:%S')
obj_line = self.browse(cr, uid, ids[0])
- date_start = datetime.datetime.strptime(obj_line.date_start,'%Y-%m-%d %H:%M:%S')
- date_finished = datetime.datetime.strptime(date_now,'%Y-%m-%d %H:%M:%S')
+ date_start = datetime.strptime(obj_line.date_start,'%Y-%m-%d %H:%M:%S')
+ date_finished = datetime.strptime(date_now,'%Y-%m-%d %H:%M:%S')
delay += (date_finished-date_start).days * 24
delay += (date_finished-date_start).seconds / float(60*60)
@@ -259,9 +257,9 @@ class mrp_production(osv.osv):
""" Computes planned and finished dates for work order.
@return: Calculated date
"""
- dt_end = DateTime.now()
+ dt_end = datetime.now()
for po in self.browse(cr, uid, ids, context=context):
- dt_end = DateTime.strptime(po.date_start or po.date_planned, '%Y-%m-%d %H:%M:%S')
+ dt_end = datetime.strptime(po.date_planned, '%Y-%m-%d %H:%M:%S')
if not po.date_start:
self.write(cr, uid, [po.id], {
'date_start': po.date_planned
@@ -275,7 +273,7 @@ class mrp_production(osv.osv):
del context['__last_update']
if (wc.date_planned < dt.strftime('%Y-%m-%d %H:%M:%S')) or mini:
self.pool.get('mrp.production.workcenter.line').write(cr, uid, [wc.id], {
- 'date_planned':dt.strftime('%Y-%m-%d %H:%M:%S')
+ 'date_planned': dt.strftime('%Y-%m-%d %H:%M:%S')
}, context=context, update=False)
i = self.pool.get('resource.calendar').interval_get(
cr,
@@ -287,7 +285,7 @@ class mrp_production(osv.osv):
if i:
dt_end = max(dt_end, i[-1][1])
else:
- dt_end = DateTime.strptime(wc.date_planned_end, '%Y-%m-%d %H:%M:%S')
+ dt_end = datetime.strptime(wc.date_planned_end, '%Y-%m-%d %H:%M:%S')
old = wc.sequence or 0
super(mrp_production, self).write(cr, uid, [po.id], {
'date_finnished': dt_end
@@ -302,7 +300,7 @@ class mrp_production(osv.osv):
if po.allow_reorder:
continue
todo = po.move_lines
- dt = DateTime.strptime(po.date_start,'%Y-%m-%d %H:%M:%S')
+ dt = datetime.strptime(po.date_start,'%Y-%m-%d %H:%M:%S')
while todo:
l = todo.pop(0)
if l.state in ('done','cancel','draft'):
@@ -426,8 +424,8 @@ class mrp_operations_operation(osv.osv):
if not i: continue
if code_lst[i-1] not in ('resume','start'):
continue
- a = datetime.datetime.strptime(time_lst[i-1],'%Y-%m-%d %H:%M:%S')
- b = datetime.datetime.strptime(time_lst[i],'%Y-%m-%d %H:%M:%S')
+ a = datetime.strptime(time_lst[i-1],'%Y-%m-%d %H:%M:%S')
+ b = datetime.strptime(time_lst[i],'%Y-%m-%d %H:%M:%S')
diff += (b-a).days * 24
diff += (b-a).seconds / float(60*60)
return diff
@@ -513,7 +511,7 @@ class mrp_operations_operation(osv.osv):
if code.start_stop=='done':
self.pool.get('mrp.production.workcenter.line').action_done(cr,uid,wc_op_id)
wf_service.trg_validate(uid, 'mrp.production.workcenter.line', wc_op_id[0], 'button_done', cr)
- self.pool.get('mrp.production').write(cr,uid,vals['production_id'],{'date_finnished':DateTime.now().strftime('%Y-%m-%d %H:%M:%S')})
+ self.pool.get('mrp.production').write(cr,uid,vals['production_id'],{'date_finnished':datetime.now().strftime('%Y-%m-%d %H:%M:%S')})
if code.start_stop=='pause':
self.pool.get('mrp.production.workcenter.line').action_pause(cr,uid,wc_op_id)
@@ -551,7 +549,7 @@ class mrp_operations_operation(osv.osv):
'order_date': fields.function(_get_order_date,method=True,string='Order Date',type='date',store={'mrp.production':(_order_date_search_production,['date_planned'], 10)}),
}
_defaults={
- 'date_start': lambda *a:DateTime.now().strftime('%Y-%m-%d %H:%M:%S')
+ 'date_start': lambda *a:datetime.now().strftime('%Y-%m-%d %H:%M:%S')
}
mrp_operations_operation()
diff --git a/addons/point_of_sale/__openerp__.py b/addons/point_of_sale/__openerp__.py
index ad466b12522..1c23a27acd1 100644
--- a/addons/point_of_sale/__openerp__.py
+++ b/addons/point_of_sale/__openerp__.py
@@ -67,12 +67,11 @@ Main features :
'report/report_pos_order_view.xml',
'report/report_cash_register_view.xml',
'pos_sequence.xml',
- 'pos_data.xml',
'pos_workflow.xml',
'statement_view.xml',
'statement_report.xml',
],
- 'demo_xml': ['pos_demo.xml','singer_statement_demo.xml','multi_company_stock_data.xml',],
+ 'demo_xml': ['pos_demo.xml','singer_statement_demo.xml'],
'test':['test/pos_test.yml',
'test/pos_report.yml',
],
diff --git a/addons/point_of_sale/multi_company_demo.xml b/addons/point_of_sale/multi_company_demo.xml
deleted file mode 100644
index 9ae66800ff9..00000000000
--- a/addons/point_of_sale/multi_company_demo.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/addons/point_of_sale/multi_company_stock_data.xml b/addons/point_of_sale/multi_company_stock_data.xml
deleted file mode 100644
index cc8d30d080d..00000000000
--- a/addons/point_of_sale/multi_company_stock_data.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/addons/point_of_sale/pos.py b/addons/point_of_sale/pos.py
index 0d6ab5f2b33..3132367d8bf 100644
--- a/addons/point_of_sale/pos.py
+++ b/addons/point_of_sale/pos.py
@@ -25,8 +25,6 @@ from osv import fields, osv
from mx import DateTime
from tools.translate import _
from decimal import Decimal
-import tools
-import re
import decimal_precision as dp
class pos_config_journal(osv.osv):
@@ -114,18 +112,18 @@ class pos_order(osv.osv):
@return: Dictionary of values """
res = {}
- pay_obj = self.pool.get('account.bank.statement')
- stat_obj_line = self.pool.get('account.bank.statement.line')
- tot =0.0
val=None
for order in self.browse(cr, uid, ids):
- cr.execute("select date_payment from pos_order where id=%d"%(order.id))
+ cr.execute("SELECT date_payment FROM pos_order WHERE id=%s", (order.id,))
date_p=cr.fetchone()
date_p=date_p and date_p[0] or None
if date_p:
res[order.id]=date_p
return res
- cr.execute(" SELECT max(l.date) from account_move_line l, account_move m, account_invoice i, account_move_reconcile r, pos_order o where i.move_id=m.id and l.move_id=m.id and l.reconcile_id=r.id and o.id=%d and o.invoice_id=i.id"%(order.id))
+ cr.execute(" SELECT max(l.date) "
+ " FROM account_move_line l, account_move m, account_invoice i, account_move_reconcile r, pos_order o "
+ " WHERE i.move_id=m.id AND l.move_id=m.id AND l.reconcile_id=r.id AND o.id=%s AND o.invoice_id=i.id",
+ (order.id,))
val=cr.fetchone()
val= val and val[0] or None
if val:
@@ -138,11 +136,9 @@ class pos_order(osv.osv):
@return: Dictionary of values """
res = {}
- pay_obj = self.pool.get('pos.payment')
- tot =0.0
val=None
for order in self.browse(cr, uid, ids):
- cr.execute("select date_validation from pos_order where id=%d"%(order.id))
+ cr.execute("SELECT date_validation FROM pos_order WHERE id=%s", (order.id,))
date_p=cr.fetchone()
date_p=date_p and date_p[0] or None
if date_p:
@@ -153,7 +149,7 @@ class pos_order(osv.osv):
if line.discount > discount_allowed:
return {order.id: None }
if order.amount_paid == order.amount_total and not date_p:
- cr.execute("select max(date) from account_bank_statement_line where pos_statement_id=%d"%(order.id))
+ cr.execute("SELECT MAX(date) FROM account_bank_statement_line WHERE pos_statement_id=%s", (order.id,))
val=cr.fetchone()
val=val and val[0] or None
if order.invoice_id and order.invoice_id.move_id and not date_p and not val:
@@ -215,7 +211,6 @@ class pos_order(osv.osv):
""" To get Shop for this order"
@return: Shop id """
- company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
res = self.pool.get('sale.shop').search(cr, uid, [])
if res:
return res[0]
@@ -242,23 +237,21 @@ class pos_order(osv.osv):
""" Changed the Validation state of order
@return: State """
- flag=False
- res_company = self.pool.get('res.company')
res_obj = self.pool.get('res.users')
company_disc=self.browse(cr,uid,ids)
if not company_disc:
comp=res_obj.browse(cr,uid,uid).company_id.company_discount or 0.0
else:
comp= company_disc[0] and company_disc[0].company_id and company_disc[0].company_id.company_discount or 0.0
- cr.execute("select discount from pos_order_line where order_id=%s and discount <= %s"%(ids[0],comp))
+ cr.execute("select discount from pos_order_line where order_id=%s and discount <= %s", (ids[0],comp))
res=cr.fetchone()
- cr.execute("select discount from pos_order_line where order_id=%s and discount > %s"%(ids[0],comp))
+ cr.execute("select discount from pos_order_line where order_id=%s and discount > %s", (ids[0],comp))
res2=cr.fetchone()
- cr.execute("select journal_id from account_bank_statement_line where pos_statement_id=%s "%(ids[0]))
+ cr.execute("select journal_id from account_bank_statement_line where pos_statement_id=%s ", (ids[0],))
res3=cr.fetchall()
list_jrnl=[]
for r in res3:
- cr.execute("select id from account_journal where name= '%s' and special_journal='t'"%(r[0]))
+ cr.execute("select id from account_journal where name= '%s' and special_journal='t'", (r[0],))
res3=cr.fetchone()
is_special=res3 and res3[0] or None
if is_special:
@@ -489,7 +482,7 @@ class pos_order(osv.osv):
continue
prop_ids = property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')])
val = property_obj.browse(cr, uid, prop_ids[0]).value_reference
- cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order.shop_id.warehouse_id.id))
+ cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id=%s", (order.shop_id.warehouse_id.id,))
res=cr.fetchone()
location_id=res and res[0] or None
stock_dest_id = val.id
@@ -540,7 +533,7 @@ class pos_order(osv.osv):
res_obj = self.pool.get('res.company')
try:
part_company=res_obj.browse(cr,uid,uid) and res_obj.browse(cr,uid,uid).parent_id and res_obj.browse(cr,uid,uid).parent_id.id or None
- except Exception, e:
+ except Exception:
raise osv.except_osv(_('Error'), _('You don\'t have enough access to validate this sale!'))
if part_company:
raise osv.except_osv(_('Error'), _('You don\'t have enough access to validate this sale!'))
@@ -559,12 +552,10 @@ class pos_order(osv.osv):
"""Create a new payment for the order"""
- res_obj = self.pool.get('res.company')
statement_obj= self.pool.get('account.bank.statement')
statementl_obj = self.pool.get('account.bank.statement.line')
prod_obj = self.pool.get('product.product')
property_obj=self.pool.get('ir.property')
- flag=''
curr_c=self.pool.get('res.users').browse(cr, uid, uid).company_id
curr_company=curr_c.id
order = self.browse(cr, uid, order_id, context)
@@ -600,7 +591,7 @@ class pos_order(osv.osv):
args['statement_id']= statement_id
args['pos_statement_id']= order_id
args['journal_id']= data['journal']
- statement_line_id = statementl_obj.create(cr, uid, args)
+ statementl_obj.create(cr, uid, args)
ids_new.append(statement_id)
wf_service = netsvc.LocalService("workflow")
@@ -661,14 +652,12 @@ class pos_order(osv.osv):
def action_invoice(self, cr, uid, ids, context=None):
"""Create a invoice of order """
- res_obj = self.pool.get('res.company')
inv_ref = self.pool.get('account.invoice')
inv_line_ref = self.pool.get('account.invoice.line')
product_obj= self.pool.get('product.product')
inv_ids = []
for order in self.pool.get('pos.order').browse(cr, uid, ids, context):
- curr_c = order.user_salesman_id.company_id
if order.invoice_id:
inv_ids.append(order.invoice_id.id)
continue
@@ -894,21 +883,12 @@ class pos_order(osv.osv):
raise osv.except_osv(_('Error !'),
_('There is no receivable account defined for this journal:'\
' "%s" (id:%d)') % (order.sale_journal.name, order.sale_journal.id, ))
- am=0.0
for payment in order.statement_ids:
- am+=payment.amount
-
- if am > 0:
- payment_account = \
- payment.statement_id.journal_id.default_debit_account_id.id
- else:
- payment_account = \
- payment.statement_id.journal_id.default_credit_account_id.id
# Create one entry for the payment
if payment.is_acc:
continue
- payment_move_id = account_move_obj.create(cr, uid, {
+ account_move_obj.create(cr, uid, {
'journal_id': payment.statement_id.journal_id.id,
'period_id': period,
}, context=context)
@@ -1022,7 +1002,7 @@ class pos_order_line(osv.osv):
def _amount_line_ttc(self, cr, uid, ids, field_name, arg, context):
res = dict.fromkeys(ids, 0.0)
account_tax_obj = self.pool.get('account.tax')
- prices = self.price_by_product_multi(cr, uid, ids)
+ self.price_by_product_multi(cr, uid, ids)
for line in self.browse(cr, uid, ids):
tax_amount = 0.0
taxes = [t for t in line.product_id.taxes_id]
@@ -1031,7 +1011,6 @@ class pos_order_line(osv.osv):
computed_taxes = account_tax_obj.compute_all(cr, uid, taxes, line.price_unit, line.qty)['taxes']
for tax in computed_taxes:
tax_amount += tax['amount']
- price = prices[line.id]
if line.discount!=0.0:
res[line.id] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0)
else:
@@ -1042,9 +1021,8 @@ class pos_order_line(osv.osv):
def _amount_line(self, cr, uid, ids, field_name, arg, context):
res = {}
- prices = self.price_by_product_multi(cr, uid, ids)
+ self.price_by_product_multi(cr, uid, ids)
for line in self.browse(cr, uid, ids):
- price = prices[line.id]
if line.discount!=0.0:
res[line.id] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0)
else:
@@ -1056,11 +1034,10 @@ class pos_order_line(osv.osv):
account_tax_obj = self.pool.get('account.tax')
- prices = self.price_by_product_multi(cr, uid, ids)
+ self.price_by_product_multi(cr, uid, ids)
for line in self.browse(cr, uid, ids):
for f in field_names:
if f == 'price_subtotal':
- price = prices[line.id]
if line.discount != 0.0:
res[line.id][f] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0)
else:
@@ -1073,7 +1050,6 @@ class pos_order_line(osv.osv):
computed_taxes = account_tax_obj.compute_all(cr, uid, taxes, line.price_unit, line.qty)['taxes']
for tax in computed_taxes:
tax_amount += tax['amount']
- price = prices[line.id]
if line.discount!=0.0:
res[line.id][f] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0)
else:
@@ -1097,8 +1073,6 @@ class pos_order_line(osv.osv):
for line in lines:
pricelist = line.order_id.pricelist_id.id
product_id = line.product_id
- qty = line.qty or 0
- partner_id = line.order_id.partner_id.id or False
if not product_id:
res[line.id] = 0.0
@@ -1108,8 +1082,6 @@ class pos_order_line(osv.osv):
_('You have to select a pricelist in the sale form !\n' \
'Please set one before choosing a product.'))
- uom_id = product_id.uom_po_id.id
-
#old_price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist], product_id.id, qty or 1.0, partner_id, {'uom': uom_id})[pricelist]
#print "prod_id: %s, pricelist: %s, price: %s" % (product_id.id, pricelist, price)
price = price_get_multi_res[line.product_id.id][pricelist]
@@ -1170,9 +1142,7 @@ class pos_order_line(osv.osv):
return {'value': {'price_subtotal_incl':sub_total_discount}}
def onchange_ded(self, cr, uid,ids, val_ded,price_u,*a):
- pos_order = self.pool.get('pos.order.line')
res_obj = self.pool.get('res.users')
- res_company = self.pool.get('res.company')
comp = res_obj.browse(cr,uid,uid).company_id.company_discount or 0.0
val=0.0
if val_ded and price_u:
@@ -1184,7 +1154,6 @@ class pos_order_line(osv.osv):
def onchange_discount(self, cr, uid,ids, discount,price,*a):
pos_order = self.pool.get('pos.order.line')
res_obj = self.pool.get('res.users')
- res_company = self.pool.get('res.company')
company_disc = pos_order.browse(cr,uid,ids)
if discount:
if not company_disc:
@@ -1282,7 +1251,7 @@ class pos_order_line(osv.osv):
}
line_id = self.write(cr, uid, order_line_id, vals)
if not line_id:
- raise wizard.except_wizard(_('Error'), _('Modify line failed !'))
+ raise osv.except_osv(_('Error'), _('Modify line failed !'))
line_id = order_line_id
price_line = float(qty)*float(price)
diff --git a/addons/point_of_sale/pos_data.xml b/addons/point_of_sale/pos_data.xml
deleted file mode 100644
index 14710cf8f37..00000000000
--- a/addons/point_of_sale/pos_data.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/addons/point_of_sale/pos_view.xml b/addons/point_of_sale/pos_view.xml
index c0f7b566879..17420b1ffe9 100644
--- a/addons/point_of_sale/pos_view.xml
+++ b/addons/point_of_sale/pos_view.xml
@@ -169,20 +169,6 @@
-
- Uninvoiced Sales
- ir.actions.act_window
- pos.order
- form
- tree,form
-
- [('state','not in', ('invoiced','done')),('invoice_id','=',False)]
- {"search_default_user_id":uid}
-
-
-
-
-
Accepted Salesir.actions.act_window
diff --git a/addons/point_of_sale/pos_wizard.xml b/addons/point_of_sale/pos_wizard.xml
deleted file mode 100644
index 4a321d7787f..00000000000
--- a/addons/point_of_sale/pos_wizard.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/addons/point_of_sale/posr_data.xml b/addons/point_of_sale/posr_data.xml
deleted file mode 100644
index 3ba8df59b13..00000000000
--- a/addons/point_of_sale/posr_data.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/addons/point_of_sale/posrule_data.xml b/addons/point_of_sale/posrule_data.xml
deleted file mode 100644
index 7f165742f03..00000000000
--- a/addons/point_of_sale/posrule_data.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/addons/point_of_sale/report/pos_details.py b/addons/point_of_sale/report/pos_details.py
index fd0eb54bc3f..d1e881befac 100644
--- a/addons/point_of_sale/report/pos_details.py
+++ b/addons/point_of_sale/report/pos_details.py
@@ -28,7 +28,7 @@ class pos_details(report_sxw.rml_parse):
def _get_invoice(self,inv_id,user):
res={}
if inv_id:
- self.cr.execute("select name from account_invoice as ac where id = %d" %(inv_id))
+ self.cr.execute("select name from account_invoice as ac where id = %s", (inv_id,))
res = self.cr.fetchone()
return res[0]
else:
@@ -107,14 +107,8 @@ class pos_details(report_sxw.rml_parse):
objects,
0.0)
- def _get_payments(self, form,user, ignore_gift=False):
+ def _get_payments(self, form,user):
statement_line_obj = self.pool.get("account.bank.statement.line")
- gift_journal_id = None
- if ignore_gift:
- config_journal_ids = self.pool.get("pos.config.journal").search(self.cr, self.uid, [('code', '=', 'GIFT')])
- if len(config_journal_ids):
- config_journal = self.pool.get("pos.config.journal").browse(self.cr, self.uid, config_journal_ids, {})[0]
- gift_journal_id = config_journal.journal_id.id
pos_ids=self.pool.get("pos.order").search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('state','in',['paid','invoiced','done']),('user_id','=',self.uid)])
data={}
if pos_ids:
@@ -162,7 +156,6 @@ class pos_details(report_sxw.rml_parse):
res = {}
temp={}
list_ids = []
- c=[]
temp2 = 0.0
pos_ids=self.pool.get("pos.order").search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('state','in',['paid','invoiced','done']),('user_id','=',self.uid)])
temp.update({'name':''})
diff --git a/addons/point_of_sale/security/ir.model.access.csv b/addons/point_of_sale/security/ir.model.access.csv
index 206c14172f9..d2bc03fd47f 100644
--- a/addons/point_of_sale/security/ir.model.access.csv
+++ b/addons/point_of_sale/security/ir.model.access.csv
@@ -7,7 +7,7 @@
"access_pos_payment","pos.payment","model_pos_payment","group_pos_user",1,1,1,1
"access_report_transaction_pos","report.transaction.pos","model_report_transaction_pos","group_pos_manager",1,1,1,1
"access_pos_config_journal_manager","pos.config.journal.manager","model_pos_config_journal","group_pos_manager",1,1,1,1
-"access_account_journal_pos_manager","account.journal pos_manager","account.model_account_journal","group_pos_manager",1,0,0,0
+"access_account_journal_pos_manager","account.journal pos_manager","account.model_account_journal","group_pos_manager",1,1,1,0
"access_account_journal_pos_user","account.journal pos_user","account.model_account_journal","group_pos_user",1,0,0,0
"access_account_move_pos_user","account.move pos_user","account.model_account_move","group_pos_user",1,0,0,0
"access_account_account_pos_user","account.account pos_user","account.model_account_account","group_pos_user",1,0,0,0
diff --git a/addons/point_of_sale/singer_statement_demo.xml b/addons/point_of_sale/singer_statement_demo.xml
index 3caf9a046c3..3862c3c97cb 100644
--- a/addons/point_of_sale/singer_statement_demo.xml
+++ b/addons/point_of_sale/singer_statement_demo.xml
@@ -6,7 +6,7 @@
VIJcash
-
+
@@ -18,7 +18,7 @@
CAJcash
-
+
@@ -30,7 +30,7 @@
BACJcash
-
+
diff --git a/addons/point_of_sale/statement_data.xml b/addons/point_of_sale/statement_data.xml
deleted file mode 100644
index 2780cd0f8d0..00000000000
--- a/addons/point_of_sale/statement_data.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/addons/point_of_sale/statement_rules.xml b/addons/point_of_sale/statement_rules.xml
deleted file mode 100644
index 3ba8df59b13..00000000000
--- a/addons/point_of_sale/statement_rules.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/addons/point_of_sale/test/pos_report.yml b/addons/point_of_sale/test/pos_report.yml
index d17e487794e..08052356104 100644
--- a/addons/point_of_sale/test/pos_report.yml
+++ b/addons/point_of_sale/test/pos_report.yml
@@ -67,6 +67,15 @@
(data, format) = netsvc.LocalService('report.pos.details').create(cr, uid, [], {'model':'ir.ui.menu', 'form':{'date_start': time.strftime('%Y-%m-%d'), 'date_end': time.strftime('%Y-%m-%d') }}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'point_of_sale- pos details report'+format), 'wb+').write(data)
+-
+ I create a cash journal.
+-
+ !record {model: account.journal, id: account_journal_cash0}:
+ name: 'Cash Journal'
+ code: 'CSJ'
+ type: 'cash'
+ view_id: account.account_journal_bank_view
+ sequence_id: account.sequence_journal
-
I create a record for Bank Statement.
-
@@ -74,7 +83,7 @@
name: St.05/19
balance_end_real: 0.0
date: '2010-05-19'
- journal_id: account.bank_journal
+ journal_id: account_journal_cash0
period_id: account.period_5
state: 'draft'
-
diff --git a/addons/point_of_sale/wizard/pos_box_entries.py b/addons/point_of_sale/wizard/pos_box_entries.py
index f7349726033..103e49be62d 100644
--- a/addons/point_of_sale/wizard/pos_box_entries.py
+++ b/addons/point_of_sale/wizard/pos_box_entries.py
@@ -36,7 +36,7 @@ def get_journal(self, cr, uid, context):
obj = self.pool.get('account.journal')
statement_obj = self.pool.get('account.bank.statement')
- cr.execute("""select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id"""%(uid))
+ cr.execute("SELECT DISTINCT journal_id from pos_journal_users where user_id=%s order by journal_id", (uid,))
j_ids = map(lambda x1: x1[0], cr.fetchall())
ids = obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)])
obj_ids= statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', ids)])
@@ -129,7 +129,7 @@ class pos_box_entries(osv.osv_memory):
if address_u:
partner_id = address_u.partner_id and address_u.partner_id.id or None
args['partner_id'] = partner_id
- statement_line_id = bank_statement.create(cr, uid, args)
+ bank_statement.create(cr, uid, args)
return {}
diff --git a/addons/point_of_sale/wizard/pos_close_statement.py b/addons/point_of_sale/wizard/pos_close_statement.py
index f12a0a16c99..82e47a2caa3 100644
--- a/addons/point_of_sale/wizard/pos_close_statement.py
+++ b/addons/point_of_sale/wizard/pos_close_statement.py
@@ -35,12 +35,11 @@ class pos_close_statement(osv.osv_memory):
@param context: A standard dictionary
@return : Blank Dictionary
"""
- company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
- list_statement = []
mod_obj = self.pool.get('ir.model.data')
statement_obj = self.pool.get('account.bank.statement')
journal_obj = self.pool.get('account.journal')
- cr.execute("""select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id"""%(uid))
+ cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users "
+ "WHERE user_id=%s ORDER BY journal_id", (uid,))
j_ids = map(lambda x1: x1[0], cr.fetchall())
journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)])
ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', journal_ids)])
diff --git a/addons/point_of_sale/wizard/pos_open_statement.py b/addons/point_of_sale/wizard/pos_open_statement.py
index 0b8219d949b..67c5b125768 100644
--- a/addons/point_of_sale/wizard/pos_open_statement.py
+++ b/addons/point_of_sale/wizard/pos_open_statement.py
@@ -21,7 +21,6 @@
from osv import osv
from tools.translate import _
-import time
class pos_open_statement(osv.osv_memory):
_name = 'pos.open.statement'
@@ -42,7 +41,8 @@ class pos_open_statement(osv.osv_memory):
statement_obj = self.pool.get('account.bank.statement')
sequence_obj = self.pool.get('ir.sequence')
journal_obj = self.pool.get('account.journal')
- cr.execute("""select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id"""%(uid))
+ cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users "
+ "WHERE user_id=%s ORDER BY journal_id"% (uid,))
j_ids = map(lambda x1: x1[0], cr.fetchall())
journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)])
@@ -50,32 +50,17 @@ class pos_open_statement(osv.osv_memory):
ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', '=', journal.id)])
if len(ids):
raise osv.except_osv(_('Message'), _('You can not open a Cashbox for "%s".\nPlease close its related Register.' %(journal.name)))
-
- statement_ids = sorted(statement_obj.search(cr, uid, [('state', '=', 'confirm'), ('user_id', '=', uid), ('journal_id', '=', journal.id)]))
- if statement_ids:
- res = []
- statement_ids.reverse()
- statement = statement_obj.browse(cr, uid, statement_ids[0])
- for end_bal in statement.ending_details_ids:
- dct = {
- 'pieces': end_bal.pieces,
- 'number': end_bal.number,
- }
- res.append((0, 0, dct))
- data['starting_details_ids'] = res
- else:
- data['starting_details_ids'] = statement_obj._get_cash_close_box_lines(cr, uid, [])
-
+
number = ''
if journal.sequence_id:
number = sequence_obj.get_id(cr, uid, journal.sequence_id.id)
else:
- number = sequence_obj.get(cr, uid, 'account.bank.statement')
+ number = sequence_obj.get(cr, uid, 'account.cash.statement')
data.update({'journal_id': journal.id,
'company_id': company_id,
'user_id': uid,
- 'state': 'open',
+ 'state': 'draft',
'name': number })
statement_id = statement_obj.create(cr, uid, data)
statement_obj.button_open(cr, uid, [statement_id], context)
diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py
index 8330be2772c..1c92ad24132 100644
--- a/addons/point_of_sale/wizard/pos_payment.py
+++ b/addons/point_of_sale/wizard/pos_payment.py
@@ -42,7 +42,8 @@ class pos_make_payment(osv.osv_memory):
active_id = context and context.get('active_id',False)
if active_id:
j_obj = self.pool.get('account.journal')
- cr.execute("""select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id"""%(uid))
+ cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users "
+ "WHERE user_id=%d ORDER BY journal_id"% (uid,))
j_ids = map(lambda x1: x1[0], cr.fetchall())
journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)])
@@ -78,7 +79,7 @@ class pos_make_payment(osv.osv_memory):
return res
def view_init(self, cr, uid, fields_list, context=None):
- res = super(pos_make_payment, self).view_init(cr, uid, fields_list, context=context)
+ super(pos_make_payment, self).view_init(cr, uid, fields_list, context=context)
active_id = context and context.get('active_id', False) or False
if active_id:
order = self.pool.get('pos.order').browse(cr, uid, active_id)
diff --git a/addons/point_of_sale/wizard/pos_payment.xml b/addons/point_of_sale/wizard/pos_payment.xml
index 36c92664e0b..58b4dc447cd 100644
--- a/addons/point_of_sale/wizard/pos_payment.xml
+++ b/addons/point_of_sale/wizard/pos_payment.xml
@@ -1,9 +1,7 @@
-
-
-"""
+
@@ -12,30 +10,38 @@
form
diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py
index dfc16e0ff96..4b975b820cb 100644
--- a/addons/point_of_sale/wizard/pos_return.py
+++ b/addons/point_of_sale/wizard/pos_return.py
@@ -123,9 +123,9 @@ class pos_return(osv.osv_memory):
+ string="Return with Echange" type="object"/>
+ string="Refund Without Exchange" type="object"/>
"""
result['arch'] = _moves_arch_lst
@@ -162,6 +162,7 @@ class pos_return(osv.osv_memory):
stock_move_obj = self.pool.get('stock.move')
property_obj= self.pool.get("ir.property")
uom_obj =self. pool.get('product.uom')
+ statementl_obj = self.pool.get('account.bank.statement.line')
wf_service = netsvc.LocalService("workflow")
#Todo :Need to clean the code
if active_id:
@@ -171,7 +172,9 @@ class pos_return(osv.osv_memory):
for order_id in order_obj.browse(cr, uid, [active_id], context=context):
prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')])
val = property_obj.browse(cr, uid, prop_ids[0]).value_reference
- cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id))
+ cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w "
+ "WHERE w.lot_stock_id=s.id AND w.id=%s ",
+ (order_id.shop_id.warehouse_id.id,))
res = cr.fetchone()
location_id = res and res[0] or None
stock_dest_id = val.id
@@ -185,10 +188,13 @@ class pos_return(osv.osv_memory):
'lines':[],
'statement_ids':[],
'picking_id':[]})
+ account_def = property_obj.get(cr, uid, 'property_account_payable', 'res.partner', context=context)
+ amount = 0.0
for line in order_id.lines:
if line.id:
try:
qty = data['return%s' %line.id]
+ amount += qty * line.price_unit
except :
qty = line.qty
stock_move_obj.create(cr, uid, {
@@ -204,6 +210,15 @@ class pos_return(osv.osv_memory):
'date_planned': date_cur
})
line_obj.copy(cr, uid, line.id, {'qty': -qty, 'order_id': new_order})
+ statementl_obj.create(cr, uid, {
+ 'name': 'Refund %s'%order_id.name,
+ 'statement_id': order_id.statement_ids[0].statement_id.id,
+ 'pos_statement_id': new_order,
+ 'date': time.strftime('%Y-%m-%d'),
+ 'account_id': order_id.partner_id and order_id.partner_id.property_account_payable \
+ and order_id.partner_id.property_account_payable.id or account_def.id,
+ 'amount': -amount,
+ })
order_obj.write(cr,uid, [active_id,new_order], {'state': 'done'})
wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr)
picking_obj.force_assign(cr, uid, [new_picking], context)
@@ -254,7 +269,9 @@ class add_product(osv.osv_memory):
qty=data['quantity']
prop_ids = property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')])
val = property_obj.browse(cr, uid, prop_ids[0]).value_reference
- cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id))
+ cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w "
+ "WHERE w.lot_stock_id=s.id AND w.id=%s ",
+ (order_id.shop_id.warehouse_id.id,))
res=cr.fetchone()
location_id=res and res[0] or None
stock_dest_id = val.id
@@ -316,7 +333,9 @@ class add_product(osv.osv_memory):
for order_id in order_obj.browse(cr, uid, active_ids, context=context):
prop_ids =property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')])
val = property_obj.browse(cr, uid, prop_ids[0]).value_reference
- cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id))
+ cr.execute("SELECT s.id FROM stock_location s, stock_warehouse w "
+ " WHERE w.lot_stock_id=s.id AND w.id=%s ",
+ (order_id.shop_id.warehouse_id.id,))
res=cr.fetchone()
location_id=res and res[0] or None
stock_dest_id = val.id
@@ -331,13 +350,13 @@ class add_product(osv.osv_memory):
'date':date_cur
})
for line in order_id.lines:
- key=('return%s') %line.id
+ key= 'return%s' % line.id
if line.id:
if data.has_key(key):
- qty = data['return%s' %line.id]
+ qty = data[key]
lines_obj.write(cr,uid,[line.id], {
- 'qty_rfd':(line.qty or 0.0) + data['return%s' %line.id],
- 'qty':line.qty-(data['return%s' %line.id] or 0.0)
+ 'qty_rfd':(line.qty or 0.0) + data[key],
+ 'qty':line.qty-(data[key] or 0.0)
})
else:
qty = line.qty
@@ -349,7 +368,7 @@ class add_product(osv.osv_memory):
'location_id':location_id,
'product_id':line.product_id.id,
'location_dest_id':stock_dest_id,
- 'name':'%s (return)' %order_id.name,
+ 'name':'%s (return)' % order_id.name,
'date':date_cur,
'date_planned':date_cur
})
diff --git a/addons/stock/report/picking.rml b/addons/stock/report/picking.rml
index 317180c7209..c2b46959e1d 100644
--- a/addons/stock/report/picking.rml
+++ b/addons/stock/report/picking.rml
@@ -181,7 +181,7 @@
[[ picking.origin or '']]
- [[ (picking.address_id and picking.address_id.title) or '' ]] [[ (picking.address_id and and picking.address_id.name) or '' ]]
+ [[ (picking.address_id and picking.address_id.title) or '' ]] [[ (picking.address_id and picking.address_id.name) or '' ]]
[[ formatLang(picking.min_date,date_time = True) ]]
diff --git a/addons/survey/report/survey_analysis_report.py b/addons/survey/report/survey_analysis_report.py
index e72034e11d2..c95bd33ac32 100644
--- a/addons/survey/report/survey_analysis_report.py
+++ b/addons/survey/report/survey_analysis_report.py
@@ -189,9 +189,9 @@ class survey_analysis(report_rml):
for ans in que.answer_choice_ids:
rml += """
""" + to_xml(tools.ustr(ans.answer)) + """
"""
- cr.execute("select count(id) from survey_response_answer sra where sra.answer_id = %d" % ans.id)
+ cr.execute("select count(id) from survey_response_answer sra where sra.answer_id = %s", (ans.id,))
tot_res = cr.fetchone()[0]
- cr.execute("select count(id) ,sra.column_id from survey_response_answer sra where sra.answer_id = %d group by sra.column_id" % ans.id)
+ cr.execute("select count(id) ,sra.column_id from survey_response_answer sra where sra.answer_id=%s group by sra.column_id", (ans.id,))
calc_res = cr.dictfetchall()
for mat_col in range(1, len(matrix_ans)):
percantage = 0.0
@@ -210,7 +210,7 @@ class survey_analysis(report_rml):
rml += """"""
if que.is_comment_require:
- cr.execute("select count(id) from survey_response_line where question_id = %d and comment != ''"% que.id)
+ cr.execute("select count(id) from survey_response_line where question_id = %s and comment != ''",(que.id,))
tot_res = cr.fetchone()[0]
rml += """
""" + to_xml(tools.ustr(que.comment_label)) + """
""" + tools.ustr(tot_res) + """
"""
@@ -244,7 +244,7 @@ class survey_analysis(report_rml):
if que.is_comment_require:
# if que.make_comment_field:
-# cr.execute("select count(id) from survey_response_line where question_id = %d and comment != ''"% que.id)
+# cr.execute("select count(id) from survey_response_line where question_id = %s and comment != ''", (que.id,))
# tot_res = cr.fetchone()[0]
# tot_avg = 0.00
# if que.tot_resp:
@@ -253,13 +253,13 @@ class survey_analysis(report_rml):
#
""" + str(tot_avg) + """%
#
""" + tools.ustr(tot_res) + """
"""
# else:
- cr.execute("select count(id) from survey_response_line where question_id = %d and comment != ''"% que.id)
+ cr.execute("select count(id) from survey_response_line where question_id = %s and comment != ''", (que.id,))
tot_res = cr.fetchone()[0]
rml += """
""" + to_xml(tools.ustr(que.comment_label)) + """
""" + tools.ustr(tot_res) + """
"""
elif que.type in['single_textbox']:
- cr.execute("select count(id) from survey_response_line where question_id = %d and single_text!=''" % que.id)
+ cr.execute("select count(id) from survey_response_line where question_id = %s and single_text!=''",(que.id,))
rml += """
@@ -270,7 +270,7 @@ class survey_analysis(report_rml):
"""
elif que.type in['comment']:
- cr.execute("select count(id) from survey_response_line where question_id = %d and comment !=''" % que.id)
+ cr.execute("select count(id) from survey_response_line where question_id = %s and comment !=''", (que.id,))
rml += """
@@ -303,12 +303,12 @@ class survey_analysis(report_rml):
rating_weight_sum = 0
for mat_col in range(1, len(matrix_ans)):
cr.execute("select count(sra.answer_id) from survey_response_line sr, survey_response_answer sra\
- where sr.id = sra.response_id and sra.answer_id = %d and sra.column_id ='%d'" % (ans.id,matrix_ans[mat_col][0]))
+ where sr.id = sra.response_id and sra.answer_id = %s and sra.column_id ='%s'", (ans.id,matrix_ans[mat_col][0]))
tot_res = cr.fetchone()[0]
cr.execute("select count(sra.answer_id),sqc.rating_weight from survey_response_line sr, survey_response_answer sra ,\
survey_question_column_heading sqc where sr.id = sra.response_id and \
- sqc.question_id = sr.question_id and sra.answer_id = %d and sqc.title ='%s'\
- group by sra.answer_id,sqc.rating_weight" % (ans.id,matrix_ans[mat_col][1]))
+ sqc.question_id = sr.question_id and sra.answer_id = %s and sqc.title ='%s'\
++ group by sra.answer_id,sqc.rating_weight", (ans.id,matrix_ans[mat_col][1]))
col_weight = cr.fetchone()
if not col_weight:
@@ -352,10 +352,10 @@ class survey_analysis(report_rml):
rml += """
""" + to_xml(tools.ustr(menu)) + """
"""
rml += """
Answer Count
"""
cr.execute("select count(id), sra.answer_id from survey_response_answer sra \
- where sra.column_id='%s' group by sra.answer_id " % (column.id))
+ where sra.column_id='%s' group by sra.answer_id ", (column.id,))
res_count = cr.dictfetchall()
cr.execute("select count(sra.id),sra.value_choice, sra.answer_id, sra.column_id from survey_response_answer sra \
- where sra.column_id='%s' group by sra.value_choice ,sra.answer_id, sra.column_id" % (column.id))
+ where sra.column_id='%s' group by sra.value_choice ,sra.answer_id, sra.column_id", (column.id,))
calc_percantage = cr.dictfetchall()
for ans in que.answer_choice_ids:
@@ -393,7 +393,7 @@ class survey_analysis(report_rml):
Answer Count
"""
for ans in que.answer_choice_ids:
- cr.execute("select answer from survey_response_answer where answer_id=%d group by answer" % ans.id)
+ cr.execute("select answer from survey_response_answer where answer_id=%s group by answer", (ans.id,))
tot_res = cr.dictfetchall()
total = 0
for tot in tot_res:
diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py
index 4b44b6a1753..109f4509d81 100644
--- a/addons/survey/wizard/survey_answer.py
+++ b/addons/survey/wizard/survey_answer.py
@@ -108,7 +108,7 @@ class survey_question_wiz(osv.osv_memory):
if sur_rec.state != "open" :
raise osv.except_osv(_('Warning !'),_("You can not give answer because of survey is not open for answer"))
cr.execute('select count(id) from survey_history where user_id=%s\
- and survey_id=%s' % (uid,survey_id))
+ and survey_id=%s', (uid,survey_id))
res = cr.fetchone()[0]
user_limit = survey_obj.browse(cr, uid, survey_id)
user_limit = user_limit.response_user
@@ -401,12 +401,12 @@ class survey_question_wiz(osv.osv_memory):
address_id = user_obj.browse(cr, uid, uid).address_id.id
if address_id:
- cr.execute("select email from res_partner_address where id =%d" % address_id)
+ cr.execute("select email from res_partner_address where id =%s", (address_id,))
user_email = cr.fetchone()[0]
resp_id = survey_data.responsible_id.address_id
if resp_id:
- cr.execute("select email from res_partner_address where id =%d" % resp_id.id)
+ cr.execute("select email from res_partner_address where id =%s", (resp_id.id,))
resp_email = cr.fetchone()[0]
if user_email and resp_email:
user_name = user_obj.browse(cr, uid, uid).name