openerp 7 - Remove SQL constraint in OpenERP7 -


in openerp7, core module account has declaration account.invoice has, @ point, following declaration:

addons/account/account_invoice.py:343

_sql_constraints = [     ('number_uniq', 'unique(number, company_id, journal_id, type)', 'invoice number must unique per company!'), ] 

in module redefined account.invoice wanted remove constraint 2 different approaches:

  1. removing in init (account_invoice::init(self, pool, cr))

    def __init__(self, pool, cr):     super(account_invoice, self).__init__(pool, cr)     try:         cr.execute('alter table account_invoice drop constraint if exists account_invoice_number_uniq')     finally:         pass 
  2. replacing constraint

    _sql_constraints = [     ('number_uniq', 'check(1=1)', 'dummy check, true, used replace previous constraint'), ] 

however, when reinstall module in 2 declarations made, error (in pg logs) telling me constraint account_invoice_number_uniq not craeted unique key since there's repeated data.

how can prevent having such error? how can prevent system attempting create (first; then... replace/delete) constraint?

check below reference link remove sql constraint of parent class in odoo

click see reference remove sql constraint in odoo(formally openerp)


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -