How to Super Create Write Functions in Odoo 17

CelineGeorge1 596 views 7 slides Mar 08, 2024
Slide 1
Slide 1 of 7
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7

About This Presentation

This slide will represent how can we super Create/Write Functions in Odoo 17.
The create method is invoked when a new record is being created. By utilizing the 'super' keyword within the create function, we can augment the creation process with additional features.


Slide Content

How to Super Create/Write Functions in Odoo 17 Enterprise

Introduction Enterpr ise This slide will represent how can we super Create/Write Functions in Odoo 17

Enterprise Understanding Create/Write Functions The create method is invoked when a new record is being created. By utilizing the 'super' keyword within the create function, we can augment the creation process with additional features The write method is triggered when an existing record is being edited. To enhance its functionality, we can employ the 'super' keyword within the write function to make modifications

Enterprise Create Method Example: class ResPartner(models.Model): _inherit = 'res.partner' @api.model_create_multi def create(self, vals_list): result = super().create(vals_list) for rec in self: rec.vat = “BE124456777” return result

Enterprise This code demonstrates an example of adding a default value to the vat field of the res.partner model by inheriting and calling the create method using super().

Enterprise Write Method Example: class ResPartner(models.Model): _inherit = 'res.partner' def write(self, vals): result = super(ResPartner, self).write(vals) return result This code demonstrates how to use the super() function within the write method of the ResPartner class to invoke the superclass's write method and perform additional actions or modifications as needed.

For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com