Hi,all:
I'm trying to avoid project name repeated while creating a project by using this code:
@api.constrains('name')
def check_info(self):
info_id = self.search([('name', '=', self.name)])
if len(info_id) > 1:
raise Warning('%s project name repeated!' % info_id)
It will warn me when I try to create a project when there is another project
with same as I created.
However,if a project named "Project_A"and its privacy is "followers" and I'm not invited,I
can still create a project named "Project_A" without receiving a warning,in fact I wanna avoid
creating this "Project_A" again.
So how can I update my code or do some configuration to meet the requirements?Thanks for your
answer
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
1798
Views
Search duplicates under the SuperUser (sudo):
@api.constrains('name')
def check_info(self):
info_id = self.sudo().search([('name', '=', self.name)])
if len(info_id) > 1:
raise Warning('%s project name repeated!' % info_id)
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
You can use method in the given answer as well as the sql constrains