My post message(success) is showing perfectly and now i want to add error message to show if the attendance is not marked.
@http.route('/new_attendance_record', type='json', auth='user')
def new_attend_record(self, **rec):
new_format = "%Y-%m-%d %H:%M:%S"
local_tz = request.env.user.tz
local_dt = pytz.timezone(local_tz)
if request.jsonrequest:
user = request.env.user
mob_checkin = rec['check_in']
# mob_checkout= rec['check_out']
locate = rec['location']
long = rec['longitude']
lat = rec['latitude']
print(long,lat,locate,'Hi')
if mob_checkin:
upd_checkin_time = datetime.strptime(mob_checkin, "%Y-%m-%dT%H:%M")
local_dt1 = local_dt.localize(upd_checkin_time, is_dst=None)
cin = local_dt1.astimezone(pytz.utc)
mob_checkin = cin.strftime(new_format)
# if mob_checkout:
# upd_checkout_time = datetime.strptime(mob_checkout, "%Y-%m-%dT%H:%M")
# local_dt2 = local_dt.localize(upd_checkout_time, is_dst=None)
# cout = local_dt2.astimezone(pytz.utc)
# mob_checkout = cout.strftime(new_format)
print(mob_checkin)
# print(mob_checkout)
print(rec['location'])
if user.id:
vals = {
# 'employee_id': user.id,
'check_in': mob_checkin,
# 'check_out': mob_checkout,
'location': locate,
'longitude': long,
'latitude': lat,
}
new_record = request.env['hr.attendance'].sudo().create(vals)
if not new_record:
return {'error': _('Unable to create attendance.')}
else:
args = {
'success': True, 'message': 'Mark Attendance successfully', 'id': new_record.id
}
return args
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
2539
Weergaven
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
2
jul. 23
|
6303 | ||
|
3
apr. 23
|
13812 | ||
|
1
dec. 17
|
7532 | ||
|
1
aug. 17
|
8735 | ||
|
4
aug. 17
|
39132 |