def getUserId(name): """ Search for an OpenERP user with the given name and return his or her uid. >>> searchUser('Administrator') [1] >>> searchUser('The Hamburgerlar') """ uid = searchRecord('res.users', [('name','=',name)]) return uid[0] if uid else False
def getUserId(name): """ Search for an OpenERP user with the given name and return his or her uid. >>> searchUser('Administrator') [1] >>> searchUser('The Hamburgerlar') """ uid = searchRecord('res.users', [('name', '=', name)]) return uid[0] if uid else False
def translateStageId(code): """ Translate Status id in CRM to a crm.case.stage id in OpenERP. """ status_codes = { 200000: # Pre Sale searchRecord('crm.case.stage', [('name', '=', 'Pre Sale')]), 200001: # Prototyping searchRecord('crm.case.stage', [('name', '=', 'Prototyping')]), 200005: # Mass Production searchRecord('crm.case.stage', [('name', '=', 'Forecasted')]), 200008: # One Time searchRecord('crm.case.stage', [('name', '=', 'Forecasted')]), 2: # On Hold searchRecord('crm.case.stage', [('name', '=', 'On Hold')]), } return (status_codes.get(code)[0] if status_codes.get(code) else searchRecord('crm.case.stage', [('name', '=', 'New')])[0])
def translateStageId(code): """ Translate Status id in CRM to a crm.case.stage id in OpenERP. """ status_codes = { 200000 : # Pre Sale searchRecord('crm.case.stage', [('name','=','Pre Sale')]), 200001 : # Prototyping searchRecord('crm.case.stage', [('name','=','Prototyping')]), 200005 : # Mass Production searchRecord('crm.case.stage', [('name','=','Forecasted')]), 200008 : # One Time searchRecord('crm.case.stage', [('name','=','Forecasted')]), 2 : # On Hold searchRecord('crm.case.stage', [('name','=','On Hold')]), } return (status_codes.get(code)[0] if status_codes.get(code) else searchRecord('crm.case.stage', [('name','=','New')])[0])
def getStateId(name): """ Return the OpenERP id of the state with the given name. See 'testMemoizedFunctions()' for doctests. """ ids = searchRecord('res.country.state',[('name', '=', name)]) return ids[0] if ids else 0
def getCustomerDepositAcctId(): """ Return the id for the customer deposit account. """ return searchRecord('account.account', [('code', '=', '21511-02')])[0]
def getPaymentCheckId(): """ Return the id for payment type 'Check'. """ return searchRecord('lgx.res.paypref', [('name', '=', 'Check')])[0]
record.update(additional_fields) # Write record to OpenERP writeRecord('res.partner', record) # Add name to the cache to avoid duplicate records seen.add(record['name']) else: skipped += 1 """ total = len(recordsToUpdate) processed = 0 skipped = 0 seen = set() _logger.info("Updating %d records in OpenERP...", len(records)) for record in recordsToUpdate: processed += 1 print "{}Updating {} of {} ({} duplicates)".format("\r", processed, total, skipped), sys.stdout.flush() if record['name'] not in seen: # Add extra fields for OpenERP record.update(additional_fields) # Write record to OpenERP id = searchRecord('res.partner',[('name','=',record['name'])]) updateRecord('res.partner', id, record) # Add name to the cache to avoid duplicate records seen.add(record['name']) else: skipped += 1
def getPartnerIdForName(name): ids = searchRecord('res.partner', [('name', '=', name)]) return ids[0] if ids else False
# Add extra fields for OpenERP record.update(additional_fields) # Write record to OpenERP writeRecord('res.partner', record) # Add name to the cache to avoid duplicate records seen.add(record['name']) else: skipped += 1 """ total = len(recordsToUpdate) processed = 0 skipped = 0 seen = set() _logger.info("Updating %d records in OpenERP...", len(records)) for record in recordsToUpdate: processed += 1 print "{}Updating {} of {} ({} duplicates)".format( "\r", processed, total, skipped), sys.stdout.flush() if record['name'] not in seen: # Add extra fields for OpenERP record.update(additional_fields) # Write record to OpenERP id = searchRecord('res.partner', [('name', '=', record['name'])]) updateRecord('res.partner', id, record) # Add name to the cache to avoid duplicate records seen.add(record['name']) else: skipped += 1
def searchPartner(name): """ Search for an OpenERP partner with the given name and return his or her uid. """ pid = searchRecord('res.partner', [('name','=',name)]) return pid[0] if pid else False
#!/usr/bin/env python import ringo from adapters.openerp import (deleteRecord, searchRecord, readRecord) from xmlrpclib import Fault import logging _logger = logging.getLogger(__name__) if __name__ == "__main__": # Find attached records partnerIdsWithInvoices = readRecord('account.invoice', [], fields='partner_id') # Find all records allIds = searchRecord('res.partner', [('customer','=','True')]) # And destroy the unattached records unattachedIds = [ x for x in allIds if x not in partnerIdsWithInvoices ] for id in unattachedIds: try: deleteRecord('res.partner', id) except Fault: _logger.warn("Error deleting partner with id %s.", id)
#!/usr/bin/env python import ringo from adapters.openerp import (deleteRecord, searchRecord, readRecord) from xmlrpclib import Fault import logging _logger = logging.getLogger(__name__) if __name__ == "__main__": # Find attached records partnerIdsWithInvoices = readRecord('account.invoice', [], fields='partner_id') # Find all records allIds = searchRecord('res.partner', [('customer', '=', 'True')]) # And destroy the unattached records unattachedIds = [x for x in allIds if x not in partnerIdsWithInvoices] for id in unattachedIds: try: deleteRecord('res.partner', id) except Fault: _logger.warn("Error deleting partner with id %s.", id)
def getStateId(name): """ Return the OpenERP id of the state with the given name. See 'testMemoizedFunctions()' for doctests. """ ids = searchRecord('res.country.state', [('name', '=', name)]) return ids[0] if ids else 0
def getPartnerIdForName(name): ids = searchRecord('res.partner', [('name','=', name)]) return ids[0] if ids else False
def searchPartner(name): """ Search for an OpenERP partner with the given name and return his or her uid. """ pid = searchRecord('res.partner', [('name', '=', name)]) return pid[0] if pid else False