예제 #1
0
def impl(ctx):
    tlangs = model('res.lang').browse([('translatable', '=', True)])
    codes = set([lang for (lang,) in ctx.table])
    mods = model('ir.module.module').browse(['state = installed'])
    assert_true(codes)
    assert_less(codes, set(tlangs.code))
    mods.button_update_translations()
예제 #2
0
def set_in_settings(ctx, option, value, menu):
    """ Define value of an option in settings by name """
    Menu = model('ir.ui.menu')
    Field = model('ir.model.fields')
    search_domain = [('module', '=', 'base'), ('name', '=', 'menu_config')]
    base_menu_config_id = model('ir.model.data').get(search_domain).res_id
    settings_menu = Menu.get(
        [('name', '=', menu),
         ('parent_id', '=', base_menu_config_id)])
    if not settings_menu and menu in ('Invoicing', 'Accounting'):
        # Try with alias name (depending on module installed)
        if menu == 'Invoicing':
            alias = 'Accounting'
        elif menu == 'Accounting':
            alias = 'Invoicing'
        settings_menu = Menu.get(
            [('name', '=', alias),
             ('parent_id', '=', base_menu_config_id)])
    assert settings_menu, "menu %s was not found" % menu
    wiz_model = settings_menu.action.res_model

    field = Field.get([('model', '=', wiz_model),
                       ('field_description', '=', option)])
    assert field
    Wiz = model(wiz_model)
    values = {}
    if wiz_model == 'account.config.settings':
        # Special call to onchange in case of account config
        company = model('res.users').browse(1).company_id
        values.update(Wiz.onchange_company_id(None, company.id)['value'])

    values[field.name] = value
    config = Wiz.create(values)

    config.execute()
def impl(ctx):
    ctx.data['lang'] = cfglang = set()
    for (lang, ) in ctx.table:
        if model('res.lang').search([('code', '=', lang)]):
            continue
        res = model('base.language.install').create({'lang': lang})
        model('base.language.install').lang_install([res.id])
        cfglang.add(lang)
예제 #4
0
def impl(ctx):
    ctx.data['lang'] = cfglang = set()
    for (lang,) in ctx.table:
        if model('res.lang').search([('code', '=', lang)]):
            continue
        res = model('base.language.install').create({'lang': lang})
        model('base.language.install').lang_install([res.id])
        cfglang.add(lang)
예제 #5
0
def impl(ctx):
    tlangs = model('res.lang').browse([('translatable', '=', True)])
    codes = set([lang for (lang,) in ctx.table])
    mods = model('ir.module.module').browse(['state = installed'])
    assert_true(codes)
    assert_less(codes, set(tlangs.code))
    if ctx.client.server_version.startswith('9'):
        mods.update_translations(None, {'overwrite': True})
    else:
        mods.button_update_translations()
def impl(ctx):
    tlangs = model('res.lang').browse([('translatable', '=', True)])
    codes = set([lang for (lang, ) in ctx.table])
    mods = model('ir.module.module').browse(['state = installed'])
    assert_true(codes)
    assert_less(codes, set(tlangs.code))
    if ctx.client.server_version.startswith('9'):
        mods.update_translations(None, {'overwrite': True})
    else:
        mods.button_update_translations()
예제 #7
0
def impl(ctx, modelname, column, value):
    assert hasattr(ctx, 'ir_property')
    ir_property = ctx.ir_property
    domain = [(column, '=', value)]
    if ir_property.company_id and 'company_id' in model(modelname).fields():
        domain.append(('company_id', '=', ir_property.company_id.id))
        res = model(modelname).get(domain)
        if not res:  # try again without company
            del domain[-1]
        res = model(modelname).get(domain)
    else:
        res = model(modelname).get(domain)
    assert res, "no value for %s value %s" % (column, value)
    ir_property.write({'value_reference': '%s,%s' % (modelname, res.id)})
예제 #8
0
파일: dsl.py 프로젝트: ccdos/oerpscenario
def impl(ctx, modelname, column, value):
    assert hasattr(ctx, 'ir_property')
    ir_property = ctx.ir_property
    domain = [(column, '=', value)]
    if ir_property.company_id and 'company_id' in model(modelname).fields():
        domain.append(('company_id', '=', ir_property.company_id.id))
        res = model(modelname).get(domain)
        if not res: # try again without company
            del domain[-1]
        res = model(modelname).get(domain)
    else:
        res = model(modelname).get(domain)
    assert res, "no value for %s value %s" % (column, value)
    ir_property.write({'value_reference': '%s,%s' % (modelname, res.id)})
예제 #9
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
예제 #10
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
예제 #11
0
파일: dsl.py 프로젝트: ccdos/oerpscenario
def impl(ctx, modelname, column, value):
    """
    Example:
    Scenario: set default values for products, the list price is only set for company2
      Given I set the default value for "product.product"."type" to 'product'
      And I set the default value for "product.product"."cost_method" to 'average'
      Given I am configuring the company with ref "scen.company2"
      And I set the default value for "product.product"."list_price" to 12.4
    """
    if hasattr(ctx, 'company_id'):
        company_id = ctx.company_id
    else:
        company_id = False
    ir_value_obj = model('ir.values')
    value = eval(value)
    ir_value_obj.set_default(modelname, column, value, company_id=company_id)
예제 #12
0
def impl(ctx, modelname, column, value):
    """
    Example:
    Scenario: set default values for products, the list price is only set for company2
      Given I set the default value for "product.product"."type" to 'product'
      And I set the default value for "product.product"."cost_method" to 'average'
      Given I am configuring the company with ref "scen.company2"
      And I set the default value for "product.product"."list_price" to 12.4
    """
    if hasattr(ctx, 'company_id'):
        company_id = ctx.company_id
    else:
        company_id = False
    ir_value_obj = model('ir.values')
    value = eval(value)
    ir_value_obj.set_default(modelname, column, value, company_id=company_id)
예제 #13
0
def impl_having(ctx):
    assert ctx.table, 'please supply a table of values'
    assert ctx.search_model_name, 'cannot use "having" step without a previous step setting a model'
    assert ctx.found_item, 'No record found'
    table_values = parse_table_values(ctx, ctx.search_model_name, ctx.table)
    if isinstance(ctx.found_item, dict):
        values = ctx.found_item
        values.update(table_values)
        if 'company_id' not in values and \
           hasattr(ctx, 'company_id') and \
           'company_id' in model(ctx.search_model_name).keys():
            values['company_id'] = ctx.company_id
        ctx.found_item = create_new_obj(ctx, ctx.search_model_name, values)

    else:
        ctx.found_item.write(table_values)
예제 #14
0
파일: dsl.py 프로젝트: ccdos/oerpscenario
def impl_having(ctx):
    assert ctx.table, 'please supply a table of values'
    assert ctx.search_model_name, 'cannot use "having" step without a previous step setting a model'
    assert ctx.found_item, 'No record found'
    table_values = parse_table_values(ctx, ctx.search_model_name,
                                      ctx.table)
    if isinstance(ctx.found_item, dict):
        values = ctx.found_item
        values.update(table_values)
        if 'company_id' not in values and \
           hasattr(ctx, 'company_id') and \
           'company_id' in model(ctx.search_model_name).keys():
            values['company_id'] = ctx.company_id
        ctx.found_item = create_new_obj(ctx, ctx.search_model_name, values)

    else:
        ctx.found_item.write(table_values)
예제 #15
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)
예제 #16
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)
예제 #17
0
def impl(ctx):
    for lang in ctx.data['lang']:
        assert_true(model('res.lang').search([('code', '=', lang)]))
예제 #18
0
def impl(ctx):
    model('ir.module.module').update_list()
예제 #19
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
예제 #20
0
def impl(ctx):
    for lang in ctx.data['lang']:
        assert_true(model('res.lang').search([('code', '=', lang)]))
예제 #21
0
def set_in_settings(ctx, option, value, menu):
    """ Define value of an option in settings by name
    :param menu: 8.0: Menu name or xmlid
                 9.0: base menu name or full path or xmlid
    """
    Menu = model('ir.ui.menu')
    Field = model('ir.model.fields')
    if menu.startswith('oid:'):
        settings_menu = Menu.get(menu[4:])
    elif 'Accounting' in menu or 'Invoicing' in menu:
        settings_menu = Menu.get('account.menu_account_config')
    else:
        if ctx.conf['server'].release.major_version >= '9.0':
            # search by full path or compose full path
            # but we need to loop on menu as full path is not stored
            # thus not searchable
            if not '/' in menu:
                menu = menu + '/Configuration/Settings'
            domain = [('name', '=', menu.split('/')[-1])]
            menus = Menu.browse(domain)
            for m in menus:
                if m.complete_name == menu:
                    settings_menu = m
                    break
        else:
            base_menu_config = Menu.get('base.menu_config')
            settings_menu = Menu.get([('name', '=', menu),
                                      ('parent_id', '=', base_menu_config.id)])
    assert settings_menu, "menu %s was not found" % menu
    wiz_model = settings_menu.action.res_model

    field = Field.get([('model', '=', wiz_model),
                       ('field_description', '=', option)])
    assert field
    Wiz = model(wiz_model)
    values = {}
    if (wiz_model == 'account.config.settings'
            and ctx.conf['server'].release.major_version < '9.0'):
        # Special call to onchange in case of account config
        company = model('res.users').browse(1).company_id
        values.update(Wiz.onchange_company_id(None, company.id)['value'])

    field_model = model(field.model)
    if field_model._fields[field.name]['type'] == 'selection':
        selection = field_model._fields[field.name]['selection']
        for elem in selection:
            if elem[1] == value:
                values[field.name] = elem[0]
                break
        assert values.get(
            field.name) is not False, "Value not found in selection"
    else:
        values[field.name] = value
    if ctx.conf['server'].release.major_version >= '9.0':
        # Due to https://github.com/odoo/odoo/issues/10775 we will call default_get
        # and replace wrong boolean values by integer
        defaults = Wiz.default_get(Wiz.fields_get_keys())
        for field_name, val in defaults.iteritems():
            if val is True and field_name.startswith('group_'):
                field = Field.get([('model', '=', wiz_model),
                                   ('name', '=', field_name)])
                # If it is a selection it is not a boolean
                if field.ttype == 'selection':
                    defaults[field_name] = 1
        defaults.update(values)
        values = defaults

    config = Wiz.create(values)
    config.execute()
예제 #22
0
def impl(ctx):
    model('ir.module.module').update_list()
예제 #23
0
파일: dsl.py 프로젝트: ccdos/oerpscenario
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
예제 #24
0
def impl(context):
    IrModuleModule = model('ir.module.module')
    ids = IrModuleModule.search([])
    IrModuleModule.write(ids, {'demo': True})
예제 #25
0
def set_in_settings(ctx, option, value, menu):
    """ Define value of an option in settings by name
    :param menu: 8.0: Menu name or xmlid
                 9.0: base menu name or full path or xmlid
    """
    Menu = model('ir.ui.menu')
    Field = model('ir.model.fields')
    if menu.startswith('oid:'):
        settings_menu = Menu.get(menu[4:])
    elif 'Accounting' in menu or 'Invoicing' in menu:
        settings_menu = Menu.get('account.menu_account_config')
    else:
        if ctx.conf['server'].release.major_version >= '9.0':
            # search by full path or compose full path
            # but we need to loop on menu as full path is not stored
            # thus not searchable
            if not '/' in menu:
                menu = menu + '/Configuration/Settings'
            domain = [('name', '=', menu.split('/')[-1])]
            menus = Menu.browse(domain)
            for m in menus:
                if m.complete_name == menu:
                    settings_menu = m
                    break
        else:
            base_menu_config = Menu.get('base.menu_config')
            settings_menu = Menu.get(
                [('name', '=', menu),
                 ('parent_id', '=', base_menu_config.id)])
    assert settings_menu, "menu %s was not found" % menu
    wiz_model = settings_menu.action.res_model

    field = Field.get([('model', '=', wiz_model),
                       ('field_description', '=', option)])
    assert field
    Wiz = model(wiz_model)
    values = {}
    if (wiz_model == 'account.config.settings' and
            ctx.conf['server'].release.major_version < '9.0'):
        # Special call to onchange in case of account config
        company = model('res.users').browse(1).company_id
        values.update(Wiz.onchange_company_id(None, company.id)['value'])

    field_model = model(field.model)
    if field_model._fields[field.name]['type'] == 'selection':
        selection = field_model._fields[field.name]['selection']
        for elem in selection:
            if elem[1] == value:
                values[field.name] = elem[0]
                break
        assert values.get(field.name) is not False, "Value not found in selection"
    else:
        values[field.name] = value
    if ctx.conf['server'].release.major_version >= '9.0':
        # Due to https://github.com/odoo/odoo/issues/10775 we will call default_get
        # and replace wrong boolean values by integer
        defaults = Wiz.default_get(Wiz.fields_get_keys())
        for field_name, val in defaults.iteritems():
            if val is True and field_name.startswith('group_'):
                field = Field.get([('model', '=', wiz_model),
                                   ('name', '=', field_name)])
                # If it is a selection it is not a boolean
                if field.ttype == 'selection':
                    defaults[field_name] = 1
        defaults.update(values)
        values = defaults

    config = Wiz.create(values)
    config.execute()