Skip to Content
Menu
This question has been flagged
1 Reply
3724 Views

in addons/website/models/ir_http.py, I have:

class ModelConverter(ir.ir_http.ModelConverter):

def to_url(self, value):
return slug(value)
I would like to override the def to_url method in my module.
How can I do this?
I tried to write this in local_addons/my_app/addons/my_module/models/my_module_ir_http.py:
class ModelConverter(odoo.addons.website.models.ir_http.ir.ir_http.ModelConverter):

def to_url(self, value):
logger.info("_____________________Let's slugify!!!!" + repr(value))
logger.info("slugged: " + str(value.id))
return str(value.id)

But it doesn't seem to work.

Can you help? Thanks

Avatar
Discard
Best Answer

Hello Nicolas De Moreau,
Check below code. I hope it will help you.
No need to override class. Try below code.

from odoo.addons.website.models.website import slug

def my_custom_to_url(self, value):

    logger.info("_____________________Let's slugify!!!!" + repr(value))

    logger.info("slugged: " + str(value.id))

    return str(value.id)

odoo.addons.website.models.ir_http.ModelConverter.to_url = my_custom_to_url


Thanks

Avatar
Discard
Related Posts Replies Views Activity
2
Nov 24
1884
1
Aug 24
427
2
Nov 24
762
3
Oct 23
13197
2
Feb 23
1229