当前位置: 首页>>代码示例>>Python>>正文


Python support.model函数代码示例

本文整理汇总了Python中support.model函数的典型用法代码示例。如果您正苦于以下问题:Python model函数的具体用法?Python model怎么用?Python model使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了model函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: search_groups

def search_groups(names):
    """ Search groups by name and full name """
    names = list(set(names))
    group_full_names = [name for name in names if '/' in name]
    group_single_names = [name for name in names if not '/' in name]
    ModuleCategory = model('ir.module.category')
    groups = []
    if group_full_names:
        full_name_cond = []
        for line in group_full_names:
            categ, name = line.split('/', 1)
            categ = categ.strip()
            name = name.strip()
            category_ids = ModuleCategory.search([('name', '=', categ)])
            assert category_ids, 'no category named %s' % categ
            condition = [
                    '&',
                    ('name', '=', name),
                    ('category_id', 'in', category_ids)
                ]
            full_name_cond += condition
        num_operators = len(group_full_names) - 1
        or_operators = ['|'] * num_operators
        search_cond = or_operators + full_name_cond
        groups.extend(model('res.groups').browse(search_cond))
    if group_single_names:
        single_name_cond = [('name', 'in', group_single_names)]
        # Search for single groups
        groups.extend(model('res.groups').browse(single_name_cond))
    return groups
开发者ID:camptocamp,项目名称:oerpscenario,代码行数:30,代码来源:user_config.py

示例2: impl

def impl(ctx, state):
    wiz = model('credit.control.marker').create({'name': state})
    lines = model('credit.control.line').search([('state', '=', 'draft')])
    assert lines
    ctx.lines = lines
    wiz.write({'line_ids': lines})
    wiz.mark_lines()
开发者ID:uynil,项目名称:odoo_accounting_extra,代码行数:7,代码来源:account_credit_control.py

示例3: impl

def impl(ctx, line_number, level, policy_name):
    assert_true(ctx.invoice)
    policy = model('credit.control.policy').get([('name', '=', policy_name)])
    assert_true(policy)
    lines = model('credit.control.line').search([('invoice_id', '=', ctx.invoice.id),
                                                 ('level', '=', level),
                                                 ('policy_id', '=', policy.id)])
    assert_equal(len(lines), line_number)
开发者ID:Asinox,项目名称:marcos_odoo,代码行数:8,代码来源:account_credit_control_changer.py

示例4: tag_user_partners

def tag_user_partners(ctx, xmlid):
    model_name, ids = ctx.loaded_objets
    obj = ref(xmlid)
    if model_name == 'res.users':
        partners = model(model_name).browse(ids).partner_id
    elif model_name == 'res.partner':
        partners = model(model_name).browse(ids)
    partners.write({'category_id': [obj.id]})
开发者ID:camptocamp,项目名称:oerpscenario,代码行数:8,代码来源:tools.py

示例5: impl

def impl(ctx, rate_code, rate_value):
    assert ctx.found_item
    company = ctx.found_item
    currency = model('res.currency').get([('name', '=', rate_code)])
    assert currency
    rate = model('res.currency.rate').get([('currency_id', '=', currency.id)])
    assert rate
    rate.write({'rate': rate_value})
    company.write({'currency_id': currency.id})
开发者ID:camptocamp,项目名称:oerpscenario,代码行数:9,代码来源:company_config.py

示例6: impl

def impl(ctx, fy_ref):
    assert '.' in fy_ref, "please use the full reference (e.g. scenario.%s)" % fy_ref
    module, xmlid = fy_ref.split('.', 1)
    _model, id = model('ir.model.data').get_object_reference(module, xmlid)
    assert _model == 'account.fiscalyear'
    fy = model('account.fiscalyear').get(id)
    fy.read('period_ids')
    if not fy.period_ids:
        model('account.fiscalyear').create_period([fy.id], {}, 1)
开发者ID:ccdos,项目名称:oerpscenario,代码行数:9,代码来源:account_config.py

示例7: impl

def impl(ctx, field, value, company_name):
    company = model('res.company').get([('name', '=', company_name)])
    assert company
    journal = model('account.journal').get([(field, '=', value), ('company_id', '=', company.id)])
    # if not journal:
    #     import pdb; pdb.set_trace()

    assert journal
    ctx.found_item = journal
    ctx.search_model_name = 'account.journal'
开发者ID:camptocamp,项目名称:oerpscenario,代码行数:10,代码来源:bank_config.py

示例8: _create_or_update_param

def _create_or_update_param(key, value):
    Params = model('ir.config_parameter')
    ids = Params.search([('key', '=', key)])
    if ids:
        Params.write(ids, {'key': key, 'value': value})
    else:
        Params.create({'key': key, 'value': value})
开发者ID:leemannd,项目名称:oerpscenario,代码行数:7,代码来源:system_params.py

示例9: impl

def impl(ctx, inv_name):
    Invoice = model('account.invoice')
    invoice = Invoice.get([('name', '=', inv_name)])
    assert invoice
    ctx.execute_steps("""
       When I pay %f on the invoice "%s"
    """ % (invoice.residual, inv_name))
开发者ID:Asinox,项目名称:marcos_odoo,代码行数:7,代码来源:account_voucher.py

示例10: impl

def impl(ctx, users):
    # search groups by name and full name
    group_names = [row['group_name'] for row in ctx.table]
    group_names = list(set(group_names))
    group_full_names = [name for name in group_names if '/' in name]
    group_single_names = [name for name in group_names if not '/' in name]
    ModulCategory = model('ir.module.category')
    groups = []
    group_full_names_category = []
    if group_full_names:
        full_name_cond = []
        for line in group_full_names:
            categ, name = line.split('/', 1)
            categ = categ.strip()
            name = name.strip()
            category_ids = ModulCategory.search([('name', '=', categ)])
            assert category_ids, 'no category named %s' % categ
            condition = [
                    '&',
                    ('name', '=', name),
                    ('category_id', 'in', category_ids)
                ]
            # Take the category_id to build the domain
            # [
            #   ('&',('name','=','User'), ('category_id','=',40)),
            #   ('&',('name','=','User'), ('category_id','=',47)),
            # ]
            full_name_cond += condition
        num_operators = len(group_full_names) - 1
        or_operators = ['|'] * num_operators
        search_cond = or_operators + full_name_cond
        groups.extend(model('res.groups').browse(search_cond))
    if group_single_names:
        single_name_cond = [('name', 'in', group_single_names)]
        # Search for single groups
        groups.extend(model('res.groups').browse(single_name_cond))
    #assert_equal(len(groups), len(group_names))
    assert users in ('user', 'users')
    if users == "users":
        for user in ctx.found_items:
            assign_groups(user, groups)
    if users == "user":
        assign_groups(ctx.found_item, groups)
开发者ID:ccdos,项目名称:oerpscenario,代码行数:43,代码来源:user_config.py

示例11: attach_file

def attach_file(ctx, filepath, res_model, oid):
    rec = model(res_model).get(oid)
    assert rec, "xmlid not found for this object"

    tmp_path = ctx.feature.filename.split(os.path.sep)
    tmp_path = tmp_path[:tmp_path.index('features')] + ['data', filepath]
    tmp_path = [str(x) for x in tmp_path]
    path = os.path.join(*tmp_path)
    with open(path, "rb") as f:
        file_data = base64.b64encode(f.read())

    values = {
        'name': os.path.basename(filepath),
        'res_id': rec.id,
        'res_model': res_model,
        'datas': file_data,
    }

    model('ir.attachment').create(values)
开发者ID:cyrilgdn,项目名称:docker-odoo-project,代码行数:19,代码来源:ir_attachment.py

示例12: import_csv_with_options

def import_csv_with_options(ctx, model_name, csvfile, options=None):
    """ import csv with options

    * handle special case to load "res.users" faster
    by setting `no_reset_password=True` in odoo context

    * currently supported options:
      * bulk={true|false}   load data in bulk mode (need a patch to odoo)
      * strict={true|false} verify that all rows are loaded
      * delimiter=","       choose CSV delimiter
    """

    tmp_path = ctx.feature.filename.split(os.path.sep)
    tmp_path = tmp_path[: tmp_path.index('features')] + ['data', csvfile]
    tmp_path = [str(x) for x in tmp_path]
    path = os.path.join(*tmp_path)
    assert os.path.exists(path)
    sep = options.get('delimiter', ',')
    strict = str2bool(options.get('strict', 'false'))

    data = csv.reader(open(path, 'rb'), delimiter=str(sep))
    head = data.next()
    values = list(data)

    if values:
        context = ctx.oe_context
        ctx.loaded_objets = None

        if model_name == 'res.users':
            context = dict(context or {}, no_reset_password=True)

        if str2bool(options.get('bulk')):
            context = dict(context or {}, bulk_mode=True)

        result = model(model_name).load(head, values, context)
        ids = result['ids']
        if not ids:
            messages = '\n'.join('- %s' % msg for msg in result['messages'])
            raise Exception("Failed to load file '%s' "
                            "in '%s'. Details:\n%s" %
                            (csvfile, model_name, messages))

        elif strict and len(values) != len(ids):
            raise Exception("Loaded only %d of %d rows" % (len(ids),
                                                           len(values)))
    else:
        # valid file with header and no further lines: noop
        ids = []

    ctx.loaded_objets = (model_name, ids)
开发者ID:camptocamp,项目名称:oerpscenario,代码行数:50,代码来源:tools.py

示例13: check_accounts

def check_accounts(context, company_name):
    company = model('res.company').get([('name', '=', company_name)])
    assert company
    assert len(model('account.account').search([
        ("company_id", "=", company.id),
    ])) > 0
开发者ID:camptocamp,项目名称:oerpscenario,代码行数:6,代码来源:account_config.py

示例14: check_no_account

def check_no_account(ctx, company_name):
    company = model('res.company').get([('name', '=', company_name)])
    assert company
    assert len(model('account.account').search([
        ("company_id", "=", company.id)
    ])) == 0
开发者ID:camptocamp,项目名称:oerpscenario,代码行数:6,代码来源:account_config.py

示例15: assert_account_installed

def assert_account_installed(ctx):
    assert model('ir.module.module').get([
        'name = account',
        'state = installed'
    ])
开发者ID:camptocamp,项目名称:oerpscenario,代码行数:5,代码来源:account_config.py


注:本文中的support.model函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。