Odoo Help

0

0
4 答案
2
头像

Pawan Kumar Sharma 印度

--Pawan Kumar Sharma--
SunArc Technologies
8827
| 6 3 7
Gangashahar(Bikaner), 印度
--Pawan Kumar Sharma--


Pawan Kumar Sharma 印度
2018/1/24 上午6:55

I already added this, but it's not work for me. Your solution from old api link, i already seen this link

_sql_constraints = [

('rental_manag_location_uniq', 'unique(location_id)', 'Location ID must be unique !'),

]

1 备注
Nikhil Krishnan 阿拉伯联合酋长国
2018/1/24 上午6:57

Try it in new database, you can get it,

0
头像

Nikhil Krishnan 阿拉伯联合酋长国

--Nikhil Krishnan--
10853
| 7 7 10
Sharjah, 阿拉伯联合酋长国
--Nikhil Krishnan--

-- Nikhilkrishnan --

Exploring new ways in odoo..!
And want to become a key to the new odoo trends.

-> Odoo Consultancy,
-> Functional and Technical Consultant,
-> Requirement Collection and Analysis,
-> Module Customization,
-> Odoo ERP Community Contributor,
-> Handling ERP/Odoo projects,
-> ERP Workshop Facilitator.
Feel happy working with best and good supporting team.

#PITS Family

Nikhil Krishnan

nikhilkrishnan0101@gmail.com

Nikhil Krishnan 阿拉伯联合酋长国
2018/1/24 上午6:50

Hai Pawan Sharma, 

_sql_constraints = [        ('name_uniq', 'UNIQUE (name)',  'You can not have two users with the same name !')    ]

'name_uniq' is constraint name give any name.(no need to define)

Example _constraints:-

    def _check_name(self, cr, uid, ids, context=None):
        for val in self.read(cr, uid, ids, ['name'], context=context):
            if val['name']:
                if len(val['name']) < 6: 
                   return False       

            return True

    _constraints = [        (_check_name, 'Name must have at least 6 characters.', ['name'])    ]

Note: Based on the above example in the records name field any duplicate record or name field less than 6 character then remove the records and add the constraints in python restart the server, update the module then only it works.

0
Sehrish 巴基斯坦
2018/2/14 上午3:42
 _sql_constraints = [
('value_campus_studenttype_policyfor_uniq', 'unique (campus_id,student_type,policy_for)', 'Record for this Campus and Student Type and Policy are already exists !')
]

Try this one

提问
Keep Informed
1 关注者(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now