How Can We Help?

使用 Openupgrade 升級 Odoo 9.0 升級流程篇

You are here:
< All Topics

這篇教學是用來記錄使用 OpenUpgrade(.238)升級 Odoo 8.0(.237)至 9.0(.239)的升級流程

需先移除使用者的 Home Action & Dashboard Report

備份未升級的資料庫(.237)到 OpenUpgrade(.238)
ssh 192.168.1.237

Dump
pg_dump GAPL -U cewolf -f GAPL.sql

SCP
scp GAPL.sql cewolf@192.168.1.238:~

Copy Image FileStore
sudo su - root
cd /var/lib/odoo/.local/share/Odoo/filestore
tar zcvf odoo9_filestore.tar.gz ./GAPL/
scp odoo9_filestore.tar.gz cewolf@192.168.1.239:~
logout

Stopping Odoo
sudo service odoo stop
OpenUpgrade 還原 Odoo 8.0 的檔案
ssh 192.168.1.238

PSQL Restore Database
psql -U cewolf -d Clone < GAPL.sql

Restore
/home/cewolf/.local/share/Odoo/filestore/
使用 DB owner 執行下列語法(此處是使用 cewolf )
/usr/bin/odoo.py -d GAPL --update=all
OpenUpgrade Server 進行升級,並將套件更新至最新版,減少出錯的機率
sudo apt-get update
sudo apt-get -y upgrade
sudo service odoo start
移除無法正常升級的模組,部分建議先行移除,升級完畢後再重新安裝

要先按『更新模組列表』一次

直接移除

im_chat:
會造成升級後系統 Layout 破損,無法正常使用

custom_filter_tabs:
已內建此功能

c2c_period_yyyymm:
9.0 好像取消 Period 了

wk_base_partner_patch:
新版 MOB 模組疑除此模組了

account_invoice_zero_autopay:
無 9.0 版可用

account_refund_invoice_fix:
無 9.0 版可用

account_refund_original:
無 9.0 版可用

report_xls:
無 9.0 版可用
需於 mis_builder 中的 __openerp__.py,移除相依性,再移除

先移除,再重新安裝

Disable force availability button
Mass Editing
MIS Builder
更新模組
sudo service odoo stop
sudo su - odoo -s /bin/bash
vi /opt/odoo_apps/server/install/openerp-server.conf (非必要)
/usr/bin/odoo.py -d Clone --update=all
進行 OpenUpgrade 升級
cd /var/tmp/openupgrade/9.0/server/
rm -f migrate.py
wget https://raw.githubusercontent.com/OpenUpgrade/OpenUpgrade/HEAD/scripts/migrate.py
python migrate.py --config=/etc/odoo/openerp-server.conf --database=Clone --run-migrations=9.0
檢查 Migration Log
檔案位置
/var/tmp/openupgrade/migration.log

 

如果 Migration Log 最後幾行顯示的是(整個流程約需 20 個小時以上)

2016-02-26 11:34:15,528 23380 INFO Hanyu_migrated openerp.modules.loading: Modules loaded.
2016-02-26 11:34:15,531 23380 INFO Hanyu_migrated openerp.models: Computing parent left and right for table ir_ui_menu...
2016-02-26 11:34:15,720 23380 INFO Hanyu_migrated openerp.models: Computing parent left and right for table stock_location...
2016-02-26 11:34:15,738 23380 INFO Hanyu_migrated openerp.service.server: Initiating shutdown
2016-02-26 11:34:15,738 23380 INFO Hanyu_migrated openerp.service.server: Hit CTRL-C again or send a second signal to force the shutdown.

據經驗這表示已經升級完成了!

After Migration

好不容易完成升級了,接下來需要把升級完成的資料庫備份並轉移到 Odoo 9 的環境下

根據目前的經驗,剛升級完成的資料庫無法使用 Odoo 內建的 Restore 還原

必須使用 PSQL 還原後,再透過 odoo 的 –update=all 指令進行完整升級(參照 After migration

備份升級後的資料庫與 FileStore 到 Odoo 9.0(.239)
Dump Database
pg_dump Clone_migrated -U cewolf -O -f GAPL_migrated.sql
pg_dump Clone_migrated -U cewolf -f GAPL_migrated.sql
scp GAPL_migrated.sql cewolf@192.168.1.239:~
Copy Image FileStore
sudo su - root
cd /var/lib/odoo/.local/share/Odoo/filestore
tar zcvf odoo9_20170408.tar.gz ./Clone_migrated/
scp odoo9_20170408.tar.gz cewolf@192.168.1.239:~
exit
於 Odoo 9.0(.239) 進行還原
Restore Database
psql -U cewolf -d GAPL < GAPL_migrated.sql

Restore FileStore
sudo su
cp odoo9_20170408.tar.gz /home/cewolf/.local/share/Odoo/filestore/
cp odoo9_20170408.tar.gz /var/lib/odoo/.local/share/Odoo/filestore
cd /home/cewolf/.local/share/Odoo/filestore/
cd /var/lib/odoo/.local/share/Odoo/filestore/
tar zxvf odoo9_20170408.tar.gz
mv Clone_migrated GAPL
rm -f odoo9_20170408.tar.gz
exit
使用 DB owner 執行下列語法(此處是使用 cewolf )
/usr/bin/odoo.py -d GAPL --update=all

看到了這行表示更新完成了
2017-04-21 01:57:59,916 1682 INFO GAPL openerp.modules.loading: Modules loaded.
2017-04-21 01:57:59,923 1682 INFO GAPL openerp.models: Computing parent left and right for table ir_ui_menu...
2017-04-21 01:58:00,086 1682 INFO GAPL openerp.addons.base.ir.ir_http: Generating routing map

接著按下 Ctrl-C 結束服務
 資料庫升級後修正
ALTER TABLE product_price_history ALTER COLUMN product_id SET NOT NULL;
ALTER TABLE account_tax ALTER COLUMN tax_group_id SET NOT NULL;
update account_move_line set date_maturity = create_date where date_maturity is null;
ALTER TABLE account_move_line ALTER COLUMN date_maturity SET NOT NULL;
update account_chart_template set currency_id = 145 where currency_id is null;
ALTER TABLE account_chart_template ALTER COLUMN currency_id SET NOT NULL;
update account_chart_template set transfer_account_id = 1;
ALTER TABLE account_chart_template ALTER COLUMN transfer_account_id SET NOT NULL;
ALTER TABLE stock_picking ALTER COLUMN location_id SET NOT NULL;
ALTER TABLE stock_picking ALTER COLUMN location_dest_id SET NOT NULL;
update delivery_carrier set name = '快遞-運費' where id = 7;
update delivery_carrier set partner_id = 1 where id = 7;
update delivery_carrier set product_id = 6005 where id = 7;
ALTER TABLE delivery_carrier ALTER COLUMN product_id SET NOT NULL;
ALTER TABLE delivery_carrier ALTER COLUMN partner_id SET NOT NULL
重新啟動 odoo 服務
/usr/bin/odoo.py

ERP 內部設定

1. 更新 MOB 模組,並修正 Order Mapping 資料表

首先需要手動安裝 bridge_skeleton 模組,接著一併更新 magento_bridge 模組

新版的 MOB 將原本的 magento_orders 轉移至 wk_order_mapping

目前 wk_order_mapping 中的 erp_order_id 是關鍵,erp_order_id 對應的 sale_order 中的 ecommerce_channel 也需要同步修改為 magento 才行

update magento_orders set mage_increment_id =replace(mage_increment_id,'100000','')
update magento_orders set mage_increment_id =replace(mage_increment_id,'10000','')
update magento_orders set mage_increment_id =replace(mage_increment_id,'10001','')
update sale_order set ecommerce_channel = 'magento' where channel = 'magento';
alter table magento_orders add ecommerce_order_id int;
update magento_orders set ecommerce_order_id = cast(mage_increment_id as int);
alter table magento_orders rename column order_ref to erp_order_id;
alter table magento_orders rename column mage_increment_id to name;
alter table magento_orders drop column oe_order_id;
alter table magento_orders drop column instance_id;
alter table magento_orders alter column ecommerce_order_id SET NOT null;
alter table magento_orders alter column erp_order_id SET NOT null;
drop table wk_order_mapping;
alter table magento_orders rename to wk_order_mapping

sudo su postgres(此處可能要登入 DB Owner "odoo")
psql
\connect GAPL
\d+ wk_order_mapping;
create sequence wk_order_mapping_seq;
select MAX(id) from wk_order_mapping;
select setval('wk_order_mapping_seq', 1, true);
select setval('wk_order_mapping_id_seq',1,true);
select nextval('wk_order_mapping_id_seq');
select currval('wk_order_mapping_id_seq');
2. 關閉報錯的 View

『設定』/『用戶介面』/『檢視』

搜尋 res.partner.opt_out.search(ID 為 1194),關閉即可

3. 重新設定新建客戶預設值

升級後新建客戶會發現在『會計分頁』中,預設的『應收科目』與『應付科目』不是不見了就是錯了

原因為原先的欄位名稱修改了

需要用 Admin 登入,到『設定』/『技術』/『動作』/『使用者定義之預設值』,搜尋 property_account 後修改

應收科目:property_account_receivable => property_account_receivable_id

應付科目:property_account_payable => property_account_payable_id

也可以用 SQL 來更新

update ir_values set name = 'property_account_receivable_id' where name = 'property_account_receivable';
update ir_values set name = 'property_account_payable_id' where name = 'property_account_payable'
4. 補完會計設定

Odoo 9.0 在會計模組作了相當大程度的修改

1. 可先至會計模組點右上角進度條補齊設定

 

2. 登記客戶付款時沒有付款方式

要去『會計』/『設定』/『會計』/『帳簿』

點進去後,到『進階設定』個別設定

可成為收款方式:勾選『Debit Methods』

可成為付款方式:勾選『付款方法』

注意!不要設定『貨幣』選項,除非是外幣帳戶!

4. 設定 Inter-Banks Transfer Account

Odoo 9 的設定多了這個必填的設定,主要是用來處理流動資金帳戶間的金流

到『會計』/『設定』/『設定』=> 『銀行和現金』/『設定』/『Inter-Bank Transfer Account』新增

名稱:Liquidity Transfers

代碼:隨意(如 6500)

類型:Current Assets

允許調節:勾選

5. 移除 Customized View

使用 SQL 來更新

truncate ir_ui_view_custom;

 

6. 移除 User 的 Home Action

使用 SQL 來更新

update res_users set action_id = null where action_id is not null

7. 補齊產品分類設定

升級後,產品內的『成本計算方式』 移至『產品分類』下

產品分類內多了『存貨估價』,原先設定好的『入庫科目』『庫存輸出科目』被清空

所以需重新設定,到『銷售』/『設定』/『產品』/『產品分類』

『入庫科目』:6100

『出庫科目』:6200

『成本計算方式』:Real Price

『存貨估價』:Perpetual (automated)

可使用 Mass Editing 一次大量設定

Model:product.category

Field 1:property_stock_account_input_categ_id

Field 2:property_stock_account_output_categ_id

Field 3:property_cost_method

Field 4:property_valuation

7. 使用 Database Cleanup

 

8. 修改 Database Owner
reassign owned by cewolf to odoo
9. 刷新現在的版本,並更新全模組
sudo service odoo stop
sudo su - odoo -s /bin/bash
/usr/bin/odoo.py -d GAPL --update=all
10. 刪除 Mass Editing 的 Action 紀錄

於『設定』/『動作』/『動作』中搜尋 Mass Editing,將除了 Mass Editing 以外的設定刪除

11. 『會計』/『設定』/『會計』無法正常顯示

於『設定』/『用戶介面』/『選單項目』中搜尋『會計』

參考資料:

After migration

Automated migration script

Db migrated to odoo 8, update stuck at computing ir_ui_menu parent_left and parent_right

Table of Contents