示例#1
0
文件: partners.py 项目: bclune/ringo
 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
示例#2
0
 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
示例#3
0
文件: projects.py 项目: bclune/ringo
 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])
示例#4
0
文件: projects.py 项目: bclune/ringo
 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])
示例#5
0
文件: partners.py 项目: bclune/ringo
 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
示例#6
0
文件: partners.py 项目: bclune/ringo
def getCustomerDepositAcctId():
    """ Return the id for the customer deposit account. """
    return searchRecord('account.account', [('code', '=', '21511-02')])[0]
示例#7
0
文件: partners.py 项目: bclune/ringo
def getPaymentCheckId():
    """ Return the id for payment type 'Check'. """
    return searchRecord('lgx.res.paypref', [('name', '=', 'Check')])[0]
示例#8
0
文件: partners.py 项目: bclune/ringo
            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
           

示例#9
0
def getCustomerDepositAcctId():
    """ Return the id for the customer deposit account. """
    return searchRecord('account.account', [('code', '=', '21511-02')])[0]
示例#10
0
def getPaymentCheckId():
    """ Return the id for payment type 'Check'. """
    return searchRecord('lgx.res.paypref', [('name', '=', 'Check')])[0]
示例#11
0
def getPartnerIdForName(name):
    ids = searchRecord('res.partner', [('name', '=', name)])
    return ids[0] if ids else False
示例#12
0
            # 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
示例#13
0
文件: projects.py 项目: bclune/ringo
 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
示例#14
0
文件: clean.py 项目: bclune/ringo
#!/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)
示例#15
0
文件: clean.py 项目: bclune/ringo
#!/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)
示例#16
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
示例#17
0
文件: notes.py 项目: bclune/ringo
def getPartnerIdForName(name):
    ids = searchRecord('res.partner', [('name','=', name)])
    return ids[0] if ids else False
示例#18
0
文件: projects.py 项目: bclune/ringo
 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