rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
'yearly_total_by_emp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Employee', digits=(16, int(config['price_accuracy']))), 'yearly_total_by_comp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Company', digits=(16, int(config['price_accuracy']))), 'monthly_total_by_emp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Employee', digits=(16, int(config['price_accuracy']))), 'monthly_total_by_comp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Company', digits=(16, int(config['price_accuracy']))),
'yearly_total_by_emp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Employee', digits=(16, 4)), 'yearly_total_by_comp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Company', digits=(16, 4)), 'monthly_total_by_emp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Employee', digits=(16, 4)), 'monthly_total_by_comp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Company', digits=(16, 4)),
def _total_contrib(self, cr, uid, ids, field_names, arg, context={}): line_pool = self.pool.get('hr.contibution.register.line') period_id = self.pool.get('account.period').search(cr,uid,[('date_start','<=',time.strftime('%Y-%m-%d')),('date_stop','>=',time.strftime('%Y-%m-%d'))])[0] fiscalyear_id = self.pool.get('account.period').browse(cr, uid, period_id).fiscalyear_id res = {} for cur in self.browse(cr, uid, ids): current = line_pool.search(cr, uid, [('period_id','=',period_id),('register_id','=',cur.id)]) years = line_pool.search(cr, uid, [('period_id.fiscalyear_id','=',fiscalyear_id.id), ('register_id','=',cur.id)])
21786ff375c69b960b487a69bd1343b8b77f3dec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21786ff375c69b960b487a69bd1343b8b77f3dec/hr_payroll.py
'emp_deduction': fields.float('Employee Deduction', digits=(16, int(config['price_accuracy']))), 'comp_deduction': fields.float('Company Deduction', digits=(16, int(config['price_accuracy']))), 'total': fields.function(_total, method=True, store=True, string='Total', digits=(16, int(config['price_accuracy']))),
'emp_deduction': fields.float('Employee Deduction', digits=(16, 4)), 'comp_deduction': fields.float('Company Deduction', digits=(16, 4)), 'total': fields.function(_total, method=True, store=True, string='Total', digits=(16, 4)),
def _total(self, cr, uid, ids, field_names, arg, context): res={} for line in self.browse(cr, uid, ids, context): res[line.id] = line.emp_deduction + line.comp_deduction return res
21786ff375c69b960b487a69bd1343b8b77f3dec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21786ff375c69b960b487a69bd1343b8b77f3dec/hr_payroll.py
'contribute_per':fields.float('Contribution', digits=(16, int(config['price_accuracy'])), help='Define Company contribution ratio 1.00=100% contribution, If Employee Contribute 5% then company will and here 0.50 defined then company will contribute 50% on employee 5% contribution'),
'contribute_per':fields.float('Contribution', digits=(16, 4), help='Define Company contribution ratio 1.00=100% contribution, If Employee Contribute 5% then company will and here 0.50 defined then company will contribute 50% on employee 5% contribution'),
def _total(self, cr, uid, ids, field_names, arg, context): res={} for line in self.browse(cr, uid, ids, context): res[line.id] = line.emp_deduction + line.comp_deduction return res
21786ff375c69b960b487a69bd1343b8b77f3dec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21786ff375c69b960b487a69bd1343b8b77f3dec/hr_payroll.py
'from_val': fields.float('From', digits=(16, int(config['price_accuracy']))), 'to_val': fields.float('To', digits=(16, int(config['price_accuracy']))),
'from_val': fields.float('From', digits=(16, 4)), 'to_val': fields.float('To', digits=(16, 4)),
def execute_function(self, cr, uid, id, value, context): """ self: pointer to self object cr: cursor to database uid: user id of current executer """
21786ff375c69b960b487a69bd1343b8b77f3dec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21786ff375c69b960b487a69bd1343b8b77f3dec/hr_payroll.py
'value': fields.float('Value', digits=(16, int(config['price_accuracy']))),
'value': fields.float('Value', digits=(16, 4)),
def execute_function(self, cr, uid, id, value, context): """ self: pointer to self object cr: cursor to database uid: user id of current executer """
21786ff375c69b960b487a69bd1343b8b77f3dec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21786ff375c69b960b487a69bd1343b8b77f3dec/hr_payroll.py
'leaves': fields.float('Leaved Deduction', readonly=True, digits=(16, 2)), 'basic': fields.float('Basic Salary - Leaves', readonly=True, digits=(16, 2)),
'leaves': fields.float('Leave Deductions', readonly=True, digits=(16, 2)), 'basic': fields.float('Net Basic', readonly=True, digits=(16, 2)),
def _calculate(self, cr, uid, ids, field_names, arg, context): res = {} for rs in self.browse(cr, uid, ids, context): allow = 0.0 deduct = 0.0 others = 0.0
21786ff375c69b960b487a69bd1343b8b77f3dec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21786ff375c69b960b487a69bd1343b8b77f3dec/hr_payroll.py
'total': fields.float('Sub Total', readonly=True, digits=(16, int(config['price_accuracy']))),
'total': fields.float('Sub Total', readonly=True, digits=(16, 4)),
def onchange_amount(self, cr, uid, ids, amount, typ): amt = amount if typ and typ == 'per': if int(amt) > 0: amt = amt / 100 return {'value':{'amount':amt}}
21786ff375c69b960b487a69bd1343b8b77f3dec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21786ff375c69b960b487a69bd1343b8b77f3dec/hr_payroll.py
'company_contrib': fields.float('Company Contribution', readonly=True, digits=(16, int(config['price_accuracy']))),
'company_contrib': fields.float('Company Contribution', readonly=True, digits=(16, 4)),
def onchange_amount(self, cr, uid, ids, amount, typ): amt = amount if typ and typ == 'per': if int(amt) > 0: amt = amt / 100 return {'value':{'amount':amt}}
21786ff375c69b960b487a69bd1343b8b77f3dec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21786ff375c69b960b487a69bd1343b8b77f3dec/hr_payroll.py
'from_val': fields.float('From', digits=(16, int(config['price_accuracy']))), 'to_val': fields.float('To', digits=(16, int(config['price_accuracy']))),
'from_val': fields.float('From', digits=(16, 4)), 'to_val': fields.float('To', digits=(16, 4)),
def execute_function(self, cr, uid, id, value, context): line_pool = self.pool.get('hr.payslip.line.line') res = 0 ids = line_pool.search(cr, uid, [('slipline_id','=',id), ('from_val','<=',value), ('to_val','>=',value)])
21786ff375c69b960b487a69bd1343b8b77f3dec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21786ff375c69b960b487a69bd1343b8b77f3dec/hr_payroll.py
'value': fields.float('Value', digits=(16, int(config['price_accuracy']))),
'value': fields.float('Value', digits=(16, 4)),
def execute_function(self, cr, uid, id, value, context): line_pool = self.pool.get('hr.payslip.line.line') res = 0 ids = line_pool.search(cr, uid, [('slipline_id','=',id), ('from_val','<=',value), ('to_val','>=',value)])
21786ff375c69b960b487a69bd1343b8b77f3dec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/21786ff375c69b960b487a69bd1343b8b77f3dec/hr_payroll.py
for product_id in data['form']['products'][0][2]: value = sale_line_obj.product_id_change(cr, uid, [], pricelist, product_id, qty=1, partner_id=partner_id, fiscal_position=fpos)['value'] value['product_id'] = product_id value['order_id'] = new_id value['tax_id'] = [(6,0,value['tax_id'])] sale_line_obj.create(cr, uid, value)
if data['form']['products']: for product_id in data['form']['products'][0][2]: value = { 'price_unit': 0.0, 'product_id': product_id, 'order_id': new_id, } value.update( sale_line_obj.product_id_change(cr, uid, [], pricelist,product_id, qty=1, partner_id=partner_id, fiscal_position=fpos)['value'] ) value['tax_id'] = [(6,0,value['tax_id'])] sale_line_obj.create(cr, uid, value)
def _makeOrder(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) mod_obj = pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'sale', 'view_sales_order_filter') id = mod_obj.read(cr, uid, result, ['res_id']) case_obj = pool.get('crm.opportunity') sale_obj = pool.get('sale.order') partner_obj = pool.get('res.partner') sale_line_obj = pool.get('sale.order.line')
466e06e60c426d01b2518766bf2cc94ec66ea26f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/466e06e60c426d01b2518766bf2cc94ec66ea26f/makesale.py
cr, uid = self.get_node_cr(node)
cr = self.get_node_cr(node)
def mkdir(self, node, basename): """Create the specified directory.""" cr = False if not node: raise OSError(1, 'Operation not permited.') cr, uid = self.get_node_cr(node) try: basename =_to_unicode(basename) cdir = node.create_child_collection(cr, basename) self._log.debug("Created child dir: %r", cdir) except Exception,e: self._log.exception('Cannot create dir "%s" at node %s', basename, repr(node)) raise OSError(1, 'Operation not permited.') finally: if cr: cr.close()
5da9c2660533a6ecfabf3359d900da3b4bdb24b3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/5da9c2660533a6ecfabf3359d900da3b4bdb24b3/abstracted_fs.py
res_obj = self.pool.get('resource.resource')
res_obj = self.pool.get('resource.resource')
def _compute_day(self, cr, uid, ids, fields, args, context={}): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Openday’s IDs @return: difference between current date and log date @param context: A standard dictionary for contextual values """ cal_obj = self.pool.get('resource.calendar') res_obj = self.pool.get('resource.resource')
c69d8bd2bac959428890d00d910e4f8ed5a4fb90 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c69d8bd2bac959428890d00d910e4f8ed5a4fb90/crm_lead.py
resource_id = len(resource_ids) or resource_ids[0]
if resource_ids: resource_id = len(resource_ids) or resource_ids[0]
def _compute_day(self, cr, uid, ids, fields, args, context={}): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Openday’s IDs @return: difference between current date and log date @param context: A standard dictionary for contextual values """ cal_obj = self.pool.get('resource.calendar') res_obj = self.pool.get('resource.resource')
c69d8bd2bac959428890d00d910e4f8ed5a4fb90 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c69d8bd2bac959428890d00d910e4f8ed5a4fb90/crm_lead.py
self._obj_list=[] self._dbname='' self._uname='admin' self._pwd='a' self._login=False self._running=False self._uid=False self._iscrm=True self.partner_id_list=None self.protocol=None
self._obj_list=[] self._dbname='' self._uname='admin' self._pwd='a' self._login=False self._running=False self._uid=False self._iscrm=True self.partner_id_list=None self.protocol=None
def __init__(self,server='localhost',port=8069,uri='http://localhost:8069'): self._server=server self._port=port self._uri=uri self._obj_list=[] self._dbname='' self._uname='admin' self._pwd='a' self._login=False self._running=False self._uid=False self._iscrm=True self.partner_id_list=None self.protocol=None
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
v=self.__getattribute__(attrib) return str(v)
v=self.__getattribute__(attrib) return str(v)
def getitem(self, attrib): v=self.__getattribute__(attrib) return str(v)
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
return self.__setattr__(attrib, value)
return self.__setattr__(attrib, value)
def setitem(self, attrib, value): return self.__setattr__(attrib, value)
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/db') try: db_list = execute(conn, 'list') if db_list == False: self._running=False return [] else: self._running=True except: db_list=-1 self._running=True return db_list
conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/db') try: db_list = execute(conn, 'list') if db_list == False: self._running=False return [] else: self._running=True except: db_list=-1 self._running=True return db_list
def GetDBList(self): conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/db') try: db_list = execute(conn, 'list') if db_list == False: self._running=False return [] else: self._running=True except: db_list=-1 self._running=True return db_list
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
self._dbname = dbname self._uname = user self._pwd = pwd conn = xmlrpclib.ServerProxy(str(self._uri) + '/xmlrpc/common') uid = execute(conn,'login',dbname, ustr(user), ustr(pwd)) return uid
self._dbname = dbname self._uname = user self._pwd = pwd conn = xmlrpclib.ServerProxy(str(self._uri) + '/xmlrpc/common') uid = execute(conn,'login',dbname, ustr(user), ustr(pwd)) return uid
def login(self,dbname, user, pwd): self._dbname = dbname self._uname = user self._pwd = pwd conn = xmlrpclib.ServerProxy(str(self._uri) + '/xmlrpc/common') uid = execute(conn,'login',dbname, ustr(user), ustr(pwd)) return uid
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[]) objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',ids,['model']) obj_list = [item['model'] for item in objects] return obj_list
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[]) objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',ids,['model']) obj_list = [item['model'] for item in objects] return obj_list
def GetAllObjects(self): conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[]) objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',ids,['model']) obj_list = [item['model'] for item in objects] return obj_list
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
self._obj_list=list(self._obj_list) self._obj_list.sort(reverse=True) return self._obj_list
self._obj_list=list(self._obj_list) self._obj_list.sort(reverse=True) return self._obj_list
def GetObjList(self): self._obj_list=list(self._obj_list) self._obj_list.sort(reverse=True) return self._obj_list
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
self._obj_list=list(self._obj_list) self._obj_list.append((obj_title,obj_name,ustr(image_path))) self._obj_list.sort(reverse=True)
self._obj_list=list(self._obj_list) self._obj_list.append((obj_title,obj_name,ustr(image_path))) self._obj_list.sort(reverse=True)
def InsertObj(self, obj_title,obj_name,image_path): self._obj_list=list(self._obj_list) self._obj_list.append((obj_title,obj_name,ustr(image_path))) self._obj_list.sort(reverse=True)
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
self._obj_list=list(self._obj_list) for obj in self._obj_list: if obj[0] == sel_text: self._obj_list.remove(obj) break
self._obj_list=list(self._obj_list) for obj in self._obj_list: if obj[0] == sel_text: self._obj_list.remove(obj) break
def DeleteObject(self,sel_text): self._obj_list=list(self._obj_list) for obj in self._obj_list: if obj[0] == sel_text: self._obj_list.remove(obj) break
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
import win32con conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/object') flag = False new_msg = ext_msg ="" message_id = referances = None try: session = win32com.client.Dispatch("MAPI.session") session.Logon('Outlook') objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) objFields = objMessage.Fields strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) strheader = ustr(strheader).encode('iso-8859-1') headers = {} strheader = strheader.replace("\n ", " ").splitlines() for line in strheader: split_here = line.find(":") headers[line[:split_here]] = line[split_here:] temp1 = headers.get('Message-ID') temp2 = headers.get('Message-Id') referances = headers.get('References') if temp1 == None: message_id = temp2 if temp2 == None: message_id = temp1 startCut = message_id.find("<") endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] if not referances == None: startCut = referances.find("<") endCut = referances.find(">") referances = referances[startCut:endCut+1] except Exception,e: win32ui.MessageBox(str(e),"Archive To OpenERP") return attachments=mail.Attachments for rec in recs:
import win32con conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/object') flag = False new_msg = ext_msg ="" message_id = referances = None try: session = win32com.client.Dispatch("MAPI.session") session.Logon('Outlook') objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) objFields = objMessage.Fields strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) strheader = ustr(strheader).encode('iso-8859-1') headers = {} strheader = strheader.replace("\n ", " ").splitlines() for line in strheader: split_here = line.find(":") headers[line[:split_here]] = line[split_here:] temp1 = headers.get('Message-ID') temp2 = headers.get('Message-Id') referances = headers.get('References') if temp1 == None: message_id = temp2 if temp2 == None: message_id = temp1 startCut = message_id.find("<") endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] if not referances == None: startCut = referances.find("<") endCut = referances.find(">") referances = referances[startCut:endCut+1] except Exception,e: win32ui.MessageBox(str(e),"Archive To OpenERP") return attachments=mail.Attachments for rec in recs:
def ArchiveToOpenERP(self, recs, mail): import win32con conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/object') flag = False new_msg = ext_msg ="" message_id = referances = None try: session = win32com.client.Dispatch("MAPI.session") session.Logon('Outlook') objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) objFields = objMessage.Fields strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) strheader = ustr(strheader).encode('iso-8859-1') headers = {} strheader = strheader.replace("\n ", " ").splitlines() for line in strheader: split_here = line.find(":") headers[line[:split_here]] = line[split_here:] temp1 = headers.get('Message-ID') temp2 = headers.get('Message-Id') referances = headers.get('References') if temp1 == None: message_id = temp2 if temp2 == None: message_id = temp1 startCut = message_id.find("<") endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] if not referances == None: startCut = referances.find("<") endCut = referances.find(">") referances = referances[startCut:endCut+1] except Exception,e: win32ui.MessageBox(str(e),"Archive To OpenERP") return attachments=mail.Attachments for rec in recs: #[('res.partner', 3, 'Agrolait')] model = rec[0] res_id = rec[1] #Check if mailgate installed object_id = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','mailgate.message')]) if not object_id: win32ui.MessageBox("Mailgate is not installed on your configured database '%s' !!\n\nPlease install it to archive the mail."%(self._dbname),"Mailgate not installed",win32con.MB_ICONERROR) return object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',model)]) object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] #Reading the Object ir.model Name ext_ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mailgate.message','search',[('message_id','=',message_id),('model','=',model),('res_id','=',res_id)]) if ext_ids: name = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,model,'read',res_id,['name'])['name'] ext_msg += """This mail is already archived to {0} '{1}'.\n""".format(object_name,name) flag = True continue msg = { 'subject':mail.Subject, 'date':str(mail.ReceivedTime), 'body':mail.Body, 'cc':mail.CC, 'from':mail.SenderEmailAddress, 'to':mail.To, 'message-id':message_id, 'references':ustr(referances), } obj_list= ['crm.lead','project.issue','hr.applicant','res.partner'] if rec[0] not in obj_list: ids = self.CreateEmailAttachment(rec,mail) result = {} if attachments: result = self.MakeAttachment([rec], mail) attachment_ids = result.get(model, {}).get(res_id, []) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','history',model, res_id, msg, attachment_ids) new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2])) flag = True
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
win32ui.MessageBox("Mailgate is not installed on your configured database '%s' !!\n\nPlease install it to archive the mail."%(self._dbname),"Mailgate not installed",win32con.MB_ICONERROR) return
win32ui.MessageBox("Mailgate is not installed on your configured database '%s' !!\n\nPlease install it to archive the mail."%(self._dbname),"Mailgate not installed",win32con.MB_ICONERROR) return
def ArchiveToOpenERP(self, recs, mail): import win32con conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/object') flag = False new_msg = ext_msg ="" message_id = referances = None try: session = win32com.client.Dispatch("MAPI.session") session.Logon('Outlook') objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) objFields = objMessage.Fields strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) strheader = ustr(strheader).encode('iso-8859-1') headers = {} strheader = strheader.replace("\n ", " ").splitlines() for line in strheader: split_here = line.find(":") headers[line[:split_here]] = line[split_here:] temp1 = headers.get('Message-ID') temp2 = headers.get('Message-Id') referances = headers.get('References') if temp1 == None: message_id = temp2 if temp2 == None: message_id = temp1 startCut = message_id.find("<") endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] if not referances == None: startCut = referances.find("<") endCut = referances.find(">") referances = referances[startCut:endCut+1] except Exception,e: win32ui.MessageBox(str(e),"Archive To OpenERP") return attachments=mail.Attachments for rec in recs: #[('res.partner', 3, 'Agrolait')] model = rec[0] res_id = rec[1] #Check if mailgate installed object_id = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','mailgate.message')]) if not object_id: win32ui.MessageBox("Mailgate is not installed on your configured database '%s' !!\n\nPlease install it to archive the mail."%(self._dbname),"Mailgate not installed",win32con.MB_ICONERROR) return object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',model)]) object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] #Reading the Object ir.model Name ext_ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mailgate.message','search',[('message_id','=',message_id),('model','=',model),('res_id','=',res_id)]) if ext_ids: name = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,model,'read',res_id,['name'])['name'] ext_msg += """This mail is already archived to {0} '{1}'.\n""".format(object_name,name) flag = True continue msg = { 'subject':mail.Subject, 'date':str(mail.ReceivedTime), 'body':mail.Body, 'cc':mail.CC, 'from':mail.SenderEmailAddress, 'to':mail.To, 'message-id':message_id, 'references':ustr(referances), } obj_list= ['crm.lead','project.issue','hr.applicant','res.partner'] if rec[0] not in obj_list: ids = self.CreateEmailAttachment(rec,mail) result = {} if attachments: result = self.MakeAttachment([rec], mail) attachment_ids = result.get(model, {}).get(res_id, []) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','history',model, res_id, msg, attachment_ids) new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2])) flag = True
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
name = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,model,'read',res_id,['name'])['name'] ext_msg += """This mail is already archived to {0} '{1}'.\n""".format(object_name,name) flag = True continue
name = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,model,'read',res_id,['name'])['name'] ext_msg += """This mail is already archived to {0} '{1}'.\n""".format(object_name,name) flag = True continue
def ArchiveToOpenERP(self, recs, mail): import win32con conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/object') flag = False new_msg = ext_msg ="" message_id = referances = None try: session = win32com.client.Dispatch("MAPI.session") session.Logon('Outlook') objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) objFields = objMessage.Fields strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) strheader = ustr(strheader).encode('iso-8859-1') headers = {} strheader = strheader.replace("\n ", " ").splitlines() for line in strheader: split_here = line.find(":") headers[line[:split_here]] = line[split_here:] temp1 = headers.get('Message-ID') temp2 = headers.get('Message-Id') referances = headers.get('References') if temp1 == None: message_id = temp2 if temp2 == None: message_id = temp1 startCut = message_id.find("<") endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] if not referances == None: startCut = referances.find("<") endCut = referances.find(">") referances = referances[startCut:endCut+1] except Exception,e: win32ui.MessageBox(str(e),"Archive To OpenERP") return attachments=mail.Attachments for rec in recs: #[('res.partner', 3, 'Agrolait')] model = rec[0] res_id = rec[1] #Check if mailgate installed object_id = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','mailgate.message')]) if not object_id: win32ui.MessageBox("Mailgate is not installed on your configured database '%s' !!\n\nPlease install it to archive the mail."%(self._dbname),"Mailgate not installed",win32con.MB_ICONERROR) return object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',model)]) object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] #Reading the Object ir.model Name ext_ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mailgate.message','search',[('message_id','=',message_id),('model','=',model),('res_id','=',res_id)]) if ext_ids: name = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,model,'read',res_id,['name'])['name'] ext_msg += """This mail is already archived to {0} '{1}'.\n""".format(object_name,name) flag = True continue msg = { 'subject':mail.Subject, 'date':str(mail.ReceivedTime), 'body':mail.Body, 'cc':mail.CC, 'from':mail.SenderEmailAddress, 'to':mail.To, 'message-id':message_id, 'references':ustr(referances), } obj_list= ['crm.lead','project.issue','hr.applicant','res.partner'] if rec[0] not in obj_list: ids = self.CreateEmailAttachment(rec,mail) result = {} if attachments: result = self.MakeAttachment([rec], mail) attachment_ids = result.get(model, {}).get(res_id, []) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','history',model, res_id, msg, attachment_ids) new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2])) flag = True
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
'subject':mail.Subject, 'date':str(mail.ReceivedTime), 'body':mail.Body, 'cc':mail.CC, 'from':mail.SenderEmailAddress, 'to':mail.To, 'message-id':message_id, 'references':ustr(referances),
'subject':mail.Subject, 'date':str(mail.ReceivedTime), 'body':mail.Body, 'cc':mail.CC, 'from':mail.SenderEmailAddress, 'to':mail.To, 'message-id':message_id, 'references':ustr(referances),
def ArchiveToOpenERP(self, recs, mail): import win32con conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/object') flag = False new_msg = ext_msg ="" message_id = referances = None try: session = win32com.client.Dispatch("MAPI.session") session.Logon('Outlook') objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) objFields = objMessage.Fields strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) strheader = ustr(strheader).encode('iso-8859-1') headers = {} strheader = strheader.replace("\n ", " ").splitlines() for line in strheader: split_here = line.find(":") headers[line[:split_here]] = line[split_here:] temp1 = headers.get('Message-ID') temp2 = headers.get('Message-Id') referances = headers.get('References') if temp1 == None: message_id = temp2 if temp2 == None: message_id = temp1 startCut = message_id.find("<") endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] if not referances == None: startCut = referances.find("<") endCut = referances.find(">") referances = referances[startCut:endCut+1] except Exception,e: win32ui.MessageBox(str(e),"Archive To OpenERP") return attachments=mail.Attachments for rec in recs: #[('res.partner', 3, 'Agrolait')] model = rec[0] res_id = rec[1] #Check if mailgate installed object_id = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','mailgate.message')]) if not object_id: win32ui.MessageBox("Mailgate is not installed on your configured database '%s' !!\n\nPlease install it to archive the mail."%(self._dbname),"Mailgate not installed",win32con.MB_ICONERROR) return object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',model)]) object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] #Reading the Object ir.model Name ext_ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mailgate.message','search',[('message_id','=',message_id),('model','=',model),('res_id','=',res_id)]) if ext_ids: name = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,model,'read',res_id,['name'])['name'] ext_msg += """This mail is already archived to {0} '{1}'.\n""".format(object_name,name) flag = True continue msg = { 'subject':mail.Subject, 'date':str(mail.ReceivedTime), 'body':mail.Body, 'cc':mail.CC, 'from':mail.SenderEmailAddress, 'to':mail.To, 'message-id':message_id, 'references':ustr(referances), } obj_list= ['crm.lead','project.issue','hr.applicant','res.partner'] if rec[0] not in obj_list: ids = self.CreateEmailAttachment(rec,mail) result = {} if attachments: result = self.MakeAttachment([rec], mail) attachment_ids = result.get(model, {}).get(res_id, []) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','history',model, res_id, msg, attachment_ids) new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2])) flag = True
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
result = self.MakeAttachment([rec], mail)
result = self.MakeAttachment([rec], mail)
def ArchiveToOpenERP(self, recs, mail): import win32con conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/object') flag = False new_msg = ext_msg ="" message_id = referances = None try: session = win32com.client.Dispatch("MAPI.session") session.Logon('Outlook') objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) objFields = objMessage.Fields strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) strheader = ustr(strheader).encode('iso-8859-1') headers = {} strheader = strheader.replace("\n ", " ").splitlines() for line in strheader: split_here = line.find(":") headers[line[:split_here]] = line[split_here:] temp1 = headers.get('Message-ID') temp2 = headers.get('Message-Id') referances = headers.get('References') if temp1 == None: message_id = temp2 if temp2 == None: message_id = temp1 startCut = message_id.find("<") endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] if not referances == None: startCut = referances.find("<") endCut = referances.find(">") referances = referances[startCut:endCut+1] except Exception,e: win32ui.MessageBox(str(e),"Archive To OpenERP") return attachments=mail.Attachments for rec in recs: #[('res.partner', 3, 'Agrolait')] model = rec[0] res_id = rec[1] #Check if mailgate installed object_id = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','mailgate.message')]) if not object_id: win32ui.MessageBox("Mailgate is not installed on your configured database '%s' !!\n\nPlease install it to archive the mail."%(self._dbname),"Mailgate not installed",win32con.MB_ICONERROR) return object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',model)]) object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] #Reading the Object ir.model Name ext_ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mailgate.message','search',[('message_id','=',message_id),('model','=',model),('res_id','=',res_id)]) if ext_ids: name = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,model,'read',res_id,['name'])['name'] ext_msg += """This mail is already archived to {0} '{1}'.\n""".format(object_name,name) flag = True continue msg = { 'subject':mail.Subject, 'date':str(mail.ReceivedTime), 'body':mail.Body, 'cc':mail.CC, 'from':mail.SenderEmailAddress, 'to':mail.To, 'message-id':message_id, 'references':ustr(referances), } obj_list= ['crm.lead','project.issue','hr.applicant','res.partner'] if rec[0] not in obj_list: ids = self.CreateEmailAttachment(rec,mail) result = {} if attachments: result = self.MakeAttachment([rec], mail) attachment_ids = result.get(model, {}).get(res_id, []) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','history',model, res_id, msg, attachment_ids) new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2])) flag = True
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
if flag: t = """Mail archived Successfully with attachments.\n"""+ext_msg t += "\n"+new_msg win32ui.MessageBox(t,"Archived to OpenERP",win32con.MB_ICONINFORMATION) return flag
if flag: t = """Mail archived Successfully with attachments.\n"""+ext_msg t += "\n"+new_msg win32ui.MessageBox(t,"Archived to OpenERP",win32con.MB_ICONINFORMATION) return flag
def ArchiveToOpenERP(self, recs, mail): import win32con conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/object') flag = False new_msg = ext_msg ="" message_id = referances = None try: session = win32com.client.Dispatch("MAPI.session") session.Logon('Outlook') objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) objFields = objMessage.Fields strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) strheader = ustr(strheader).encode('iso-8859-1') headers = {} strheader = strheader.replace("\n ", " ").splitlines() for line in strheader: split_here = line.find(":") headers[line[:split_here]] = line[split_here:] temp1 = headers.get('Message-ID') temp2 = headers.get('Message-Id') referances = headers.get('References') if temp1 == None: message_id = temp2 if temp2 == None: message_id = temp1 startCut = message_id.find("<") endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] if not referances == None: startCut = referances.find("<") endCut = referances.find(">") referances = referances[startCut:endCut+1] except Exception,e: win32ui.MessageBox(str(e),"Archive To OpenERP") return attachments=mail.Attachments for rec in recs: #[('res.partner', 3, 'Agrolait')] model = rec[0] res_id = rec[1] #Check if mailgate installed object_id = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','mailgate.message')]) if not object_id: win32ui.MessageBox("Mailgate is not installed on your configured database '%s' !!\n\nPlease install it to archive the mail."%(self._dbname),"Mailgate not installed",win32con.MB_ICONERROR) return object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',model)]) object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] #Reading the Object ir.model Name ext_ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mailgate.message','search',[('message_id','=',message_id),('model','=',model),('res_id','=',res_id)]) if ext_ids: name = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,model,'read',res_id,['name'])['name'] ext_msg += """This mail is already archived to {0} '{1}'.\n""".format(object_name,name) flag = True continue msg = { 'subject':mail.Subject, 'date':str(mail.ReceivedTime), 'body':mail.Body, 'cc':mail.CC, 'from':mail.SenderEmailAddress, 'to':mail.To, 'message-id':message_id, 'references':ustr(referances), } obj_list= ['crm.lead','project.issue','hr.applicant','res.partner'] if rec[0] not in obj_list: ids = self.CreateEmailAttachment(rec,mail) result = {} if attachments: result = self.MakeAttachment([rec], mail) attachment_ids = result.get(model, {}).get(res_id, []) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','history',model, res_id, msg, attachment_ids) new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2])) flag = True
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','crm.lead')]) return id
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','crm.lead')]) return id
def IsCRMInstalled(self): conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','crm.lead')]) return id
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = execute(conn,'execute',self._dbname,int(int(self._uid)),self._pwd,'crm.case.section','search',[]) objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'crm.case.section','read',ids,['name']) obj_list = [ustr(item['name']).encode('iso-8859-1') for item in objects] return obj_list
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = execute(conn,'execute',self._dbname,int(int(self._uid)),self._pwd,'crm.case.section','search',[]) objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'crm.case.section','read',ids,['name']) obj_list = [ustr(item['name']).encode('iso-8859-1') for item in objects] return obj_list
def GetCSList(self): conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = execute(conn,'execute',self._dbname,int(int(self._uid)),self._pwd,'crm.case.section','search',[]) objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'crm.case.section','read',ids,['name']) obj_list = [ustr(item['name']).encode('iso-8859-1') for item in objects] return obj_list
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids=[] obj_list=[] domain = [] if not search_partner.strip() == '': domain.append(('name','ilike',ustr(search_partner))) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',domain) if ids: ids.sort() obj_list.append((-999, ustr(''))) for id in ids: object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','read',[id],['id','name'])[0] obj_list.append((object['id'], ustr(object['name']))) obj_list.sort(lambda x, y: cmp(x[1],y[1])) return obj_list
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids=[] obj_list=[] domain = [] if not search_partner.strip() == '': domain.append(('name','ilike',ustr(search_partner))) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',domain) if ids: ids.sort() obj_list.append((-999, ustr(''))) for id in ids: object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','read',[id],['id','name'])[0] obj_list.append((object['id'], ustr(object['name']))) obj_list.sort(lambda x, y: cmp(x[1],y[1])) return obj_list
def GetPartners(self, search_partner=''): conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids=[] obj_list=[] domain = [] if not search_partner.strip() == '': domain.append(('name','ilike',ustr(search_partner))) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',domain) if ids: ids.sort() obj_list.append((-999, ustr(''))) for id in ids: object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','read',[id],['id','name'])[0] obj_list.append((object['id'], ustr(object['name']))) obj_list.sort(lambda x, y: cmp(x[1],y[1])) return obj_list
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
res = [] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') for obj in search_list: object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',obj)]) object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] if obj == "res.partner.address": ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',['|',('name','ilike',ustr(search_text)),('email','ilike',ustr(search_text))]) recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name','street','city']) for rec in recs: name = ustr(rec['name']) if rec['street']: name += ', ' + ustr(rec['street']) if rec['city']: name += ', ' + ustr(rec['city']) res.append((obj,rec['id'],name,object_name)) else: ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',[('name','ilike',ustr(search_text))]) recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name']) for rec in recs: name = ustr(rec['name']) res.append((obj,rec['id'],name,object_name)) return res
res = [] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') for obj in search_list: object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',obj)]) object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] if obj == "res.partner.address": ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',['|',('name','ilike',ustr(search_text)),('email','ilike',ustr(search_text))]) recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name','street','city']) for rec in recs: name = ustr(rec['name']) if rec['street']: name += ', ' + ustr(rec['street']) if rec['city']: name += ', ' + ustr(rec['city']) res.append((obj,rec['id'],name,object_name)) else: ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',[('name','ilike',ustr(search_text))]) recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name']) for rec in recs: name = ustr(rec['name']) res.append((obj,rec['id'],name,object_name)) return res_id
def GetObjectItems(self, search_list=[], search_text=''): res = [] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') for obj in search_list: object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',obj)]) object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] if obj == "res.partner.address": ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',['|',('name','ilike',ustr(search_text)),('email','ilike',ustr(search_text))]) recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name','street','city']) for rec in recs: name = ustr(rec['name']) if rec['street']: name += ', ' + ustr(rec['street']) if rec['city']: name += ', ' + ustr(rec['city']) res.append((obj,rec['id'],name,object_name)) else: ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',[('name','ilike',ustr(search_text))]) recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name']) for rec in recs: name = ustr(rec['name']) res.append((obj,rec['id'],name,object_name)) return res
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
import eml flag = False id = -1 try: conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') email=eml.generateEML(mail) message_id = None session = win32com.client.Dispatch("MAPI.session") session.Logon('Outlook') objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) objFields = objMessage.Fields strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) strheader = ustr(strheader).encode('iso-8859-1') headers = {} strheader = strheader.replace("\n ", " ").splitlines() for line in strheader: split_here = line.find(":") headers[line[:split_here]] = line[split_here:] temp1 = headers.get('Message-ID') temp2 = headers.get('Message-Id') if temp1 == None: message_id = temp2 if temp2 == None: message_id = temp1 startCut = message_id.find("<") endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] email.replace_header('Message-Id',message_id) id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','process_email',section, str(email)) if id > 0: flag = True return flag else: flag = False return flag except Exception,e: win32ui.MessageBox("Create Case\n"+str(e),"Mail Reading Error") return flag
import eml flag = False id = -1 try: conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') email=eml.generateEML(mail) message_id = None session = win32com.client.Dispatch("MAPI.session") session.Logon('Outlook') objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) objFields = objMessage.Fields strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) strheader = ustr(strheader).encode('iso-8859-1') headers = {} strheader = strheader.replace("\n ", " ").splitlines() for line in strheader: split_here = line.find(":") headers[line[:split_here]] = line[split_here:] temp1 = headers.get('Message-ID') temp2 = headers.get('Message-Id') if temp1 == None: message_id = temp2 if temp2 == None: message_id = temp1 startCut = message_id.find("<") endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] email.replace_header('Message-Id',message_id) id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','process_email',section, str(email)) if id > 0: flag = True return flag else: flag = False return flag except Exception,e: win32ui.MessageBox("Create Case\n"+str(e),"Mail Reading Error") return flag
def CreateCase(self, section, mail, partner_ids, with_attachments=True): import eml flag = False id = -1 try: conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') email=eml.generateEML(mail) message_id = None session = win32com.client.Dispatch("MAPI.session") session.Logon('Outlook') objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) objFields = objMessage.Fields strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) strheader = ustr(strheader).encode('iso-8859-1') headers = {} strheader = strheader.replace("\n ", " ").splitlines() for line in strheader: split_here = line.find(":") headers[line[:split_here]] = line[split_here:] temp1 = headers.get('Message-ID') temp2 = headers.get('Message-Id') if temp1 == None: message_id = temp2 if temp2 == None: message_id = temp1 startCut = message_id.find("<") endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] email.replace_header('Message-Id',message_id) id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','process_email',section, str(email)) if id > 0: flag = True return flag else: flag = False return flag except Exception,e: win32ui.MessageBox("Create Case\n"+str(e),"Mail Reading Error") return flag
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
attachments = mail.Attachments result = {} conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') att_folder_path = os.path.abspath(os.path.dirname("%temp%\\")) if not os.path.exists(att_folder_path): os.makedirs(att_folder_path) for rec in recs: obj = rec[0] obj_id = rec[1] res={} res['res_model'] = obj attachment_ids = [] if obj not in result: result[obj] = {} for i in xrange(1, attachments.Count+1): fn = ustr(attachments[i].FileName) if len(fn) > 64: l = 64 - len(fn) f = fn.split('.') fn = f[0][0:l] + '.' + f[-1] att_path = os.path.join(att_folder_path,fn) attachments[i].SaveAsFile(att_path) f=open(att_path,"rb") content = "".join(f.readlines()).encode('base64') f.close() res['name'] = ustr(attachments[i].DisplayName) res['datas_fname'] = ustr(fn) res['datas'] = content res['res_id'] = obj_id id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.attachment','create',res) attachment_ids.append(id) result[obj].update({obj_id: attachment_ids}) return result
attachments = mail.Attachments result = {} conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') att_folder_path = os.path.abspath(os.path.dirname("%temp%\\")) if not os.path.exists(att_folder_path): os.makedirs(att_folder_path) for rec in recs: obj = rec[0] obj_id = rec[1] res={} res['res_model'] = obj attachment_ids = [] if obj not in result: result[obj] = {} for i in xrange(1, attachments.Count+1): fn = ustr(attachments[i].FileName) if len(fn) > 64: l = 64 - len(fn) f = fn.split('.') fn = f[0][0:l] + '.' + f[-1] att_path = os.path.join(att_folder_path,fn) attachments[i].SaveAsFile(att_path) f=open(att_path,"rb") content = "".join(f.readlines()).encode('base64') f.close() res['name'] = ustr(attachments[i].DisplayName) res['datas_fname'] = ustr(fn) res['datas'] = content res['res_id'] = obj_id id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.attachment','create',res) attachment_ids.append(id) result[obj].update({obj_id: attachment_ids}) return result
def MakeAttachment(self, recs, mail): attachments = mail.Attachments result = {} conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') att_folder_path = os.path.abspath(os.path.dirname("%temp%\\")) if not os.path.exists(att_folder_path): os.makedirs(att_folder_path) for rec in recs: #[('res.partner', 3, 'Agrolait')] obj = rec[0] obj_id = rec[1] res={} res['res_model'] = obj attachment_ids = [] if obj not in result: result[obj] = {} for i in xrange(1, attachments.Count+1): fn = ustr(attachments[i].FileName) if len(fn) > 64: l = 64 - len(fn) f = fn.split('.') fn = f[0][0:l] + '.' + f[-1] att_path = os.path.join(att_folder_path,fn) attachments[i].SaveAsFile(att_path) f=open(att_path,"rb") content = "".join(f.readlines()).encode('base64') f.close() res['name'] = ustr(attachments[i].DisplayName) res['datas_fname'] = ustr(fn) res['datas'] = content res['res_id'] = obj_id id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.attachment','create',res) attachment_ids.append(id) result[obj].update({obj_id: attachment_ids}) return result
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
res=eval(str(res)) partner = res['partner_id'] state = res['state_id'] country = res['country_id'] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') if not partner.strip() == '': partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) res.update({'partner_id' : partner_id[0]}) else: res.pop('partner_id') if not state == "": country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country))]) res.update({'country_id' : country_id[0]}) else: res.pop('country_id') if not country == "": state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state))]) res.update({'state_id' : state_id[0]}) else: res.pop('state_id') id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner.address','create',res) return id
res=eval(str(res)) partner = res['partner_id'] state = res['state_id'] country = res['country_id'] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') if not partner.strip() == '': partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) res.update({'partner_id' : partner_id[0]}) else: res.pop('partner_id') if not state == "": country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country))]) res.update({'country_id' : country_id[0]}) else: res.pop('country_id') if not country == "": state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state))]) res.update({'state_id' : state_id[0]}) else: res.pop('state_id') id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner.address','create',res) return id
def CreateContact(self, res=None): res=eval(str(res)) partner = res['partner_id'] state = res['state_id'] country = res['country_id'] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') if not partner.strip() == '': partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) res.update({'partner_id' : partner_id[0]}) else: res.pop('partner_id') if not state == "": country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country))]) res.update({'country_id' : country_id[0]}) else: res.pop('country_id') if not country == "": state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state))]) res.update({'state_id' : state_id[0]}) else: res.pop('state_id') id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner.address','create',res) return id
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
res=eval(str(res)) conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',[('name','=',res['name'])]) if ids: return False id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','create',res) return id
res=eval(str(res)) conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',[('name','=',res['name'])]) if ids: return False id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','create',res) return id
def CreatePartner(self, res): res=eval(str(res)) conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',[('name','=',res['name'])]) if ids: return False id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','create',res) return id
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
res_vals = [] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') address_id = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','ilike',ustr(search_email_id))]) if not address_id : return address = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address','read',address_id[0],['id','partner_id','name','street','street2','city','state_id','country_id','phone','mobile','email','fax','zip']) for key, vals in address.items(): res_vals.append([key,vals]) return res_vals
res_vals = [] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') address_id = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','ilike',ustr(search_email_id))]) if not address_id : return address = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address','read',address_id[0],['id','partner_id','name','street','street2','city','state_id','country_id','phone','mobile','email','fax','zip']) for key, vals in address.items(): res_vals.append([key,vals]) return res_vals
def SearchPartnerDetail(self, search_email_id): res_vals = [] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') address_id = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','ilike',ustr(search_email_id))]) if not address_id : return address = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address','read',address_id[0],['id','partner_id','name','street','street2','city','state_id','country_id','phone','mobile','email','fax','zip']) for key, vals in address.items(): res_vals.append([key,vals]) return res_vals
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
flag = -1 new_dict = dict(new_vals) email=new_dict['email'] partner = new_dict['partner'] country_val = new_dict['country'] state_val = new_dict['state'] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country_val))]) state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state_val))]) address_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(email))]) if not partner_id or not address_id or not country_id or not state_id: return flag address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address','read',address_id[0],['id','partner_id','state_id','country_id']) vals_res_address={ 'partner_id' : partner_id[0], 'name' : new_dict['name'], 'street':new_dict['street'], 'street2' : new_dict['street2'], 'city' : new_dict['city'], 'phone' : new_dict['phone'], 'mobile' : new_dict['mobile'], 'fax' : new_dict['fax'], 'zip' : new_dict['zip'], 'country_id' : country_id[0], 'state_id' : state_id[0] } temp = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'write', address_id, vals_res_address) if temp: flag=1 else: flag=0 return flag
flag = -1 new_dict = dict(new_vals) email=new_dict['email'] partner = new_dict['partner'] country_val = new_dict['country'] state_val = new_dict['state'] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country_val))]) state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state_val))]) address_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(email))]) if not partner_id or not address_id or not country_id or not state_id: return flag address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address','read',address_id[0],['id','partner_id','state_id','country_id']) vals_res_address={ 'partner_id' : partner_id[0], 'name' : new_dict['name'], 'street':new_dict['street'], 'street2' : new_dict['street2'], 'city' : new_dict['city'], 'phone' : new_dict['phone'], 'mobile' : new_dict['mobile'], 'fax' : new_dict['fax'], 'zip' : new_dict['zip'], 'country_id' : country_id[0], 'state_id' : state_id[0] } temp = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'write', address_id, vals_res_address) if temp: flag=1 else: flag=0 return flag
def WritePartnerValues(self, new_vals): flag = -1 new_dict = dict(new_vals) email=new_dict['email'] partner = new_dict['partner'] country_val = new_dict['country'] state_val = new_dict['state'] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country_val))]) state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state_val))]) address_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(email))]) if not partner_id or not address_id or not country_id or not state_id: return flag address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address','read',address_id[0],['id','partner_id','state_id','country_id']) vals_res_address={ 'partner_id' : partner_id[0], 'name' : new_dict['name'], 'street':new_dict['street'], 'street2' : new_dict['street2'], 'city' : new_dict['city'], 'phone' : new_dict['phone'], 'mobile' : new_dict['mobile'], 'fax' : new_dict['fax'], 'zip' : new_dict['zip'], 'country_id' : country_id[0], 'state_id' : state_id[0] } temp = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'write', address_id, vals_res_address) if temp: flag=1 else: flag=0 return flag
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
state_list = [] state_ids = [] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') state_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', []) for state_id in state_ids: obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'read', [state_id],['id','name'])[0] state_list.append((obj['id'], ustr(obj['name']))) return state_list
state_list = [] state_ids = [] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') state_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', []) for state_id in state_ids: obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'read', [state_id],['id','name'])[0] state_list.append((obj['id'], ustr(obj['name']))) return state_list
def GetAllState(self): state_list = [] state_ids = [] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') state_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', []) for state_id in state_ids: obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'read', [state_id],['id','name'])[0] state_list.append((obj['id'], ustr(obj['name']))) return state_list
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
country_list = [] country_ids = [] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') country_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', []) for country_id in country_ids: obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country','read', [country_id], ['id','name'])[0] country_list.append((obj['id'], ustr(obj['name']))) return country_list
country_list = [] country_ids = [] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') country_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', []) for country_id in country_ids: obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country','read', [country_id], ['id','name'])[0] country_list.append((obj['id'], ustr(obj['name']))) return country_list
def GetAllCountry(self): country_list = [] country_ids = [] conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') country_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', []) for country_id in country_ids: obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country','read', [country_id], ['id','name'])[0] country_list.append((obj['id'], ustr(obj['name']))) return country_list
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(mail_id))]) if not address: return None else: add_rec = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'read', address[0]) partner = add_rec.get('partner_id',False) if partner: return partner[0]
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(mail_id))]) if not address: return None else: add_rec = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'read', address[0]) partner = add_rec.get('partner_id',False) if partner: return partner[0]
def SearchPartner(self, mail_id = ""): conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(mail_id))]) if not address: return None else: add_rec = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'read', address[0]) partner = add_rec.get('partner_id',False) if partner: return partner[0] return True
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') res_vals = [] mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message', 'search', [('message_id','=',message_id)]) if not mail_id: return None address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message','read',mail_id[0],['model','res_id']) for key, vals in address.items(): res_vals.append([key,vals]) return res_vals
connector = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') res_vals = [] mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message', 'search', [('message_id','=',message_id)]) if not mail_id: return None address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message','read',mail_id[0],['model','res_id']) for key, vals in address.items(): res_vals.append([key,vals]) return res_vals
def SearchEmailResources(self, message_id): conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') res_vals = [] mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message', 'search', [('message_id','=',message_id)]) if not mail_id: return None address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message','read',mail_id[0],['model','res_id']) for key, vals in address.items(): res_vals.append([key,vals]) return res_vals
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids=[] obj_list=[] domain = [] if not country_search.strip() == '': domain.append(('name','ilike',ustr(country_search))) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','search',domain) if ids: ids.sort() for id in ids: object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','read',[id],['id','name'])[0] obj_list.append((object['id'], ustr(object['name']))) obj_list.sort(lambda x, y: cmp(x[1],y[1])) return obj_list
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids=[] obj_list=[] domain = [] if not country_search.strip() == '': domain.append(('name','ilike',ustr(country_search))) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','search',domain) if ids: ids.sort() for id in ids: object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','read',[id],['id','name'])[0] obj_list.append((object['id'], ustr(object['name']))) obj_list.sort(lambda x, y: cmp(x[1],y[1])) return obj_list
def GetCountry(self, country_search=''): conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids=[] obj_list=[] domain = [] if not country_search.strip() == '': domain.append(('name','ilike',ustr(country_search))) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','search',domain) if ids: ids.sort() for id in ids: object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','read',[id],['id','name'])[0] obj_list.append((object['id'], ustr(object['name']))) obj_list.sort(lambda x, y: cmp(x[1],y[1])) return obj_list
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = [] c_id = [] obj_list = [] domain = [] if not state_search.strip() == '': domain.append(('name','ilike',ustr(state_search))) if country == None: ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',domain) if not country == None: c_id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','search',[('name','=',ustr(country))]) domain.append(('country_id','=',c_id[0])) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',domain) if ids: ids.sort() for id in ids: object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','read',[id],['id','name'])[0] obj_list.append((object['id'], ustr(object['name']))) obj_list.sort(lambda x, y: cmp(x[1],y[1])) return obj_list
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = [] c_id = [] obj_list = [] domain = [] if not state_search.strip() == '': domain.append(('name','ilike',ustr(state_search))) if country == None: ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',domain) if not country == None: c_id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','search',[('name','=',ustr(country))]) domain.append(('country_id','=',c_id[0])) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',domain) if ids: ids.sort() for id in ids: object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','read',[id],['id','name'])[0] obj_list.append((object['id'], ustr(object['name']))) obj_list.sort(lambda x, y: cmp(x[1],y[1])) return obj_list
def GetStates(self, state_search='', country=None): conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = [] c_id = [] obj_list = [] domain = [] if not state_search.strip() == '': domain.append(('name','ilike',ustr(state_search)))
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',[('name','=',ustr(state_search))]) if not ids: return None object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','read',ids)[0] country = object['country_id'][1] return country
conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',[('name','=',ustr(state_search))]) if not ids: return None object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','read',ids)[0] country = object['country_id'][1] return country
def FindCountryForState(self, state_search=''): conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',[('name','=',ustr(state_search))]) if not ids: return None object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','read',ids)[0] country = object['country_id'][1] return country
bc3c1f7a22dbca3c418f700cf48883617e53933e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bc3c1f7a22dbca3c418f700cf48883617e53933e/tiny_xmlrpc.py
'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal'),
'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal', digits=(16, int(config['price_accuracy']))),
def _number_packages(self, cr, uid, ids, field_name, arg, context): res = {} for line in self.browse(cr, uid, ids): try: res[line.id] = int(line.product_uom_qty / line.product_packaging.qty) except: res[line.id] = 1 return res
d81dcdc8cf8a7aab25fbda1de7d2a2ff3bfde909 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/d81dcdc8cf8a7aab25fbda1de7d2a2ff3bfde909/sale.py
except Exception, ex:
except Exception:
def init_logger(): import os from tools.translate import resetlocale resetlocale() # create a format for log messages and dates format = '[%(asctime)s][%(dbname)s] %(levelname)s:%(name)s:%(message)s' if tools.config['syslog']: # SysLog Handler if os.name == 'nt': handler = logging.handlers.NTEventLogHandler("%s %s" % (release.description, release.version)) else: handler = logging.handlers.SysLogHandler('/dev/log') format = '%s %s' % (release.description, release.version) \ + ':%(dbname)s:%(levelname)s:%(name)s:%(message)s' elif tools.config['logfile']: # LogFile Handler logf = tools.config['logfile'] try: dirname = os.path.dirname(logf) if dirname and not os.path.isdir(dirname): os.makedirs(dirname) if tools.config['logrotate'] is not False: handler = logging.handlers.TimedRotatingFileHandler(logf,'D',1,30) elif os.name == 'posix': handler = logging.handlers.WatchedFileHandler(logf) else: handler = logging.handlers.FileHandler(logf) except Exception, ex: sys.stderr.write("ERROR: couldn't create the logfile directory. Logging to the standard output.\n") handler = logging.StreamHandler(sys.stdout) else: # Normal Handler on standard output handler = logging.StreamHandler(sys.stdout) if isinstance(handler, logging.StreamHandler) and os.isatty(handler.stream.fileno()): formatter = ColoredFormatter(format) else: formatter = DBFormatter(format) handler.setFormatter(formatter) # add the handler to the root logger logger = logging.getLogger() logger.addHandler(handler) logger.setLevel(int(tools.config['log_level'] or '0'))
78000cae6d03c9416daca95f2d18c805dbaaea04 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/78000cae6d03c9416daca95f2d18c805dbaaea04/netsvc.py
except IOError,e:
except IOError:
def notifyChannel(self, name, level, msg): warnings.warn("notifyChannel API shouldn't be used anymore, please use " "the standard `logging` module instead", PendingDeprecationWarning, stacklevel=2) from service.web_services import common
78000cae6d03c9416daca95f2d18c805dbaaea04 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/78000cae6d03c9416daca95f2d18c805dbaaea04/netsvc.py
except:
except Exception:
def notifyChannel(self, name, level, msg): warnings.warn("notifyChannel API shouldn't be used anymore, please use " "the standard `logging` module instead", PendingDeprecationWarning, stacklevel=2) from service.web_services import common
78000cae6d03c9416daca95f2d18c805dbaaea04 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/78000cae6d03c9416daca95f2d18c805dbaaea04/netsvc.py
self.log('params', params)
self.log('params', params, depth=(logger.isEnabledFor(logging.DEBUG_RPC_ANSWER) and 3 or 1))
def dispatch(self, service_name, method, params): try: self.log('service', service_name) self.log('method', method) self.log('params', params) auth = getattr(self, 'auth_provider', None) result = ExportService.getService(service_name).dispatch(method, auth, params) logger = logging.getLogger('result') self.log('result', result, channel=logging.DEBUG_RPC_ANSWER, depth=(logger.isEnabledFor(logging.DEBUG_SQL) and 1 or None)) return result except Exception, e: self.log('exception', tools.exception_to_unicode(e)) tb = getattr(e, 'traceback', sys.exc_info()) tb_s = "".join(traceback.format_exception(*tb)) if tools.config['debug_mode']: import pdb pdb.post_mortem(tb[2]) raise OpenERPDispatcherException(e, tb_s)
78000cae6d03c9416daca95f2d18c805dbaaea04 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/78000cae6d03c9416daca95f2d18c805dbaaea04/netsvc.py
logger = logging.getLogger('result') self.log('result', result, channel=logging.DEBUG_RPC_ANSWER, depth=(logger.isEnabledFor(logging.DEBUG_SQL) and 1 or None))
self.log('result', result, channel=logging.DEBUG_RPC_ANSWER, depth=(logger.isEnabledFor(logging.DEBUG_SQL) and 5 or 3))
def dispatch(self, service_name, method, params): try: self.log('service', service_name) self.log('method', method) self.log('params', params) auth = getattr(self, 'auth_provider', None) result = ExportService.getService(service_name).dispatch(method, auth, params) logger = logging.getLogger('result') self.log('result', result, channel=logging.DEBUG_RPC_ANSWER, depth=(logger.isEnabledFor(logging.DEBUG_SQL) and 1 or None)) return result except Exception, e: self.log('exception', tools.exception_to_unicode(e)) tb = getattr(e, 'traceback', sys.exc_info()) tb_s = "".join(traceback.format_exception(*tb)) if tools.config['debug_mode']: import pdb pdb.post_mortem(tb[2]) raise OpenERPDispatcherException(e, tb_s)
78000cae6d03c9416daca95f2d18c805dbaaea04 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/78000cae6d03c9416daca95f2d18c805dbaaea04/netsvc.py
title = link.renderContents()
title = unicode(link)
def html2plaintext(html, body_id=None, encoding='utf-8'): ## (c) Fry-IT, www.fry-it.com, 2007 ## <[email protected]> ## download here: http://www.peterbe.com/plog/html2plaintext """ from an HTML text, convert the HTML to plain text. If @body_id is provided then this is the tag where the body (not necessarily <body>) starts. """ try: from BeautifulSoup import BeautifulSoup, SoupStrainer, Comment except: return html urls = [] if body_id is not None: strainer = SoupStrainer(id=body_id) else: strainer = SoupStrainer('body') soup = BeautifulSoup(html, parseOnlyThese=strainer, fromEncoding=encoding) for link in soup.findAll('a'): title = link.renderContents() for url in [x[1] for x in link.attrs if x[0]=='href']: urls.append(dict(url=url, tag=str(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
35fb39a353d212b29fbca953832064af202b72f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/35fb39a353d212b29fbca953832064af202b72f4/openerp_mailgate.py
urls.append(dict(url=url, tag=str(link), title=title))
urls.append(dict(url=url, tag=unicode(link), title=title))
def html2plaintext(html, body_id=None, encoding='utf-8'): ## (c) Fry-IT, www.fry-it.com, 2007 ## <[email protected]> ## download here: http://www.peterbe.com/plog/html2plaintext """ from an HTML text, convert the HTML to plain text. If @body_id is provided then this is the tag where the body (not necessarily <body>) starts. """ try: from BeautifulSoup import BeautifulSoup, SoupStrainer, Comment except: return html urls = [] if body_id is not None: strainer = SoupStrainer(id=body_id) else: strainer = SoupStrainer('body') soup = BeautifulSoup(html, parseOnlyThese=strainer, fromEncoding=encoding) for link in soup.findAll('a'): title = link.renderContents() for url in [x[1] for x in link.attrs if x[0]=='href']: urls.append(dict(url=url, tag=str(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
35fb39a353d212b29fbca953832064af202b72f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/35fb39a353d212b29fbca953832064af202b72f4/openerp_mailgate.py
except UnicodeError: pass try: return s.decode('ascii') except UnicodeError: return s
except UnicodeError: pass return s.decode('latin1')
def _to_decode(self, s, charsets): for charset in charsets: if charset: try: return s.decode(charset) except UnicodeError: pass try: return s.decode('ascii') except UnicodeError: return s
35fb39a353d212b29fbca953832064af202b72f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/35fb39a353d212b29fbca953832064af202b72f4/openerp_mailgate.py
obj_payment_order.set_done(cr, uid, context['active_id'], context)
obj_payment_order.set_done(cr, uid, [context['active_id']], context)
def launch_wizard(self, cr, uid, ids, context=None): """ Search for a wizard to launch according to the type. If type is manual. just confirm the order. """ obj_payment_order = self.pool.get('payment.order')
b1c90cee3cfe41e6d71eb25f913e6e66b1646bb0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/b1c90cee3cfe41e6d71eb25f913e6e66b1646bb0/account_payment_pay.py
datetime = datetime.strptime(self.name, DHM_FORMAT) return datetime.strftime(self.lang_obj.date_format+ " " + self.lang_obj.time_format)
return datetime.strptime(self.name, DHM_FORMAT)\ .strftime("%s %s"%(self.lang_obj.date_format, self.lang_obj.time_format))
def __str__(self): if self.val: if getattr(self,'name', None): datetime = datetime.strptime(self.name, DHM_FORMAT) return datetime.strftime(self.lang_obj.date_format+ " " + self.lang_obj.time_format) return self.val
210ac606ae7f6d18cdaa1481c64d189f0ac6983d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/210ac606ae7f6d18cdaa1481c64d189f0ac6983d/report_sxw.py
if not journal_id or not journal_id:
if not partner_id or not journal_id:
def onchange_journal_voucher(self, cr, uid, ids, partner_id=False, journal_id=False, context={}): """price Returns a dict that contains new values and context @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 """ default = { 'value':{}, } if not journal_id or not journal_id: return default partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal')
a37b87e332435b46872c3309cbc6627c04f3d016 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a37b87e332435b46872c3309cbc6627c04f3d016/voucher.py
def onchange_journal_voucher(self, cr, uid, ids, partner_id=False, journal_id=False, context={}): """price Returns a dict that contains new values and context @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 """ default = { 'value':{}, } if not journal_id or not journal_id: return default partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal')
a37b87e332435b46872c3309cbc6627c04f3d016 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/a37b87e332435b46872c3309cbc6627c04f3d016/voucher.py
'description': body_data, 'history_line': [(0, 0, {'description': body_data, 'email': msg['From']})],
'description': body_data,
def msg_update(self, cr, uid, ids, msg, data={}, default_act='pending'): mailgate_obj = self.pool.get('mail.gateway') msg_actions, body_data = mailgate_obj.msg_act_get(msg) data.update({ 'description': body_data, 'history_line': [(0, 0, {'description': body_data, 'email': msg['From']})], }) act = 'case_'+default_act if 'state' in msg_actions: if msg_actions['state'] in ['draft','close','cancel','open','pending']: act = 'case_' + msg_actions['state'] for k1,k2 in [('cost','planned_cost'),('revenue','planned_revenue'),('probability','probability')]: try: data[k2] = float(msg_actions[k1]) except: pass
767e644fafc9d61adf9fd5e1116f85f336f2f532 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/767e644fafc9d61adf9fd5e1116f85f336f2f532/crm_mailgate.py
res = self.write(cr, uid, ids, data)
res = self.write(cr, uid, ids, data) cases = self.browse(cr, uid, [res]) self.__history(cr, uid, cases, _('Receive'), history=True, email=msg['From'])
def msg_update(self, cr, uid, ids, msg, data={}, default_act='pending'): mailgate_obj = self.pool.get('mail.gateway') msg_actions, body_data = mailgate_obj.msg_act_get(msg) data.update({ 'description': body_data, 'history_line': [(0, 0, {'description': body_data, 'email': msg['From']})], }) act = 'case_'+default_act if 'state' in msg_actions: if msg_actions['state'] in ['draft','close','cancel','open','pending']: act = 'case_' + msg_actions['state'] for k1,k2 in [('cost','planned_cost'),('revenue','planned_revenue'),('probability','probability')]: try: data[k2] = float(msg_actions[k1]) except: pass
767e644fafc9d61adf9fd5e1116f85f336f2f532 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/767e644fafc9d61adf9fd5e1116f85f336f2f532/crm_mailgate.py
cr.execute('SELECT p.id FROM account_fiscalyear AS f \ LEFT JOIN account_period AS p on p.fiscalyear_id=f.id \ WHERE p.id IN \ (SELECT id FROM account_period \ WHERE p.fiscalyear_id = f.id \ AND p.date_start IN \ (SELECT max(date_start) from account_period WHERE p.fiscalyear_id = f.id)\ OR p.date_stop IN \ (SELECT min(date_stop) from account_period WHERE p.fiscalyear_id = f.id)) \ AND f.id = ' + str(fiscalyear_id) + ' order by p.date_start')
cr.execute(''' SELECT * FROM (SELECT p.id FROM account_period p LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id) WHERE f.id = %s ORDER BY p.date_start ASC LIMIT 1) AS period_start UNION SELECT * FROM (SELECT p.id FROM account_period p LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id) WHERE f.id = %s AND p.date_start < NOW() ORDER BY p.date_stop DESC LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id))
def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None): res = {} if filter == 'filter_no': res['value'] = {'period_from': False, 'period_to': False, 'date_from': False ,'date_to': False} if filter == 'filter_date': res['value'] = {'period_from': False, 'period_to': False, 'date_from': time.strftime('%Y-01-01'), 'date_to': time.strftime('%Y-%m-%d')} if filter == 'filter_period' and fiscalyear_id: start_period = end_period = False cr.execute('SELECT p.id FROM account_fiscalyear AS f \ LEFT JOIN account_period AS p on p.fiscalyear_id=f.id \ WHERE p.id IN \ (SELECT id FROM account_period \ WHERE p.fiscalyear_id = f.id \ AND p.date_start IN \ (SELECT max(date_start) from account_period WHERE p.fiscalyear_id = f.id)\ OR p.date_stop IN \ (SELECT min(date_stop) from account_period WHERE p.fiscalyear_id = f.id)) \ AND f.id = ' + str(fiscalyear_id) + ' order by p.date_start') periods = [i[0] for i in cr.fetchall()] if periods: start_period = periods[0] end_period = periods[1] res['value'] = {'period_from': start_period, 'period_to': end_period, 'date_from': False, 'date_to': False} return res
3006c346e94e86534532236b79ee1f824b3101bf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3006c346e94e86534532236b79ee1f824b3101bf/account_report_common.py
if periods:
if periods and len(periods) > 1:
def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None): res = {} if filter == 'filter_no': res['value'] = {'period_from': False, 'period_to': False, 'date_from': False ,'date_to': False} if filter == 'filter_date': res['value'] = {'period_from': False, 'period_to': False, 'date_from': time.strftime('%Y-01-01'), 'date_to': time.strftime('%Y-%m-%d')} if filter == 'filter_period' and fiscalyear_id: start_period = end_period = False cr.execute('SELECT p.id FROM account_fiscalyear AS f \ LEFT JOIN account_period AS p on p.fiscalyear_id=f.id \ WHERE p.id IN \ (SELECT id FROM account_period \ WHERE p.fiscalyear_id = f.id \ AND p.date_start IN \ (SELECT max(date_start) from account_period WHERE p.fiscalyear_id = f.id)\ OR p.date_stop IN \ (SELECT min(date_stop) from account_period WHERE p.fiscalyear_id = f.id)) \ AND f.id = ' + str(fiscalyear_id) + ' order by p.date_start') periods = [i[0] for i in cr.fetchall()] if periods: start_period = periods[0] end_period = periods[1] res['value'] = {'period_from': start_period, 'period_to': end_period, 'date_from': False, 'date_to': False} return res
3006c346e94e86534532236b79ee1f824b3101bf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/3006c346e94e86534532236b79ee1f824b3101bf/account_report_common.py
def onchange_company_id(self, cr, uid, ids, company_id, context=None):
def onchange_company_id(self, cr, uid, ids, company_id=False, context=None):
def onchange_company_id(self, cr, uid, ids, company_id, context=None): res = {} if context is None: context = {} if company_id: company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) res.update({'bank': company.partner_id.bank_ids[0].bank.name}) return { 'value':res }
2c9f004a195c873133d9ca6c2240cb34b756cbaf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2c9f004a195c873133d9ca6c2240cb34b756cbaf/hr_payroll.py
res.update({'bank': company.partner_id.bank_ids[0].bank.name})
if company.partner_id.bank_ids: res.update({'bank': company.partner_id.bank_ids[0].bank.name})
def onchange_company_id(self, cr, uid, ids, company_id, context=None): res = {} if context is None: context = {} if company_id: company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) res.update({'bank': company.partner_id.bank_ids[0].bank.name}) return { 'value':res }
2c9f004a195c873133d9ca6c2240cb34b756cbaf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/2c9f004a195c873133d9ca6c2240cb34b756cbaf/hr_payroll.py
(ca_obj.campaign_id.fixed_cost / len(wi_ids))
((ca_obj.campaign_id.fixed_cost or 0.00) / len(wi_ids))
def _total_cost(self, cr, uid, ids, field_name, arg, context={}): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case and section Data’s IDs @param context: A standard dictionary for contextual values """ result = {} for ca_obj in self.browse(cr, uid, ids, context): wi_ids = self.pool.get('marketing.campaign.workitem').search(cr, uid, [('segment_id.campaign_id', '=', ca_obj.campaign_id.id)]) total_cost = ca_obj.activity_id.variable_cost + \ (ca_obj.campaign_id.fixed_cost / len(wi_ids)) result[ca_obj.id] = total_cost return result
c10fb7f664e9ddc117b788377d98bb2140afbfc8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c10fb7f664e9ddc117b788377d98bb2140afbfc8/campaign_analysis.py
if current.child_id: sums[current.id][fn] += sum(sums[child.id][fn] for child in current.child_id)
for child in current.child_id: if child.company_id.currency_id.id == current.company_id.currency_id.id: sums[current.id][fn] += sums[child.id][fn] else: sums[current.id][fn] += currency_obj.compute(cr, uid, child.company_id.currency_id.id, current.company_id.currency_id.id, sums[child.id][fn], context=context)
def __compute(self, cr, uid, ids, field_names, arg=None, context=None, query='', query_params=()): """ compute the balance, debit and/or credit for the provided account ids Arguments: `ids`: account ids `field_names`: the fields to compute (a list of any of 'balance', 'debit' and 'credit') `arg`: unused fields.function stuff `query`: additional query filter (as a string) `query_params`: parameters for the provided query string (__compute will handle their escaping) as a tuple """ mapping = { 'balance': "COALESCE(SUM(l.debit),0) " \ "- COALESCE(SUM(l.credit), 0) as balance", 'debit': "COALESCE(SUM(l.debit), 0) as debit", 'credit': "COALESCE(SUM(l.credit), 0) as credit" } #get all the necessary accounts children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context) #compute for each account the balance/debit/credit from the move lines accounts = {} if children_and_consolidated: aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
c279d8bbffd2a51bc77b439a834635e3815dcf91 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/c279d8bbffd2a51bc77b439a834635e3815dcf91/account.py
query = "l.date >= '%s' AND l.date <= '%s'" (st_date, end_date)
query = "l.date >= '%s' AND l.date <= '%s'" % (st_date, end_date)
def compute_total(self, cr, uid, ids, yr_st_date, yr_end_date, st_date, end_date, field_names, context={}): if not (st_date >= yr_st_date and end_date <= yr_end_date): return {} query = "l.date >= '%s' AND l.date <= '%s'" (st_date, end_date) return self.__compute(cr, uid, ids, field_names, context=context, query=query)
7551d6420b96fe60c7a3f17165278d10ab191fe0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/7551d6420b96fe60c7a3f17165278d10ab191fe0/account.py
self.load_lang(cr, uid, tools.config.get('lang'))
avil_ids = self.search(cr, uid, [('code','=', tools.config.get('lang'))]) if not avil_ids: self.load_lang(cr, uid, tools.config.get('lang'))
def install_lang(self, cr, uid, **args): self.load_lang(cr, uid, tools.config.get('lang')) return True
75bb78d293e90e4995107357e5422c8ee642daee /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/75bb78d293e90e4995107357e5422c8ee642daee/res_lang.py
def copy(self, cr, uid, id, default=None,context={}): raise osv.except_osv(_('Warning !'),_('You cannot duplicate the resource!'))
def copy(self, cr, uid, ids, default=None, context={}): vals = {} current_rec = self.read(cr, uid, ids, context=context) title = current_rec.get('title') + ' (Copy)' vals.update({'title':title}) return super(survey, self).copy(cr, uid, ids, vals, context=context)
def survey_cancel(self, cr, uid, ids, arg): self.write(cr, uid, ids, {'state': 'cancel' }) return True
aa6e62b7df1ada29812cf9e5603d20fe516b8034 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/aa6e62b7df1ada29812cf9e5603d20fe516b8034/survey.py
def copy(self, cr, uid, id, default=None, context={}): raise osv.except_osv(_('Warning !'),_('You cannot duplicate the resource!'))
def copy(self, cr, uid, ids, default=None, context={}): vals = {} current_rec = self.read(cr, uid, ids, context=context) title = current_rec.get('title') + ' (Copy)' vals.update({'title':title}) return super(survey_page, self).copy(cr, uid, ids, vals, context=context)
def copy(self, cr, uid, id, default=None, context={}): raise osv.except_osv(_('Warning !'),_('You cannot duplicate the resource!'))
aa6e62b7df1ada29812cf9e5603d20fe516b8034 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/aa6e62b7df1ada29812cf9e5603d20fe516b8034/survey.py
def set_context(self, objects, data, ids, report_type=None): super(pos_invoice, self).set_context(objects, data, ids, report_type)
def set_context(self, order, data, ids, report_type=None): super(pos_invoice, self).set_context(order, data, ids, report_type)
def set_context(self, objects, data, ids, report_type=None): super(pos_invoice, self).set_context(objects, data, ids, report_type) iids = [] nids = []
1f5c37ee327989ca148f5c870f8551048eaa8698 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1f5c37ee327989ca148f5c870f8551048eaa8698/pos_invoice.py
for order in objects: order.write({'nb_print': order.nb_print + 1})
def set_context(self, objects, data, ids, report_type=None): super(pos_invoice, self).set_context(objects, data, ids, report_type) iids = [] nids = []
1f5c37ee327989ca148f5c870f8551048eaa8698 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1f5c37ee327989ca148f5c870f8551048eaa8698/pos_invoice.py
if order.invoice_id and order.invoice_id not in iids: if not order.invoice_id: raise osv.except_osv(_('Error !'), _('Please create an invoice for this sale.')) iids.append(order.invoice_id) nids.append(order.invoice_id.id)
order.write({'nb_print': order.nb_print + 1}) if order.invoice_id and order.invoice_id not in iids: if not order.invoice_id: raise osv.except_osv(_('Error !'), _('Please create an invoice for this sale.')) iids.append(order.invoice_id) nids.append(order.invoice_id.id)
def set_context(self, objects, data, ids, report_type=None): super(pos_invoice, self).set_context(objects, data, ids, report_type) iids = [] nids = []
1f5c37ee327989ca148f5c870f8551048eaa8698 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/1f5c37ee327989ca148f5c870f8551048eaa8698/pos_invoice.py
'company_id' : fields.many2one('res.company', 'Company', required=True),
'company_id' : fields.many2one('res.company', 'Company', required=False),
def interval_get(self, cr, uid, id, dt_from, hours, resource=False, byday=True): resource_cal_leaves = self.pool.get('resource.calendar.leaves') dt_leave = [] if not id: return [(dt_from,dt_from + mx.DateTime.RelativeDateTime(hours=int(hours)*3))] resource_leave_ids = resource_cal_leaves.search(cr, uid, [('calendar_id','=',id), '|', ('resource_id','=',False), ('resource_id','=',resource)]) res_leaves = resource_cal_leaves.read(cr, uid, resource_leave_ids, ['date_from', 'date_to']) for leave in res_leaves: dtf = mx.DateTime.strptime(leave['date_from'], '%Y-%m-%d %H:%M:%S') dtt = mx.DateTime.strptime(leave['date_to'], '%Y-%m-%d %H:%M:%S') no = dtt - dtf [dt_leave.append((dtf + mx.DateTime.RelativeDateTime(days=x)).strftime('%Y-%m-%d')) for x in range(int(no.days + 1))] dt_leave.sort() todo = hours cycle = 0 result = [] maxrecur = 100 current_hour = dt_from.hour while (todo>0) and maxrecur: cr.execute("select hour_from,hour_to from resource_calendar_week where dayofweek='%s' and calendar_id=%s order by hour_from", (dt_from.day_of_week,id)) for (hour_from,hour_to) in cr.fetchall(): leave_flag = False if (hour_to>current_hour) and (todo>0): m = max(hour_from, current_hour) if (hour_to-m)>todo: hour_to = m+todo dt_check = dt_from.strftime('%Y-%m-%d') for leave in dt_leave: if dt_check == leave: dt_check = mx.DateTime.strptime(dt_check, "%Y-%m-%d") + mx.DateTime.RelativeDateTime(days=1) leave_flag = True if leave_flag: break else: d1 = mx.DateTime.DateTime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(m)), int((m%1) * 60)) d2 = mx.DateTime.DateTime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(hour_to)), int((hour_to%1) * 60)) result.append((d1, d2)) current_hour = hour_to todo -= (hour_to - m) dt_from += mx.DateTime.RelativeDateTime(days=1) current_hour = 0 maxrecur -= 1 return result
92a2f3c0a780b1cdc9b79483106d4da0d3186fdf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/92a2f3c0a780b1cdc9b79483106d4da0d3186fdf/resource.py
if basic_alarm and meeting.state in ('open'):
if basic_alarm:
def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] for meeting in self.browse(cr, uid, ids): self.do_alarm_unlink(cr, uid, [meeting.id]) basic_alarm = meeting.alarm_id if basic_alarm and meeting.state in ('open'): vals = { 'action': 'display', 'description': meeting.description, 'name': meeting.name, 'attendee_ids': [(6,0, map(lambda x:x.id, meeting.attendee_ids))], 'trigger_related': basic_alarm.trigger_related, 'trigger_duration': basic_alarm.trigger_duration, 'trigger_occurs': basic_alarm.trigger_occurs, 'trigger_interval': basic_alarm.trigger_interval, 'duration': basic_alarm.duration, 'repeat': basic_alarm.repeat, 'state' : 'run', 'event_date' : meeting.date, 'res_id' : meeting.id, 'model_id' : model_id, 'user_id' : uid } alarm_id = alarm_obj.create(cr, uid, vals) cr.execute('Update crm_meeting set caldav_alarm_id=%s where id=%s' % (alarm_id, meeting.id)) cr.commit() return True
596b4dfea94baa2cc5eda9f15b51a495a8adb2e9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/596b4dfea94baa2cc5eda9f15b51a495a8adb2e9/crm_meeting.py
def import_cal(self, cr, uid, data, context={}): file_content = base64.decodestring(data) event_obj = self.pool.get('basic.calendar.event') event_obj.__attribute__.update(self.__attribute__)
596b4dfea94baa2cc5eda9f15b51a495a8adb2e9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/596b4dfea94baa2cc5eda9f15b51a495a8adb2e9/crm_meeting.py
val['alarm_id'] = self.browse(cr, uid, is_exists).caldav_alarm_id.alarm_id.id
cal_alarm = self.browse(cr, uid, is_exists).caldav_alarm_id val['alarm_id'] = cal_alarm.alarm_id and cal_alarm.alarm_id.id or False
def import_cal(self, cr, uid, data, context={}): file_content = base64.decodestring(data) event_obj = self.pool.get('basic.calendar.event') event_obj.__attribute__.update(self.__attribute__)
596b4dfea94baa2cc5eda9f15b51a495a8adb2e9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/596b4dfea94baa2cc5eda9f15b51a495a8adb2e9/crm_meeting.py
if caldav_alarm_id: alarm_id = self.browse(cr, uid, is_exists).caldav_alarm_id.alarm_id self.write(cr, uid, case_id, {'alarm_id': alarm_id})
if val['caldav_alarm_id']: cal_alarm = self.browse(cr, uid, case_id).caldav_alarm_id alarm_id = cal_alarm.alarm_id and cal_alarm.alarm_id.id or False self.write(cr, uid, [case_id], {'alarm_id': alarm_id})
def import_cal(self, cr, uid, data, context={}): file_content = base64.decodestring(data) event_obj = self.pool.get('basic.calendar.event') event_obj.__attribute__.update(self.__attribute__)
596b4dfea94baa2cc5eda9f15b51a495a8adb2e9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/596b4dfea94baa2cc5eda9f15b51a495a8adb2e9/crm_meeting.py
return b
return b
def _coerce_bool(self, value, default=False): if isinstance(value, types.BooleanType): b = value if isinstance(value, types.StringTypes): b = value.strip().lower() not in ('0', 'false', 'off', 'no') elif isinstance(value, types.IntType): b = bool(value) else: b = default return b
e05850f9e1a2a186155d8016b54b4394e5897dad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e05850f9e1a2a186155d8016b54b4394e5897dad/yaml_import.py
def create_osv_memory_record(self, record, fields): model = self.get_model(record.model) record_dict = self._create_record(model, fields) id_new=model.create(self.cr, self.uid, record_dict, context=self.context) self.id_map[record.id] = int(id_new) return record_dict
e05850f9e1a2a186155d8016b54b4394e5897dad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e05850f9e1a2a186155d8016b54b4394e5897dad/yaml_import.py
model_bases = model.__class__.__bases__ if osv.osv.osv_memory in model_bases:
if isinstance(model, osv.osv.osv_memory):
def process_record(self, node): import osv record, fields = node.items()[0] model = self.get_model(record.model) model_bases = model.__class__.__bases__ if osv.osv.osv_memory in model_bases: record_dict=self.create_osv_memory_record(record, fields) else: self.validate_xml_id(record.id) if self.isnoupdate(record) and self.mode != 'init': id = self.pool.get('ir.model.data')._update_dummy(self.cr, self.uid, record.model, self.module, record.id) # check if the resource already existed at the last update if id: self.id_map[record] = int(id) return None else: if not self._coerce_bool(record.forcecreate): return None model = self.get_model(record.model) record_dict = self._create_record(model, fields) self.logger.debug("RECORD_DICT %s" % record_dict) if not osv.osv.osv_memory in model_bases: id = self.pool.get('ir.model.data')._update(self.cr, self.uid, record.model, \ self.module, record_dict, record.id, noupdate=self.isnoupdate(record), mode=self.mode) self.id_map[record.id] = int(id) if config.get('import_partial', False): self.cr.commit()
e05850f9e1a2a186155d8016b54b4394e5897dad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e05850f9e1a2a186155d8016b54b4394e5897dad/yaml_import.py
model = self.get_model(record.model)
def process_record(self, node): import osv record, fields = node.items()[0] model = self.get_model(record.model) model_bases = model.__class__.__bases__ if osv.osv.osv_memory in model_bases: record_dict=self.create_osv_memory_record(record, fields) else: self.validate_xml_id(record.id) if self.isnoupdate(record) and self.mode != 'init': id = self.pool.get('ir.model.data')._update_dummy(self.cr, self.uid, record.model, self.module, record.id) # check if the resource already existed at the last update if id: self.id_map[record] = int(id) return None else: if not self._coerce_bool(record.forcecreate): return None model = self.get_model(record.model) record_dict = self._create_record(model, fields) self.logger.debug("RECORD_DICT %s" % record_dict) if not osv.osv.osv_memory in model_bases: id = self.pool.get('ir.model.data')._update(self.cr, self.uid, record.model, \ self.module, record_dict, record.id, noupdate=self.isnoupdate(record), mode=self.mode) self.id_map[record.id] = int(id) if config.get('import_partial', False): self.cr.commit()
e05850f9e1a2a186155d8016b54b4394e5897dad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e05850f9e1a2a186155d8016b54b4394e5897dad/yaml_import.py
if not osv.osv.osv_memory in model_bases: id = self.pool.get('ir.model.data')._update(self.cr, self.uid, record.model, \ self.module, record_dict, record.id, noupdate=self.isnoupdate(record), mode=self.mode) self.id_map[record.id] = int(id) if config.get('import_partial', False): self.cr.commit()
id = self.pool.get('ir.model.data')._update(self.cr, self.uid, record.model, \ self.module, record_dict, record.id, noupdate=self.isnoupdate(record), mode=self.mode) self.id_map[record.id] = int(id) if config.get('import_partial'): self.cr.commit()
def process_record(self, node): import osv record, fields = node.items()[0] model = self.get_model(record.model) model_bases = model.__class__.__bases__ if osv.osv.osv_memory in model_bases: record_dict=self.create_osv_memory_record(record, fields) else: self.validate_xml_id(record.id) if self.isnoupdate(record) and self.mode != 'init': id = self.pool.get('ir.model.data')._update_dummy(self.cr, self.uid, record.model, self.module, record.id) # check if the resource already existed at the last update if id: self.id_map[record] = int(id) return None else: if not self._coerce_bool(record.forcecreate): return None model = self.get_model(record.model) record_dict = self._create_record(model, fields) self.logger.debug("RECORD_DICT %s" % record_dict) if not osv.osv.osv_memory in model_bases: id = self.pool.get('ir.model.data')._update(self.cr, self.uid, record.model, \ self.module, record_dict, record.id, noupdate=self.isnoupdate(record), mode=self.mode) self.id_map[record.id] = int(id) if config.get('import_partial', False): self.cr.commit()
e05850f9e1a2a186155d8016b54b4394e5897dad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e05850f9e1a2a186155d8016b54b4394e5897dad/yaml_import.py
return record_dict
return record_dict
def _create_record(self, model, fields): record_dict = {} for field_name, expression in fields.items(): field_value = self._eval_field(model, field_name, expression) record_dict[field_name] = field_value return record_dict
e05850f9e1a2a186155d8016b54b4394e5897dad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e05850f9e1a2a186155d8016b54b4394e5897dad/yaml_import.py
def process_ref(self, node, column=None): if node.search: if node.model: model_name = node.model elif column: model_name = column._obj else: raise YamlImportException('You need to give a model for the search, or a column to infer it.') model = self.get_model(model_name) q = eval(node.search, self.eval_context) ids = model.search(self.cr, self.uid, q) if node.use: instances = model.browse(self.cr, self.uid, ids) value = [inst[node.use] for inst in instances] else: value = ids elif node.id: value = self.get_id(node.id) else: value = None return value
e05850f9e1a2a186155d8016b54b4394e5897dad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e05850f9e1a2a186155d8016b54b4394e5897dad/yaml_import.py
def process_eval(self, node): return eval(node.expression, self.eval_context)
e05850f9e1a2a186155d8016b54b4394e5897dad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/e05850f9e1a2a186155d8016b54b4394e5897dad/yaml_import.py
def setActive(self, cr, uid, ids, value=True, context=None): task_obj = self.pool.get('project.task') for proj in self.browse(cr, uid, ids, context=None): self.write(cr, uid, [proj.id], {'state': value and 'open' or 'template'}, context) cr.execute('select id from project_task where project_id=%s', (proj.id,)) tasks_id = [x[0] for x in cr.fetchall()] if tasks_id: task_obj.write(cr, uid, tasks_id, {'active': value}, context=context) child_ids = self.search(cr, uid, [('parent_id','=', proj.analytic_account_id.id)]) if child_ids: self.setActive(cr, uid, child_ids, value, context=None) return True
bef2f4f82ade6a7713ab90d89d69452676757db3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bef2f4f82ade6a7713ab90d89d69452676757db3/project.py
id = isinstance(domain[2], list) and int(domain[2][0]) or int(domain[2]) if id: if self.pool.get('project.project').read(cr, user, id, ['state'])['state'] == 'template': args.append(['active', '=', False])
id = isinstance(domain[2], list) and domain[2][0] or domain[2] if id and isinstance(id, (long, int)): if obj_project.read(cr, user, id, ['state'])['state'] == 'template': args.append(('active', '=', False))
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): for domain in args: if domain[0] == 'project_id' and (not isinstance(domain[2], str)): id = isinstance(domain[2], list) and int(domain[2][0]) or int(domain[2]) if id: if self.pool.get('project.project').read(cr, user, id, ['state'])['state'] == 'template': args.append(['active', '=', False]) return super(task, self).search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
bef2f4f82ade6a7713ab90d89d69452676757db3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bef2f4f82ade6a7713ab90d89d69452676757db3/project.py
def _str_get(self, task, level=0, border='***', context=None): return border+' '+(task.user_id and task.user_id.name.upper() or '')+(level and (': L'+str(level)) or '')+(' - %.1fh / %.1fh'%(task.effective_hours or 0.0,task.planned_hours))+' '+border+'\n'+ \ border[0]+' '+(task.name or '')+'\n'+ \ (task.description or '')+'\n\n'
bef2f4f82ade6a7713ab90d89d69452676757db3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bef2f4f82ade6a7713ab90d89d69452676757db3/project.py
def _hours_get(self, cr, uid, ids, field_names, args, context=None): project_obj = self.pool.get('project.project') res = {} cr.execute("SELECT task_id, COALESCE(SUM(hours),0) FROM project_task_work WHERE task_id IN %s GROUP BY task_id",(tuple(ids),)) hours = dict(cr.fetchall()) uom_obj = self.pool.get('product.uom') user_uom, default_uom = project_obj._get_user_and_default_uom_ids(cr, uid) if user_uom != default_uom: for task in self.browse(cr, uid, ids, context=context): if hours.get(task.id, False): dur_in_user_uom = uom_obj._compute_qty(cr, uid, default_uom, hours.get(task.id, 0.0), user_uom) hours[task.id] = dur_in_user_uom for task in self.browse(cr, uid, ids, context=context): res[task.id] = {'effective_hours': hours.get(task.id, 0.0), 'total_hours': task.remaining_hours + hours.get(task.id, 0.0)} res[task.id]['delay_hours'] = res[task.id]['total_hours'] - task.planned_hours res[task.id]['progress'] = 0.0 if (task.remaining_hours + hours.get(task.id, 0.0)): res[task.id]['progress'] = round(min(100.0 * hours.get(task.id, 0.0) / res[task.id]['total_hours'], 99.99),2) if task.state in ('done','cancelled'): res[task.id]['progress'] = 100.0 return res
bef2f4f82ade6a7713ab90d89d69452676757db3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/bef2f4f82ade6a7713ab90d89d69452676757db3/project.py
pick_name=self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out')
def create_picking(self, cr, uid, ids, context={}): """Create a picking for each order and validate it.""" picking_obj = self.pool.get('stock.picking')
ccd6981b369e60c554a63a80cd399043f722c296 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/ccd6981b369e60c554a63a80cd399043f722c296/pos.py
'name': fields.char('Last Name', size=30, required=True), 'first_name': fields.char('First Name', size=30), 'mobile': fields.char('Mobile', size=30),
'name': fields.char('Last Name', size=64, required=True), 'first_name': fields.char('First Name', size=64), 'mobile': fields.char('Mobile', size=64),
def _main_job(self, cr, uid, ids, fields, arg, context=None): """ @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 partner contact’s IDs @fields: Get Fields @param context: A standard dictionary for contextual values @param arg: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. """
06145300d218a1f996c3f68da488c8074b672c49 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/06145300d218a1f996c3f68da488c8074b672c49/base_contact.py
'function': fields.char('Partner Function', size=34, help="Function of this contact with this partner"),
'function': fields.char('Partner Function', size=64, help="Function of this contact with this partner"),
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ search parnter job @param self: The object pointer @param cr: the current row, from the database cursor, @param user: the current user @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. @param offset: The Number of Results to Pass @param limit: The Number of Results to Return @param context: A standard dictionary for contextual values """
06145300d218a1f996c3f68da488c8074b672c49 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/06145300d218a1f996c3f68da488c8074b672c49/base_contact.py
price_type.field, context=context)[prod_id], round=False, context=context)
price_type.field)[prod_id], round=False, context=context)
def price_get(self, cr, uid, ids, prod_id, qty, partner=None, context=None): ''' context = { 'uom': Unit of Measure (int), 'partner': Partner ID (int), 'date': Date of the pricelist (%Y-%m-%d), } ''' context = context or {} currency_obj = self.pool.get('res.currency') product_obj = self.pool.get('product.product') supplierinfo_obj = self.pool.get('product.supplierinfo') price_type_obj = self.pool.get('product.price.type')
656b1dd1be8900b7292955e1182158ad1a98dc74 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/656b1dd1be8900b7292955e1182158ad1a98dc74/pricelist.py
self.log.debug('get_objects() model_list: %s', ','.join(model_list))
self.log.debug('get_objects() model_list: %s', ','.join(map(str, model_list)))
def get_objects(self, cr, uid, module): # This function returns all object of the given module.. pool = pooler.get_pool(cr.dbname) ids2 = pool.get('ir.model.data').search(cr, uid, [('module', '=', module), ('model', '=', 'ir.model')]) model_list = [] model_data = pool.get('ir.model.data').browse(cr, uid, ids2) for model in model_data: model_list.append(model.res_id) self.log.debug('get_objects() model_list: %s', ','.join(model_list)) obj_list = [] for mod in pool.get('ir.model').browse(cr, uid, model_list): obj_list.append(str(mod.model)) self.log.debug('get_objects() obj_list: %s', ','.join(obj_list)) return obj_list
0dd8aee3e472d7d286e1facb0f677a9e3abf7ba8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0dd8aee3e472d7d286e1facb0f677a9e3abf7ba8/base_module_quality.py
def check_quality(self, cr, uid, module_name, module_state=None): ''' This function will calculate score of openerp module It will return data in below format: Format: {'final_score':'80.50', 'name': 'sale', 'check_detail_ids': [(0,0,{'name':'workflow_test', 'score':'100', 'ponderation':'0', 'summary': text_wiki format data, 'detail': html format data, 'state':'done', 'note':'XXXX'}), ((0,0,{'name':'terp_test', 'score':'60', 'ponderation':'1', 'summary': text_wiki format data, 'detail': html format data, 'state':'done', 'note':'terp desctioption'}), ..........]} So here the detail result is in html format and summary will be in text_wiki format. ''' pool = pooler.get_pool(cr.dbname) obj_module = pool.get('ir.module.module') if not module_state: module_id = obj_module.search(cr, uid, [('name', '=', module_name)]) if module_id: module_state = obj_module.browse(cr, uid, module_id[0]).state
0dd8aee3e472d7d286e1facb0f677a9e3abf7ba8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/0dd8aee3e472d7d286e1facb0f677a9e3abf7ba8/base_module_quality.py
where.append('(user_id=%s or (user_id IS NULL))')
where.append('(user_id=%s or (user_id IS NULL)) order by id')
def get(self, cr, uid, key, key2, models, meta=False, context={}, res_id_req=False, without_user=True, key2_req=True): result = [] for m in models: if type(m)==type([]) or type(m)==type(()): m,res_id = m else: res_id=False
683fbd05a71d8d3faeab54f1aab52e62346a47af /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/683fbd05a71d8d3faeab54f1aab52e62346a47af/ir_values.py
def create_shortcut(self, cr, uid, values, context={}):
def create_shortcut(self, cr, uid, values, context=None):
def create_shortcut(self, cr, uid, values, context={}): dataobj = self.pool.get('ir.model.data') new_context = context.copy() for key in context: if key.startswith('default_'): del new_context[key]
49dc2ec5ecb630eb60b8d7191273f64837f8e104 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/49dc2ec5ecb630eb60b8d7191273f64837f8e104/ir_ui_menu.py
'icon' : lambda *a: 'STOCK_OPEN', 'icon_pict': lambda *a: ('stock', ('STOCK_OPEN','ICON_SIZE_MENU')), 'sequence' : lambda *a: 10,
'icon' : 'STOCK_OPEN', 'icon_pict': ('stock', ('STOCK_OPEN','ICON_SIZE_MENU')), 'sequence' : 10,
def _rec_message(self, cr, uid, ids, context=None): return _('Error ! You can not create recursive Menu.')
49dc2ec5ecb630eb60b8d7191273f64837f8e104 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7397/49dc2ec5ecb630eb60b8d7191273f64837f8e104/ir_ui_menu.py