当前位置: 首页>>代码示例>>Python>>正文


Python api.model方法代码示例

本文整理汇总了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 
开发者ID:PacktPublishing,项目名称:Odoo-12-Development-Cookbook-Third-Edition,代码行数:22,代码来源:library_book.py

示例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 
开发者ID:PacktPublishing,项目名称:Odoo-12-Development-Cookbook-Third-Edition,代码行数:18,代码来源:models.py

示例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 
开发者ID:elfgzp,项目名称:wechat_mall,代码行数:18,代码来源:order.py

示例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'} 
开发者ID:ScottAI,项目名称:Odoo-Python-ERP-,代码行数:11,代码来源:bug_wizard.py

示例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([]) 
开发者ID:PacktPublishing,项目名称:Odoo-12-Development-Cookbook-Third-Edition,代码行数:5,代码来源:library_book.py

示例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] 
开发者ID:PacktPublishing,项目名称:Odoo-12-Development-Cookbook-Third-Edition,代码行数:5,代码来源:library_book.py

示例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(' ', '') 
开发者ID:elfgzp,项目名称:wechat_mall,代码行数:13,代码来源:ir_attachment.py


注:本文中的odoo.api.model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。