添加功能
This commit is contained in:
@@ -17,11 +17,6 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
_name = "soong.workflow.mixin"
|
||||
_description = "Soong Workflow Mixin"
|
||||
|
||||
def end_approval(self):
|
||||
record = self.env['soong.workflow.record'].search([('code', '=', self.code)])
|
||||
if record:
|
||||
record.write({'approve_state': 'end'})
|
||||
|
||||
def read(self, fields=None, load='_classic_read'):
|
||||
if self.log_ids:
|
||||
if self.log_ids[-1].done_by.id == self.env.user.id and self.log_ids[-1].approval_state == '0':
|
||||
@@ -518,6 +513,7 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
@api.model
|
||||
def get_view(self, view_id=None, view_type="form", **options):
|
||||
res = super().get_view(view_id, view_type, **options)
|
||||
active_id = self._context.get('active_id')
|
||||
if '<form create="false"' not in res['arch']:
|
||||
if view_type in ["tree", "form"]:
|
||||
params = {}
|
||||
@@ -610,9 +606,6 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
this = self
|
||||
model = self._name
|
||||
wkf_obj = self.env["soong.workflow"]
|
||||
wkf_record = self.env["soong.workflow.record"].search(
|
||||
[("res_model", "=", self._name), ("res_id", "=", self.id)])
|
||||
approve_state = wkf_record.approve_state if wkf_record else ""
|
||||
arch = etree.fromstring(res["arch"])
|
||||
|
||||
# Helper Functions
|
||||
@@ -749,7 +742,7 @@ class SoongWorkflowMixin(models.AbstractModel):
|
||||
id_el.set("name", "log_ids")
|
||||
id_el.set("invisible", "1")
|
||||
invisible += " or not log_ids "
|
||||
if approve_state == "end" and button.name == "结束":
|
||||
if button.name == "结束" :
|
||||
invisible += " or True"
|
||||
# invisible += " or not work_end "
|
||||
btn_exec_action_el.set("invisible", invisible)
|
||||
|
||||
@@ -47,13 +47,6 @@ class AppletAttendance(Controller):
|
||||
current_data = fields.Date.today()
|
||||
user_id = request.env(user=SUPERUSER_ID)["res.users"].search([('id', '=', int(kw['user_id']))])
|
||||
employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('name', '=', user_id.name)])
|
||||
address_id = request.env(user=SUPERUSER_ID)["applet.address"].search([('address_name', '=', employee_id.company_id.name)])
|
||||
self_address = self.get_address_from_coords(kw['att_latitude'], kw['att_longitude'])
|
||||
|
||||
_logger.info(f"打卡经度{kw['att_longitude'] }打卡纬度{kw['att_latitude']}__________")
|
||||
_logger.info(f"人员{employee_id.name}地址{self_address['formatted_address']}__________")
|
||||
|
||||
card_rice = address_id.card_rice * 0.001 # 打卡范围
|
||||
attendance_id = request.env(user=SUPERUSER_ID)["hr.attendance"].search([('employee_id', '=', employee_id.id), ('current_data', '=', current_data)])
|
||||
check_in = attendance_id.check_in + timedelta(hours=8)
|
||||
check_out = attendance_id.check_out + timedelta(hours=8)
|
||||
@@ -78,11 +71,22 @@ class AppletAttendance(Controller):
|
||||
check_out_str = check_out.strftime('%H:%M:%S') if check_out else ' '
|
||||
check_in_html = f'<p style="color:red">{check_in_str}</p>' if check_in_status in ['迟到', '早退', '缺卡'] else f'<p style="color:green">{check_in_str}</p>'
|
||||
check_out_html = f'<p style="color:red">{check_out_str}</p>' if check_out_status in ['迟到', '早退', '缺卡'] else f'<p style="color:green">{check_out_str}</p>'
|
||||
if not self.is_within_radius_geopy(kw['att_latitude'], kw['att_longitude'], address_id.latitude, address_id.longitude, card_rice):
|
||||
data = {"message": "超出范围,不允许打卡", 'state': 'no', 'state_result': '超出范围'}
|
||||
_logger.info("-------触发超出范围,不允许打卡---------")
|
||||
else:
|
||||
data = {'location': '%s' % address_id.address_name,
|
||||
self_address = self.get_address_from_coords(kw['att_latitude'], kw['att_longitude'])
|
||||
_logger.info(f"打卡经度{kw['att_longitude'] }打卡纬度{kw['att_latitude']}__________")
|
||||
_logger.info(f"人员{employee_id.name}地址{self_address['formatted_address']}__________")
|
||||
address_ids = request.env(user=SUPERUSER_ID)["applet.address"].search([('address_name', '=', employee_id.company_id.name)])
|
||||
data = {"message": "超出范围,不允许打卡", 'state': 'no', 'state_result': '超出范围'}
|
||||
for address_id in address_ids:
|
||||
card_rice = address_id.card_rice * 0.001
|
||||
if self.is_within_radius_geopy(
|
||||
kw['att_latitude'],
|
||||
kw['att_longitude'],
|
||||
address_id.latitude,
|
||||
address_id.longitude,
|
||||
card_rice
|
||||
):
|
||||
data = {
|
||||
'location': '%s' % address_id.address_name,
|
||||
'user_id': user_id.id,
|
||||
'state': 'yes',
|
||||
'class': [f"{attendance_id.shift_name}{start_time_str}-{end_time_str}"],
|
||||
@@ -91,7 +95,8 @@ class AppletAttendance(Controller):
|
||||
'check_in_status': check_in_status,
|
||||
'check_out': check_out_html,
|
||||
'check_out_status': check_out_status,
|
||||
},
|
||||
}
|
||||
break
|
||||
return_data = {'data': data, 'code': '200', 'message': 'OK'}
|
||||
return json.dumps(return_data)
|
||||
|
||||
@@ -185,7 +190,8 @@ class AppletAttendance(Controller):
|
||||
}
|
||||
"""
|
||||
_logger.info("----------------/yuthon/att/att---------接口收到响应-------------------------------")
|
||||
user_id = int(kw['user_id'])
|
||||
user_id = request.env(user=SUPERUSER_ID)["res.users"].search([('id', '=', int(kw['user_id']))])
|
||||
employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('name', '=', user_id.name)])
|
||||
month = kw['selected_month'] # 2015-01
|
||||
year = int(month[0:4])
|
||||
month = int(month[-2:])
|
||||
@@ -202,7 +208,7 @@ class AppletAttendance(Controller):
|
||||
# 本月考勤记录
|
||||
leave_days = 0
|
||||
current_attendance = request.env(user=SUPERUSER_ID)['hr.attendance'].sudo().search([
|
||||
('employee_id.user_id', '=', user_id),
|
||||
('employee_id', '=', employee_id.id),
|
||||
('current_data', '>=', current_month_first.date()),
|
||||
('current_data', '<=', current_month_last.date()),
|
||||
('week', 'not in', ['seven', 'six'])
|
||||
@@ -245,7 +251,6 @@ class AppletAttendance(Controller):
|
||||
records = []
|
||||
for att in attendances:
|
||||
# 获取班次信息
|
||||
shift_name = att.shift_id.name if att.shift_id else ""
|
||||
check_in_start = att.shift_id.template_id.check_in_start if att.shift_id and att.shift_id.template_id else 0
|
||||
check_out_end = att.shift_id.template_id.check_out_end if att.shift_id and att.shift_id.template_id else 0
|
||||
start_hour = int(check_in_start)
|
||||
@@ -270,7 +275,7 @@ class AppletAttendance(Controller):
|
||||
# 添加到记录列表
|
||||
records.append({
|
||||
'date': att.current_data.strftime('%Y-%m-%d'),
|
||||
'class': [f"{shift_name}{standard_check_in_str}-{standard_check_out_str}"],
|
||||
'class': [f"{att.shift_name}{standard_check_in_str}-{standard_check_out_str}"],
|
||||
'user_id': user_id,
|
||||
'check_in': check_in_str,
|
||||
'check_in_state': check_in_html,
|
||||
|
||||
@@ -809,6 +809,7 @@
|
||||
<field name="name">合同管理</field>
|
||||
<field name="res_model">property.lease.contract</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{'search_default_group_by_admin_id': True}</field>
|
||||
<field name="view_ids" eval="[(5, 0, 0),
|
||||
(0, 0, {'view_mode': 'tree', 'view_id': ref('yuthon_property_approval.view_property_lease_contract_tree1')}),
|
||||
(0, 0, {'view_mode': 'form', 'view_id': ref('yuthon_property_approval.view_property_lease_contract_form1')})]"/>
|
||||
@@ -818,6 +819,7 @@
|
||||
<field name="res_model">property.lease.contract</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('condition', 'in', ['new', 'approval', 'cancel'])]</field>
|
||||
<field name="context">{'search_default_group_by_admin_id': True}</field>
|
||||
<field name="view_ids" eval="[(5, 0, 0),
|
||||
(0, 0, {'view_mode': 'tree', 'view_id': ref('yuthon_property_approval.view_property_lease_contract_tree')}),
|
||||
(0, 0, {'view_mode': 'form', 'view_id': ref('yuthon_property_approval.view_property_lease_contract_form')})]"/>
|
||||
|
||||
Reference in New Issue
Block a user