Odoo Help

Andreas Brueckl
On 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!'),

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 ?


Versão Integral, Anabela Damas
on 1/29/14, 9:23 AM

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

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

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

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

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

fadhel salhi
on 3/29/14, 5:05 PM
Francesco OpenCode
On 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!'),]


About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 3/11/13, 6:42 AM
Seen: 11461 times
Last updated: 9/30/17, 6:21 AM