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

I have developed a new addon to add new fields into "crm.lead" model. Also trying to update import functionality for leads, i.e, system will skip duplicate lead import by checking it's name attribute (Label is "Opportunity" in view). Please view my code attached,

class MyCustomModule(models.Model):    
    _inherit = "crm.lead"
        
    customfield1 = fields.Char("My Custom Field 1")     customfield2 = fields.char("My Custom field 2")    
   
    @api.model
    def create(self, vals):
        context = dict(self._context or {})
        valCount = self.search_count([('name''='vals.get('name'))])
        if valCount == 0:
            return super(Lead, self.with_context(contextmail_create_nolog=True)).create(vals)
        else:
            return False

How to solve this issue.

Avatar
Discard
Author Best Answer

Solved it :)
"else" part in "create" method shouldn't contain a Boolean return, instead it should return the model object.

Avatar
Discard
Related Posts Replies Views Activity
1
Apr 18
5443
2
May 25
705
4
May 25
4049
2
Apr 25
803
1
Aug 24
1639