0

when i click on the action email payslip i am getting this error ValueError: : "'hr.payslip' object has no attribute 'action_email_payslip_send'" while evaluating 'action = records.action_email_payslip_send()'

manifest.py

'name': 'Emailpayslip',
'summary': """This module will send the payslip to the employee as pdf document""",
'version': '10.0.1.0.0',
'description': """This module will send the payslip to the employee as pdf document""",
'author': 'Pramod Kumar',
'company': 'Net Tantra Technology',
'website': 'http://www.nettantra.com',
'category': 'Human Resource',
'depends': ['base','hr_payroll','mail','web'],
'license': 'AGPL-3',
'data': [
    'views/emailpayslip.xml',
    'data/email_template_data.xml'
],
'demo': [],
'installable': True,
'auto_install': False,

models/emailpayslip.py

from odoo import fields, models, api, _ from odoo.exceptions import Warning

class Emailpayslip(models.Model):

_name = 'email.payslip'
_inherit = 'hr.payslip'
@api.multi
def action_email_payslip_send(self):
  self.ensure_one()
  template = self.env.ref(
    'Email_Payslip.email_template_payslip',
    False,
  )
  compose_form = self.env.ref(
    'mail.email_compose_message_wizard_form',
    False,
  )
  ctx = dict(
    default_model='hr.payslip',
    default_res_id=self.id,
    default_use_template=bool(template),
    default_template_id=template and template.id or False,
    default_composition_mode='comment',
    )
  return {
    'name': _('Compose Email'),
    'type': 'ir.actions.act_window',
    'view_type': 'form',
    'view_mode': 'form',
    'res_model': 'mail.compose.message',
    'views': [(compose_form.id, 'form')],
    'view_id': compose_form.id,
    'target': 'new',
    'context': ctx,
    }

init.py

from . import models

views/emailpayslip.xml

emailpayslip.xml

Error message Error Message

Pramod
  • 26
  • 1
  • 5
  • Could you make a [mcve] and include the relevant information in the question ([edit])? We're all volunteers here, and it's much easier for us to help you if all the relevant code is in the question and it's simplified as much as possible. – wizzwizz4 Jun 29 '19 at 06:55
  • And by "in the question" I mean text. – wizzwizz4 Jun 29 '19 at 06:55
  • 1
    Actually, scratch the [mcve]; this is fine. We just need it written as text, not images! Thank you. – wizzwizz4 Jun 29 '19 at 06:59

2 Answers2

0

Your problem is that you've got a hr.payslips object, but that method you're trying to call is only available one the Emails subclass.

Implement the attributes on the superclass instead.

wizzwizz4
  • 6,140
  • 2
  • 26
  • 62
  • Plz check this link:https://stackoverflow.com/questions/55949799/how-to-send-an-email-from-a-button-located-in-the-action-dropdown-of-an-odoo-11 – Pramod Jun 29 '19 at 07:17
  • I suggest you re-read that. It appears not to have this problem, though I'm no expert. – wizzwizz4 Jun 29 '19 at 07:19
0

In models/emailpayslip.py make some change. Just change the _name = 'hr.payslip'.It will work .

Pramod
  • 26
  • 1
  • 5
  • It is because you have added method in email.payslip and added server action in hr.payslip So hr.payslip, doesn't access that method and from action you can access methods of given model. – Mital Vaghani Jul 02 '19 at 07:05