示例#1
0
def impl(ctx, word1, word2, word3, model_name, domain):
    # n is counted as word there for the english grammar, but not used
    # words can be 'possibly' of 'possibly inactive'
    active_text = ' '.join(w for w in (word1, word2, word3) if w and w != 'n')
    assert active_text in ('', 'inactive', 'active', 'possibly inactive')
    Model = model(model_name)
    ctx.search_model_name = model_name
    oe_context = getattr(ctx, 'oe_context', None)
    values = parse_domain(domain)
    active = True
    if active_text == 'inactive':
        active = False
    elif active_text == 'possibly inactive':
        active = None
    domain = build_search_domain(ctx, model_name, values, active=active)

    if domain is None:
        ctx.found_item = None
        ctx.found_items = erppeek.RecordList(Model, [])
    else:
        ctx.found_items = Model.browse(domain, context=oe_context)
        if len(ctx.found_items) == 1:
            ctx.found_item = ctx.found_items[0]
        else:
            ctx.found_item = None
示例#2
0
def impl(ctx, word1, word2, word3, model_name, domain):
    # n is counted as word there for the english grammar, but not used
    # words can be 'possibly' of 'possibly inactive'
    active_text = ' '.join(w for w in (word1, word2, word3) if w and w != 'n')
    assert active_text in ('', 'inactive', 'active', 'possibly inactive')
    Model = model(model_name)
    ctx.search_model_name = model_name
    oe_context = getattr(ctx, 'oe_context', None)
    values = parse_domain(domain)
    active = True
    if active_text == 'inactive':
        active = False
    elif active_text == 'possibly inactive':
        active = None
    domain = build_search_domain(ctx, model_name, values, active=active)

    if domain is None:
        ctx.found_item = None
        ctx.found_items = erppeek.RecordList(Model, [])
    else:
        ctx.found_items = Model.browse(domain, context=oe_context)
        if len(ctx.found_items) == 1:
            ctx.found_item = ctx.found_items[0]
        else:
            ctx.found_item = None
示例#3
0
def impl(ctx, word1, word2, word3, model_name, domain):
    # n is there for the english grammar, but not used
    active_text = ' '.join(w for w in (word1, word2, word3) if w and w != 'n')
    assert active_text in ('', 'inactive', 'active', 'possibly inactive')
    Model = model(model_name)
    ctx.search_model_name = model_name
    values = parse_domain(domain)
    active = True
    if active_text == 'inactive':
        active = False
    elif active_text == 'possibly inactive':
        active = None
    # if the scenario specifies xmlid + other attributes in an "I
    # need" phrase then we want to look for the entry with the xmlid
    # only, and update the other attributes if we found something
    if 'xmlid' in values:
        domain = build_search_domain(ctx,
                                     model_name, {'xmlid': values['xmlid']},
                                     active=active)
    else:
        domain = build_search_domain(ctx, model_name, values, active=active)
    if domain is not None:
        ids = Model.search(domain)
    else:
        ids = []
    if not ids:  # nothing found
        ctx.found_item = values
        ctx.found_items = [values]
    else:
        if len(ids) == 1:
            ctx.found_item = Model.browse(ids[0])
        else:
            ctx.found_item = None
        ctx.found_items = Model.browse(ids)
        if 'xmlid' in values and len(values) > 1:
            new_attrs = values.copy()
            del new_attrs['xmlid']
            puts('writing %s to %s' % (new_attrs, ids))
            Model.write(ids, new_attrs)
示例#4
0
def impl(ctx, word1, word2, word3, model_name, domain):
    # n is there for the english grammar, but not used
    active_text = ' '.join(w for w in (word1, word2, word3) if w and w != 'n')
    assert active_text in ('', 'inactive', 'active', 'possibly inactive')
    Model = model(model_name)
    ctx.search_model_name = model_name
    values = parse_domain(domain)
    active = True
    if active_text == 'inactive':
        active = False
    elif active_text == 'possibly inactive':
        active = None
    # if the scenario specifies xmlid + other attributes in an "I
    # need" phrase then we want to look for the entry with the xmlid
    # only, and update the other attributes if we found something
    if 'xmlid' in values:
        domain = build_search_domain(ctx, model_name,
                                     {'xmlid': values['xmlid']},
                                     active=active)
    else:
        domain = build_search_domain(ctx, model_name, values, active=active)
    if domain is not None:
        ids = Model.search(domain)
    else:
        ids = []
    if not ids: # nothing found
        ctx.found_item = values
        ctx.found_items = [values]
    else:
        if len(ids) == 1:
            ctx.found_item = Model.browse(ids[0])
        else:
            ctx.found_item = None
        ctx.found_items = Model.browse(ids)
        if 'xmlid' in values and len(values) > 1:
            new_attrs = values.copy()
            del new_attrs['xmlid']
            puts('writing %s to %s' % (new_attrs, ids))
            Model.write(ids, new_attrs)
示例#5
0
def impl(ctx, company_oid):
    c_domain = build_search_domain(ctx, 'res.company', {'xmlid': company_oid})
    company = model('res.company').get(c_domain)
    ctx.company_id = company.id
示例#6
0
def impl(ctx, company_oid):
    c_domain = build_search_domain(ctx, 'res.company', {'xmlid': company_oid})
    company = model('res.company').get(c_domain)
    ctx.company_id = company.id