I am trying to remove the already exisiting write but its not working
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Účetnictví
- Sklad
- PoS
- Projekty
- MRP
This question has been flagged
Hi,
Here is a sample code how to override the write method:
from odoo import models, api
class CustomResPartner(models.Model):
_inherit = 'res.partner'
@api.model
def write(self, vals):
# Add custom logic here
# For example, let's capitalize the 'name' field when updating a partner
if 'name' in vals and vals['name']:
vals['name'] = vals['name'].capitalize()
# Call the original write method to update the record
return super(CustomResPartner, self).write(vals)
Hope it helps
try like this:
from odoo import models, fields, api
class CustomResPartner(models.Model):
_inherit = 'res.partner'
# Add any additional fields or methods as needed
@api.multi
def write(self, values):
# Your custom logic goes here
# You can modify the values or perform additional actions
# before or after calling the super method
result = super(CustomResPartner, self).write(values)
# Add any post-write logic here
return result
Write like this:
record.write({'field_to_update': new_value})
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Přihlásit se