Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

salary rule for unpaid leaves based on number of days of months

Subscriure's

Get notified when there's activity on this post

This question has been flagged
python2.7odooodoo10
2 Respostes
9495 Vistes
Avatar
SSS

Hello,

I am trying to deduct salary for unpaid leaves based on number of days of month. 

​In hr.payslip following line is added.

day =  datetime.strptime(date_to,"%Y-%m-%d").day

res['value'].update({
'day': day,
})

'day' give me last day of month. For salary rule I have try:

result=(contract.wage/payslip.day)*worked_days.Unpaid.number_of_days

But Following error occur:

res['value'].update({
TypeError: list indices must be integers, not str 

I understand error, also try for integer list but nothing will happen.Any suggestion

For above I refer following link:

https://www.odoo.com/forum/help-1/question/unpaid-leaves-deduction-not-working-16131

​and also I want to define organisation holiday. For organisation holiday salary not deduct for that I want add salary rule.

1
Avatar
Descartar
Avatar
Hilar Andikkadavath
Best Answer

The calculations you defined here are entirely wrong. How can u make sure your to-date in payslip is the last day of the month. One more thing to be checked here is if you put the salary for two months then which day you gonna take. 

In case of a payslip period in a single month.

Total days in a month can be calculated using this formula.

import calendar
day_from = fields.Date.from_string(from_date) #TO date object
calendar.monthrange(day_from.year, day_from.month)[1] # will be 31 | 30, For FEB 28|29
Payslip period for more than a month.
for this case I can suggest you two logics. 
1. You can predefine the the total days like 30 | 31.
2. result will be the sum of total of all months.
eg: result = result + (contract.wage/payslip.day of nth month)*worked_days.Unpaid.number_of_days
To do that, you can either split the Worked day lines according to the months or you can hard code in salary rules.
4
Avatar
Descartar
SSS
Autor

I want payslip only for one month not for more than month that's the reason I am consider to_date as a last date of month. But the problem is that when adding result=(contract.wage/payslip.day)*worked_days.Unpaid.number_of_days into the salary rule. gives me error "float division by zero" means payslip.day not contain 30 | 31. I dont understand why this happen. I am also tried your suggestion for one month payslip but not work.

Hilar Andikkadavath

Your payslip.day is zero, that's why. Properly update value to payslip.day

Hilar Andikkadavath

I don't know how you are updating payslip.day, but I can suggest you keep that as a computed field. I think you are updating the value wrongly.

SSS
Autor

Firstly i inherit hr.payslip with get_worked_day_lines method in that I have try this code

day_from = fields.Date.from_string(date_from)

day = calendar.monthrange(day_from.year, day_from.month)[1]

res1.append(day)

return res1[0]

I think I am inheriting wrong method that's the reason payslip.day

SSS
Autor

I think I am inheriting wrong method that's the reason payslip.day contain zero.

Hilar Andikkadavath

okay, make your field as computed and in the computed function, do the tweak

SSS
Autor

Thanks @Hilar AK for your time and suggestion. My problem is solved.

Avatar
Niyas Raphy (Walnut Software Solutions)
Best Answer

Hi,

Please check whether this helps,

1. Deduct Employee Salary When Taking Leaves In Odoo Payroll

2. How To Set Public Holidays/Global Leaves In Odoo

Thanks

2
Avatar
Descartar
SSS
Autor

Thanks @Niyas Paphy for your time and suggestion.links given by you also helpfull.

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

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

Registrar-se
Related Posts Respostes Vistes Activitat
How can i call my method after create new object in odoo 10?
python2.7 odoo odoo10
Avatar
Avatar
Avatar
2
d’ag. 22
12492
[SOLVED] How to Hide or Delete Trash Icon in One2many field Solved
python python2.7 odoo odoo10
Avatar
Avatar
2
d’ag. 25
12939
Filter value 2 field of Many2one
python python2.7 odoo odoo10
Avatar
Avatar
Avatar
5
de set. 20
6994
Filter field domain one2many to many2one Solved
python python2.7 odoo odoo10
Avatar
Avatar
1
de des. 19
10359
How to open direct list view instead of select "Search More.." in Many2one field for Odoo10
python2.7 many2one_list odoo odoo10
Avatar
Avatar
1
de febr. 24
7209
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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