2017-08-28 141 views
2

我想創建一個子菜單到工資模塊。嘗試了很多方式,但我不能做到這一點。odoo10添加子菜單到另一個模塊

我在論壇中發現這個代碼,但它不工作。

<menuitem id="menu_test" parent="hr_payroll.menu_hr_payroll_root" name="Test Module Parent"/> 
<menuitem id="menu_test_child" parent="menu_test" name="My Menu" action="action_view_hr_module_reports_form"/> 

員工工資單

工資單批次

配置

Salary Structures 
Salary Structures Hierarchy 
Salary Rules 
Contribution Registers 

這些都是在工資默認子菜單,我想添加一個新的報告菜單。我怎樣才能做到這一點?

有人可以幫助我嗎?謝謝。

+1

你是什麼意思「它不工作」?嘗試使用它時是否有任何錯誤信息?你鏈接的代碼看起來應該很好,只要你有一個爲action_view_hr_module_reports_form定義的動作。查看[Actions Documentation](http://www.odoo.com/documentation/10.0/reference/actions.html)和/或核心代碼中的一些示例以獲取更多詳細信息。爲了幫助我們,我們需要知道你正在得到什麼錯誤。 – travisw

回答

0

這裏是我的行動,

<record id="action_view_hr_module_reports_form" model="ir.actions.act_window"> 
      <field name="name">Reports</field> 
      <field name="res_model">hr_module.reports</field> 
      <field name="view_type">form</field>  
      <field name="view_mode">list,form</field> 
     </record> 

和Python文件,

class hr_payroll_reports(models.Model): 
    name = 'hr_module.reports' 
    _description = 'Reports' 

,並給了我這個錯誤,

無效的型號名稱u'hr_module.reports'在行動定義。

+0

我找到了解決方案,我的錯誤是類名hr_payroll_reports應該像HrModuleReports,我認爲odoo有一些類名稱的方法,它分開大寫字母,並把「。」在信件之間。所以odoo可以通過名稱找到方法。 –

相關問題