Created
July 18, 2014 20:58
-
-
Save mrsarm/4699a24ca1b0bc12eb84 to your computer and use it in GitHub Desktop.
OpenERP / Odoo Script - Adds Partner ID constraints in those columns without FK
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