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
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
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})
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden