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:
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
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
Post a Comment