Odooers论坛

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Prevent Leads Duplicate

形象
odoo
1 备注
形象
丢弃
形象
odoo
-

have a look at this app - https://apps.odoo.com/apps/modules/13.0/crm_duplicates/ - possible to define any stored fields as soft duplicates (just to warn) or rigid duplicate (to restrict creation)

3 答案
0
形象
odoo
最佳答案

Hi,

As you are looking to do it from the user interface activate the debug mode and make sure that the module named(technical name) base_automation is installed in database.

Navigate to Settings -> Technical -> Automation -> Automated Action, here you can create a new record for this purpose, in the below example it is shown for preventing the duplicates in the field Email in crm.lead Model,


Give a name for the record let it be Prevent Duplicates in Lead, select the model as Lead/Opportunity, set trigger condition and in the action to do choose execute python code.

Python Code to add:

leads = model.search([('email_from', '=', record.email_from)])
if leads:
  raise Warning("Email Already Exists")


Click and save record, now when you create lead with duplicated email, it will raise warning like this,




Thanks

3 注释
形象
丢弃
形象
odoo
-

Is there any way, that I need to allow duplicates to prevent typing Extra Info every time and but I have to block the entering same name twice.

形象
odoo
-

I tried this but now any lead or opportunity gets that message even when there isn't a duplicate. using v14.

形象
odoo
-

Try as follows,
leads = model.search([('email_from', '=', record.email_from)m ('id', '!=', record.id])
if leads:
raise Warning("Email Already Exists")

0
形象
odoo
最佳答案

Hey guys!

I tried to follow these instructions here. 

I have a custom filed done with studio for product shortname. Name of the field is x_studio_category_shortname_3

I tried to create an automated action.

Match records with the following rule:
Category shortname
is set

Wathed field is - x_studio_category_shortname_3

Python code is:

category = model.search([('x_studio_category_shortname_3', '=', record.x_studio_category_shortname_3)])
if category:
    raise Warning("Category Already Exists")


The warning appears only when I try to delete the category shortname. 
My expectation is to raise a warning when the name is duplicated. What am I doing wrong?

I hope my explanation is not too confusing. 

形象
丢弃
0
形象
odoo
最佳答案

can make it for many field or must creat new recoerd for every field ?

1 备注
形象
丢弃
形象
odoo
-

How would someone edit this code to work with Odoo 16?

leads = model.search([('email_from', '=', record.email_from)])
if leads:
raise Warning("Email Already Exists")