Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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()
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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 3/11/13, 6:42 AM|
|Seen: 7266 times|
|Last updated: 7/22/16, 9:39 AM|