Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

how to create the Scheduled Actions for timesheet attendance reporting module

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
ScheduledActions
2 Replies
4163 Rodiniai
Portretas
vijay

Hi Team,

 I have created a scheduler action for timesheet reminder for the next day morning at 8 am if user forget to enter the working hours .  

python code:

from datetime import datetime, timedelta

from odoo import api, fields, models

class TimesheetReminder(models.TransientModel):

    _name = 'timesheet.reminder'


    @api.model

    def send_timesheet_reminder(self):

        # Find employees with missing timesheets for the previous day

        today = fields.Date.today()

        yesterday = today - timedelta(days=1)


        employees_with_missing_timesheets = self.env['hr.employee'].search([

            ('user_id', '!=', False),

            ('timesheet_ids.date', '=', yesterday),

            ('timesheet_ids.state', '!=', 'done'),

        ])


        # Send reminder emails

        for employee in employees_with_missing_timesheets:

            template = self.env.ref('your_module.email_template_id')

            template.send_mail(employee.user_id.id, force_send=True)


while unbale to find the module.email_template_id  ..


Getting below error :  forbidden opcode(s) in "# Available variables:\n# - env: Odoo Environment on which the action is triggered\n# - model: Odoo Model of the record on which the action is triggered; is a void recordset\n# - record: record on which the action is triggered; may be void\n# - records: recordset of all records on which the action is triggered in multi-mode; may be void\n# - time, datetime, dateutil, timezone: useful Python libraries\n# - float_compare: Odoo function to compare floats based on specific precisions\n# - log: log(message, level='info'): logging function to record debug information in ir.logging table\n# - UserError: Warning Exception to use with raise\n# - Command: x2Many commands namespace\n# To return an action, assign: action = {...}\n\nfrom datetime import datetime, timedelta\nfrom odoo import api, fields, models\nclass TimesheetReminder(models.TransientModel):\n _name = 'timesheet.reminder'\n\n @api.model\n def send_timesheet_reminder(self):\n # Find employees with missing timesheets for the previous day\n today = fields.Date.today()\n yesterday = today - timedelta(days=1)\n\n employees_with_missing_timesheets = self.env['hr.employee'].search([\n ('user_id', '!=', False),\n ('timesheet_ids.date', '=', yesterday),\n ('timesheet_ids.state', '!=', 'done'),\n ])\n\n # Send reminder emails\n for employee in employees_with_missing_timesheets:\n template = self.env.ref('your_module.email_template_id')\n template.send_mail(employee.user_id.id, force_send=True)\n\n# Add this function to the Scheduled Action": IMPORT_NAME, IMPORT_FROM, LOAD_BUILD_CLASS




Thanks and Regards
Vijay Yadav


0
Portretas
Atmesti
Portretas
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

The execution of python is a bit different in the scheduled action script


You should try this instead


today = datetime.datetime.today()

yesterday = today - datetime.timedelta(1)


employees_with_missing_timesheets = env['hr.employee'].search([

    ('user_id', '!=', False),

    ('timesheet_ids.date', '=', yesterday),

    ('timesheet_ids.state', '!=', 'done'),

])

for employee in employees_with_missing_timesheets:

    template = env.ref('your_module.email_template_id')

    template.send_mail(employee.user_id.id, force_send=True)


Hope it helps

2
Portretas
Atmesti
Portretas
vijay
Autorius Best Answer

hi @cybrosys Team,

will this code help with web code editor  and how do we know module and template id for this line of code  your_module.email_template_id' please suggest 

 

getting this error 

 File "C:\Users\www.abcom.in\Desktop\odoo engineering\odoo\odoo\tools\safe_eval.py", line 376, in safe_eval
    raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr))
ValueError: : "Invalid field hr.employee.timesheet_ids in leaf ('timesheet_ids.state', '!=', 'done')" while evaluating
"today = datetime.datetime.today()\r\n\r\nyesterday = today - datetime.timedelta(1)\r\n\r\n\r\n\r\nemployees_with_missing_timesheets = env['hr.employee'].search([\r\n\r\n    ('user_id', '!=', False),\r\n\r\n    ('timesheet_ids.date', '=', yesterday),\r\n\r\n    ('timesheet_ids.state', '!=', 'done'),\r\n\r\n])\r\n\r\nfor employee in employees_with_missing_timesheets:\r\n\r\n    template = env.ref('your_module.email_template_id')\r\n\r\n    template.send_mail(employee.user_id.id, force_send=True)"


0
Portretas
Atmesti
Enjoying the discussion? Don't just read, join in!

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

Registracija
Related Posts Replies Rodiniai Veikla
Reference Next Execution date in Scheduled Action code
ScheduledActions
Portretas
Portretas
1
geg. 24
3743
Scheduled action to assign unpaid leave in attendance where no check in and check out is marked
attendance ScheduledActions
Portretas
Portretas
1
liep. 25
1462
How to configure the scheduled action to automate the validation of the receipts in one of your warehouses
AutomatedActions ScheduledActions
Portretas
Portretas
2
saus. 24
2240
Automated actions Solved
product ScheduledActions
Portretas
Portretas
1
geg. 23
2186
Update every res.partner via scheduled action
update res.partner ScheduledActions
Portretas
Portretas
Portretas
3
liep. 23
3213
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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