Skip to Content
āđ€āļĄāļ™āļđ
āļ„āļļāļ“āļ•āđ‰āļ­āļ‡āļĨāļ‡āļ—āļ°āđ€āļšāļĩāļĒāļ™āđ€āļžāļ·āđˆāļ­āđ‚āļ•āđ‰āļ•āļ­āļšāļāļąāļšāļ„āļ­āļĄāļĄāļđāļ™āļīāļ•āļĩāđ‰
āļ„āļģāļ–āļēāļĄāļ™āļĩāđ‰āļ–āļđāļāļ•āļąāđ‰āļ‡āļ„āđˆāļēāļŠāļ–āļēāļ™āļ°
3 āļ•āļ­āļšāļāļĨāļąāļš
4421 āļĄāļļāļĄāļĄāļ­āļ‡

Hello everyone,
I created a new module 'my_module', I created a view 'cours_view.xml' and a model 'cours.py', in the model, I overloaded the unlink and create function, but when I delete a course on the web interface the unlink function that I declared in the model is not called the same for create. 

I spent the day on it, so please help me ðŸĨļ

below is the code of cours.py:

from odoo import models, fields, api
from odoo.exceptions import ValidationError

class MycustomemoduleCours(models.Model):
_name = 'mycustomemodule.cours'
_rec_name = 'title'
title = fields.Char()
description = fields.Text()


def unlink(self):
raise ValidationError("impossible")
print("*************************** test customize delete****************")
return super(MycustomemoduleCours, self).unlink()

@api.model
def create(self, vals):
print("***********create customize methodes")
return super(MycustomemoduleCours, self).create(vals)

āļ­āļ§āļ•āļēāļĢ
āļĨāļ°āļ—āļīāđ‰āļ‡
āļœāļđāđ‰āđ€āļ‚āļĩāļĒāļ™ āļ„āļģāļ•āļ­āļšāļ—āļĩāđˆāļ”āļĩāļ—āļĩāđˆāļŠāļļāļ”

Thanks WALEED you for tested my code, I think the problems was internal to odoo, I have already update the modules from application

I solved the problem by re-installing odoo.

Note: I working on k8s cluster, so all modules odoo are not directly in 

/usr/lib/python3/dist-packages/odoo/addons/ but in /mnt/addons, so I think that's cause of no-synchronization.

āļ­āļ§āļ•āļēāļĢ
āļĨāļ°āļ—āļīāđ‰āļ‡
āļ„āļģāļ•āļ­āļšāļ—āļĩāđˆāļ”āļĩāļ—āļĩāđˆāļŠāļļāļ”

For more information you can visit this playlist, How each base methods you can override with example.

https://www.youtube.com/playlist?list=PLAR8TpPnVeTSsvwN1uWd8bcTbvCVAb8gq

For create you can try this discussion.

https://youtu.be/76LGYkRCSmI


For Unlink/Delete method you can try this discussion.

https://youtu.be/kqSM4P9QEBM

Thank You


āļ­āļ§āļ•āļēāļĢ
āļĨāļ°āļ—āļīāđ‰āļ‡
āļ„āļģāļ•āļ­āļšāļ—āļĩāđˆāļ”āļĩāļ—āļĩāđˆāļŠāļļāļ”

I have tested your code and its working and I got ValidationError message "impossible"

Try to restart the service and upgrade your module.

āļ­āļ§āļ•āļēāļĢ
āļĨāļ°āļ—āļīāđ‰āļ‡
Related Posts āļ•āļ­āļšāļāļĨāļąāļš āļĄāļļāļĄāļĄāļ­āļ‡ āļāļīāļˆāļāļĢāļĢāļĄ
1
āļĄ.āļ„. 22
3791
Duplicate after overriding create function āđāļāđ‰āđ„āļ‚āđāļĨāđ‰āļ§
2
āļ˜.āļ„. 22
2872
Patch unlink() 'states check' on Sale Order āđāļāđ‰āđ„āļ‚āđāļĨāđ‰āļ§
1
āļ•.āļ„. 22
1916
odoo 14: override controller to add more fields in Odoo SignUp form āđāļāđ‰āđ„āļ‚āđāļĨāđ‰āļ§
2
āļž.āļ„. 24
5164
Override create method with sudo() āđāļāđ‰āđ„āļ‚āđāļĨāđ‰āļ§
1
āđ€āļĄ.āļĒ. 24
579