Hi, im trying to modify the model website.track by adding a many2one field , this field have to pick a contact depending on some URL parameters.
To do that I have inherited the website.track model and added a function. To test the function I used a button to trigger it and works fine. The problem starts when I try to override the create method to trigger the function everytime a record is created. I dont understand why the create function is not doing anything even the log doesnt show up.
Any help is welcome
Here is mi code:
import logging
from odoo import fields, models, api
logger = logging.getLogger(__name__)
class visita(models.Model):
_inherit = 'website.track'
partner_id = fields.Many2one(comodel_name = 'mailing.contact',string='visitante')
@api.depends("url")
def reconoce(self):
for a in self:
var = a.url
if "?" in var:
try:
var2 = int(var[var.find('?')+1:var.find('%')])
a['partner_id'] = self.env['mailing.contact'].browse(var2) #Code for get an Id from the url
except:
a['partner_id'] = False
@api.model
def create(self,vals_list):
logger.info("TESTING FUNCION CREATE ")
result = super(visita, self).create(vals_list)
result.reconoce()
return result