本文整理汇总了Python中odoo._属性的典型用法代码示例。如果您正苦于以下问题:Python odoo._属性的具体用法?Python odoo._怎么用?Python odoo._使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类odoo
的用法示例。
在下文中一共展示了odoo._属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: callback_api_register
# 需要导入模块: import odoo [as 别名]
# 或者: from odoo import _ [as 别名]
def callback_api_register(self):
"""
注册钉钉业务回调接口
"""
config = self.env['ir.config_parameter'].sudo()
# 回调Tag
call_back_tag = ['user_add_org']
# 生成Token
token = self.generate_random_str(16)
# 生成AESKey并进行Base64编码
aes_key = base64.b64encode(self.generate_random_str(32).encode()).decode().rstrip('=')
# 保存Token和AESKey
config.set_param('dingtalk_call_back_api_token', token)
config.set_param('dingtalk_call_back_api_aes_key', aes_key)
# 回调Url
call_back_url = request.httprequest.host_url + 'dingtalk/call_back'
try:
# 向钉钉接口发起回调接口注册请求
dingtalk = DingTalk(config.get_param('dingtalk_app_key'), config.get_param('dingtalk_app_secret'))
dingtalk.callback_api_register(call_back_tag, config.get_param('dingtalk_call_back_api_token'),
config.get_param('dingtalk_call_back_api_aes_key'), call_back_url)
except Exception as e:
raise UserError(
_('回调接口注册失败!\n\n错误原因:\n' + str(
e) + '\n\n请检查:\n(1)基本参数是否正确。\n(2)回调地址是否已注册。\n(3)Odoo服务器是否可以被外网访问。\n(4)钉钉后台权限设置是否正确。'))
示例2: book_rent
# 需要导入模块: import odoo [as 别名]
# 或者: from odoo import _ [as 别名]
def book_rent(self):
self.ensure_one()
if self.state != 'available':
raise UserError(_('Book is not available for renting'))
rent_as_superuser = self.env['library.book.rent'].sudo()
rent_as_superuser.create({
'book_id': self.id,
'borrower_id': self.env.user.partner_id.id,
})
示例3: check_dates
# 需要导入模块: import odoo [as 别名]
# 或者: from odoo import _ [as 别名]
def check_dates(self):
for record in self:
start_date = fields.Date.from_string(record.start_date)
end_date = fields.Date.from_string(record.end_date)
if start_date > end_date:
raise ValidationError(_("End Date cannot be set before \
Start Date."))
示例4: _check_date_time
# 需要导入模块: import odoo [as 别名]
# 或者: from odoo import _ [as 别名]
def _check_date_time(self):
if self.start_datetime > self.end_datetime:
raise ValidationError(_(
'End Time cannot be set before Start Time.'))
示例5: _check_birthdate
# 需要导入模块: import odoo [as 别名]
# 或者: from odoo import _ [as 别名]
def _check_birthdate(self):
for record in self:
if record.birth_date > fields.Date.today():
raise ValidationError(_(
"出生日期不可以晚于今天!"))
示例6: check_dates
# 需要导入模块: import odoo [as 别名]
# 或者: from odoo import _ [as 别名]
def check_dates(self):
start_date = fields.Date.from_string(self.start_date)
end_date = fields.Date.from_string(self.end_date)
if start_date > end_date:
raise ValidationError(_("End Date cannot be set before \
Start Date."))
示例7: create
# 需要导入模块: import odoo [as 别名]
# 或者: from odoo import _ [as 别名]
def create(self, vals):
res = super(LxbFeesTerms, self).create(vals)
if not res.line_ids:
raise exceptions.AccessError(_("Fees Terms must be Required!"))
total = 0.0
for line in res.line_ids:
if line.value:
total += line.value
if total != 100.0:
raise exceptions.AccessError(_("Fees terms must be divided \
as such sum up in 100%"))
return res
示例8: update_users_and_departments
# 需要导入模块: import odoo [as 别名]
# 或者: from odoo import _ [as 别名]
def update_users_and_departments(self):
"""
手动同步成员与部门
"""
try:
self.env['res.users'].sudo().create_users_from_dingtalk()
except Exception as e:
raise UserError(_('同步失败!\n\n错误原因:\n' + str(e)))
示例9: _check_active
# 需要导入模块: import odoo [as 别名]
# 或者: from odoo import _ [as 别名]
def _check_active(self):
# do not check during installation
if self.env.registry.ready and not self.search_count([]):
raise ValidationError(_('At least one language must be active.'))
示例10: _check_format
# 需要导入模块: import odoo [as 别名]
# 或者: from odoo import _ [as 别名]
def _check_format(self):
for lang in self:
for pattern in lang._disallowed_datetime_patterns:
if (lang.time_format and pattern in lang.time_format) or \
(lang.date_format and pattern in lang.date_format):
raise ValidationError(_('Invalid date/time format directive specified. '
'Please refer to the list of allowed directives, '
'displayed when you edit a language.'))
示例11: _check_grouping
# 需要导入模块: import odoo [as 别名]
# 或者: from odoo import _ [as 别名]
def _check_grouping(self):
warning = _('The Separator Format should be like [,n] where 0 < n :starting from Unit digit. '
'-1 will end the separation. e.g. [3,2,-1] will represent 106500 to be 1,06,500;'
'[1,2,-1] will represent it to be 106,50,0;[3] will represent it as 106,500. '
'Provided as the thousand separator in each case.')
for lang in self:
try:
if not all(isinstance(x, int) for x in json.loads(lang.grouping)):
raise ValidationError(warning)
except Exception:
raise ValidationError(warning)
示例12: write
# 需要导入模块: import odoo [as 别名]
# 或者: from odoo import _ [as 别名]
def write(self, vals):
lang_codes = self.mapped('code')
if 'code' in vals and any(code != vals['code'] for code in lang_codes):
raise UserError(_("Language code cannot be modified."))
if vals.get('active') == False:
if self.env['res.users'].search([('lang', 'in', lang_codes)]):
raise UserError(_("Cannot deactivate a language that is currently used by users."))
# delete linked ir.default specifying default partner's language
self.env['ir.default'].discard_values('res.partner', 'lang', lang_codes)
res = super(Lang, self).write(vals)
self.flush()
self.clear_caches()
return res
示例13: unlink
# 需要导入模块: import odoo [as 别名]
# 或者: from odoo import _ [as 别名]
def unlink(self):
for language in self:
if language.code == 'en_US':
raise UserError(_("Base Language 'en_US' can not be deleted."))
ctx_lang = self._context.get('lang')
if ctx_lang and (language.code == ctx_lang):
raise UserError(_("You cannot delete the language which is the user's preferred language."))
if language.active:
raise UserError(_("You cannot delete the language which is Active!\nPlease de-activate the language first."))
self.env['ir.translation'].search([('lang', '=', language.code)]).unlink()
self.clear_caches()
return super(Lang, self).unlink()