本文整理匯總了Python中odoo.api.model方法的典型用法代碼示例。如果您正苦於以下問題:Python api.model方法的具體用法?Python api.model怎麽用?Python api.model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類odoo.api
的用法示例。
在下文中一共展示了api.model方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_categories
# 需要導入模塊: from odoo import api [as 別名]
# 或者: from odoo.api import model [as 別名]
def create_categories(self):
categ1 = {
'name': 'Child category 1',
'description': 'Description for child 1'
}
categ2 = {
'name': 'Child category 2',
'description': 'Description for child 2'
}
parent_category_val = {
'name': 'Parent category',
'email': 'Description for parent category',
'child_ids': [
(0, 0, categ1),
(0, 0, categ2),
]
}
# Total 3 records (1 parent and 2 child) will be craeted in library.book.category model
record = self.env['library.book.category'].create(parent_category_val)
return True
示例2: get_m2m_group_data
# 需要導入模塊: from odoo import api [as 別名]
# 或者: from odoo.api import model [as 別名]
def get_m2m_group_data(self, domain, m2m_field):
records = self.search(domain)
result_dict = {}
for record in records:
for m2m_record in record[m2m_field]:
if m2m_record.id not in result_dict:
result_dict[m2m_record.id] = {
'name': m2m_record.display_name,
'children': [],
'model': m2m_record._name
}
result_dict[m2m_record.id]['children'].append({
'name': record.display_name,
'id': record.id,
})
return result_dict
示例3: order_link
# 需要導入模塊: from odoo import api [as 別名]
# 或者: from odoo.api import model [as 別名]
def order_link(self):
result = []
for each_record in self:
order_action_id = self.env.ref('wechat_mall.wechat_mall_order_action_134').id
order_menu_id = self.env.ref('wechat_mall.wechat_mall_order_menuitem_118').id
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
link = '{base_url}/web#id={order_id}&view_type=form&model=wechat_mall.order&menu_id={menu_id}&action={action_id}'.format(
base_url=base_url,
order_id=self.id,
menu_id=order_menu_id,
action_id=order_action_id,
)
result.append((each_record.id, link))
return result
示例4: helper_form
# 需要導入模塊: from odoo import api [as 別名]
# 或者: from odoo.api import model [as 別名]
def helper_form(self):
self.ensure_one()
return {
'type': 'ir.actions.act_window',
'res_model': self._name, # this model
'res_id': self.id, # the current wizard record
'view_type': 'form',
'view_mode': 'form',
'target': 'new'}
示例5: get_all_library_members
# 需要導入模塊: from odoo import api [as 別名]
# 或者: from odoo.api import model [as 別名]
def get_all_library_members(self):
library_member_model = self.env['library.member'] # This is an empty recordset of model library.member
return library_member_model.search([])
示例6: _referencable_models
# 需要導入模塊: from odoo import api [as 別名]
# 或者: from odoo.api import model [as 別名]
def _referencable_models(self):
models = self.env['ir.model'].search([('field_id.name', '=', 'message_ids')])
return [(x.model, x.name) for x in models]
示例7: _reopen_form
# 需要導入模塊: from odoo import api [as 別名]
# 或者: from odoo.api import model [as 別名]
def _reopen_form(self):
self.ensure_one()
return {
'type': 'ir.actions.act_window',
'res_model': self._name, # this model
'res_id': self.id, # the current wizard record
'view_type': 'form',
'view_mode': 'form',
'target': 'new'}
開發者ID:PacktPublishing,項目名稱:Odoo-11-Development-Essentials-Third-Edition,代碼行數:11,代碼來源:todo_wizard_model.py
示例8: static_link
# 需要導入模塊: from odoo import api [as 別名]
# 或者: from odoo.api import model [as 別名]
def static_link(self):
self.ensure_one()
return '{base_url}/web/content?' \
'model=ir.attachment&' \
'field=datas&' \
'id={attachment_id}&' \
'download=true&' \
'filename_field=datas_fname'.format(
base_url=self.env['ir.config_parameter'].sudo().get_param('web.base.url'),
attachment_id=self.id
).replace('\n', '').replace(' ', '')