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?
関連投稿 | 返信 | ビュー | 活動 | |
---|---|---|---|---|
|
0
3月 24
|
1557 | ||
|
2
9月 23
|
2570 | ||
|
1
12月 23
|
4686 | ||
|
1
1月 23
|
5403 | ||
|
2
6月 23
|
2699 |