當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。