Hello Guys I am using Odoo 13 enterprise and I am trying to compute the number of days that an employee spent serving the company to use it in the calculation payroll that will calculate the number of days that an employee spends working for a company based on the Hiring date and current date.
I don't know the python code that I can use to do a rule in the payslip calculation or to create a field in the employee view screen that computes the current working days (up to date automatically)
hope that someone can point me in the right direction
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Hello Ahmed Naji,
You should try this for get employee spends days in company with 2 way depends on data.
Option 1)
If you create new functionality with a fresh database or you don't have any records in the employee, then you can calculate days such a way like below.
from datetime import date
hiring_date = fields.Date(string='Hiring Date' , default=lambda self: date.today())
spend_day = fields.Integer('Spend Days', compute='_compute_days')
def _compute_days(self):
for record in self:
record.spend_day = (date.today() - record.hiring_date).days
Option 2)
If you are using database with already employee data, then you can calculate days such a way like below.
from datetime import date
hiring_date = fields.Date(string='Hiring Date')
spend_day = fields.Integer('Spend Days', compute='_compute_days')
def _compute_days(self):
for record in self:
record.spend_day = (date.today() - record.hiring_date).days if record.hiring_date else 0
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
Hello Jainesh Shah,
Thank you for replying to my post. I am using Odoo SaaS so I don't have access to the server backend.so I don't know how I can apply this code from the user interface. I only can do custom fields and do the computing in the advanced property in the user interface.so if you know of a way or how to do it, I will really appreciate it
Thank you in advance
in which model should I put it into?
Hi Ahmed,
What was the solution you found?
Thank you for everyone try to help
I solve this by myself.
may we know, how did you solve it?
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
3
Mar 15
|
8993 | ||
|
2
Nov 24
|
77 | ||
|
2
Mar 24
|
477 | ||
|
0
Sep 23
|
610 | ||
|
2
Aug 23
|
19974 |