工资条和考勤单接口
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import binascii
|
||||
import binascii, json
|
||||
from odoo import fields, http, SUPERUSER_ID, _
|
||||
from odoo.exceptions import AccessError, MissingError, ValidationError
|
||||
from odoo.http import request
|
||||
@@ -49,3 +49,52 @@ class CustomerPortal(portal.CustomerPortal):
|
||||
'force_refresh': True,
|
||||
'redirect_url': attendance_sudo.get_portal_url(query_string=query_string),
|
||||
}
|
||||
|
||||
@http.route('/phone/vacation/self', type='http', auth="none", csrf=False, cors='*')
|
||||
def phone_vacation_self(self, **kw):
|
||||
employee_id = int(kw.get('employee'))
|
||||
# employee_id = request.env['res.users'].sudo().browse(kw.get('employee'))
|
||||
# employee_id = user_id.with_company(user_id.company_id.id).employee_id
|
||||
records = request.env['yuthon.vacation.reports'].sudo().search(
|
||||
[('employee_id', '=', employee_id)])
|
||||
data = {}
|
||||
for record in records:
|
||||
year = record.vacation_date.year
|
||||
month = record.vacation_date.month
|
||||
data[year] = year
|
||||
data[month] = month
|
||||
return json.dumps({'data': data, 'code': 200, 'message': ''})
|
||||
|
||||
@http.route('/phone/vacation/self/detail', type='http', auth="none", csrf=False, cors='*')
|
||||
def phone_vacation_self_detail(self, **kw):
|
||||
employee_id = int(kw.get('employee'))
|
||||
year = int(kw.get('year'))
|
||||
month = int(kw.get('month'))
|
||||
# employee_id = request.env['res.users'].sudo().browse(kw.get('employee'))
|
||||
# employee_id = user_id.with_company(user_id.company_id.id).employee_id
|
||||
records = request.env['yuthon.vacation.reports'].sudo().search(
|
||||
[('employee_id', '=', employee_id)])
|
||||
detail = {}
|
||||
for record in records:
|
||||
tar_year = record.date_from.year
|
||||
tar_month = record.date_from.month
|
||||
if tar_year == year and tar_month == month:
|
||||
detail = record.read([])
|
||||
data = {
|
||||
'year': year,
|
||||
'month': month,
|
||||
'detail': detail
|
||||
}
|
||||
return json.dumps({'data': data, 'code': 200, 'message': ''})
|
||||
|
||||
@http.route('/phone/vacation/self/status', type='http', auth="none", csrf=False, cors='*')
|
||||
def phone_vacation_self_detail(self, **kw):
|
||||
record_id = int(kw.get('record_id'))
|
||||
state = kw.get('state')
|
||||
record = request.env['yuthon.vacation.reports'].sudo().browse(record_id)
|
||||
if state == 'done':
|
||||
record.vacation_state = 'confirmed'
|
||||
data = 'success'
|
||||
else:
|
||||
data = ''
|
||||
return json.dumps({'data': data, 'code': 200, 'message': ''})
|
||||
|
||||
@@ -50,3 +50,69 @@ class YuthonWillTask(http.Controller):
|
||||
def meal_list_confirm(self, **kwargs):
|
||||
meal_id = request.env['yuthon.meal.expenses'].sudo().search([('id', '=', kwargs.get('id'))])
|
||||
meal_id.write({'toll_state': 'True'})
|
||||
|
||||
@http.route('/phone/salary/self', type='http', auth="none", csrf=False, cors='*')
|
||||
def phone_salary_self(self, **kw):
|
||||
employee_id = int(kw.get('employee'))
|
||||
# employee_id = request.env['res.users'].sudo().browse(kw.get('employee'))
|
||||
# employee_id = user_id.with_company(user_id.company_id.id).employee_id
|
||||
records = request.env['hr.payslip'].sudo().search(
|
||||
[('employee_id', '=', employee_id)])
|
||||
data = {}
|
||||
for record in records:
|
||||
year = record.date_from.year
|
||||
month = record.date_from.month
|
||||
if year not in data.keys():
|
||||
data[year] = {'total': 0}
|
||||
if month not in data[year].keys():
|
||||
data[year][month] = {
|
||||
'total': record.actual_salary
|
||||
}
|
||||
data[year]['total'] += record.actual_salary
|
||||
return json.dumps({'data': data, 'code': 200, 'message': ''})
|
||||
|
||||
@http.route('/phone/salary/self/detail', type='http', auth="none", csrf=False, cors='*')
|
||||
def phone_salary_self_detail(self, **kw):
|
||||
employee_id = int(kw.get('employee'))
|
||||
year = int(kw.get('year'))
|
||||
month = int(kw.get('month'))
|
||||
# employee_id = request.env['res.users'].sudo().browse(kw.get('employee'))
|
||||
# employee_id = user_id.with_company(user_id.company_id.id).employee_id
|
||||
records = request.env['hr.payslip'].sudo().search(
|
||||
[('employee_id', '=', employee_id)])
|
||||
detail = {}
|
||||
total = 0
|
||||
for record in records:
|
||||
tar_year = record.date_from.year
|
||||
tar_month = record.date_from.month
|
||||
if tar_year == year and tar_month == month:
|
||||
for line in record.line_ids:
|
||||
name = line.name
|
||||
contract = line.contract_id.name
|
||||
amount = line.amount
|
||||
if contract not in detail.keys():
|
||||
detail[contract] = {'total': 0}
|
||||
if name not in detail[contract]:
|
||||
detail[contract][name] = amount
|
||||
detail[contract]['total'] += amount
|
||||
total += amount
|
||||
data = {
|
||||
'year': year,
|
||||
'month': month,
|
||||
'tatal': total,
|
||||
'detail': detail
|
||||
}
|
||||
return json.dumps({'data': data, 'code': 200, 'message': ''})
|
||||
|
||||
@http.route('/phone/salary/self/status', type='http', auth="none", csrf=False, cors='*')
|
||||
def phone_salary_self_detail(self, **kw):
|
||||
record_id = int(kw.get('record_id'))
|
||||
state = kw.get('state')
|
||||
record = request.env['hr.payslip'].sudo().browse(record_id)
|
||||
if state == 'done':
|
||||
record.state = 'done'
|
||||
data = 'success'
|
||||
else:
|
||||
data = ''
|
||||
return json.dumps({'data': data, 'code': 200, 'message': ''})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user