İçereği Atla
Menü
Bu soru işaretlendi
11 Cevaplar
8833 Görünümler

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
Avatar
Vazgeç
En İyi Yanıt

Hello

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


Thanks

Avatar
Vazgeç

he already given the action for the menu

En İyi Yanıt

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

Avatar
Vazgeç
Üretici En İyi Yanıt

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>

Avatar
Vazgeç

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

Üretici

'depends': [

'base',

'hr',

'hr_contract',

'hr_payroll',

],

here is my _manifest_.py

Üretici

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 ?

Üretici

yes in my module.py defined like

class hr_payroll_reports(models.Model):

name = 'hr_module.reports'

_description = 'Reports'

Üretici

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 ?

Üretici

yes of course

Üretici

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.

İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Oca 17
4051
0
Mar 20
2829
4
Kas 19
5787
1
Ağu 19
4875
2
Tem 25
4778