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 have over 100,000 partners that need to have their Account Payable and Account Receivable accounts changed.
How do I do this via SQL?
WARNING: Updating the PostgreSQL database via SQL is considered a very advanced technique and should never be done unless you have a complete understanding of the Odoo schema and business logic, and you perform extensive testing on what you are attempting to do.
AP and AR accounts for partners are stored in the ir_property table.
The field database id's are 1102 (AR) and 1104 (AP). If you manually set the accounts and search where res_id = 'res.partner,DATABASE_ID_OF_PARTNER' you can see the two relevant rows and verify the field id's for yourself.
You need to know the database id's of your AP and AR accounts, and once you do, for each partner you run the following SQL statements
1. Delete existing AR and AP account settings for every partner:
delete from ir_property where name in ('property_account_payable','property_account_receivable');
The next two statements need to be run for EVERY partner:
2. Add an AR account to a partner:
insert into ir_property (create_uid,create_date, write_date,write_uid, name,type,company_id,fields_id,value_reference,res_id) VALUES (1,current_date,current_date,1,'property_account_receivable','many2one',1,1102,'account.account,db_id_of_ar_account','res.partner,db_id_of_partner');
3. Add an AP account to a partner:
insert into ir_property (create_uid,create_date, write_date,write_uid, name,type,company_id,fields_id,value_reference,res_id) VALUES (1,current_date,current_date,1,'property_account_payable','many2one',1,1104,'account.account,db_id_of_ap_account','res.partner,db_id_of_partner');
TIP: Export all of the database id's into a CSV file, prepend the relevant SQL, replace the linefeed character with the end quote and a semicolon, save the result as a *.sql file and import into the database.
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
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: 7/3/14, 5:55 PM|
|Seen: 1254 times|
|Last updated: 3/16/15, 8:10 AM|