bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
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.
|
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.
| 468,400
|
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
|
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
| 468,401
|
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
|
defselection_field(in_field):col_obj=self.pool.get(in_field.keys()[0])iff[i]incol_obj._columns.keys():returncol_obj._columns[f[i]]eliff[i]incol_obj._inherits.keys():selection_field(col_obj._inherits)else:returnFalse
| 468,402
|
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
|
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
| 468,403
|
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
|
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
| 468,404
|
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
|
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
| 468,405
|
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
|
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)]) cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" ,(tuple(dept_ids),)) 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
| 468,406
|
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
|
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), ], 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
| 468,407
|
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
|
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: 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
| 468,408
|
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
|
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_ids, so_line_product_ids, 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
| 468,409
|
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
|
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_ids, so_line_product_ids, 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
| 468,410
|
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
|
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_ids, so_line_product_ids, 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
| 468,411
|
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
|
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_ids, so_line_product_ids, 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
| 468,412
|
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 })
|
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, })
| 468,413
|
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
|
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_')): 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
| 468,414
|
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 """
|
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 """
| 468,415
|
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 """
|
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 """
| 468,416
|
def html2plaintext(html, body_id=None, encoding='utf-8'): ## (c) Fry-IT, www.fry-it.com, 2007 ## <peter@fry-it.com> ## 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
|
defhtml2plaintext(html,body_id=None,encoding='utf-8'):##(c)Fry-IT,www.fry-it.com,2007##<peter@fry-it.com>##downloadhere:http://www.peterbe.com/plog/html2plaintext"""fromanHTMLtext,converttheHTMLtoplaintext.If@body_idisprovidedthenthisisthetagwherethebody(notnecessarily<body>)starts."""try:fromBeautifulSoupimportBeautifulSoup,SoupStrainer,Commentexcept:returnhtmlurls=[]ifbody_idisnotNone:strainer=SoupStrainer(id=body_id)else:strainer=SoupStrainer('body')soup=BeautifulSoup(html,parseOnlyThese=strainer,fromEncoding=encoding)forlinkinsoup.findAll('a'):title=unicode(link)forurlin[x[1]forxinlink.attrsifx[0]=='href']:urls.append(dict(url=url,tag=unicode(link),title=title))html=unicode(soup)url_index=[]i=0fordinurls:ifd['title']==d['url']or'http://'+d['title']==d['url']:html=html.replace(d['tag'],d['url'])else:i+=1html=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>','/')#theonlylinebreakswerespectisthoseofendingtagsand#breakshtml=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,'')#forallothertagswefailedtocleanup,justremovethenand#complainaboutthemonthestderrdefdesperate_fixer(g):#print>>sys.stderr,"failedtocleanup%s"%str(g.group())return''html=re.sub('<.*?>',desperate_fixer,html)#lstripalllineshtml='\n'.join([x.lstrip()forxinhtml.splitlines()])fori,urlinenumerate(url_index):ifi==0:html+='\n\n'html+='[%s]%s\n'%(i+1,url)returnhtml
| 468,417
|
def html2plaintext(html, body_id=None, encoding='utf-8'): ## (c) Fry-IT, www.fry-it.com, 2007 ## <peter@fry-it.com> ## 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
|
def html2plaintext(html, body_id=None, encoding='utf-8'): ## (c) Fry-IT, www.fry-it.com, 2007 ## <peter@fry-it.com> ## 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
| 468,418
|
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 []))
|
def _decode_header(self, text): 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 []))
| 468,419
|
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 []))
|
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 []))
| 468,420
|
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))
|
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))
| 468,421
|
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))
|
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))
| 468,422
|
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))
|
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))
| 468,423
|
def msg_body_get(self, msg): message = {}; message['body'] = ''; message['attachment'] = {}; attachment = message['attachment']; counter = 1; def replace(match): return ''
|
def msg_body_get(self, msg): message = { 'body' : '', 'attachment' : {}, } attachment = message['attachment']; counter = 1; def replace(match): return ''
| 468,424
|
def replace(match): return ''
|
def replace(match): return ''
| 468,425
|
def replace(match): return ''
|
def replace(match): return ''
| 468,426
|
def replace(match): return ''
|
def replace(match): return ''
| 468,427
|
def replace(match): return ''
|
def replace(match): return ''
| 468,428
|
def replace(match): return ''
|
def replace(match): return ''
| 468,429
|
def replace(match): return ''
|
def replace(match): return ''
| 468,430
|
def replace(match): return ''
|
def replace(match): return ''
| 468,431
|
def msg_user(self, msg, id): body = self.msg_body_get(msg)
|
def msg_user(self, msg, id): body = self.msg_body_get(msg)
| 468,432
|
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
|
def msg_send(self, msg, emails, priority=None): if not 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
| 468,433
|
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
|
def msg_send(self, msg, emails, priority=None): if not len(emails): return False 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
| 468,434
|
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
|
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: 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
| 468,435
|
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
|
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:]) 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
| 468,436
|
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)
|
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)
| 468,437
|
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)
|
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)
| 468,438
|
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)
|
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)
| 468,439
|
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()+'>'
|
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: 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'])): 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()+'>'
| 468,440
|
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()+'>'
|
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()+'>'
| 468,441
|
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()+'>'
|
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', ''): msg['Subject'] = '['+str(case_id)+'] '+subject msg['Message-Id'] = '<'+str(time.time())+'-openerpcrm-'+str(case_id)+'@'+socket.gethostname()+'>'
| 468,442
|
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()+'>'
|
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()+'>'
| 468,443
|
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()+'>'
|
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()+'>'
| 468,444
|
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()+'>'
|
defparse(self,msg):case_str=reference_re.search(msg.get('References',''))ifcase_str:case_str=case_str.group(1)else:case_str=case_re.search(msg.get('Subject',''))ifcase_str:case_str=case_str.group(1)(case_id,emails)=self.msg_test(msg,case_str)ifcase_id:ifemails[0]andself.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'])ifmsg.get('Subject',''):delmsg['Subject']msg['Subject']='['+str(case_id)+']'+subjectmsg['Message-Id']='<'+str(time.time())+'-openerpcrm-'+str(case_id)+'@'+socket.gethostname()+'>'
| 468,445
|
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)
| 468,446
|
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
|
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: message['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
| 468,447
|
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
|
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]), message.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
| 468,448
|
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
|
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
| 468,449
|
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
|
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
| 468,450
|
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'
|
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'
| 468,451
|
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'
|
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'
| 468,452
|
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'
|
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'
| 468,453
|
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
|
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
| 468,454
|
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
|
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
| 468,455
|
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
|
defrec_ids = [] action_move_line_create(self,rec_ids = [] cr,rec_ids = [] uid,rec_ids = [] ids,rec_ids = [] *args):rec_ids = [] journal_poolrec_ids = [] =rec_ids = [] self.pool.get('account.journal')rec_ids = [] sequence_poolrec_ids = [] =rec_ids = [] self.pool.get('ir.sequence')rec_ids = [] move_poolrec_ids = [] =rec_ids = [] self.pool.get('account.move')rec_ids = [] move_line_poolrec_ids = [] =rec_ids = [] self.pool.get('account.move.line')rec_ids = [] analytic_poolrec_ids = [] =rec_ids = [] self.pool.get('account.analytic.line')rec_ids = [] currency_poolrec_ids = [] =rec_ids = [] self.pool.get('res.currency')rec_ids = [] invoice_poolrec_ids = [] =rec_ids = [] self.pool.get('account.invoice')rec_ids = [] rec_ids = [] forrec_ids = [] invrec_ids = [] inrec_ids = [] self.browse(cr,rec_ids = [] uid,rec_ids = [] ids):rec_ids = [] rec_ids = [] ifrec_ids = [] inv.move_id:rec_ids = [] continue
| 468,456
|
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
|
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
| 468,457
|
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
|
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
| 468,458
|
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
|
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
| 468,459
|
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
|
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
| 468,460
|
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
|
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
| 468,461
|
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)
|
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)
| 468,462
|
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')
|
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')
| 468,463
|
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
|
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=%%s' % model_obj._table,(datas.id,)) return True
| 468,464
|
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
|
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
| 468,465
|
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)
|
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)
| 468,466
|
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)
|
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)
| 468,467
|
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")
|
defres_user=self.pool.get('res.users').browse(cr,uid,uid) action_move_create(self,res_user=self.pool.get('res.users').browse(cr,uid,uid) cr,res_user=self.pool.get('res.users').browse(cr,uid,uid) uid,res_user=self.pool.get('res.users').browse(cr,uid,uid) ids,context=None):res_user=self.pool.get('res.users').browse(cr,uid,uid) proc_objres_user=self.pool.get('res.users').browse(cr,uid,uid) =res_user=self.pool.get('res.users').browse(cr,uid,uid) self.pool.get('procurement.order')res_user=self.pool.get('res.users').browse(cr,uid,uid) move_objres_user=self.pool.get('res.users').browse(cr,uid,uid) =res_user=self.pool.get('res.users').browse(cr,uid,uid) self.pool.get('stock.move')res_user=self.pool.get('res.users').browse(cr,uid,uid) location_objres_user=self.pool.get('res.users').browse(cr,uid,uid) =res_user=self.pool.get('res.users').browse(cr,uid,uid) self.pool.get('stock.location')res_user=self.pool.get('res.users').browse(cr,uid,uid) wf_serviceres_user=self.pool.get('res.users').browse(cr,uid,uid) =res_user=self.pool.get('res.users').browse(cr,uid,uid) netsvc.LocalService("workflow")
| 468,468
|
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")
|
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")
| 468,469
|
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")
|
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")
| 468,470
|
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")
|
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")
| 468,471
|
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
|
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
| 468,472
|
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
|
def action_number(self, cr, uid, ids, *args): 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 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
| 468,473
|
def create(self, cr, uid, ids, datas, context=None):
|
def create(self, cr, uid, ids, datas, context=None):
| 468,474
|
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}
|
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}
| 468,475
|
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 )""")
|
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, 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 )""")
| 468,476
|
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)
|
def process_function(self, node): function, params = 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)
| 468,477
|
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)
|
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 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) method = function.name getattr(model, method)(self.cr, self.uid, *args)
| 468,478
|
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
|
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
| 468,479
|
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
|
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') or vals.has_key('caldav_alarm_id'): alarm_obj = self.pool.get('res.alarm') alarm_obj.do_alarm_create(cr, uid, new_ids, self._name, 'date') return res
| 468,480
|
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
|
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') context.update({'alarm_id': vals.get('alarm_id')}) alarm_obj.do_alarm_create(cr, uid, new_ids, self._name, 'date', context=context) return res
| 468,481
|
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.
|
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.
| 468,482
|
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.
|
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.
| 468,483
|
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
|
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
| 468,484
|
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 """
|
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 """
| 468,485
|
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 !'))
|
def post(self, cr, uid, ids, context=None): invoice = context.get('invoice', False) 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 !'))
| 468,486
|
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 !'))
|
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 and 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 !'))
| 468,487
|
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)
|
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', 'get_sqlcount']: 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)
| 468,488
|
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()
|
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()
| 468,489
|
def log_request(self, code='-', size='-'): self._logger.debug('"%s" %s %s', self.requestline, str(code), str(size))
|
def log_request(self, code='-', size='-'): self._logger.log(netsvc.logging.DEBUG_RPC, '"%s" %s %s', self.requestline, str(code), str(size))
| 468,490
|
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")
|
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")
| 468,491
|
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()
|
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: 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()
| 468,492
|
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()
|
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 = None if node.text: image_data = base64.decodestring(node.text) if image_data: s = cStringIO.StringIO(image_data) else: return False 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()
| 468,493
|
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 ) """)
|
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(nullif(l.product_uom_qty * u.factor,0))*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 ) """)
| 468,494
|
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
|
defaccount_id = False onchange_partner_id(self,account_id = False cursor,account_id = False user,account_id = False line_id,account_id = False partner_id,account_id = False type,account_id = False currency_id,account_id = False context=None):account_id = False resaccount_id = False =account_id = False {'value':account_id = False {}}account_id = False obj_partneraccount_id = False =account_id = False self.pool.get('res.partner')account_id = False ifaccount_id = False contextaccount_id = False isaccount_id = False None:account_id = False contextaccount_id = False =account_id = False {}account_id = False ifaccount_id = False notaccount_id = False partner_id:account_id = False returnaccount_id = False res
| 468,495
|
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
|
def 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) button_cancel(self, 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) cr, 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) uid, 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) ids, 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) context=None): 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) if 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) context 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) is 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) None: 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) context 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 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 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) self.write(cr, 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) uid, 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) ids,{'state':'cancel'}, 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) context=context) 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) return 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) True
| 468,496
|
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
|
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, '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 } ) 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
| 468,497
|
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
|
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, '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 } ) return amount
| 468,498
|
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
|
def _current_rate(self, cr, uid, ids, name, arg, context=None): if context is None: 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
| 468,499
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.