0

I am creating my first module in Odoo. The Odoo version is 11.00. So basically what I want is add a new option in Payslip Action called as email Salary Slip. So when clicking on that it will automatically send an email to the employee email.

So for that I have made my module folder structure like this

email_payslip [main folder]
 - __init__.py
 - __manifest__.py
|
|            - __init__.py 
 - Models - |
|            - email_payslip.py
|
|           
 - Views - email-payslip.xml

So for __init__.py the code is like this

from . import models

For __manifest__.py code is like this

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

in Models __init__.py the code is like this

from . import email_payslip

In email_payslip.py the code is

from odoo import fields, models, tools, api

In the views folder email_payslip.xml the code is this

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <record id="from_view_form" model="ir.ui.view">
            <field name="name">form.view.form</field>
            <field name="model">my.form</field>
            <field name="arch" type="xml">
                <form string="Form">
                    <button name="send_email" string="Send Email"
                        type="object" class="oe_highlight" />
                </form>
            </field>
        </record>

    </data>
</odoo>
NewUser
  • 12,713
  • 39
  • 142
  • 236
  • There isn't much business logic in email_payslip.py yet? Little hint: look into model `mail.template`. You can get a template in code by using `self.env.ref('xml-id-of-that-template')` and then call `send_mail()`. – CZoellner Apr 30 '19 at 14:19
  • @CZollner thanks for the hint. Can you share some code for this. I am really a newbie in odoo. – NewUser Apr 30 '19 at 15:26
  • [That's](https://github.com/odoo/odoo/blob/eb5e8d660a8e94849590537102ef4bc149c13562/addons/calendar/models/calendar.py#L162-L217) maybe a bit much, but hopefully understandable and original Odoo code. – CZoellner Apr 30 '19 at 15:58
  • What about the drop-down option which I want to show? For now it's not showing my option. – NewUser Apr 30 '19 at 16:01
  • You've never written something about a drop-down... – CZoellner Apr 30 '19 at 19:36
  • In the question you can check that I have written I want to add a new option in payslip action called as email salary slip. – NewUser May 01 '19 at 02:20
  • Thought a button, hmm never worked with payslips. – CZoellner May 01 '19 at 06:05
  • @CZoellner it will only send email to the employee, thats all. So basically what I need is when admin will click on that link it will send email to that selected employee. Here is another question in details what I have https://stackoverflow.com/questions/55949799/odoo-custom-module-add-new-action-to-hr-module – NewUser May 02 '19 at 10:06

0 Answers0