Odoo Help

2 Answers

Andreas Brueckl

--Andreas Brueckl--

| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
3/11/13, 6:50 AM

With the following steps I was able to remove SQL constraints in version 6.0 (but it should also work for v7.0):

  1. Remove SQL constraint in Python code
  2. Manually remove the constraint in PostgreSQL using PgAdmin3

If you do not want to change the existing module, you can

  • Create a new module and
  • replace the SQL constraint with the value CHECK(1=1)

In your example you can create a new module and write:

class account_invoice(osv.osv):
    _inherit = "account.invoice"
    _sql_constraints = [
    ('number_uniq', 'Check(1=1)', 'Invoice Number must be unique per Company!'),
Versão Integral, Anabela Damas
1/29/14, 9:23 AM

Hello @Andreas Brueckl, If I have something like this: _sql_constraints = [ ('name_company_uniq', 'unique(name, company_id)', 'Tax Name must be unique per company!'), ] But I just want to remove the unique from name, do you know how should I do it ? To keep the company and remove the name from being unique ?


Andreas Brueckl
2/3/14, 4:46 AM

Just keep the name 'name_company_uniq' and replace the logic with 'unique(company_id)'.

Versão Integral, Anabela Damas
2/3/14, 7:54 AM

That is the way I try, but I have always an error in log, so I found an workaround. But thanks.

fadhel salhi
3/29/14, 5:05 PM

ca marche pas avec moi "check(1=1)"


Francesco OpenCode

--Francesco OpenCode--

| 6 8 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
3/11/13, 6:52 AM

Create you personal module. Inherith the account invoice class and set the _sql_constraints to null.

This is an example that I use to change the sale order _sql_constraints

class sale_order(osv.osv):

    _name = "sale.order"
    _inherit = "sale.order"

    _sql_constraints = [('name_uniq', 'unique(name, date_order)', 'Order Reference must be unique per Date!'),]

Ask a Question
Keep Informed
1 follower(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.

Odoo Training Center

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

Test it now