Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
11 Відповіді
8828 Переглядів

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.

Related Posts Відповіді Переглядів Дія
0
січ. 17
4045
0
бер. 20
2818
4
лист. 19
5784
1
серп. 19
4874
2
лип. 25
4776