This question has been flagged

I am just a newbie in Odoo. I am creating a custom module for Odoo 11. I want to add a new link as email payslip in hr payroll module . So when admin will navigate to an individual's Payslip, in the action I want to add a new option called email payslip. So when it will be clicked then it will send an email to the employee.

So to achieve this I have made my custom module named as email payslip.

The code is like this

__init__.py

from . import models


__manifest__.py

{
    'name': 'Email Payslip',
    'summary': """This module will send email with payslip""",
    'version': '10.0.1.0.0',
    'description': """This module will send email with payslip""",
    'author': 'Test',
    'company': 'test',
    'website': 'https://test.com',
    'category': 'Tools',
    'depends': ['base'],
    'license': 'AGPL-3',
    'data': [
        'views/email_payslip.xml',
    ],
    'demo': [],
    'installable': True,
    'auto_install': False,
}

Models __init__.py

from . import email_payslip

Models email_payslip.py


from odoo import api, fields, models, tools, _
 
class EmailPayslip(models.Model):
#print 'sdabhd'
_name = 'email.payslip'
name = fields.Char(string="Title", required=True)
description = 'Email Payslip'

EmailPayslip()

Views email_payslip.xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<act_window id="email_payslip" src_model="hr.payslip" res_model="hr.payslip.line"  name="Email Payslip"/>
</odoo>

The above code shows the email payslip menu in the action but I don't think its right way. Also when I am doing click on the link its showing the employee payslip record.

So can someone help me here? What will be the right approach to achieve this? Any help and suggestions will be really appreciable.


Avatar
Discard
Best Answer

Hello @kshirod,

I would suggest you that there is no need to create the new object i.e _name = 'email.payslip'. You can use the base functionality.

You can also have the reference of below attached Screenshot :-



Regards,




Email: odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   

Avatar
Discard