本文整理匯總了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