Python odoo.api.model() Examples
The following are 23
code examples of odoo.api.model().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
odoo.api
, or try the search function
.
Example #1
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 6 votes |
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
Example #2
Source File: order.py From wechat_mall with MIT License | 6 votes |
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
Example #3
Source File: models.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 6 votes |
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
Example #4
Source File: models.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 6 votes |
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
Example #5
Source File: models.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 6 votes |
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
Example #6
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 6 votes |
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
Example #7
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 6 votes |
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
Example #8
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 6 votes |
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
Example #9
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 6 votes |
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
Example #10
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 6 votes |
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
Example #11
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 6 votes |
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
Example #12
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 5 votes |
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([])
Example #13
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 5 votes |
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([])
Example #14
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 5 votes |
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([])
Example #15
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 5 votes |
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([])
Example #16
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 5 votes |
def _referencable_models(self): models = self.env['ir.model'].search([('field_id.name', '=', 'message_ids')]) return [(x.model, x.name) for x in models]
Example #17
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 5 votes |
def _referencable_models(self): models = self.env['ir.model'].search([('field_id.name', '=', 'message_ids')]) return [(x.model, x.name) for x in models]
Example #18
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 5 votes |
def _referencable_models(self): models = self.env['ir.model'].search([('field_id.name', '=', 'message_ids')]) return [(x.model, x.name) for x in models]
Example #19
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 5 votes |
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([])
Example #20
Source File: library_book.py From Odoo-12-Development-Cookbook-Third-Edition with MIT License | 5 votes |
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([])
Example #21
Source File: todo_wizard_model.py From Odoo-11-Development-Essentials-Third-Edition with MIT License | 5 votes |
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'}
Example #22
Source File: ir_attachment.py From wechat_mall with MIT License | 5 votes |
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(' ', '')
Example #23
Source File: bug_wizard.py From Odoo-Python-ERP- with GNU General Public License v3.0 | 5 votes |
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'}