Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4094 Lượt xem

Hi everyone, I'd like to constraint contact/company with same name,

I added this lines of code to /odoo/models.py , /odoo/addons/base/models/res_partner.py


_sql_constraints = [('name_uniq', 'unique (name)', 'The company name must be unique !'),

('email_uniq', 'unique(email)', ' Please enter Unique email no.')]       #: SQL constraints [(name, sql_def, message)]


a restart odoo in windows and in linux aswell, but constraint doesn't work, 

in what file I have to add this lines?

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

thank you Niyas, I upgraded the base module in App>Contacts>(3 point menu)>upgrade but it doesn't make any difference, also I did not see any duplicates in res_partners table. 

could you tell me from what path  I edit file module from the UI?

Have you a guide on how to develop custom module?


thank you so much I'm going crazy :)

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,


Did you upgrade the base module after adding the constrains ? If not upgrade the module and see whether it makes any difference.

Also the sql constrains will not work, if there is already duplicated names in the database.


NB: also it is not recommended to edit the original odoo source code, instead do it using a custom module or from user interface.


Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 12 24
1368
1
thg 3 24
2427
1
thg 6 23
12441
0
thg 1 23
3136
6
thg 9 20
29523