跳至内容
菜单
此问题已终结
11 回复
8848 查看

Hi everyone,

I am trying to create a sub-menu to Payroll Modules. Tried so many way but i cant make it.

I found this code in forum but it is not working.

<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"/>
Employee Payslips
Payslips Batches
Configuration
形象
丢弃
最佳答案

Hello

The issue is you didn't define any action in menuitem..iN ODOO10 you have to assign action in menuitem.


Thanks

形象
丢弃

he already given the action for the menu

最佳答案

Hi,

The code you have given to create the menu is correct. I think you may didn't have defined the action for the menu as well as corresponding views on clicking the menu. If you not defined the action "action_view_hr_module_reports_form" and the view, please do it , then you can see the menu.

Thanks

形象
丢弃
编写者 最佳答案

Defined like that, but still gives me an error "External ID not found..."


<record id="view_hr_module_reports_tree" model="ir.ui.view">

            <field name="name">hr_module.reports.tree</field>

            <field name="model">hr_module.reports</field>

            <field name="arch" type="xml">

                <tree string="Payslips Batches">

                    <field name="name"/>

                    <field name="date_start"/>

                    <field name="credit_note"/>

                    <field name="state"/>

                </tree>

            </field>

        </record>

        

        <record id="action_view_hr_module_reports_form" model="ir.actions.act_window">

            <field name="name">Employee Payslips</field>

            <field name="res_model">hr_module.reports</field>

            <field name="view_type">form</field>

            <field name="view_id" ref="view_hr_module_reports_tree"/>

        </record>

形象
丢弃

Check that you mention the inherited module name in your manifest file.

编写者

'depends': [

'base',

'hr',

'hr_contract',

'hr_payroll',

],

here is my _manifest_.py

编写者

ParseError: "External ID not found in the system: hr_module.action_view_hr_module_reports_form" while parsing /home/dev1/odoo-10.0/custom_addons/hr_module/views/payroll_payslips_view.xml:5, near

<menuitem id="menu_test_child" parent="menu_test" name="My Menu" action="action_view_hr_module_reports_form"/> gives me this error

try to change to tree instead of form,

<field name="view_type">tree</field>

and did you have defined the model , hr_module.reports ?

编写者

yes in my module.py defined like

class hr_payroll_reports(models.Model):

name = 'hr_module.reports'

_description = 'Reports'

编写者

here is my full code,

<data>

<menuitem id="menu_test" parent="hr_payroll.menu_hr_payroll_root" name="Test Module Parent"/>

<record id="view_hr_module_reports_tree" model="ir.ui.view">

<field name="name">hr_module.reports.tree</field>

<field name="model">hr_module.reports</field>

<field name="arch" type="xml">

<tree string="Payslips Batches">

<field name="name"/>

<field name="date_start"/>

<field name="credit_note"/>

</tree>

</field>

</record>

<record id="action_view_hr_module_reports_form" model="ir.actions.act_window">

<field name="name">Employee Payslips</field>

<field name="res_model">hr_module.reports</field>

<field name="view_type">tree</field>

<field name="view_id" ref="view_hr_module_reports_tree"/>

</record>

<menuitem id="menu_test_child" parent="menu_test" name="My Menu" action="action_view_hr_module_reports_form"/>

</data>

models.py

class hr_payroll_reports(models.Model):

name = 'hr_module.reports'

_description = 'Reports'

name = fields.Char(required=True, readonly=True, states={'draft': [('readonly', False)]})

date_start = fields.Date(string='Date From', required=True, readonly=True)

credit_note = fields.Boolean(string='Credit Note', readonly=True,

states={'draft': [('readonly', False)]},

help="If its checked, indicates that all payslips generated from here are refund payslips.")

and gives me this error

Model not found: hr_module.reports

Error context:

View `hr_module.reports.tree`

[view_id: 1114, xml_id: n/a, model: hr_module.reports, parent_id: n/a]

None" while parsing /home/dev1/odoo-10.0/custom_addons/hr_module/views/payroll_payslips_view.xml:6, near

<record id="view_hr_module_reports_tree" model="ir.ui.view">

<field name="name">hr_module.reports.tree</field>

<field name="model">hr_module.reports</field>

<field name="arch" type="xml">

<tree string="Payslips Batches">

<field name="name"/>

<field name="date_start"/>

<field name="credit_note"/>

</tree>

</field>

</record>

py file mentioned in init ?

编写者

yes of course

编写者

I found the solution, my mistake is class name hr_payroll_reports should be like HrModuleReports, i think in odoo has some method for class name and it is seperating capital letters than put dot between letters. So odoo find and use methods something like that.

相关帖文 回复 查看 活动
0
1月 17
4054
0
3月 20
2841
4
11月 19
5793
1
8月 19
4877
2
7月 25
4787