hi everyone,
I want to ask, how can I accumulate the number of days in 1 month from each person, where each person inputs the number of days per week. Is there a separate program code?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
hi everyone,
I want to ask, how can I accumulate the number of days in 1 month from each person, where each person inputs the number of days per week. Is there a separate program code?
Yes, you can achieve this in Odoo by creating computed fields for the number of days and weeks. Here’s a basic example of how you might set this up:
from datetime import datetime
def _days_between(self, cr, uid, ids, field_name, arg, context=None):
res = {}
for cur_data in self.browse(cr, uid, ids, context=context):
st_date = datetime.strptime(cur_data.st_date, "%Y-%m-%d")
en_date = datetime.strptime(cur_data.en_date, "%Y-%m-%d")
res[cur_data.id] = abs((en_date - st_date).days)
return res
_columns = {
'st_date': fields.date('Start date'),
'en_date': fields.date('End date'),
'days': fields.function(_days_between, type='char', string='NoD'),
}
In this example, st_date and en_date are the start and end dates, and days is a computed field that calculates the number of days between these two dates.
If each person inputs the number of days per week, you could create a similar function to accumulate these inputs over a month. However, the exact implementation would depend on how your Odoo system is set up and how the data is being inputted.
Please note that this is a simplified example and might need to be adjusted based on your specific requirements and Odoo setup.
How can it be implemented into custom fields created through Odoo Studio?
Create an account today to enjoy exclusive features and engage with our awesome community!
Înscrie-teRelated Posts | Răspunsuri | Vizualizări | Activitate | |
---|---|---|---|---|
|
0
mar. 24
|
1554 | ||
|
2
sept. 23
|
2568 | ||
|
1
dec. 23
|
4685 | ||
|
1
ian. 23
|
5399 | ||
|
2
iun. 23
|
2699 |