I want to remove
_sql_constraints (database level).
For example in account_invoice.py there is a constraints on number field. Now I want to remove it.
Can anyone have idea how to deal with this?
With the following steps I was able to remove SQL constraints in version 6.0 (but it should also work for v7.0):
- Remove SQL constraint in Python code
- 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
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!'), ] account_invoice()
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!'),] sale_order()
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 3/11/13, 6:42 AM|
|Seen: 6309 times|
|Last updated: 7/22/16, 9:39 AM|