通用問題
模型名變更
字段變更
方法名變更
方法參數變更
xml數據結構定義變化
xml的id變更
view視圖變化,導致xpath路徑出差
template結構變化,,導致xpath路徑出差,或者id不存在
升16問題
前端owl的架構變化
升17問題
前端
標簽棄置、改動:
attrs棄置
例
attrs="{'invisible':?['|',?'&',?('is_company','=',?True),('parent_id',?'=',?False),('company_name',?'!=',?False),('company_name',?'!=',?'')]}"
可變為
?invisible="((is_company?and?not?parent_id)?or?company_name)?and?company_name?!=?''"
【原attrs內的'='在新邏輯里為==:'a','=','123' ??a=='123'】
states棄置
例
states="pending,error"
可變為
?invisible=“state not in ['pending','error'] ”
<attribute>標簽改動
例
<attribute name="attrs">{'invisible': [('is_system', '=', False)]}</attribute>
可變為
<attribute name="invisible">not is_system</attribute>
res.partner模塊刪除gender性別字段
stock庫存模塊有問題,安裝之后有時候打開設置會報錯
運行當中會莫名報錯NameError: name 'GEOIP_EMPTY_COUNTRY' is not defined
mail.template 去掉了字段report_template,report_name
看板視圖取消了quick_add屬性
web/views/graph/colors.js 改到了web/core/colors/colors.js
ir.ui.view模型取消了field_parent字段
odoo.exceptions 去掉了Warning異常處理
模版 id=“portal_layout”中去掉了<div class="o_portal_my_security mt-3">這個div
原div<div class="row justify-content-between mt-4">下的布局移動到了 模版id=“side_content
”下面
<button icon="fa-code">按鈕需加入title以及class="oe_stat_button" 否則日志會報提醒
例
<button icon="fa-code" type="object" ?title="導出 xml 源" class="oe_stat_button" name="export_xml_source" />
設置 res_config_settings_view_form試圖 新增設置視圖邏輯變更
(源碼搜索 ref="base.res_config_settings_view_form" 可查看新設置視圖邏輯)
例:
<div class="..." data-string="Anodoo Develop" string="Anodoo Develop" >
<div id="develop_setting">
<h2>開發設置</h2>
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box" id="default_is_replace" title=" 默認是否替換開發目錄">
...........
</div>
</div>
</div>
</div>
變為
<app data-string="Anodoo Develop" string="開發設置" name="Anodoo" groups="base.group_system" ?>
<block title="開發設置" name="develop_setting">
<setting string="默認是否替換開發目錄" ?help="默認是否替換開發目錄" ?????????id="default_is_replace">
..........
</setting>
</block>
</app>
Manifest文件
- 版本:不再支持4位版本號,精簡掉最開頭的大版本號,格式只能為`x.y`, `x.y.z`。比如原來為 16.24.03.30,現在要將大版本號去掉,使用?24.03.30
- hook變化,只有一個env參數
def post_init_hook(env) def pre_init_hook(env) def uninstall_hook(env)
.py后臺python開發文件
- Fields定義:不再支持 states?處理只讀與否,一般放到 xml?中處理特殊的只讀屬性
- name_get: 改為? _compute_display_name
- 模型變更:具體業務模塊中比較。核心的如?
mail.channel 改為 discuss.channel
.xml界面文件升級,可在rng中查看
- 關鍵屬性:?Since 17.0, the "attrs" and "states" attributes are no longer used.?直接使用py表達式 invisible="is_mega_menu != True"
- 設置Block中的中調整:多用app,setting標簽
- 不在root級別支持 groups標簽,可直接刪除,在xml內部fields等定義中處理
- widget提級:widget提級,可以不綁定在field直接使用,比如 tree中直接與數據無關的使用
- tree視圖:?增加 open_form_view,可以特殊處理查看詳情。可以直接掛載widget,不被field包裹。不可見調整為 column_invisible。
- graph視圖:柱圖增加處理 cumulated_start
- calendar視圖:quick_add 變為 quick_create 且可以通過quick_create_view_id指定視圖
- pivot視圖:無變化
- search視圖:無變化
.js前端升級owl2
詳情參考?官方文檔?Framework Overview — Odoo 17.0 documentation
細節較多,可參考官方市場 app_web_widget_ztree?模塊,基本全面應用新 js?規范
Many2One Hierarchy Parent Child M2o Selector, zTree 樹狀下拉選擇器 | Odoo Apps Store
- web端全面使用owl2,es規范
- website端可使用舊snippets,同時可以使用owl
- 取消registerPatch,統一用類的 patch處理。如:?patch(類.prototype, {xxx})
- patch原類無需給新命名,但要自行處理相關依賴級別
Odoo Attrs 替代品
由于 Odoo 在 v17 中將 attrs 更改為(不再有 attrs),我創建了這個小腳本來幫助您直接將 XML 文件中的所有 attrs 替換為 XML 中的相應屬性。
依賴關系
只需安裝
pip install beautifulsoup4 lxml
或者
pip install -r requirements.txt
用法
啟動Python腳本
python3 replace_attrs.py
它會詢問您根目錄以檢查XML文件。您可以給出項目的絕對路徑。
如果沒有給出參數,它將使用當前目錄。
對于每個文件,腳本將詢問您是否要將所有attrs=and替換為標簽中states=的相關attrs(invisible,readonly,required,column_invisible) - (不可見串聯或創建)(對于每個標簽的所有實例)。states
除非您在開頭選擇“y”進行自動替換(不要詢問每個文件)