跳至內容
選單
此問題已被標幟
1 回覆
5301 瀏覽次數

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.

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
7月 16
3855
1
3月 17
6779
3
3月 24
12551
1
11月 22
3943
1
6月 17
12054