rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
raise LookupError(_("Couldn't find previous ir.actions.todo"))
self.__logger.warn(_("Couldn't find previous ir.actions.todo")) return
def _set_previous_todo(self, cr, uid, state, context=None): """ lookup the previous (which is still the next at this point) ir.actions.todo, set it to whatever state was provided.
89af2f0c8e1fe2b8154dbae862c824ad285d3663 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/89af2f0c8e1fe2b8154dbae862c824ad285d3663/res_config.py
if not len(XMLRPCRequestHandler.rpc_paths): XMLRPCRequestHandler.rpc_paths = map(lambda s: '/%s' % s, netsvc.ExportService._services.keys()) pass
self.rpc_paths = map(lambda s: '/%s' % s, netsvc.ExportService._services.keys())
def setup(self): self.connection = dummyconn() if not len(XMLRPCRequestHandler.rpc_paths): XMLRPCRequestHandler.rpc_paths = map(lambda s: '/%s' % s, netsvc.ExportService._services.keys()) pass
5f3939be3c61a895d961dda559d4793a9ca75dfb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5f3939be3c61a895d961dda559d4793a9ca75dfb/http_server.py
def selection_field(in_field): col_obj = self.pool.get(in_field.keys()[0]) if f[i] in col_obj._columns.keys(): return col_obj._columns[f[i]] elif f[i] in col_obj._inherits.keys(): selection_field(col_obj._inherits) else: return False
9338fc0c4838de6da3f4e8b7897009ba230641b4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9338fc0c4838de6da3f4e8b7897009ba230641b4/orm.py
done = []
def selection_field(in_field): col_obj = self.pool.get(in_field.keys()[0]) if f[i] in col_obj._columns.keys(): return col_obj._columns[f[i]] elif f[i] in col_obj._inherits.keys(): selection_field(col_obj._inherits) else: return False
9338fc0c4838de6da3f4e8b7897009ba230641b4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/9338fc0c4838de6da3f4e8b7897009ba230641b4/orm.py
"AND (s.user_id IN %s) " %(tuple(so_line), tuple(so), company, tuple(users)))
"AND (s.user_id IN %s) " ,(tuple(so_line), tuple(so), company, tuple(users)))
def _sales_per_users(self, cr, uid, so, so_line, company, users): cr.execute("SELECT sum(sol.product_uom_qty) FROM sale_order_line AS sol LEFT JOIN sale_order AS s ON (s.id = sol.order_id) " \ "WHERE (sol.id IN %s) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN %s) AND (s.company_id=%s) " \ "AND (s.user_id IN %s) " %(tuple(so_line), tuple(so), company, tuple(users))) ret = cr.fetchone()[0] or 0.0 return ret
bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf/stock_planning.py
"AND (s.shop_id IN %s)" %(tuple(so_line), tuple(so), company, tuple(shops)))
"AND (s.shop_id IN %s)" ,(tuple(so_line), tuple(so), company, tuple(shops)))
def _sales_per_warehouse(self, cr, uid, so, so_line, company, shops): cr.execute("SELECT sum(sol.product_uom_qty) FROM sale_order_line AS sol LEFT JOIN sale_order AS s ON (s.id = sol.order_id) " \ "WHERE (sol.id IN %s) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN %s)AND (s.company_id=%s) " \ "AND (s.shop_id IN %s)" %(tuple(so_line), tuple(so), company, tuple(shops))) ret = cr.fetchone()[0] or 0.0 return ret
bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf/stock_planning.py
dept_ids_set = ','.join(map(str,dept_ids)) cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" %(tuple(dept_ids_set),))
cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" ,(tuple(dept_ids),))
def calculate_sales_history(self, cr, uid, ids, context, *args): sales=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],] for obj in self.browse(cr, uid, ids): periods =obj.analyzed_period1_id, obj.analyzed_period2_id, obj.analyzed_period3_id, obj.analyzed_period4_id, obj.analyzed_period5_id so_obj = self.pool.get('sale.order') so_line_obj= self.pool.get('sale.order.line') so_line_product_ids = so_line_obj.search(cr, uid, [('product_id','=', obj.product_id.id)], context = context) if so_line_product_ids: so_line_product_set = ','.join(map(str,so_line_product_ids)) if obj.analyzed_warehouse_id: shops = self.pool.get('sale.shop').search(cr, uid,[('warehouse_id','=', obj.analyzed_warehouse_id.id)], context = context) shops_set = ','.join(map(str,shops)) else: shops = False if obj.analyzed_dept_id: dept_obj = self.pool.get('hr.department') dept_id = obj.analyzed_dept_id.id and [obj.analyzed_dept_id.id] or [] dept_ids = dept_obj.search(cr,uid,[('parent_id','child_of',dept_id)]) dept_ids_set = ','.join(map(str,dept_ids)) cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" %(tuple(dept_ids_set),)) dept_users = [x for x, in cr.fetchall()] dept_users_set = ','.join(map(str,dept_users)) else: dept_users = False factor, round_value = self._from_default_uom_factor(cr, uid, obj, obj.product_uom.id, context=context) for i, period in enumerate(periods): if period: so_period_ids = so_obj.search(cr, uid, [('date_order','>=',period.date_start), ('date_order','<=',period.date_stop)], context = context) if so_period_ids: so_period_set = ','.join(map(str,so_period_ids)) if obj.analyzed_user_id: user_set = str(obj.analyzed_user_id.id) sales[i][0] =self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, user_set) sales[i][0] *=factor if dept_users: sales[i][1]= self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, dept_users_set) sales[i][1]*=factor if shops: sales[i][2]= self._sales_per_warehouse(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, shops_set) sales[i][2]*=factor if obj.analyze_company: sales[i][3]= self._sales_per_company(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, ) sales[i][3]*=factor self.write(cr, uid, ids, { 'analyzed_period1_per_user':sales[0][0], 'analyzed_period2_per_user':sales[1][0], 'analyzed_period3_per_user':sales[2][0], 'analyzed_period4_per_user':sales[3][0], 'analyzed_period5_per_user':sales[4][0], 'analyzed_period1_per_dept':sales[0][1], 'analyzed_period2_per_dept':sales[1][1], 'analyzed_period3_per_dept':sales[2][1], 'analyzed_period4_per_dept':sales[3][1], 'analyzed_period5_per_dept':sales[4][1], 'analyzed_period1_per_warehouse':sales[0][2], 'analyzed_period2_per_warehouse':sales[1][2], 'analyzed_period3_per_warehouse':sales[2][2], 'analyzed_period4_per_warehouse':sales[3][2], 'analyzed_period5_per_warehouse':sales[4][2], 'analyzed_period1_per_company':sales[0][3], 'analyzed_period2_per_company':sales[1][3], 'analyzed_period3_per_company':sales[2][3], 'analyzed_period4_per_company':sales[3][3], 'analyzed_period5_per_company':sales[4][3], }) return True
bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf/stock_planning.py
so_period_ids = so_obj.search(cr, uid, [('date_order','>=',period.date_start), ('date_order','<=',period.date_stop)], context = context)
so_period_ids = so_obj.search(cr, uid, [('date_order','>=',period.date_start), ], context = context)
def calculate_sales_history(self, cr, uid, ids, context, *args): sales=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],] for obj in self.browse(cr, uid, ids): periods =obj.analyzed_period1_id, obj.analyzed_period2_id, obj.analyzed_period3_id, obj.analyzed_period4_id, obj.analyzed_period5_id so_obj = self.pool.get('sale.order') so_line_obj= self.pool.get('sale.order.line') so_line_product_ids = so_line_obj.search(cr, uid, [('product_id','=', obj.product_id.id)], context = context) if so_line_product_ids: so_line_product_set = ','.join(map(str,so_line_product_ids)) if obj.analyzed_warehouse_id: shops = self.pool.get('sale.shop').search(cr, uid,[('warehouse_id','=', obj.analyzed_warehouse_id.id)], context = context) shops_set = ','.join(map(str,shops)) else: shops = False if obj.analyzed_dept_id: dept_obj = self.pool.get('hr.department') dept_id = obj.analyzed_dept_id.id and [obj.analyzed_dept_id.id] or [] dept_ids = dept_obj.search(cr,uid,[('parent_id','child_of',dept_id)]) dept_ids_set = ','.join(map(str,dept_ids)) cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" %(tuple(dept_ids_set),)) dept_users = [x for x, in cr.fetchall()] dept_users_set = ','.join(map(str,dept_users)) else: dept_users = False factor, round_value = self._from_default_uom_factor(cr, uid, obj, obj.product_uom.id, context=context) for i, period in enumerate(periods): if period: so_period_ids = so_obj.search(cr, uid, [('date_order','>=',period.date_start), ('date_order','<=',period.date_stop)], context = context) if so_period_ids: so_period_set = ','.join(map(str,so_period_ids)) if obj.analyzed_user_id: user_set = str(obj.analyzed_user_id.id) sales[i][0] =self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, user_set) sales[i][0] *=factor if dept_users: sales[i][1]= self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, dept_users_set) sales[i][1]*=factor if shops: sales[i][2]= self._sales_per_warehouse(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, shops_set) sales[i][2]*=factor if obj.analyze_company: sales[i][3]= self._sales_per_company(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, ) sales[i][3]*=factor self.write(cr, uid, ids, { 'analyzed_period1_per_user':sales[0][0], 'analyzed_period2_per_user':sales[1][0], 'analyzed_period3_per_user':sales[2][0], 'analyzed_period4_per_user':sales[3][0], 'analyzed_period5_per_user':sales[4][0], 'analyzed_period1_per_dept':sales[0][1], 'analyzed_period2_per_dept':sales[1][1], 'analyzed_period3_per_dept':sales[2][1], 'analyzed_period4_per_dept':sales[3][1], 'analyzed_period5_per_dept':sales[4][1], 'analyzed_period1_per_warehouse':sales[0][2], 'analyzed_period2_per_warehouse':sales[1][2], 'analyzed_period3_per_warehouse':sales[2][2], 'analyzed_period4_per_warehouse':sales[3][2], 'analyzed_period5_per_warehouse':sales[4][2], 'analyzed_period1_per_company':sales[0][3], 'analyzed_period2_per_company':sales[1][3], 'analyzed_period3_per_company':sales[2][3], 'analyzed_period4_per_company':sales[3][3], 'analyzed_period5_per_company':sales[4][3], }) return True
bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf/stock_planning.py
so_period_set = ','.join(map(str,so_period_ids))
def calculate_sales_history(self, cr, uid, ids, context, *args): sales=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],] for obj in self.browse(cr, uid, ids): periods =obj.analyzed_period1_id, obj.analyzed_period2_id, obj.analyzed_period3_id, obj.analyzed_period4_id, obj.analyzed_period5_id so_obj = self.pool.get('sale.order') so_line_obj= self.pool.get('sale.order.line') so_line_product_ids = so_line_obj.search(cr, uid, [('product_id','=', obj.product_id.id)], context = context) if so_line_product_ids: so_line_product_set = ','.join(map(str,so_line_product_ids)) if obj.analyzed_warehouse_id: shops = self.pool.get('sale.shop').search(cr, uid,[('warehouse_id','=', obj.analyzed_warehouse_id.id)], context = context) shops_set = ','.join(map(str,shops)) else: shops = False if obj.analyzed_dept_id: dept_obj = self.pool.get('hr.department') dept_id = obj.analyzed_dept_id.id and [obj.analyzed_dept_id.id] or [] dept_ids = dept_obj.search(cr,uid,[('parent_id','child_of',dept_id)]) dept_ids_set = ','.join(map(str,dept_ids)) cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" %(tuple(dept_ids_set),)) dept_users = [x for x, in cr.fetchall()] dept_users_set = ','.join(map(str,dept_users)) else: dept_users = False factor, round_value = self._from_default_uom_factor(cr, uid, obj, obj.product_uom.id, context=context) for i, period in enumerate(periods): if period: so_period_ids = so_obj.search(cr, uid, [('date_order','>=',period.date_start), ('date_order','<=',period.date_stop)], context = context) if so_period_ids: so_period_set = ','.join(map(str,so_period_ids)) if obj.analyzed_user_id: user_set = str(obj.analyzed_user_id.id) sales[i][0] =self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, user_set) sales[i][0] *=factor if dept_users: sales[i][1]= self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, dept_users_set) sales[i][1]*=factor if shops: sales[i][2]= self._sales_per_warehouse(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, shops_set) sales[i][2]*=factor if obj.analyze_company: sales[i][3]= self._sales_per_company(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, ) sales[i][3]*=factor self.write(cr, uid, ids, { 'analyzed_period1_per_user':sales[0][0], 'analyzed_period2_per_user':sales[1][0], 'analyzed_period3_per_user':sales[2][0], 'analyzed_period4_per_user':sales[3][0], 'analyzed_period5_per_user':sales[4][0], 'analyzed_period1_per_dept':sales[0][1], 'analyzed_period2_per_dept':sales[1][1], 'analyzed_period3_per_dept':sales[2][1], 'analyzed_period4_per_dept':sales[3][1], 'analyzed_period5_per_dept':sales[4][1], 'analyzed_period1_per_warehouse':sales[0][2], 'analyzed_period2_per_warehouse':sales[1][2], 'analyzed_period3_per_warehouse':sales[2][2], 'analyzed_period4_per_warehouse':sales[3][2], 'analyzed_period5_per_warehouse':sales[4][2], 'analyzed_period1_per_company':sales[0][3], 'analyzed_period2_per_company':sales[1][3], 'analyzed_period3_per_company':sales[2][3], 'analyzed_period4_per_company':sales[3][3], 'analyzed_period5_per_company':sales[4][3], }) return True
bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf/stock_planning.py
sales[i][0] =self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, user_set)
sales[i][0] =self._sales_per_users(cr, uid, so_period_ids, so_line_product_ids, obj.company_id.id, user_set)
def calculate_sales_history(self, cr, uid, ids, context, *args): sales=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],] for obj in self.browse(cr, uid, ids): periods =obj.analyzed_period1_id, obj.analyzed_period2_id, obj.analyzed_period3_id, obj.analyzed_period4_id, obj.analyzed_period5_id so_obj = self.pool.get('sale.order') so_line_obj= self.pool.get('sale.order.line') so_line_product_ids = so_line_obj.search(cr, uid, [('product_id','=', obj.product_id.id)], context = context) if so_line_product_ids: so_line_product_set = ','.join(map(str,so_line_product_ids)) if obj.analyzed_warehouse_id: shops = self.pool.get('sale.shop').search(cr, uid,[('warehouse_id','=', obj.analyzed_warehouse_id.id)], context = context) shops_set = ','.join(map(str,shops)) else: shops = False if obj.analyzed_dept_id: dept_obj = self.pool.get('hr.department') dept_id = obj.analyzed_dept_id.id and [obj.analyzed_dept_id.id] or [] dept_ids = dept_obj.search(cr,uid,[('parent_id','child_of',dept_id)]) dept_ids_set = ','.join(map(str,dept_ids)) cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" %(tuple(dept_ids_set),)) dept_users = [x for x, in cr.fetchall()] dept_users_set = ','.join(map(str,dept_users)) else: dept_users = False factor, round_value = self._from_default_uom_factor(cr, uid, obj, obj.product_uom.id, context=context) for i, period in enumerate(periods): if period: so_period_ids = so_obj.search(cr, uid, [('date_order','>=',period.date_start), ('date_order','<=',period.date_stop)], context = context) if so_period_ids: so_period_set = ','.join(map(str,so_period_ids)) if obj.analyzed_user_id: user_set = str(obj.analyzed_user_id.id) sales[i][0] =self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, user_set) sales[i][0] *=factor if dept_users: sales[i][1]= self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, dept_users_set) sales[i][1]*=factor if shops: sales[i][2]= self._sales_per_warehouse(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, shops_set) sales[i][2]*=factor if obj.analyze_company: sales[i][3]= self._sales_per_company(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, ) sales[i][3]*=factor self.write(cr, uid, ids, { 'analyzed_period1_per_user':sales[0][0], 'analyzed_period2_per_user':sales[1][0], 'analyzed_period3_per_user':sales[2][0], 'analyzed_period4_per_user':sales[3][0], 'analyzed_period5_per_user':sales[4][0], 'analyzed_period1_per_dept':sales[0][1], 'analyzed_period2_per_dept':sales[1][1], 'analyzed_period3_per_dept':sales[2][1], 'analyzed_period4_per_dept':sales[3][1], 'analyzed_period5_per_dept':sales[4][1], 'analyzed_period1_per_warehouse':sales[0][2], 'analyzed_period2_per_warehouse':sales[1][2], 'analyzed_period3_per_warehouse':sales[2][2], 'analyzed_period4_per_warehouse':sales[3][2], 'analyzed_period5_per_warehouse':sales[4][2], 'analyzed_period1_per_company':sales[0][3], 'analyzed_period2_per_company':sales[1][3], 'analyzed_period3_per_company':sales[2][3], 'analyzed_period4_per_company':sales[3][3], 'analyzed_period5_per_company':sales[4][3], }) return True
bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf/stock_planning.py
sales[i][1]= self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, dept_users_set)
sales[i][1]= self._sales_per_users(cr, uid, so_period_ids, so_line_product_ids, obj.company_id.id, dept_users_set)
def calculate_sales_history(self, cr, uid, ids, context, *args): sales=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],] for obj in self.browse(cr, uid, ids): periods =obj.analyzed_period1_id, obj.analyzed_period2_id, obj.analyzed_period3_id, obj.analyzed_period4_id, obj.analyzed_period5_id so_obj = self.pool.get('sale.order') so_line_obj= self.pool.get('sale.order.line') so_line_product_ids = so_line_obj.search(cr, uid, [('product_id','=', obj.product_id.id)], context = context) if so_line_product_ids: so_line_product_set = ','.join(map(str,so_line_product_ids)) if obj.analyzed_warehouse_id: shops = self.pool.get('sale.shop').search(cr, uid,[('warehouse_id','=', obj.analyzed_warehouse_id.id)], context = context) shops_set = ','.join(map(str,shops)) else: shops = False if obj.analyzed_dept_id: dept_obj = self.pool.get('hr.department') dept_id = obj.analyzed_dept_id.id and [obj.analyzed_dept_id.id] or [] dept_ids = dept_obj.search(cr,uid,[('parent_id','child_of',dept_id)]) dept_ids_set = ','.join(map(str,dept_ids)) cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" %(tuple(dept_ids_set),)) dept_users = [x for x, in cr.fetchall()] dept_users_set = ','.join(map(str,dept_users)) else: dept_users = False factor, round_value = self._from_default_uom_factor(cr, uid, obj, obj.product_uom.id, context=context) for i, period in enumerate(periods): if period: so_period_ids = so_obj.search(cr, uid, [('date_order','>=',period.date_start), ('date_order','<=',period.date_stop)], context = context) if so_period_ids: so_period_set = ','.join(map(str,so_period_ids)) if obj.analyzed_user_id: user_set = str(obj.analyzed_user_id.id) sales[i][0] =self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, user_set) sales[i][0] *=factor if dept_users: sales[i][1]= self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, dept_users_set) sales[i][1]*=factor if shops: sales[i][2]= self._sales_per_warehouse(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, shops_set) sales[i][2]*=factor if obj.analyze_company: sales[i][3]= self._sales_per_company(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, ) sales[i][3]*=factor self.write(cr, uid, ids, { 'analyzed_period1_per_user':sales[0][0], 'analyzed_period2_per_user':sales[1][0], 'analyzed_period3_per_user':sales[2][0], 'analyzed_period4_per_user':sales[3][0], 'analyzed_period5_per_user':sales[4][0], 'analyzed_period1_per_dept':sales[0][1], 'analyzed_period2_per_dept':sales[1][1], 'analyzed_period3_per_dept':sales[2][1], 'analyzed_period4_per_dept':sales[3][1], 'analyzed_period5_per_dept':sales[4][1], 'analyzed_period1_per_warehouse':sales[0][2], 'analyzed_period2_per_warehouse':sales[1][2], 'analyzed_period3_per_warehouse':sales[2][2], 'analyzed_period4_per_warehouse':sales[3][2], 'analyzed_period5_per_warehouse':sales[4][2], 'analyzed_period1_per_company':sales[0][3], 'analyzed_period2_per_company':sales[1][3], 'analyzed_period3_per_company':sales[2][3], 'analyzed_period4_per_company':sales[3][3], 'analyzed_period5_per_company':sales[4][3], }) return True
bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf/stock_planning.py
sales[i][2]= self._sales_per_warehouse(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, shops_set)
sales[i][2]= self._sales_per_warehouse(cr, uid, so_period_ids, so_line_product_ids, obj.company_id.id, shops_set)
def calculate_sales_history(self, cr, uid, ids, context, *args): sales=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],] for obj in self.browse(cr, uid, ids): periods =obj.analyzed_period1_id, obj.analyzed_period2_id, obj.analyzed_period3_id, obj.analyzed_period4_id, obj.analyzed_period5_id so_obj = self.pool.get('sale.order') so_line_obj= self.pool.get('sale.order.line') so_line_product_ids = so_line_obj.search(cr, uid, [('product_id','=', obj.product_id.id)], context = context) if so_line_product_ids: so_line_product_set = ','.join(map(str,so_line_product_ids)) if obj.analyzed_warehouse_id: shops = self.pool.get('sale.shop').search(cr, uid,[('warehouse_id','=', obj.analyzed_warehouse_id.id)], context = context) shops_set = ','.join(map(str,shops)) else: shops = False if obj.analyzed_dept_id: dept_obj = self.pool.get('hr.department') dept_id = obj.analyzed_dept_id.id and [obj.analyzed_dept_id.id] or [] dept_ids = dept_obj.search(cr,uid,[('parent_id','child_of',dept_id)]) dept_ids_set = ','.join(map(str,dept_ids)) cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" %(tuple(dept_ids_set),)) dept_users = [x for x, in cr.fetchall()] dept_users_set = ','.join(map(str,dept_users)) else: dept_users = False factor, round_value = self._from_default_uom_factor(cr, uid, obj, obj.product_uom.id, context=context) for i, period in enumerate(periods): if period: so_period_ids = so_obj.search(cr, uid, [('date_order','>=',period.date_start), ('date_order','<=',period.date_stop)], context = context) if so_period_ids: so_period_set = ','.join(map(str,so_period_ids)) if obj.analyzed_user_id: user_set = str(obj.analyzed_user_id.id) sales[i][0] =self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, user_set) sales[i][0] *=factor if dept_users: sales[i][1]= self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, dept_users_set) sales[i][1]*=factor if shops: sales[i][2]= self._sales_per_warehouse(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, shops_set) sales[i][2]*=factor if obj.analyze_company: sales[i][3]= self._sales_per_company(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, ) sales[i][3]*=factor self.write(cr, uid, ids, { 'analyzed_period1_per_user':sales[0][0], 'analyzed_period2_per_user':sales[1][0], 'analyzed_period3_per_user':sales[2][0], 'analyzed_period4_per_user':sales[3][0], 'analyzed_period5_per_user':sales[4][0], 'analyzed_period1_per_dept':sales[0][1], 'analyzed_period2_per_dept':sales[1][1], 'analyzed_period3_per_dept':sales[2][1], 'analyzed_period4_per_dept':sales[3][1], 'analyzed_period5_per_dept':sales[4][1], 'analyzed_period1_per_warehouse':sales[0][2], 'analyzed_period2_per_warehouse':sales[1][2], 'analyzed_period3_per_warehouse':sales[2][2], 'analyzed_period4_per_warehouse':sales[3][2], 'analyzed_period5_per_warehouse':sales[4][2], 'analyzed_period1_per_company':sales[0][3], 'analyzed_period2_per_company':sales[1][3], 'analyzed_period3_per_company':sales[2][3], 'analyzed_period4_per_company':sales[3][3], 'analyzed_period5_per_company':sales[4][3], }) return True
bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf/stock_planning.py
sales[i][3]= self._sales_per_company(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, )
sales[i][3]= self._sales_per_company(cr, uid, so_period_ids, so_line_product_ids, obj.company_id.id, )
def calculate_sales_history(self, cr, uid, ids, context, *args): sales=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],] for obj in self.browse(cr, uid, ids): periods =obj.analyzed_period1_id, obj.analyzed_period2_id, obj.analyzed_period3_id, obj.analyzed_period4_id, obj.analyzed_period5_id so_obj = self.pool.get('sale.order') so_line_obj= self.pool.get('sale.order.line') so_line_product_ids = so_line_obj.search(cr, uid, [('product_id','=', obj.product_id.id)], context = context) if so_line_product_ids: so_line_product_set = ','.join(map(str,so_line_product_ids)) if obj.analyzed_warehouse_id: shops = self.pool.get('sale.shop').search(cr, uid,[('warehouse_id','=', obj.analyzed_warehouse_id.id)], context = context) shops_set = ','.join(map(str,shops)) else: shops = False if obj.analyzed_dept_id: dept_obj = self.pool.get('hr.department') dept_id = obj.analyzed_dept_id.id and [obj.analyzed_dept_id.id] or [] dept_ids = dept_obj.search(cr,uid,[('parent_id','child_of',dept_id)]) dept_ids_set = ','.join(map(str,dept_ids)) cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" %(tuple(dept_ids_set),)) dept_users = [x for x, in cr.fetchall()] dept_users_set = ','.join(map(str,dept_users)) else: dept_users = False factor, round_value = self._from_default_uom_factor(cr, uid, obj, obj.product_uom.id, context=context) for i, period in enumerate(periods): if period: so_period_ids = so_obj.search(cr, uid, [('date_order','>=',period.date_start), ('date_order','<=',period.date_stop)], context = context) if so_period_ids: so_period_set = ','.join(map(str,so_period_ids)) if obj.analyzed_user_id: user_set = str(obj.analyzed_user_id.id) sales[i][0] =self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, user_set) sales[i][0] *=factor if dept_users: sales[i][1]= self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, dept_users_set) sales[i][1]*=factor if shops: sales[i][2]= self._sales_per_warehouse(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, shops_set) sales[i][2]*=factor if obj.analyze_company: sales[i][3]= self._sales_per_company(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, ) sales[i][3]*=factor self.write(cr, uid, ids, { 'analyzed_period1_per_user':sales[0][0], 'analyzed_period2_per_user':sales[1][0], 'analyzed_period3_per_user':sales[2][0], 'analyzed_period4_per_user':sales[3][0], 'analyzed_period5_per_user':sales[4][0], 'analyzed_period1_per_dept':sales[0][1], 'analyzed_period2_per_dept':sales[1][1], 'analyzed_period3_per_dept':sales[2][1], 'analyzed_period4_per_dept':sales[3][1], 'analyzed_period5_per_dept':sales[4][1], 'analyzed_period1_per_warehouse':sales[0][2], 'analyzed_period2_per_warehouse':sales[1][2], 'analyzed_period3_per_warehouse':sales[2][2], 'analyzed_period4_per_warehouse':sales[3][2], 'analyzed_period5_per_warehouse':sales[4][2], 'analyzed_period1_per_company':sales[0][3], 'analyzed_period2_per_company':sales[1][3], 'analyzed_period3_per_company':sales[2][3], 'analyzed_period4_per_company':sales[3][3], 'analyzed_period5_per_company':sales[4][3], }) return True
bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc84ee95c63ab674a62ad477d7cffbaeb2eb2ddf/stock_planning.py
'get_start_date': self.get_start_date, 'get_end_date': self.get_end_date
def __init__(self, cr, uid, name, context=None): if context is None: context = {} super(journal_print, self).__init__(cr, uid, name, context=context) self.period_ids = [] self.journal_ids = [] self.localcontext.update({ 'time': time, 'lines': self.lines, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_start_date': self.get_start_date, 'get_end_date': self.get_end_date })
c5b104951fb0bfaf14537e4a0b29222b415623b3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c5b104951fb0bfaf14537e4a0b29222b415623b3/central_journal.py
print 'Not Found', key
def write(self, cr, uid, ids, values, context=None): if not hasattr(ids, '__iter__'): ids = [ids] if ids == [uid]: for key in values.keys(): if not (key in self.SELF_WRITEABLE_FIELDS or key.startswith('context_')): print 'Not Found', key break else: if 'company_id' in values: if not (values['company_id'] in self.read(cr, uid, uid, ['company_ids'], context=context)['company_ids']): del values['company_id'] uid = 1 # safe fields only, so we write as super-user to bypass access rights
5ba8d704991309c2e60ba451e915322c8aa61694 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5ba8d704991309c2e60ba451e915322c8aa61694/res_user.py
if isinstance(ids, (str, int, long)): ids = [ids] data = super(ir_model, self).read(cr, uid, ids, fields=fields, \
new_ids = isinstance(ids, (str, int, long)) and [ids] or ids data = super(ir_model, self).read(cr, uid, new_ids, fields=fields, \
def read(self, cr, uid, ids, fields=None, context={}, load='_classic_read'): """ Read IR Model @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of IR Model’s IDs. @param context: A standard dictionary for contextual values """
08042b1fb3b1da1ab55a6f6f1888f7c452199cf1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/08042b1fb3b1da1ab55a6f6f1888f7c452199cf1/base_calendar.py
return data
return new_ids = isinstance(ids, (str, int, long)) and data[0] or data
def read(self, cr, uid, ids, fields=None, context={}, load='_classic_read'): """ Read IR Model @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of IR Model’s IDs. @param context: A standard dictionary for contextual values """
08042b1fb3b1da1ab55a6f6f1888f7c452199cf1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/08042b1fb3b1da1ab55a6f6f1888f7c452199cf1/base_calendar.py
def html2plaintext(html, body_id=None, encoding='utf-8'): ## (c) Fry-IT, www.fry-it.com, 2007 ## <[email protected]> ## download here: http://www.peterbe.com/plog/html2plaintext """ from an HTML text, convert the HTML to plain text. If @body_id is provided then this is the tag where the body (not necessarily <body>) starts. """ try: from BeautifulSoup import BeautifulSoup, SoupStrainer, Comment except: return html urls = [] if body_id is not None: strainer = SoupStrainer(id=body_id) else: strainer = SoupStrainer('body') soup = BeautifulSoup(html, parseOnlyThese=strainer, fromEncoding=encoding) for link in soup.findAll('a'): title = unicode(link) for url in [x[1] for x in link.attrs if x[0]=='href']: urls.append(dict(url=url, tag=unicode(link), title=title)) html = unicode(soup) url_index = [] i = 0 for d in urls: if d['title'] == d['url'] or 'http://'+d['title'] == d['url']: html = html.replace(d['tag'], d['url']) else: i += 1 html = html.replace(d['tag'], '%s [%s]' % (d['title'], i)) url_index.append(d['url']) html = html.replace('<strong>', '*').replace('</strong>', '*') html = html.replace('<b>', '*').replace('</b>', '*') html = html.replace('<h3>', '*').replace('</h3>', '*') html = html.replace('<h2>', '**').replace('</h2>', '**') html = html.replace('<h1>', '**').replace('</h1>', '**') html = html.replace('<em>', '/').replace('</em>', '/') # the only line breaks we respect is those of ending tags and # breaks html = html.replace('\n', ' ') html = html.replace('<br>', '\n') html = html.replace('<tr>', '\n') html = html.replace('</p>', '\n\n') html = re.sub('<br\s*/>', '\n', html) html = html.replace(' ' * 2, ' ') # for all other tags we failed to clean up, just remove then and # complain about them on the stderr def desperate_fixer(g): #print >>sys.stderr, "failed to clean up %s" % str(g.group()) return ' ' html = re.sub('<.*?>', desperate_fixer, html) # lstrip all lines html = '\n'.join([x.lstrip() for x in html.splitlines()]) for i, url in enumerate(url_index): if i == 0: html += '\n\n' html += '[%s] %s\n' % (i+1, url) return html
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
def desperate_fixer(g): return ' ' html = re.sub('<.*?>', desperate_fixer, html)
html = re.sub('<.*?>', ' ', html)
def html2plaintext(html, body_id=None, encoding='utf-8'): ## (c) Fry-IT, www.fry-it.com, 2007 ## <[email protected]> ## download here: http://www.peterbe.com/plog/html2plaintext """ from an HTML text, convert the HTML to plain text. If @body_id is provided then this is the tag where the body (not necessarily <body>) starts. """ try: from BeautifulSoup import BeautifulSoup, SoupStrainer, Comment except: return html urls = [] if body_id is not None: strainer = SoupStrainer(id=body_id) else: strainer = SoupStrainer('body') soup = BeautifulSoup(html, parseOnlyThese=strainer, fromEncoding=encoding) for link in soup.findAll('a'): title = unicode(link) for url in [x[1] for x in link.attrs if x[0]=='href']: urls.append(dict(url=url, tag=unicode(link), title=title)) html = unicode(soup) url_index = [] i = 0 for d in urls: if d['title'] == d['url'] or 'http://'+d['title'] == d['url']: html = html.replace(d['tag'], d['url']) else: i += 1 html = html.replace(d['tag'], '%s [%s]' % (d['title'], i)) url_index.append(d['url']) html = html.replace('<strong>', '*').replace('</strong>', '*') html = html.replace('<b>', '*').replace('</b>', '*') html = html.replace('<h3>', '*').replace('</h3>', '*') html = html.replace('<h2>', '**').replace('</h2>', '**') html = html.replace('<h1>', '**').replace('</h1>', '**') html = html.replace('<em>', '/').replace('</em>', '/') # the only line breaks we respect is those of ending tags and # breaks html = html.replace('\n', ' ') html = html.replace('<br>', '\n') html = html.replace('<tr>', '\n') html = html.replace('</p>', '\n\n') html = re.sub('<br\s*/>', '\n', html) html = html.replace(' ' * 2, ' ') # for all other tags we failed to clean up, just remove then and # complain about them on the stderr def desperate_fixer(g): #print >>sys.stderr, "failed to clean up %s" % str(g.group()) return ' ' html = re.sub('<.*?>', desperate_fixer, html) # lstrip all lines html = '\n'.join([x.lstrip() for x in html.splitlines()]) for i, url in enumerate(url_index): if i == 0: html += '\n\n' html += '[%s] %s\n' % (i+1, url) return html
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
def _decode_header(self, s):
def _decode_header(self, text):
def _decode_header(self, s): from email.Header import decode_header s = decode_header(s.replace('\r', '')) return ''.join(map(lambda x:self._to_decode(x[0], [x[1]]), s or []))
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
s = decode_header(s.replace('\r', '')) return ''.join(map(lambda x:self._to_decode(x[0], [x[1]]), s or []))
if text: text = decode_header(text.replace('\r', '')) return ''.join(map(lambda x:self._to_decode(x[0], [x[1]]), text or []))
def _decode_header(self, s): from email.Header import decode_header s = decode_header(s.replace('\r', '')) return ''.join(map(lambda x:self._to_decode(x[0], [x[1]]), s or []))
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
try: id = self.rpc(self.model, 'create', data) self.rpc(self.model, 'history', [id], 'Receive', True, msg_to, message['body'], msg_from, False, {'model' : self.model}) except Exception, e: if getattr(e, 'faultCode', '') and 'AccessError' in e.faultCode: e = '\n\nThe Specified user does not have an access to the CRM case.' print e
values = { 'message_ids' : [ (0, 0, { 'model_id' : self.rpc('ir.model', 'search', [('name', '=', self.model)])[0], 'date' : time.strftime('%Y-%m-%d %H:%M:%S'), 'description' : message['body'], 'email_from' : msg_from, 'email_to' : msg_to, 'name' : 'Receive', 'history' : True, 'user_id' : self.rpc.user_id, } ) ] } thread_id = self.rpc('mailgate.thread', 'create', values) data['thread_id'] = thread_id oid = self.rpc(self.model, 'create', data)
def msg_new(self, msg): message = self.msg_body_get(msg) msg_subject = self._decode_header(msg['Subject']) msg_from = self._decode_header(msg['From']) msg_to = self._decode_header(msg['To']) msg_cc = self._decode_header(msg['Cc'] or '') data = { 'name': msg_subject, 'email_from': msg_from, 'email_cc': msg_cc, 'user_id': False, 'description': message['body'], 'state' : 'draft', } data.update(self.partner_get(msg_from))
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
'res_id': id
'res_id': oid
def msg_new(self, msg): message = self.msg_body_get(msg) msg_subject = self._decode_header(msg['Subject']) msg_from = self._decode_header(msg['From']) msg_to = self._decode_header(msg['To']) msg_cc = self._decode_header(msg['Cc'] or '') data = { 'name': msg_subject, 'email_from': msg_from, 'email_cc': msg_cc, 'user_id': False, 'description': message['body'], 'state' : 'draft', } data.update(self.partner_get(msg_from))
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
return id
return (oid, thread_id,)
def msg_new(self, msg): message = self.msg_body_get(msg) msg_subject = self._decode_header(msg['Subject']) msg_from = self._decode_header(msg['From']) msg_to = self._decode_header(msg['To']) msg_cc = self._decode_header(msg['Cc'] or '') data = { 'name': msg_subject, 'email_from': msg_from, 'email_cc': msg_cc, 'user_id': False, 'description': message['body'], 'state' : 'draft', } data.update(self.partner_get(msg_from))
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
message = {}; message['body'] = ''; message['attachment'] = {};
message = { 'body' : '', 'attachment' : {}, }
def msg_body_get(self, msg): message = {}; message['body'] = ''; message['attachment'] = {}; attachment = message['attachment']; counter = 1; def replace(match): return ''
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
def replace(match): return ''
def replace(match): return ''
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
txt = re.sub("<(\w)>", replace, txt) txt = re.sub("<\/(\w)>", replace, txt)
txt = re.sub("<\/?(\w)>", '', txt)
def replace(match): return ''
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
elif txt and part.get_content_subtype() == 'html':
elif txt and part.get_content_subtype() == 'html':
def replace(match): return ''
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
def replace(match): return ''
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
elif part.get_content_maintype()=='application' or part.get_content_maintype()=='image' or part.get_content_maintype()=='text':
elif part.get_content_maintype() in ('application', 'image', 'text'):
def replace(match): return ''
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
if filename : attachment[filename] = part.get_payload(decode=True); else:
if not filename :
def replace(match): return ''
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
attachment[filename] = part.get_payload(decode=True);
attachment[filename] = part.get_payload(decode=True);
def replace(match): return ''
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
self.rpc(self.model, 'history', [id], 'Send', True, self._decode_header(msg['To']), body['body'], self._decode_header(msg['From']), False, {'model' : self.model})
self.create_message(id, msg['From'], msg['To'], 'Send', message['body'])
def msg_user(self, msg, id): body = self.msg_body_get(msg)
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
if not len(emails):
if not emails:
def msg_send(self, msg, emails, priority=None): if not len(emails): return False del msg['To'] msg['To'] = emails[0] if len(emails)>1: if 'Cc' in msg: del msg['Cc'] msg['Cc'] = ','.join(emails[1:]) del msg['Reply-To'] msg['Reply-To'] = self.email if priority: msg['X-Priority'] = priorities.get(priority, '3 (Normal)') s = smtplib.SMTP() s.connect() s.sendmail(self.email, emails, msg.as_string()) s.close() return True
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
del msg['To']
def msg_send(self, msg, emails, priority=None): if not len(emails): return False del msg['To'] msg['To'] = emails[0] if len(emails)>1: if 'Cc' in msg: del msg['Cc'] msg['Cc'] = ','.join(emails[1:]) del msg['Reply-To'] msg['Reply-To'] = self.email if priority: msg['X-Priority'] = priorities.get(priority, '3 (Normal)') s = smtplib.SMTP() s.connect() s.sendmail(self.email, emails, msg.as_string()) s.close() return True
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
if len(emails)>1: if 'Cc' in msg: del msg['Cc']
if len(emails) > 1:
def msg_send(self, msg, emails, priority=None): if not len(emails): return False del msg['To'] msg['To'] = emails[0] if len(emails)>1: if 'Cc' in msg: del msg['Cc'] msg['Cc'] = ','.join(emails[1:]) del msg['Reply-To'] msg['Reply-To'] = self.email if priority: msg['X-Priority'] = priorities.get(priority, '3 (Normal)') s = smtplib.SMTP() s.connect() s.sendmail(self.email, emails, msg.as_string()) s.close() return True
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
del msg['Reply-To']
def msg_send(self, msg, emails, priority=None): if not len(emails): return False del msg['To'] msg['To'] = emails[0] if len(emails)>1: if 'Cc' in msg: del msg['Cc'] msg['Cc'] = ','.join(emails[1:]) del msg['Reply-To'] msg['Reply-To'] = self.email if priority: msg['X-Priority'] = priorities.get(priority, '3 (Normal)') s = smtplib.SMTP() s.connect() s.sendmail(self.email, emails, msg.as_string()) s.close() return True
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
def msg_partner(self, msg, id): message = self.msg_body_get(msg) body = message['body'] act = 'case_open' self.rpc(self.model, act, [id]) #body2 = '\n'.join(map(lambda l: '> '+l, (body or '').split('\n'))) #data = { # 'description':body, #} #self.rpc(self.model, 'write', [id], data) attachments = message['attachment'] for attach in attachments or []: data_attach = { 'name': str(attach), 'datas': binascii.b2a_base64(str(attachments[attach])), 'datas_fname': str(attach), 'description': 'Mail attachment', 'res_model': self.model, 'res_id': id } self.rpc('ir.attachment', 'create', data_attach)
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
self.rpc(self.model, 'history', [id], 'Send', True, self._decode_header(msg['To']), message['body'], self._decode_header(msg['From']), False, {'model' : self.model})
self.create_message(id, msg['From'], msg['To'], 'Send', message['body'])
def msg_partner(self, msg, id): message = self.msg_body_get(msg) body = message['body'] act = 'case_open' self.rpc(self.model, act, [id]) #body2 = '\n'.join(map(lambda l: '> '+l, (body or '').split('\n'))) #data = { # 'description':body, #} #self.rpc(self.model, 'write', [id], data) attachments = message['attachment'] for attach in attachments or []: data_attach = { 'name': str(attach), 'datas': binascii.b2a_base64(str(attachments[attach])), 'datas_fname': str(attach), 'description': 'Mail attachment', 'res_model': self.model, 'res_id': id } self.rpc('ir.attachment', 'create', data_attach)
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
emails = self.rpc(self.model, 'emails_get', int(case_str)) return (int(case_str), emails)
case_id = int(case_str) emails = self.rpc(self.model, 'emails_get', [case_id]) return (case_id, emails)
def msg_test(self, msg, case_str): if not case_str: return (False, False) emails = self.rpc(self.model, 'emails_get', int(case_str)) return (int(case_str), emails)
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
if emails[0] and self.email_get(emails[0])==self.email_get(self._decode_header(msg['From'])):
values = self.rpc(self.model, 'read', [case_id], ['thread_id']) if values: thread_id = values[0]['thread_id'][0] emails = emails[str(thread_id)] user_email = filter(None, emails['user_email'])[0] if user_email and self.email_get(user_email) == self.email_get(self._decode_header(msg['From'])):
def parse(self, msg): case_str = reference_re.search(msg.get('References', '')) if case_str: case_str = case_str.group(1) else: case_str = case_re.search(msg.get('Subject', '')) if case_str: case_str = case_str.group(1) (case_id, emails) = self.msg_test(msg, case_str) if case_id: if emails[0] and self.email_get(emails[0])==self.email_get(self._decode_header(msg['From'])): self.msg_user(msg, case_id) else: self.msg_partner(msg, case_id) else: case_id = self.msg_new(msg) subject = self._decode_header(msg['subject']) if msg.get('Subject', ''): del msg['Subject'] msg['Subject'] = '['+str(case_id)+'] '+subject msg['Message-Id'] = '<'+str(time.time())+'-openerpcrm-'+str(case_id)+'@'+socket.gethostname()+'>'
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
case_id = self.msg_new(msg) subject = self._decode_header(msg['subject']) if msg.get('Subject', ''): del msg['Subject'] msg['Subject'] = '['+str(case_id)+'] '+subject msg['Message-Id'] = '<'+str(time.time())+'-openerpcrm-'+str(case_id)+'@'+socket.gethostname()+'>' emails = self.rpc(self.model, 'emails_get', case_id) priority = emails[3] em = [emails[0], emails[1]] + (emails[2] or '').split(',')
case_id, thread_id = self.msg_new(msg) subject = self._decode_header(msg['Subject']) msg['Subject'] = "[%s] %s" % (case_id, subject,) msg['Message-Id'] = "<%s-openerpcrm-%s@%s>" % (time.time(), case_id, socket.gethostname(),) logging.info(" case: %r", case_id) logging.info(" thread: %r", thread_id) values = self.rpc(self.model, 'emails_get', [case_id]) emails = values[str(thread_id)] priority = emails.get('piority', [3])[0] em = emails['user_email'] + emails['email_from'] + emails['email_cc']
def parse(self, msg): case_str = reference_re.search(msg.get('References', '')) if case_str: case_str = case_str.group(1) else: case_str = case_re.search(msg.get('Subject', '')) if case_str: case_str = case_str.group(1) (case_id, emails) = self.msg_test(msg, case_str) if case_id: if emails[0] and self.email_get(emails[0])==self.email_get(self._decode_header(msg['From'])): self.msg_user(msg, case_id) else: self.msg_partner(msg, case_id) else: case_id = self.msg_new(msg) subject = self._decode_header(msg['subject']) if msg.get('Subject', ''): del msg['Subject'] msg['Subject'] = '['+str(case_id)+'] '+subject msg['Message-Id'] = '<'+str(time.time())+'-openerpcrm-'+str(case_id)+'@'+socket.gethostname()+'>'
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
del msg['Subject']
def parse(self, msg): case_str = reference_re.search(msg.get('References', '')) if case_str: case_str = case_str.group(1) else: case_str = case_re.search(msg.get('Subject', '')) if case_str: case_str = case_str.group(1) (case_id, emails) = self.msg_test(msg, case_str) if case_id: if emails[0] and self.email_get(emails[0])==self.email_get(self._decode_header(msg['From'])): self.msg_user(msg, case_id) else: self.msg_partner(msg, case_id) else: case_id = self.msg_new(msg) subject = self._decode_header(msg['subject']) if msg.get('Subject', ''): del msg['Subject'] msg['Subject'] = '['+str(case_id)+'] '+subject msg['Message-Id'] = '<'+str(time.time())+'-openerpcrm-'+str(case_id)+'@'+socket.gethostname()+'>'
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
return case_id, emails
return case_id, thread_id, emails
def parse(self, msg): case_str = reference_re.search(msg.get('References', '')) if case_str: case_str = case_str.group(1) else: case_str = case_re.search(msg.get('Subject', '')) if case_str: case_str = case_str.group(1) (case_id, emails) = self.msg_test(msg, case_str) if case_id: if emails[0] and self.email_get(emails[0])==self.email_get(self._decode_header(msg['From'])): self.msg_user(msg, case_id) else: self.msg_partner(msg, case_id) else: case_id = self.msg_new(msg) subject = self._decode_header(msg['subject']) if msg.get('Subject', ''): del msg['Subject'] msg['Subject'] = '['+str(case_id)+'] '+subject msg['Message-Id'] = '<'+str(time.time())+'-openerpcrm-'+str(case_id)+'@'+socket.gethostname()+'>'
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
import sys, optparse
def parse(self, msg): case_str = reference_re.search(msg.get('References', '')) if case_str: case_str = case_str.group(1) else: case_str = case_re.search(msg.get('Subject', '')) if case_str: case_str = case_str.group(1) (case_id, emails) = self.msg_test(msg, case_str) if case_id: if emails[0] and self.email_get(emails[0])==self.email_get(self._decode_header(msg['From'])): self.msg_user(msg, case_id) else: self.msg_partner(msg, case_id) else: case_id = self.msg_new(msg) subject = self._decode_header(msg['subject']) if msg.get('Subject', ''): del msg['Subject'] msg['Subject'] = '['+str(case_id)+'] '+subject msg['Message-Id'] = '<'+str(time.time())+'-openerpcrm-'+str(case_id)+'@'+socket.gethostname()+'>'
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
def parse(self, msg): case_str = reference_re.search(msg.get('References', '')) if case_str: case_str = case_str.group(1) else: case_str = case_re.search(msg.get('Subject', '')) if case_str: case_str = case_str.group(1) (case_id, emails) = self.msg_test(msg, case_str) if case_id: if emails[0] and self.email_get(emails[0])==self.email_get(self._decode_header(msg['From'])): self.msg_user(msg, case_id) else: self.msg_partner(msg, case_id) else: case_id = self.msg_new(msg) subject = self._decode_header(msg['subject']) if msg.get('Subject', ''): del msg['Subject'] msg['Subject'] = '['+str(case_id)+'] '+subject msg['Message-Id'] = '<'+str(time.time())+'-openerpcrm-'+str(case_id)+'@'+socket.gethostname()+'>'
58e9a51264038e97e4ac99a3a64ac10d68e4c26a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/58e9a51264038e97e4ac99a3a64ac10d68e4c26a/openerp_mailgate.py
def create(self, cr, uid, vals, context=None): if (not vals.get('company_ids',[])): company_ids = self._get_companies(cr, uid, context=context) if company_ids and len(company_ids): vals['company_ids'] = [(6, 0, company_ids)] return super(users, self).create(cr, uid, vals, context=context)
def create(self, cr, uid, vals, context=None): if (not vals.get('company_ids',[])): company_ids = self._get_companies(cr, uid, context=context) if company_ids and len(company_ids): vals['company_ids'] = [(6, 0, company_ids)] return super(users, self).create(cr, uid, vals, context=context)
236e74c3964942f354ae00f5bea0883b4842693e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/236e74c3964942f354ae00f5bea0883b4842693e/res_user.py
msg['Message-Id'] = "<%s-openobject-%s@%s>" % (time.time(), openobject_id, socket.gethostname())
message['Message-Id'] = "<%s-openobject-%s@%s>" % (time.time(), openobject_id, socket.gethostname())
def _email_send(message, openobject_id=None, debug=False): """Low-level method to send directly a Message through the configured smtp server. :param message: an email.message.Message to send :param debug: True if messages should be output to stderr before being sent, and smtplib.SMTP put into debug mode. :return: True if the mail was delivered successfully to the smtp, else False (+ exception logged) """ if openobject_id: msg['Message-Id'] = "<%s-openobject-%s@%s>" % (time.time(), openobject_id, socket.gethostname()) try: oldstderr = smtplib.stderr s = smtplib.SMTP() try: # in case of debug, the messages are printed to stderr. if debug: smtplib.stderr = WriteToLogger() s.set_debuglevel(int(bool(debug))) # 0 or 1 s.connect(smtp_server, config['smtp_port']) if ssl: s.ehlo() s.starttls() s.ehlo() if config['smtp_user'] or config['smtp_password']: s.login(config['smtp_user'], config['smtp_password']) s.sendmail(email_from, flatten([email_to, email_cc, email_bcc]), msg.as_string()) finally: s.quit() if debug: smtplib.stderr = oldstderr except Exception, e: _logger.error('could not deliver email', exc_info=True) return False return True
09e9462aae9d7f9df75e5426f279281adcbc8a53 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/09e9462aae9d7f9df75e5426f279281adcbc8a53/misc.py
msg.as_string())
message.as_string())
def _email_send(message, openobject_id=None, debug=False): """Low-level method to send directly a Message through the configured smtp server. :param message: an email.message.Message to send :param debug: True if messages should be output to stderr before being sent, and smtplib.SMTP put into debug mode. :return: True if the mail was delivered successfully to the smtp, else False (+ exception logged) """ if openobject_id: msg['Message-Id'] = "<%s-openobject-%s@%s>" % (time.time(), openobject_id, socket.gethostname()) try: oldstderr = smtplib.stderr s = smtplib.SMTP() try: # in case of debug, the messages are printed to stderr. if debug: smtplib.stderr = WriteToLogger() s.set_debuglevel(int(bool(debug))) # 0 or 1 s.connect(smtp_server, config['smtp_port']) if ssl: s.ehlo() s.starttls() s.ehlo() if config['smtp_user'] or config['smtp_password']: s.login(config['smtp_user'], config['smtp_password']) s.sendmail(email_from, flatten([email_to, email_cc, email_bcc]), msg.as_string()) finally: s.quit() if debug: smtplib.stderr = oldstderr except Exception, e: _logger.error('could not deliver email', exc_info=True) return False return True
09e9462aae9d7f9df75e5426f279281adcbc8a53 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/09e9462aae9d7f9df75e5426f279281adcbc8a53/misc.py
'remaining_hours' : fields.float('Remaining Hours', digits=(16,2), help="Re-estimated time that will change the remaining hours of the task"), }
'remaining_hours' : fields.float('Remaining Hours', digits=(16,2), help="Put here the remaining hours required to close the task."), }
def _get_remaining(self,cr, uid, ctx): task_obj = self.pool.get('project.task') if 'active_id' in ctx: return task_obj.browse(cr,uid,ctx['active_id'],context=ctx).remaining_hours return False
c3ccf9696856263ef2aa044e1a0c6b015c50fb2b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c3ccf9696856263ef2aa044e1a0c6b015c50fb2b/project.py
}
}
def _get_remaining(self,cr, uid, ctx): task_obj = self.pool.get('project.task') if 'active_id' in ctx: return task_obj.browse(cr,uid,ctx['active_id'],context=ctx).remaining_hours return False
c3ccf9696856263ef2aa044e1a0c6b015c50fb2b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c3ccf9696856263ef2aa044e1a0c6b015c50fb2b/project.py
amount = 0.0
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, journal_id=False, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, time zone @return: Returns a dict which contains new values, and context """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') move_line_pool = self.pool.get('account.move.line') partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) if journal_id: context.update({ 'journal_id':journal_id, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default account_id = False partner = partner_pool.browse(cr, uid, partner_id) if ttype in ('sale'): account_id = partner.property_account_receivable.id elif ttype in ('purchase'): account_id = partner.property_account_payable.id elif ttype in ('payment', 'receipt'): journal = journal_pool.browse(cr, uid, journal_id) if ttype == 'payment': account_id = journal.default_credit_account_id.id elif ttype == 'receipt': account_id = journal.default_debit_account_id.id default['value'].update({ 'account_id':account_id }) if ttype not in ('payment', 'receipt'): return default voucher_id = ids and ids[0] or False search_type = 'credit' account_type = False if ttype == 'receipt': search_type = 'debit' account_type = 'receivable' elif ttype == 'payment': search_type = 'credit' account_type = 'payable'
bf6f28068a75d64e45c8c384f74b759fbd4ebf5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bf6f28068a75d64e45c8c384f74b759fbd4ebf5b/voucher.py
'amount':line.credit
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, journal_id=False, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, time zone @return: Returns a dict which contains new values, and context """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') move_line_pool = self.pool.get('account.move.line') partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) if journal_id: context.update({ 'journal_id':journal_id, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default account_id = False partner = partner_pool.browse(cr, uid, partner_id) if ttype in ('sale'): account_id = partner.property_account_receivable.id elif ttype in ('purchase'): account_id = partner.property_account_payable.id elif ttype in ('payment', 'receipt'): journal = journal_pool.browse(cr, uid, journal_id) if ttype == 'payment': account_id = journal.default_credit_account_id.id elif ttype == 'receipt': account_id = journal.default_debit_account_id.id default['value'].update({ 'account_id':account_id }) if ttype not in ('payment', 'receipt'): return default voucher_id = ids and ids[0] or False search_type = 'credit' account_type = False if ttype == 'receipt': search_type = 'debit' account_type = 'receivable' elif ttype == 'payment': search_type = 'credit' account_type = 'payable'
bf6f28068a75d64e45c8c384f74b759fbd4ebf5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bf6f28068a75d64e45c8c384f74b759fbd4ebf5b/voucher.py
'amount':line.debit
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, journal_id=False, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, time zone @return: Returns a dict which contains new values, and context """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') move_line_pool = self.pool.get('account.move.line') partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) if journal_id: context.update({ 'journal_id':journal_id, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default account_id = False partner = partner_pool.browse(cr, uid, partner_id) if ttype in ('sale'): account_id = partner.property_account_receivable.id elif ttype in ('purchase'): account_id = partner.property_account_payable.id elif ttype in ('payment', 'receipt'): journal = journal_pool.browse(cr, uid, journal_id) if ttype == 'payment': account_id = journal.default_credit_account_id.id elif ttype == 'receipt': account_id = journal.default_debit_account_id.id default['value'].update({ 'account_id':account_id }) if ttype not in ('payment', 'receipt'): return default voucher_id = ids and ids[0] or False search_type = 'credit' account_type = False if ttype == 'receipt': search_type = 'debit' account_type = 'receivable' elif ttype == 'payment': search_type = 'credit' account_type = 'payable'
bf6f28068a75d64e45c8c384f74b759fbd4ebf5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bf6f28068a75d64e45c8c384f74b759fbd4ebf5b/voucher.py
'name':inv.name,
'name':inv.name and inv.name or '/',
def action_move_line_create(self, cr, uid, ids, *args): journal_pool = self.pool.get('account.journal') sequence_pool = self.pool.get('ir.sequence') move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') currency_pool = self.pool.get('res.currency') invoice_pool = self.pool.get('account.invoice') for inv in self.browse(cr, uid, ids): if inv.move_id: continue
bf6f28068a75d64e45c8c384f74b759fbd4ebf5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bf6f28068a75d64e45c8c384f74b759fbd4ebf5b/voucher.py
rec_ids = []
def action_move_line_create(self, cr, uid, ids, *args): journal_pool = self.pool.get('account.journal') sequence_pool = self.pool.get('ir.sequence') move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') currency_pool = self.pool.get('res.currency') invoice_pool = self.pool.get('account.invoice') for inv in self.browse(cr, uid, ids): if inv.move_id: continue
bf6f28068a75d64e45c8c384f74b759fbd4ebf5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bf6f28068a75d64e45c8c384f74b759fbd4ebf5b/voucher.py
rec_ids = []
def action_move_line_create(self, cr, uid, ids, *args): journal_pool = self.pool.get('account.journal') sequence_pool = self.pool.get('ir.sequence') move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') currency_pool = self.pool.get('res.currency') invoice_pool = self.pool.get('account.invoice') for inv in self.browse(cr, uid, ids): if inv.move_id: continue
bf6f28068a75d64e45c8c384f74b759fbd4ebf5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bf6f28068a75d64e45c8c384f74b759fbd4ebf5b/voucher.py
'name':line.name,
'name':line.name and line.name or '/',
def action_move_line_create(self, cr, uid, ids, *args): journal_pool = self.pool.get('account.journal') sequence_pool = self.pool.get('ir.sequence') move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') currency_pool = self.pool.get('res.currency') invoice_pool = self.pool.get('account.invoice') for inv in self.browse(cr, uid, ids): if inv.move_id: continue
bf6f28068a75d64e45c8c384f74b759fbd4ebf5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bf6f28068a75d64e45c8c384f74b759fbd4ebf5b/voucher.py
def action_move_line_create(self, cr, uid, ids, *args): journal_pool = self.pool.get('account.journal') sequence_pool = self.pool.get('ir.sequence') move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') currency_pool = self.pool.get('res.currency') invoice_pool = self.pool.get('account.invoice') for inv in self.browse(cr, uid, ids): if inv.move_id: continue
bf6f28068a75d64e45c8c384f74b759fbd4ebf5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bf6f28068a75d64e45c8c384f74b759fbd4ebf5b/voucher.py
for move_line in line.move_id.line_id: if line.account_id.id == move_line.account_id.id: rec_ids += [move_line.id]
if line.move_line_id: rec_ids += [line.move_line_id.id] if rec_ids: cr.commit() move_line_pool.reconcile_partial(cr, uid, rec_ids)
def action_move_line_create(self, cr, uid, ids, *args): journal_pool = self.pool.get('account.journal') sequence_pool = self.pool.get('ir.sequence') move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') currency_pool = self.pool.get('res.currency') invoice_pool = self.pool.get('account.invoice') for inv in self.browse(cr, uid, ids): if inv.move_id: continue
bf6f28068a75d64e45c8c384f74b759fbd4ebf5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bf6f28068a75d64e45c8c384f74b759fbd4ebf5b/voucher.py
'name':inv.tax_id.name,
'name':name,
def action_move_line_create(self, cr, uid, ids, *args): journal_pool = self.pool.get('account.journal') sequence_pool = self.pool.get('ir.sequence') move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') currency_pool = self.pool.get('res.currency') invoice_pool = self.pool.get('account.invoice') for inv in self.browse(cr, uid, ids): if inv.move_id: continue
bf6f28068a75d64e45c8c384f74b759fbd4ebf5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bf6f28068a75d64e45c8c384f74b759fbd4ebf5b/voucher.py
if rec_ids: move_line_pool.reconcile_partial(cr, uid, rec_ids)
def action_move_line_create(self, cr, uid, ids, *args): journal_pool = self.pool.get('account.journal') sequence_pool = self.pool.get('ir.sequence') move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') currency_pool = self.pool.get('res.currency') invoice_pool = self.pool.get('account.invoice') for inv in self.browse(cr, uid, ids): if inv.move_id: continue
bf6f28068a75d64e45c8c384f74b759fbd4ebf5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bf6f28068a75d64e45c8c384f74b759fbd4ebf5b/voucher.py
cr.execute(""" SELECT move.id FROM stock_picking pick RIGHT JOIN stock_move move ON move.picking_id = pick.id AND move.state = %s WHERE pick.id = %s""", ('done', move.picking_id.id)) res = cr.fetchall() if len(res) == len(move.picking_id.move_lines): picking_obj.action_move(cr, uid, [move.picking_id.id]) wf_service.trg_validate(uid, 'stock.picking', move.picking_id.id, 'button_done', cr)
if move.picking_id.id : cr.execute(""" SELECT move.id FROM stock_picking pick RIGHT JOIN stock_move move ON move.picking_id = pick.id AND move.state = %s WHERE pick.id = %s""", ('done', move.picking_id.id)) res = cr.fetchall() if len(res) == len(move.picking_id.move_lines): picking_obj.action_move(cr, uid, [move.picking_id.id]) wf_service.trg_validate(uid, 'stock.picking', move.picking_id.id, 'button_done', cr)
def do_partial(self, cr, uid, ids, partial_datas, context={}): """ Makes partial pickings and moves done. @param partial_datas: Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom """ res = {} picking_obj = self.pool.get('stock.picking') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) tracking_lot = context.get('tracking_lot', False)
77fc796e7f50b245eee03d59571118913429c80c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/77fc796e7f50b245eee03d59571118913429c80c/stock.py
def action_ship_create(self, cr, uid, ids, *args): wf_service = netsvc.LocalService("workflow") picking_id = False company = self.pool.get('res.users').browse(cr, uid, uid).company_id for order in self.browse(cr, uid, ids, context={}): proc_ids = [] output_id = order.shop_id.warehouse_id.lot_output_id.id picking_id = False for line in order.order_line: proc_id = False date_planned = datetime.now() + relativedelta(days=line.delay or 0.0) date_planned = (date_planned - timedelta(days=company.security_lead)).strftime('%Y-%m-%d %H:%M:%S')
6fe87d7ea4f860425b7134018d1eba52ba789fe7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6fe87d7ea4f860425b7134018d1eba52ba789fe7/sale.py
where id=%%d' % model_obj._table,(datas.id,))
where id=%%s' % model_obj._table,(datas.id,))
def do_alarm_unlink(self, cr, uid, ids, model, context=None): """ Delete alarm specified in ids @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of res alarm’s IDs. @param model: Model name for which alarm is to be cleared. @return: True """ if not context: context = {} alarm_obj = self.pool.get('calendar.alarm') ir_obj = self.pool.get('ir.model') model_id = ir_obj.search(cr, uid, [('model', '=', model)])[0] model_obj = self.pool.get(model) for datas in model_obj.browse(cr, uid, ids, context): alarm_ids = alarm_obj.search(cr, uid, [('model_id', '=', model_id), ('res_id', '=', datas.id)]) 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=%%d' % model_obj._table,(datas.id,)) return True
d5b94c8d65264b4aa437c2dc011ee8a6bae2ced1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d5b94c8d65264b4aa437c2dc011ee8a6bae2ced1/base_calendar.py
cr.execute('select id from %s where recurrent_uid=%s' % (self._table, event_id))
cr.execute('select id from %s where recurrent_uid=%s' , (self._table, event_id))
def unlink_events(self, cr, uid, ids, context=None): """ This function deletes event which are linked with the event with recurrent_uid (Removes the events which refers to the same UID value) """ if not context: context = {} for event_id in ids: cr.execute('select id from %s where recurrent_uid=%s' % (self._table, event_id)) r_ids = map(lambda x: x[0], cr.fetchall()) self.unlink(cr, uid, r_ids, context=context) return True
d5b94c8d65264b4aa437c2dc011ee8a6bae2ced1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d5b94c8d65264b4aa437c2dc011ee8a6bae2ced1/base_calendar.py
to_write.update({'email_cc' : case.email_cc or '' + ','.join(new_cc)})
to_write.update({'email_cc' : ', '.join(new_cc) })
def action_forward(self, cr, uid, ids, context=None): """ Forward the lead to a partner """ this = self.browse(cr, uid, ids[0], context=context) case_pool = self.pool.get(context.get('active_model')) res_id = context and context.get('active_id', False) or False case = case_pool.browse(cr, uid, res_id, context=context)
bdef8968eef5e8b2cc6951f91115f5cac1140ba0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bdef8968eef5e8b2cc6951f91115f5cac1140ba0/crm_forward_to_partner.py
self.log(cr, user, id, message) return super(stock_picking, self).create(cr, user, vals, context)
self.log(cr, user, new_id, message) return new_id
def create(self, cr, user, vals, context=None): if ('name' not in vals) or (vals.get('name')=='/'): vals['name'] = self.pool.get('ir.sequence').get(cr, user, 'stock.picking') type_list = { 'out':_('Packing List'), 'in':_('Reception'), 'internal': _('Internal picking'), 'delivery': _('Delivery order') } if not vals.get('auto_picking', False): message = type_list.get(vals.get('type', False), _('Picking')) + " '" + (vals['name'] or "n/a") + "' "+ _("created.") self.log(cr, user, id, message) return super(stock_picking, self).create(cr, user, vals, context)
d29cc529804edcdbdd6babe358327ff781738ac0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d29cc529804edcdbdd6babe358327ff781738ac0/stock.py
res_user=self.pool.get('res.users').browse(cr,uid,uid)
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') location_obj = self.pool.get('stock.location') wf_service = netsvc.LocalService("workflow")
cae8860346af6b4598b807f36782ed61c41ffbaf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cae8860346af6b4598b807f36782ed61c41ffbaf/mrp_pull.py
'company_id': line.company_id and line.company_id.id or False,
'company_id': res_user.company_id and res_user.company_id.id or False,
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') location_obj = self.pool.get('stock.location') wf_service = netsvc.LocalService("workflow")
cae8860346af6b4598b807f36782ed61c41ffbaf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cae8860346af6b4598b807f36782ed61c41ffbaf/mrp_pull.py
'company_id': line.company_id and line.company_id.id or False,
'company_id': res_user.company_id and res_user.company_id.id or False,
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') location_obj = self.pool.get('stock.location') wf_service = netsvc.LocalService("workflow")
cae8860346af6b4598b807f36782ed61c41ffbaf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cae8860346af6b4598b807f36782ed61c41ffbaf/mrp_pull.py
'company_id': line.company_id and line.company_id.id or False,
'company_id': res_user.company_id and res_user.company_id.id or False,
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') location_obj = self.pool.get('stock.location') wf_service = netsvc.LocalService("workflow")
cae8860346af6b4598b807f36782ed61c41ffbaf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/cae8860346af6b4598b807f36782ed61c41ffbaf/mrp_pull.py
message = _('Invoice ') + " '" + inv.name + "' "+ _("is confirm") self.log(cr, uid, inv.id, message)
def action_move_create(self, cr, uid, ids, *args): """Creates invoice related analytics and financial move lines""" ait_obj = self.pool.get('account.invoice.tax') cur_obj = self.pool.get('res.currency') context = {} for inv in self.browse(cr, uid, ids): if not inv.journal_id.invoice_sequence_id: raise osv.except_osv(_('Error !'), _('Please define invoice sequence on invoice journal')) if not inv.invoice_line: raise osv.except_osv(_('No Invoice Lines !'), _('Please create some invoice lines.')) if inv.move_id: continue
0f74edc455e7ed12e4c98a6c9311e91290b9ef70 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0f74edc455e7ed12e4c98a6c9311e91290b9ef70/invoice.py
cr.execute('SELECT id, type, number, move_id, reference ' \ 'FROM account_invoice ' \ 'WHERE id IN %s', (tuple(ids),)) obj_inv = self.browse(cr, uid, ids)[0] for (id, invtype, number, move_id, reference) in cr.fetchall():
for obj_inv in self.browse(cr, uid, ids): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number move_id = obj_inv.move_id and obj_inv.move_id.id or False reference = obj_inv.reference
def action_number(self, cr, uid, ids, *args): cr.execute('SELECT id, type, number, move_id, reference ' \ 'FROM account_invoice ' \ 'WHERE id IN %s', (tuple(ids),)) obj_inv = self.browse(cr, uid, ids)[0] for (id, invtype, number, move_id, reference) in cr.fetchall(): if not number: if obj_inv.journal_id.invoice_sequence_id: sid = obj_inv.journal_id.invoice_sequence_id.id number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id', {'fiscalyear_id': obj_inv.period_id.fiscalyear_id.id}) else: number = self.pool.get('ir.sequence').get(cr, uid, 'account.invoice.' + invtype) if invtype in ('in_invoice', 'in_refund'): ref = reference else: ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_invoice SET number=%s ' \ 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move SET ref=%s ' \ 'WHERE id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) return True
0f74edc455e7ed12e4c98a6c9311e91290b9ef70 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0f74edc455e7ed12e4c98a6c9311e91290b9ef70/invoice.py
tools.pdf_utils.fill_pdf(tools.config['addons_path']+'/l10n_lu/wizard/2008_DECL_F_M10.pdf', '/tmp/output.pdf', result)
tools.pdf_utils.fill_pdf(addons.get_module_resource('l10n_lu','wizard', '2008_DECL_F_M10.pdf'), '/tmp/output.pdf', result)
def create(self, cr, uid, ids, datas, context=None):
7f5e2da3d42fcb90bd765ad2042cb6c21b992772 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7f5e2da3d42fcb90bd765ad2042cb6c21b992772/print_vat.py
def print_vat_declaration_report(self, cr, uid, ids, context=None): active_ids = context.get('active_ids',[]) data = {} data['form'] = {} data['ids'] = active_ids data['form']['tax_code_id'] = self.browse(cr, uid, ids)[0].tax_code_id.id data['form']['period_id'] = self.browse(cr, uid, ids)[0].period_id.id return { 'type': 'ir.actions.report.xml', 'report_name': 'l10n_lu.tax.report.print', 'datas': data}
7f5e2da3d42fcb90bd765ad2042cb6c21b992772 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7f5e2da3d42fcb90bd765ad2042cb6c21b992772/print_vat.py
count(*) as nbr, sum(planned_revenue) as amount_revenue, sum(planned_cost) as amount_costs, sum(planned_revenue*probability/100)::decimal(16,2) as amount_revenue_prob, avg(probability)::decimal(16,2) as probability,
count(*) as nbr,
def init(self, cr): tools.drop_view_if_exists(cr, 'project_issue_report') cr.execute(""" create or replace view project_issue_report as ( select min(c.id) as id, to_char(c.create_date, 'YYYY') as name, to_char(c.create_date, 'MM') as month, c.state, c.user_id, c.section_id, c.categ_id, c.stage_id, to_char(c.date_closed, 'YYYY/mm/dd') as date_closed, u.company_id as company_id, c.priority as priority, c.project_id as project_id, c.type_id as type_id, count(*) as nbr, sum(planned_revenue) as amount_revenue, sum(planned_cost) as amount_costs, sum(planned_revenue*probability/100)::decimal(16,2) as amount_revenue_prob, avg(probability)::decimal(16,2) as probability, to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close from project_issue c left join res_users u on (c.id = u.id) group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state, c.user_id,c.section_id,c.categ_id,c.stage_id ,c.date_closed,u.company_id,c.priority,c.project_id,c.type_id )""")
415d714484c5d54d1cc8079746452135bb06741b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/415d714484c5d54d1cc8079746452135bb06741b/project_issue_report.py
function, values = node.items()[0]
function, params = node.items()[0]
def process_function(self, node): function, values = node.items()[0] if self.isnoupdate(function) and self.mode != 'init': return context = self.get_context(function, self.eval_context) args = [] if function.eval: args = eval(function.eval, self.eval_context) for value in values: if not 'model' in value and (not 'eval' in value or not 'search' in value): raise YamlImportException('You must provide a "model" and an "eval" or "search" to evaluate.') value_model = self.get_model(value['model']) local_context = {'obj': lambda x: value_model.browse(self.cr, self.uid, x, context=context)} local_context.update(self.id_map) id = eval(value['eval'], self.eval_context, local_context) if id != None: args.append(id) model = self.get_model(function.model) method = function.name getattr(model, method)(self.cr, self.uid, *args)
60cd823fa36df6749813124441c9c36d3eb493a7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/60cd823fa36df6749813124441c9c36d3eb493a7/yaml_import.py
for value in values: if not 'model' in value and (not 'eval' in value or not 'search' in value): raise YamlImportException('You must provide a "model" and an "eval" or "search" to evaluate.') value_model = self.get_model(value['model']) local_context = {'obj': lambda x: value_model.browse(self.cr, self.uid, x, context=context)} local_context.update(self.id_map) id = eval(value['eval'], self.eval_context, local_context) if id != None: args.append(id) model = self.get_model(function.model)
for i, param in enumerate(params): if 'model' in param: param_model = self.get_model(param['model']) else: param_model = model if 'search' in param: q = eval(param['search'], self.eval_context) ids = param_model.search(cr, uid, q) value = self._get_first_result(ids) elif 'eval' in param: local_context = {'obj': lambda x: value_model.browse(self.cr, self.uid, x, context)} local_context.update(self.id_map) value = eval(param['eval'], self.eval_context, local_context) else: raise YamlImportException('You must provide at least a "eval" or a "search" to function parameter args.append(value)
def process_function(self, node): function, values = node.items()[0] if self.isnoupdate(function) and self.mode != 'init': return context = self.get_context(function, self.eval_context) args = [] if function.eval: args = eval(function.eval, self.eval_context) for value in values: if not 'model' in value and (not 'eval' in value or not 'search' in value): raise YamlImportException('You must provide a "model" and an "eval" or "search" to evaluate.') value_model = self.get_model(value['model']) local_context = {'obj': lambda x: value_model.browse(self.cr, self.uid, x, context=context)} local_context.update(self.id_map) id = eval(value['eval'], self.eval_context, local_context) if id != None: args.append(id) model = self.get_model(function.model) method = function.name getattr(model, method)(self.cr, self.uid, *args)
60cd823fa36df6749813124441c9c36d3eb493a7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/60cd823fa36df6749813124441c9c36d3eb493a7/yaml_import.py
_inherits = {'res.alarm': "alarm_id"}
_inherit = 'res.alarm'
def do_alarm_unlink(self, cr, uid, ids, model, context={}): alarm_obj = self.pool.get('calendar.alarm') ir_obj = self.pool.get('ir.model') model_id = ir_obj.search(cr, uid, [('model', '=', model)])[0] model_obj = self.pool.get(model) for datas in model_obj.browse(cr, uid, ids): alarm_ids = alarm_obj.search(cr, uid, [('model_id', '=', model_id), ('res_id', '=', datas.id)]) if alarm_ids and len(alarm_ids): alarm_obj.unlink(cr, uid, alarm_ids) cr.execute('Update %s set caldav_alarm_id=NULL, alarm_id=NULL\ where id=%s' % (model_obj._table, datas.id)) cr.commit() return True
1011c0fffa29564de054c4e0235c2e6b107e1fa2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1011c0fffa29564de054c4e0235c2e6b107e1fa2/caldav.py
if vals.has_key('alarm_id'):
if vals.has_key('alarm_id') or vals.has_key('caldav_alarm_id'):
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): if isinstance(ids, (str, int, long)): select = [ids] else: select = ids new_ids = [] for id in select: id = caldav_id2real_id(id) if not id in new_ids: new_ids.append(id) res = super(calendar_event, self).write(cr, uid, new_ids, vals, context=context) if vals.has_key('alarm_id'): alarm_obj = self.pool.get('res.alarm') alarm_obj.do_alarm_create(cr, uid, new_ids, self._name, 'date') return res
1011c0fffa29564de054c4e0235c2e6b107e1fa2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1011c0fffa29564de054c4e0235c2e6b107e1fa2/caldav.py
alarm_obj.do_alarm_create(cr, uid, new_ids, self._name, 'date')
context.update({'alarm_id': vals.get('alarm_id')}) alarm_obj.do_alarm_create(cr, uid, new_ids, self._name, 'date', context=context)
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): if isinstance(ids, (str, int, long)): select = [ids] else: select = ids new_ids = [] for id in select: id = caldav_id2real_id(id) if not id in new_ids: new_ids.append(id) res = super(calendar_event, self).write(cr, uid, new_ids, vals, context=context) if vals.has_key('alarm_id'): alarm_obj = self.pool.get('res.alarm') alarm_obj.do_alarm_create(cr, uid, new_ids, self._name, 'date') return res
1011c0fffa29564de054c4e0235c2e6b107e1fa2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1011c0fffa29564de054c4e0235c2e6b107e1fa2/caldav.py
r['amount'] = round(r['balance'] * quantity, self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')) - total
r['amount'] = round(r.get('balance', 0.0) * quantity, self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')) - total
def _compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): """ Compute tax values for given PRICE_UNIT, QUANTITY and a buyer/seller ADDRESS_ID.
0a97edf8b3606179c15bdc49d6bfbbf186d33dc3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0a97edf8b3606179c15bdc49d6bfbbf186d33dc3/account.py
r['amount'] = round(r['amount'] * quantity, self.pool.get('decimal.precision').precision_get(cr, uid, 'Account'))
r['amount'] = round(r.get('amount', 0.0) * quantity, self.pool.get('decimal.precision').precision_get(cr, uid, 'Account'))
def _compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): """ Compute tax values for given PRICE_UNIT, QUANTITY and a buyer/seller ADDRESS_ID.
0a97edf8b3606179c15bdc49d6bfbbf186d33dc3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0a97edf8b3606179c15bdc49d6bfbbf186d33dc3/account.py
response_re = response_re = re.compile("Are you coming\?.*\n*.*(YES|NO|MAYBE).*", re.UNICODE)
response_re = re.compile("Are you coming\?.*\n*.*(YES|NO|MAYBE).*", re.UNICODE)
def _lang_get(self, cr, uid, context={}): obj = self.pool.get('res.lang') ids = obj.search(cr, uid, []) res = obj.read(cr, uid, ids, ['code', 'name'], context) res = [((r['code']).replace('_', '-'), r['name']) for r in res] return res
7444a76e9711d5729a6a68f6fa8ebaf327779891 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7444a76e9711d5729a6a68f6fa8ebaf327779891/base_calendar.py
if journal.type in journal_type and not journal.invoice_sequence_id: res_ids = date_pool.search(cr, uid, [('model','=','ir.sequence'), ('name','=',journal_seq.get(journal.type, 'sale'))]) inv_seq_id = date_pool.browse(cr, uid, res_ids[0]).res_id inv_seq_id res.update({ 'invoice_sequence_id':inv_seq_id })
def create_sequence(self, cr, uid, ids, context={}): """ Create new entry sequence for every new Joural @param cr: cursor to database @param user: id of current user @param ids: list of record ids to be process @param context: context arguments, like lang, time zone @return: return a result """
684a10886e660577d2faa16ef1d6be7544bc0335 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/684a10886e660577d2faa16ef1d6be7544bc0335/account.py
invoice = context.get('invoice')
invoice = context.get('invoice', False)
def post(self, cr, uid, ids, context=None): invoice = context.get('invoice') if self.validate(cr, uid, ids, context) and len(ids): for move in self.browse(cr, uid, ids): if move.name =='/': new_name = False journal = move.journal_id if invoice.internal_number: new_name = invoice.internal_number else: if journal.sequence_id: c = {'fiscalyear_id': move.period_id.fiscalyear_id.id} new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id, context=c) else: raise osv.except_osv(_('Error'), _('No sequence defined in the journal !'))
684a10886e660577d2faa16ef1d6be7544bc0335 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/684a10886e660577d2faa16ef1d6be7544bc0335/account.py
if invoice.internal_number:
if invoice and invoice.internal_number:
def post(self, cr, uid, ids, context=None): invoice = context.get('invoice') if self.validate(cr, uid, ids, context) and len(ids): for move in self.browse(cr, uid, ids): if move.name =='/': new_name = False journal = move.journal_id if invoice.internal_number: new_name = invoice.internal_number else: if journal.sequence_id: c = {'fiscalyear_id': move.period_id.fiscalyear_id.id} new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id, context=c) else: raise osv.except_osv(_('Error'), _('No sequence defined in the journal !'))
684a10886e660577d2faa16ef1d6be7544bc0335 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/684a10886e660577d2faa16ef1d6be7544bc0335/account.py
elif method in ['get_available_updates', 'get_migration_scripts', 'set_loglevel', 'get_os_time']:
elif method in ['get_available_updates', 'get_migration_scripts', 'set_loglevel', 'get_os_time', 'get_sqlcount']:
def dispatch(self, method, auth, params): logger = netsvc.Logger() if method in [ 'ir_set','ir_del', 'ir_get' ]: return self.common_dispatch(method,auth,params) if method == 'login': # At this old dispatcher, we do NOT update the auth proxy res = security.login(params[0], params[1], params[2]) msg = res and 'successful login' or 'bad login or password' # TODO log the client ip address.. logger.notifyChannel("web-service", netsvc.LOG_INFO, "%s from '%s' using database '%s'" % (msg, params[1], params[0].lower())) return res or False elif method == 'logout': if auth: auth.logout(params[1]) logger.notifyChannel("web-service", netsvc.LOG_INFO,'Logout %s from database %s'%(login,db)) return True elif method in ['about', 'timezone_get', 'get_server_environment', 'login_message','get_stats', 'check_connectivity', 'list_http_services']: pass elif method in ['get_available_updates', 'get_migration_scripts', 'set_loglevel', 'get_os_time']: passwd = params[0] params = params[1:] security.check_super(passwd) else: raise Exception("Method not found: %s" % method) fn = getattr(self, 'exp_'+method) return fn(*params)
1f380f050417c247e40f2f29d14d6c1fbd80360e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1f380f050417c247e40f2f29d14d6c1fbd80360e/web_services.py
'company_id': fields.related('shop_id','company_id',type='many2one',relation='res.company',string='Company',store=True)
'company_id': fields.related('shop_id','company_id',type='many2one',relation='res.company',string='Company',store=True, required=True)
def _get_order(self, cr, uid, ids, context=None): if context is None: context = {} result = {} for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context): result[line.order_id.id] = True return result.keys()
e96c7220fbbece8cdff118cf5321fd35792de3e1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e96c7220fbbece8cdff118cf5321fd35792de3e1/sale.py
self._logger.debug('"%s" %s %s',
self._logger.log(netsvc.logging.DEBUG_RPC, '"%s" %s %s',
def log_request(self, code='-', size='-'): self._logger.debug('"%s" %s %s', self.requestline, str(code), str(size))
0ee47f021c9e8ee4dd61b0b3df9c58d9bdfc29c8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0ee47f021c9e8ee4dd61b0b3df9c58d9bdfc29c8/http_server.py
class StaticHTTPHandler(HttpLogHandler, HTTPHandler):
class StaticHTTPHandler(HttpLogHandler, FixSendError, HTTPHandler):
def init_xmlrpc(): if tools.config.get('xmlrpc', False): # Example of http file serving: # reg_http_service(HTTPDir('/test/',HTTPHandler)) reg_http_service(HTTPDir('/xmlrpc/', XMLRPCRequestHandler)) logging.getLogger("web-services").info("Registered XML-RPC over HTTP") if tools.config.get('xmlrpcs', False): reg_http_service(HTTPDir('/xmlrpc/', XMLRPCRequestHandler, True)) logging.getLogger("web-services").info("Registered XML-RPC over HTTPS")
59efa51612d8f85fab2ad503080b353fe4930bde /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/59efa51612d8f85fab2ad503080b353fe4930bde/http_server.py
import base64
def _image(self, node): import urllib from reportlab.lib.utils import ImageReader if not node.get('file') : if node.get('name'): image_data = self.images[node.get('name')] s = cStringIO.StringIO(image_data) else: import base64 if self.localcontext: res = utils._regex.findall(node.text) for key in res: newtext = eval(key, {}, self.localcontext) node.text = newtext image_data = base64.decodestring(node.text) if not image_data: return False s = cStringIO.StringIO(image_data) else: if node.get('file') in self.images: s = cStringIO.StringIO(self.images[node.get('file')]) else: try: u = urllib.urlopen(str(node.get('file'))) s = cStringIO.StringIO(u.read()) except Exception: u = file(os.path.join(self.path,str(node.get('file'))), 'rb') s = cStringIO.StringIO(u.read()) img = ImageReader(s) (sx,sy) = img.getSize()
6e3c34ddd5717bef2d81b2348d2310bc60425889 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6e3c34ddd5717bef2d81b2348d2310bc60425889/trml2pdf.py
res = utils._regex.findall(node.text) for key in res: newtext = eval(key, {}, self.localcontext) node.text = newtext image_data = base64.decodestring(node.text) if not image_data: return False s = cStringIO.StringIO(image_data)
res = utils._regex.findall(node.text) for key in res: newtext = eval(key, {}, self.localcontext) node.text = newtext image_data = None if node.text: image_data = base64.decodestring(node.text) if image_data: s = cStringIO.StringIO(image_data) else: return False
def _image(self, node): import urllib from reportlab.lib.utils import ImageReader if not node.get('file') : if node.get('name'): image_data = self.images[node.get('name')] s = cStringIO.StringIO(image_data) else: import base64 if self.localcontext: res = utils._regex.findall(node.text) for key in res: newtext = eval(key, {}, self.localcontext) node.text = newtext image_data = base64.decodestring(node.text) if not image_data: return False s = cStringIO.StringIO(image_data) else: if node.get('file') in self.images: s = cStringIO.StringIO(self.images[node.get('file')]) else: try: u = urllib.urlopen(str(node.get('file'))) s = cStringIO.StringIO(u.read()) except Exception: u = file(os.path.join(self.path,str(node.get('file'))), 'rb') s = cStringIO.StringIO(u.read()) img = ImageReader(s) (sx,sy) = img.getSize()
6e3c34ddd5717bef2d81b2348d2310bc60425889 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/6e3c34ddd5717bef2d81b2348d2310bc60425889/trml2pdf.py
(sum(l.product_uom_qty*l.price_unit)/sum(l.product_uom_qty * u.factor)*count(l.product_id))::decimal(16,2) as price_average,
(sum(l.product_uom_qty*l.price_unit)/sum(nullif(l.product_uom_qty * u.factor,0))*count(l.product_id))::decimal(16,2) as price_average,
def init(self, cr): tools.drop_view_if_exists(cr, 'sale_report') cr.execute(""" create or replace view sale_report as ( select el.*, -- (select count(1) from sale_order_line where order_id = s.id) as nbr, (select 1) as nbr, s.date_order as date, s.date_confirm as date_confirm, to_char(s.date_order, 'YYYY') as year, to_char(s.date_order, 'MM') as month, to_char(s.date_order, 'YYYY-MM-DD') as day, s.partner_id as partner_id, s.user_id as user_id, s.shop_id as shop_id, s.company_id as company_id, extract(epoch from avg(date_trunc('day',s.date_confirm)-date_trunc('day',s.create_date)))/(24*60*60)::decimal(16,2) as delay, s.state, s.shipped, s.shipped::integer as shipped_qty_1, s.pricelist_id as pricelist_id, s.project_id as analytic_account_id from sale_order s, ( select l.id as id, l.product_id as product_id, u.name as uom_name, sum(l.product_uom_qty * u.factor) as product_uom_qty, sum(l.product_uom_qty*l.price_unit) as price_total, (sum(l.product_uom_qty*l.price_unit)/sum(l.product_uom_qty * u.factor)*count(l.product_id))::decimal(16,2) as price_average, pt.categ_id, l.order_id from sale_order_line l left join product_uom u on (u.id=l.product_uom) left join product_template pt on (pt.id=l.product_id) group by l.id, l.order_id, l.product_id, u.name, pt.categ_id) el where s.id = el.order_id group by el.id, el.product_id, el.uom_name, el.product_uom_qty, el.price_total, el.price_average, el.categ_id, el.order_id, s.date_order, s.date_confirm, s.partner_id, s.user_id, s.shop_id, s.company_id, s.state, s.shipped, s.pricelist_id, s.project_id ) """)
dc8fef96db0a0891a6217549883889f273b00dd4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/dc8fef96db0a0891a6217549883889f273b00dd4/sale_report.py
account_id = False
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res = {'value': {}} obj_partner = self.pool.get('res.partner') if context is None: context = {} if not partner_id: return res
0ff1aecac1373f7324c3f2f5212cfb5654cdce8d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0ff1aecac1373f7324c3f2f5212cfb5654cdce8d/account_bank_statement.py
def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} if 'date' in vals: new_vals = {} obj_hr_eval_iterview = self.pool.get('hr.evaluation.interview') current_record = self.browse(cr, uid, ids, context=context)[0] survey_requests = current_record.survey_request_ids new_vals.update({'date_deadline':vals.get('date')}) if survey_requests: for survey_req in survey_requests: obj_hr_eval_iterview.write(cr, uid, survey_req.id, new_vals,context=context) return super(hr_evaluation, self).write(cr, uid, ids, vals, context=context)
def button_cancel(self, cr, uid, ids, context=None): if context is None: context = {} self.write(cr, uid, ids,{'state':'cancel'}, context=context) return True
bee7aabb044619af2af858a03fcce88ae24a873b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bee7aabb044619af2af858a03fcce88ae24a873b/hr_evaluation.py
'code': wc.code
'ref': wc.code, 'product_id': wc.product_id.id, 'unit_amount': wc.costs_hour * wc.time_cycle, 'product_uom_id': wc.product_id.uom_id.id
def _costs_generate(self, cr, uid, production): """ Calculates total costs at the end of the production. @param production: Id of production order. @return: Calculated amount. """ amount = 0.0 analytic_line_obj = self.pool.get('account.analytic.line') for wc_line in production.workcenter_lines: wc = wc_line.workcenter_id if wc.costs_journal_id and wc.costs_general_account_id: value = wc_line.hour * wc.costs_hour account = wc.costs_hour_account_id.id if value and account: amount += value analytic_line_obj.create(cr, uid, { 'name': wc_line.name + ' (H)', 'amount': value, 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, 'journal_id': wc.costs_journal_id.id, 'code': wc.code } ) if wc.costs_journal_id and wc.costs_general_account_id: value = wc_line.cycle * wc.costs_cycle account = wc.costs_cycle_account_id.id if value and account: amount += value analytic_line_obj.create(cr, uid, { 'name': wc_line.name+' (C)', 'amount': value, 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, 'journal_id': wc.costs_journal_id.id, 'code': wc.code, } ) return amount
b25062ed300bbc94a7fc21332672d685e1e0cda0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b25062ed300bbc94a7fc21332672d685e1e0cda0/mrp.py
'code': wc.code,
'ref': wc.code, 'product_id': wc.product_id.id, 'unit_amount': wc.costs_hour * wc.time_cycle, 'product_uom_id': wc.product_id.uom_id.id
def _costs_generate(self, cr, uid, production): """ Calculates total costs at the end of the production. @param production: Id of production order. @return: Calculated amount. """ amount = 0.0 analytic_line_obj = self.pool.get('account.analytic.line') for wc_line in production.workcenter_lines: wc = wc_line.workcenter_id if wc.costs_journal_id and wc.costs_general_account_id: value = wc_line.hour * wc.costs_hour account = wc.costs_hour_account_id.id if value and account: amount += value analytic_line_obj.create(cr, uid, { 'name': wc_line.name + ' (H)', 'amount': value, 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, 'journal_id': wc.costs_journal_id.id, 'code': wc.code } ) if wc.costs_journal_id and wc.costs_general_account_id: value = wc_line.cycle * wc.costs_cycle account = wc.costs_cycle_account_id.id if value and account: amount += value analytic_line_obj.create(cr, uid, { 'name': wc_line.name+' (C)', 'amount': value, 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, 'journal_id': wc.costs_journal_id.id, 'code': wc.code, } ) return amount
b25062ed300bbc94a7fc21332672d685e1e0cda0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b25062ed300bbc94a7fc21332672d685e1e0cda0/mrp.py
def _current_rate(self, cr, uid, ids, name, arg, context={}): res={}
def _current_rate(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} res = {}
def _current_rate(self, cr, uid, ids, name, arg, context={}): res={} if 'date' in context: date=context['date'] else: date=time.strftime('%Y-%m-%d') date= date or time.strftime('%Y-%m-%d') for id in ids: cr.execute("SELECT currency_id, rate FROM res_currency_rate WHERE currency_id = %s AND name <= %s ORDER BY name desc LIMIT 1" ,(id, date)) if cr.rowcount: id, rate=cr.fetchall()[0] res[id]=rate else: res[id]=0 return res
36b0157f8b336cf9d43a953525eed60e7d679f75 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/36b0157f8b336cf9d43a953525eed60e7d679f75/res_currency.py