Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Leaves manager notification to approve leave after manager approve (odoo 10)

Naroči se

Get notified when there's activity on this post

This question has been flagged
odoo10pycharm
1 Odgovori
5435 Prikazi
Avatar
marwa

I have a new module called new_leaves as I made some changes in hr.holidays module 
I have to approves one for the manager of the department and the other for leaves manager( I created a new user and I set his sittings as manager of leaves and an officer in employee category) , I want that the leaves manager receives a notification after manager approve for an employee leave I updated this function in my new module but it does not work , any help? 

class new_leaves(models.Model):
_inherit = 'hr.holidays'
state = fields.Selection([
('draft', 'To Submit'),
('cancel', 'Cancelled'),
('confirm', 'To Approve'),
('manager', 'Manager Approve'),
('hr_approve','HR Approve'),
('refuse', 'Refused'),
('validate1', 'Second Approval'),
('validate', 'Approved')
], string='Status', readonly=True, track_visibility='onchange', copy=False, default='confirm',
help="The status is set to 'To Submit', when a holiday request is created." +
"\nThe status is 'To Approve', when holiday request is confirmed by user." +
"\nThe status is 'Refused', when holiday request is refused by manager." +
"\nThe status is 'Approved', when holiday request is approved by manager.")

@api.multi
def _notification_recipients(self, message, groups):
""" Handle HR users and officers recipients that can validate or refuse holidays
directly from email. """
groups = super(new_leaves, self)._notification_recipients(message, groups)

self.ensure_one()
hr_actions = []
if self.state == 'manager':
app_action = self._notification_link_helper('controller', controller='/new_leaves/hr_approve')
hr_actions += [{'url': app_action, 'title': _('Approve')}]
if self.state in ['confirm', 'validate', 'validate1','manager','hr_approve']:
ref_action = self._notification_link_helper('controller', controller='/new_leaves/refuse')
hr_actions += [{'url': ref_action, 'title': _('Refuse')}]

new_group = (
'group_hr_holidays_manager', lambda partner: bool(partner.user_ids) and any(user.has_group('hr_holidays.group_hr_holidays_manager') for user in partner.user_ids), {
'actions': hr_actions,
})

return [new_group] + groups
and in controller file :

from odoo.addons.mail.controllers.main import MailController
from odoo import http

class Ra(http.Controller):

@http.route('/new_leaves/manager', type='http', auth='user', methods=['GET'])
def hr_holidays_validate(self, res_id, token):
comparison, record, redirect = MailController._check_token_and_record_or_redirect('hr.holidays', int(res_id), token)
if comparison and record:
try:
record.action_approve()
except Exception:
return MailController._redirect_to_messaging()
return redirect

@http.route('/new_leaves/refuse', type='http', auth='user', methods=['GET'])
def hr_holidays_refuse(self, res_id, token):
comparison, record, redirect = MailController._check_token_and_record_or_redirect('hr.holidays', int(res_id), token)
if comparison and record:
try:
record.action_refuse()
except Exception:
return MailController._redirect_to_messaging()
return redirect

​

0
Avatar
Opusti
Avatar
Thomas Blum
Best Answer

Hi marwa,

in case your question is still not answered, I extended hr.leave (not hr.holidays) like that:


from odoo import models, fields, api


class HRLeave(models.Model):

     _inherit = "hr.leave"

     @api.multi

     def action_approve(self):

          self.ensure_one()

          result = super(HRLeave, self).action_approve()

          self.env['mail.template'].browse(23).send_mail(self.id)

          return result


I also created a mail template with the email address of the hr officer in the "TO: " field. This template, in my case, is referenced in the database by id "23".

What's still necessary ist to make your module depend on "hr" in the __manifest.py__:

'depends': ['base','hr'],




Best regards


Thomas

0
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
How to know if current logged in user is the leaves manager (odoo 10) Solved
odoo10 pycharm
Avatar
Avatar
1
sep. 19
4555
Leaves Double validation( odoo 10) Solved
odoo10 pycharm
Avatar
Avatar
2
sep. 19
4590
Create schedule action For sending emails
odoo10
Avatar
Avatar
Avatar
2
jul. 25
6526
v16: unresolved reference 'odoo'
pycharm
Avatar
Avatar
Avatar
3
mar. 25
4348
How to send messages that are not shown in chatter? Solved
odoo10
Avatar
Avatar
Avatar
2
okt. 25
8847
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now