本文整理汇总了Python中odoo.models.Model方法的典型用法代码示例。如果您正苦于以下问题:Python models.Model方法的具体用法?Python models.Model怎么用?Python models.Model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类odoo.models
的用法示例。
在下文中一共展示了models.Model方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_test_model
# 需要导入模块: from odoo import models [as 别名]
# 或者: from odoo.models import Model [as 别名]
def _init_test_model(cls, model_cls):
""" It builds a model from model_cls in order to test abstract models
Args:
model_cls: (odoo.models.BaseModel) Class of model to initialize
Returns:
Model instance
"""
model_cls._build_model(cls.registry, cls.cr)
model = cls.env[model_cls._name].with_context(todo=[])
model._prepare_setup()
model._setup_base(partial=False)
model._setup_fields(partial=False)
model._setup_complete()
model._auto_init()
model.init()
model._auto_end()
return model
示例2: get_config
# 需要导入模块: from odoo import models [as 别名]
# 或者: from odoo.models import Model [as 别名]
def get_config(self, key, uid=False, obj=False):
config = self.search([('create_uid', '=', uid)])
if obj:
return config
if config:
config.ensure_one()
return config.__getattribute__(key) if not isinstance(config.__getattribute__(key),models.Model) \
else config.get_relative_field_val(key)
else:
return False
示例3: get_config_by_subdomain
# 需要导入模块: from odoo import models [as 别名]
# 或者: from odoo.models import Model [as 别名]
def get_config_by_subdomain(self, key, sub_domain=False, obj=False):
config = self.search([('sub_domain', '=', sub_domain)])
if obj:
return config
if config:
config.ensure_one()
return config.__getattribute__(key) if not isinstance(config.__getattribute__(key), models.Model) \
else config.get_relative_field_val(key)
else:
return False
示例4: default_get
# 需要导入模块: from odoo import models [as 别名]
# 或者: from odoo.models import Model [as 别名]
def default_get(self, fields_list):
config = self.env['wechat_mall.config'].search([('create_uid', '=', self.env.uid)])
result = super(ConfigSettingWizard, self).default_get(fields_list)
if config:
config.ensure_one()
result.update({
f: config.__getattribute__(f) if not isinstance(config.__getattribute__(f), models.Model)
else config.get_relative_field_val(f)
for f in fields_list if f not in result.keys()})
return result
else:
return result
示例5: get_config
# 需要导入模块: from odoo import models [as 别名]
# 或者: from odoo.models import Model [as 别名]
def get_config(self, key, uid=False, obj=False):
uid = uid if uid else self.env.uid
config = self.env['wechat_mall.config'].search([('create_uid', '=', uid)])
if obj:
return config
if config:
config.ensure_one()
return config.__getattribute__(key) if not isinstance(config.__getattribute__(key), models.Model) \
else config.get_relative_field_val(key)
else:
return False