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(context, mail_create_nolog=True)).create(vals)
else:
return False
How to solve this issue.