Forked from mrsarm/openerp_add_partner_constraints.sql
Last active
August 29, 2015 14:07
-
-
Save hanovo/ea88be8f78421206a10f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* OpenERP / Odoo Script - Adds Partner ID constraints. | |
* | |
* Issue: | |
* Sometimes, OpenERP / Odoo defines foreign keys without constraints. | |
* This mainly happens with related fields with store=True, | |
* which create a column of integers without constraints. | |
* | |
* Author: Mariano Ruiz <[email protected]> | |
* Created: 2014-07-18 | |
* | |
* NOTE: If the script fails, verify if the BBDD has all the tables | |
* present here. Also you should be check if your database has more | |
* references to the partner table. | |
* If you execute this with ``psql`` command without ``-1`` argument | |
* (single transaction), only will be added those fkeys that | |
* currently not exist and the table exist. | |
*/ | |
ALTER TABLE account_invoice_line ADD CONSTRAINT account_invoice_line_partner_id_fkey FOREIGN KEY (partner_id) REFERENCES res_partner(id); | |
ALTER TABLE stock_picking ADD CONSTRAINT stock_picking_partner_id_fkey FOREIGN KEY (partner_id) REFERENCES res_partner(id); | |
ALTER TABLE account_move ADD CONSTRAINT account_move_partner_id_fkey FOREIGN KEY (partner_id) REFERENCES res_partner(id); | |
ALTER TABLE payment_mode ADD CONSTRAINT payment_mode_partner_id_fkey FOREIGN KEY (partner_id) REFERENCES res_partner(id); | |
ALTER TABLE hr_analytic_timesheet ADD CONSTRAINT hr_analytic_timesheet_partner_id_fkey FOREIGN KEY (partner_id) REFERENCES res_partner(id); | |
ALTER TABLE purchase_order_line ADD CONSTRAINT purchase_order_line_partner_id_fkey FOREIGN KEY (partner_id) REFERENCES res_partner(id); | |
ALTER TABLE sale_order_line ADD CONSTRAINT sale_order_line_partner_id_fkey FOREIGN KEY (order_partner_id) REFERENCES res_partner(id); | |
ALTER TABLE stock_move ADD CONSTRAINT stock_move_partner_id_fkey FOREIGN KEY (partner_id) REFERENCES res_partner(id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment