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