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


Python Model.get方法代码示例

本文整理汇总了Python中proteus.Model.get方法的典型用法代码示例。如果您正苦于以下问题:Python Model.get方法的具体用法?Python Model.get怎么用?Python Model.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在proteus.Model的用法示例。


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

示例1: install_modules

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
def install_modules():
    print u'\n>>> instalando modulos...'
    Module = Model.get('ir.module.module')
    modules_to_install=[
        'account_ar',
        'account_voucher_ar',
        'account_check_ar',
        'account_bank_ar',
        'account_retencion_ar',
        'account_coop_ar',
        'company_logo',
        'account_invoice_ar',
        ]
    modules = Module.find([
        ('name', 'in', modules_to_install),
        ])
    for module in modules:
        module.click('install')
    Wizard('ir.module.module.install_upgrade').execute('upgrade')

    print u'\n>>> wizards de configuracion se marcan como done...'
    ConfigWizardItem = Model.get('ir.module.module.config_wizard.item')
    for item in ConfigWizardItem.find([('state', '!=', 'done')]):
        item.state = 'done'
        item.save()
开发者ID:tryton-ar,项目名称:deploy-localizacion-argentina,代码行数:27,代码来源:scenario_base.py

示例2: test_save

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
    def test_save(self):
        User = Model.get('res.user')
        test = User()
        test.name = 'Test'
        test.login = 'test'
        test.save()
        self.assert_(test.id > 0)

        test = User(test.id)
        self.assertEqual(test.name, 'Test')
        self.assertEqual(test.login, 'test')
        self.assert_(test.active)

        test.signature = 'Test signature'
        self.assertEqual(test.signature, 'Test signature')
        test.save()
        self.assertEqual(test.signature, 'Test signature')
        test = User(test.id)
        self.assertEqual(test.signature, 'Test signature')

        Group = Model.get('res.group')
        test2 = User(name='Test 2', login='test2',
                groups=[Group(name='Test 2')])
        test2.save()
        self.assert_(test2.id > 0)
        self.assertEqual(test2.name, 'Test 2')
        self.assertEqual(test2.login, 'test2')
开发者ID:ferchuochoa,项目名称:SIGCoop,代码行数:29,代码来源:test_model.py

示例3: loadCustomers

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
def loadCustomers():
    f = open(sys.argv[2], 'rb')
    countrycode = sys.argv[3]
    if countrycode is None:
        print "Please provide a country code. e.g. 'CH'"
    try:
        reader = csv.DictReader(f)
        Lang = Model.get('ir.lang')
        (en,) = Lang.find([('code', '=', 'en_US')])
        Country = Model.get('country.country')
        (ch, ) = Country.find([('code', '=', countrycode)])
        for row in reader:
            print(row['first_name'], row['last_name'], row['company_name'])
            Party = Model.get('party.party')
            party = Party()
            if party.id < 0:
                party.name = row['company_name']
                party.lang = en
                party.addresses[0].name = row['first_name']+' '+row['last_name']
                party.addresses[0].street = row['address']
                party.addresses[0].streetbis = None
                party.addresses[0].zip = row['zip']
                party.addresses[0].city = row['city']
                party.addresses[0].country = ch
                # party.addresses[0].subdivision = row['state']
                party.addresses[0].invoice = True
                party.addresses[0].delivery = True
                party.save()
    finally:
        f.close()
开发者ID:jerome76,项目名称:web-prototype,代码行数:32,代码来源:loader.py

示例4: test_default_set

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
    def test_default_set(self):
        User = Model.get('res.user')
        Group = Model.get('res.group')
        group_ids = [x.id for x in Group.find()]
        test = User()
        test._default_set({
            'name': 'Test',
            'groups': group_ids,
            })
        self.assertEqual(test.name, 'Test')
        self.assertEqual([x.id for x in test.groups], group_ids)

        test = User()
        test._default_set({
            'name': 'Test',
            'groups': [
                {
                    'name': 'Group 1',
                },
                {
                    'name': 'Group 2',
                },
                ],
            })
        self.assertEqual(test.name, 'Test')
        self.assertEqual([x.name for x in test.groups], ['Group 1', 'Group 2'])
开发者ID:ferchuochoa,项目名称:SIGCoop,代码行数:28,代码来源:test_model.py

示例5: crear_inmuebles

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
def crear_inmuebles():
	Address = Model.get("party.address")
	address = Address.find([])

	for item in address:
		print item.street
		new_inmueble = Model.get('sigcoop_inmueble.inmueble')()
		
		if len(item.street)==0:
			new_inmueble.calle_dom = 'SIN DATOS'
		else:
			new_inmueble.calle_dom = item.street
		
		if len(item.streetbis)==0:
			new_inmueble.numero_dom = '0'
		else:
			new_inmueble.numero_dom = item.streetbis
				
		
		new_inmueble.localidad_dom = 'PUAN'
		new_inmueble.partido_dom = 'PUAN'
		new_inmueble.cp_dom = '8180'
		new_inmueble.save()
		inmuebleid = new_inmueble.id

		#crea la relacion con party
		crear_relacion_titular(inmuebleid, item.party.id)
开发者ID:ferjavrec,项目名称:imp_firebird,代码行数:29,代码来源:crear_inmuebles.py

示例6: create_entity

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
def create_entity(values):
    if not values.get("model"):
        print "Falta el modelo. Que estamos haciendo??"
        return None
    if (values.get("id") is None):
        print "Falta el id. Que estamos haciendo??"
        return None
    model = values.pop("model")
    _id = values.pop("id")

    print "Creando la entidad %s para el registro numero %s" % (model, _id)

    #Contructor del modelo
    const = Model.get(model)
    entity = const()
    save_for_last = []

    for k,v in values.iteritems():
        if (isinstance(v, tuple)):
            ref = Model.get(v[0]).find(v[1])[0]
            setattr(entity, k, ref)
        elif (isinstance(v, list)):
            constructor = Model.get(v[0])
            to_save = []
            for elem in v[1]:
                to_save.append(constructor.find([elem])[0])
            save_for_last.append((k, to_save))
        else:
            setattr(entity, k, v)
    for i in save_for_last:
        getattr(entity, i[0]).extend(i[1])
    entity.save()
    return entity
开发者ID:ferchuochoa,项目名称:SIGCoop,代码行数:35,代码来源:creator.py

示例7: create_chart

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
def create_chart(company=None, config=None):
    """Create chart of accounts"""
    AccountTemplate = Model.get('account.account.template', config=config)
    ModelData = Model.get('ir.model.data')
    AccountChart = Model.get('account.account', config=config)

    existing_chart = AccountChart.find([('name', '=', CHART_OF_ACCOUNT_NAME)], limit=1)
    if existing_chart:
        print("Warning: Account Chart '" + CHART_OF_ACCOUNT_NAME + "' already exists!")
        return existing_chart[0]

    if not company:
        company = get_company()
    data, = ModelData.find([
            ('module', '=', 'account'),
            ('fs_id', '=', 'account_template_root_en'),
            ], limit=1)

    account_template = AccountTemplate(data.db_id)

    create_chart = Wizard('account.create_chart')
    create_chart.execute('account')
    create_chart.form.account_template = account_template
    create_chart.form.company = company
    create_chart.execute('create_account')

    accounts = get_accounts(company, config=config)

    create_chart.form.account_receivable = accounts['receivable']
    create_chart.form.account_payable = accounts['payable']
    create_chart.execute('create_properties')
    print("Success: Account Chart '" + CHART_OF_ACCOUNT_NAME + "' created!")
    return create_chart
开发者ID:jerome76,项目名称:web-prototype,代码行数:35,代码来源:initial_config.py

示例8: test_on_change_set

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
    def test_on_change_set(self):
        User = Model.get('res.user')
        Group = Model.get('res.group')

        test = User()
        test._on_change_set('name', 'Test')
        self.assertEqual(test.name, 'Test')
        group_ids = [x.id for x in Group.find()]
        test._on_change_set('groups', group_ids)
        self.assertEqual([x.id for x in test.groups], group_ids)

        test._on_change_set('groups', {'remove': [group_ids[0]]})
        self.assertEqual([x.id for x in test.groups], group_ids[1:])

        test._on_change_set('groups', {'add': [{
            'name': 'Bar',
            }]})
        self.assert_([x for x in test.groups if x.name == 'Bar'])

        test.groups.extend(Group.find())
        group = test.groups[0]
        test._on_change_set('groups', {'update': [{
            'id': group.id,
            'name': 'Foo',
            }]})
        self.assert_([x for x in test.groups if x.name == 'Foo'])
开发者ID:ferchuochoa,项目名称:SIGCoop,代码行数:28,代码来源:test_model.py

示例9: crear_company

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
def crear_company(config, lang):
    """ Crear company. Traer datos de AFIP"""
    Currency = Model.get('currency.currency')
    Company = Model.get('company.company')
    Party = Model.get('party.party')

    # crear company
    # obtener nombre de la compania de un archivo.
    print u'\n>>> creando company...'

    import ConfigParser
    ini_config = ConfigParser.ConfigParser()
    ini_config.read('company.ini')
    currencies = Currency.find([('code', '=', 'ARS')])
    currency, = currencies
    company_config = Wizard('company.company.config')
    company_config.execute('company')
    company = company_config.form
    party = Party(name='NOMBRE COMPANY')
    party.lang = lang
    party.vat_country = 'AR'
    try:
        party.vat_number = ini_config.get('company', 'cuit')
        party.iva_condition = ini_config.get('company', 'iva_condition')
    except Exception,e:
        print 'Error: No se ha configurado correctamente company.ini\n'
        raise SystemExit(repr(e))
开发者ID:tryton-ar,项目名称:deploy-localizacion-argentina,代码行数:29,代码来源:scenario_base.py

示例10: create_chart

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
def create_chart(company=None, config=None):
    "Create chart of accounts"
    AccountTemplate = Model.get('account.account.template', config=config)
    ModelData = Model.get('ir.model.data')

    if not company:
        company = get_company()
    data, = ModelData.find([
            ('module', '=', 'account'),
            ('fs_id', '=', 'account_template_root_en'),
            ], limit=1)

    account_template = AccountTemplate(data.db_id)

    create_chart = Wizard('account.create_chart')
    create_chart.execute('account')
    create_chart.form.account_template = account_template
    create_chart.form.company = company
    create_chart.execute('create_account')

    accounts = get_accounts(company, config=config)

    create_chart.form.account_receivable = accounts['receivable']
    create_chart.form.account_payable = accounts['payable']
    create_chart.execute('create_properties')
    return create_chart
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:28,代码来源:tools.py

示例11: crear_account_invoice_ar_pos

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
def crear_account_invoice_ar_pos(config, lang):
    """ Crear Punto de Venta Electronico con Factura A, B y C """

    print u'\n>>> Comienza creacion de POS Electronico para Facturas A, B y C'
    Company = Model.get('company.company')
    Pos = Model.get('account.pos')
    PosSequence = Model.get('account.pos.sequence')

    company, = Company.find([])
    punto_de_venta = Pos()
    punto_de_venta.pos_type = 'electronic'
    punto_de_venta.number = 2
    punto_de_venta.pyafipws_electronic_invoice_service = 'wsfe'
    punto_de_venta.save()


    facturas = {
        '1': '01-Factura A',
        '6': '06-Factura B',
        '11': '11-Factura C'
    }

    for key, name in facturas.iteritems():
        print u'\n>>> Creamos POS para '+name
        pos_sequence = PosSequence()
        pos_sequence.invoice_type = key
        pos_sequence.invoice_sequence = _crear_seq(config, name, company)
        pos_sequence.pos = punto_de_venta
        pos_sequence.save()
开发者ID:tryton-ar,项目名称:deploy-localizacion-argentina,代码行数:31,代码来源:scenario_base.py

示例12: test_class_cache

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
    def test_class_cache(self):
        User1 = Model.get('res.user')
        User2 = Model.get('res.user')
        self.assertEqual(id(User1), id(User2))

        Model.reset()
        User3 = Model.get('res.user')
        self.assertNotEqual(id(User1), id(User3))
开发者ID:ferchuochoa,项目名称:SIGCoop,代码行数:10,代码来源:test_model.py

示例13: test_translation_export

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
 def test_translation_export(self):
     Lang = Model.get('ir.lang')
     Module = Model.get('ir.module.module')
     translation_export = Wizard('ir.translation.export')
     translation_export.form.language, = Lang.find([('code', '=', 'en_US')])
     translation_export.form.module, = Module.find([('name', '=', 'ir')])
     translation_export.execute('export')
     self.assert_(translation_export.form.file)
     translation_export.execute('end')
开发者ID:ferchuochoa,项目名称:SIGCoop,代码行数:11,代码来源:test_wizard.py

示例14: test_reference

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
 def test_reference(self):
     Attachment = Model.get('ir.attachment')
     User = Model.get('res.user')
     admin = User.find([('login', '=', 'admin')])[0]
     attachment = Attachment()
     attachment.name = 'Test'
     attachment.resource = admin
     attachment.save()
     self.assertEqual(attachment.resource, admin)
开发者ID:ferchuochoa,项目名称:SIGCoop,代码行数:11,代码来源:test_model.py

示例15: check_category

# 需要导入模块: from proteus import Model [as 别名]
# 或者: from proteus.Model import get [as 别名]
def check_category(cat_name, simulate):
    cats = Model.get('product.category').find([("name", "=", cat_name)])
    if not cats:
        if not simulate:
            cat = Model.get('product.category')()
            cat.name = cat_name
            cat.save()
            return cat
        return None
    return cats[0]
开发者ID:ferchuochoa,项目名称:SIGCoop,代码行数:12,代码来源:creator.py


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