def map(self, parms): oerp = super(IrProperty, self).getConnection() module_parms = super(IrProperty, self).getWorkingSource(parms) wksht = module_parms["wksht"] numCols = module_parms["numCols"] nameCol = module_parms["nameCol"] print " wkbk -- {}".format(module_parms["wkbk"]) print " wksht -- {}".format(wksht) print " dictRange -- {}".format(module_parms["dictRange"]) print " numCols -- {}".format(numCols) print " nameCol -- {}".format(module_parms["nameCol"]) fields = wksht.row_values(int(parms["titles_row"]))[:numCols:] print " - - - fields - - - " print fields rng = wksht.range(parms["data_range"]) data = self.groupToArray(numCols, [cell.value for cell in rng]) print " - - - data - - - " properties = [] for row in data: print str(row)[:160] company = row[nameCol["company_id"] - 1] map_type = row[nameCol["map_type"] - 1] target_uid = row[nameCol["target_uid"] - 1] target_model = row[nameCol["target_model"] - 1] source_model = row[nameCol["source_model"] - 1] source_field = row[nameCol["source_field"] - 1] aMap = OErpModel.get_mapping_by_property(self, source_model, source_field) fields_id = "{}.{}".format(aMap["module"], aMap["name"]) print fields_id obj_id = OErpModel.get_object_id_by_code(self, target_model, target_uid) value_reference = "{}.{}".format(target_model, obj_id) print "value_reference = {}".format(value_reference) prprty = [source_field, map_type, fields_id, company, value_reference] print prprty properties.append(prprty) titles = ["name", "type", "fields_id/id", "company_id/id", "value_reference"] oerpModel = oerp.get(OPENERP_MODULE_NAME) oerpModel.load(titles, properties) """
def update(self, parms): oerp = super(ResUsers, self).getConnection() # Obtain an array of record ids that match the selection criteria (only # one in this case) idUser = oerp.search( OPENERP_MODULE_NAME, [("login", "=", parms['login'])])[0] # Read the existing data (only what we need) aUser = oerp.browse(OPENERP_MODULE_NAME, idUser) print "Login " + parms['login'] + " -- " + aUser.login # Write it back out with update applied for key in parms: if key not in ignored_fields: # Ignore the record key attribute val = OErpModel.parseSpecial(self, parms[key]) print 'Editing : (User : {}, "{}":"{}") from "{}"'.format( aUser.login, key, val, parms[key]) if key in indirect_fields: ext_ids = parms[key].split(',') aUser.company_ids += list(super(ResUsers, self).get_aliased_records(ext_ids, relations[key])) pass else: setattr(aUser, key, val) oerp.write_record(aUser) print 'Written'
def update(self, parms): oerp = super(IrMailServer, self).getConnection() # Read the existing data (only what we need) idMailServer = oerp.search( OPENERP_MODULE_NAME, [(identifier, 'ilike', parms[identifier])])[0] theMailServer = oerp.browse(OPENERP_MODULE_NAME, idMailServer) print "Mail server named {}".format(theMailServer.name) # Write it back out with update applied for key in parms: if key not in ignored_fields: # Ignore the record key attribute val = OErpModel.parseSpecial(self, parms[key]) print 'Editing : (Mail server : {}, "{}":"{}") from "{}"'.format( parms[identifier], key, val, parms[key]) setattr(theMailServer, key, val) oerp.write_record(theMailServer) print 'Written'
def chkTask(self, parms): print 'Task check . . . ' for key in parms: if key not in ("ResUsers", "login"): print "Key : " + key + " Parm : " print OErpModel.parseSpecial(self, parms[key])