Logo

dev-resources.site

for different kinds of informations.

How to override the create and write methods in Odoo?

Published at
11/13/2024
Categories
odoo
odoodevelopment
odooconsulting
erp
Author
sdlc_corp
Author
9 person written this
sdlc_corp
open
How to override the create and write methods in Odoo?
from odoo import models

class MyModel(models.Model):
    _name = 'my.model'

    def create(self, vals):
        vals['name'] = vals.get('name', '').upper()
        record = super(MyModel, self).create(vals)
        return record

    def write(self, vals):
        if 'name' in vals:
            vals['name'] = vals['name'].upper()
        result = super(MyModel, self).write(vals)
        return result

Enter fullscreen mode Exit fullscreen mode
  • create: Called when a new record is created. Here, it modifies the name field to uppercase.
  • write: Called when updating an existing record.

For companies seeking to expand the functionality of their ERP systems, SDLC Corp, an Odoo development company, offers robust solutions to integrate and customize Odoo for specific business needs, including solutions like S-Invoice. With a team of experienced developers, SDLC Corp ensures seamless integration of advanced tools and customizations into the Odoo framework.

As a trusted Odoo development partner, SDLC Corp provides end-to-end services, from requirement analysis and module development to post-implementation support. Their expertise allows companies to leverage Odoo's flexibility and power while tailoring the platform to their unique workflows. By handling all technical requirements, SDLC Corp enables businesses to optimize their ERP efficiently, with a focus on maximizing functionality and improving operational efficiency.

Featured ones: