@@ -2,5 +2,6 @@
|
||||
|
||||
from . import attendance_banner_route
|
||||
from . import portal
|
||||
from . import applet_attendance
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
from odoo.http import Controller, request, route
|
||||
from odoo import models, fields, api, http, SUPERUSER_ID, _
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
# _logger.info("Connected to MQTT Broker")
|
||||
class AppletAttendance(Controller):
|
||||
|
||||
@route('/yuthon/att/today', methods=['POST'], type='json', auth='none', csrf=False)
|
||||
def apple_yuthon_att_today(self):
|
||||
"""
|
||||
小程序获取当前用户打卡信息
|
||||
:return:
|
||||
"""
|
||||
data = request.httprequest.json
|
||||
user_id = request.env(user=SUPERUSER_ID)["res.user"].search([('wecom_id', '=', data.get('user_id'))])
|
||||
if not user_id:
|
||||
return {"Msg": "获取失败,没有找到对应用户", 'data': False}
|
||||
data_info = {'location': '', 'class': '行政班次', 'user_id': '', 'check_in': '', "check_out": '', 'state': '正常'}
|
||||
today = fields.Date.context_today(self)
|
||||
attendances = request.env['hr.attendance.detail'].search([
|
||||
('employee_id', '=', user_id.employee_id.id),
|
||||
('checkin_time', '>=', today + ' 00:00:00'),
|
||||
('checkin_time', '<=', today + ' 23:59:59')
|
||||
], order='check_in asc')
|
||||
if attendances:
|
||||
first_attendance = attendances[0]
|
||||
data_info['check_in'] = first_attendance.checkin_time
|
||||
if len(attendances) > 1:
|
||||
last_attendance = attendances[-1]
|
||||
data_info['check_out'] = last_attendance.checkin_time
|
||||
elif len(attendances) == 1:
|
||||
data_info['check_out'] = False
|
||||
return {"Msg": "获取成功", 'data': data_info}
|
||||
|
||||
@route('/yuthon/att/record', methods=['POST'], type='json', auth='none', csrf=False)
|
||||
def apple_yuthon_att_record(self):
|
||||
"""
|
||||
小程序创建打卡记录
|
||||
:return:
|
||||
"""
|
||||
data = request.httprequest.json
|
||||
user_name = data.get('user_id')
|
||||
employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('user_id', '=', user_name.id)])
|
||||
if not employee_id:
|
||||
return {"Msg": "获取失败,没有找到对应员工", 'data': False}
|
||||
data_info = {}
|
||||
self.env['hr.attendance.detail'].create({
|
||||
'employee_id': employee_id.id,
|
||||
'checkin_time': data.get('checkin_time'),
|
||||
})
|
||||
return {"Msg": "打卡成功", 'data': data_info}
|
||||
|
||||
@@ -98,13 +98,6 @@ class YuthonProperty(models.Model):
|
||||
else:
|
||||
record.first_letter = ''
|
||||
|
||||
@api.onchange('title_information_ids')
|
||||
def _onchange_title_information_ids(self):
|
||||
for rec in self:
|
||||
if rec.title_information_ids:
|
||||
latest_title_information = rec.title_information_ids[-1]
|
||||
rec.title_deed = latest_title_information.title_certificate
|
||||
|
||||
@api.onchange('manage_information_ids', 'title_information_ids')
|
||||
def _onchange_information_ids(self):
|
||||
today = fields.Date.today()
|
||||
@@ -246,6 +239,7 @@ class YuthonProperty(models.Model):
|
||||
else:
|
||||
manage_id = False
|
||||
property_list.append([0, 0, {'property_id': record.id,
|
||||
'precinct_id': record.precinct_id.id,
|
||||
'purpose_id': manage_id.purpose_id.id,
|
||||
'information_line_id': manage_id.id}])
|
||||
return {
|
||||
@@ -363,10 +357,15 @@ class YuthonProperty(models.Model):
|
||||
property_ids = self.env["yuthon.property"].browse(
|
||||
self._context.get('active_ids', self._context.get('active_id')))
|
||||
for record in property_ids:
|
||||
precinct_id = self.env["yuthon.precinct.message"].search([('employee_id.name', '=', record.admin_id.name)])
|
||||
company_id = record.manage_information_ids[0].company_id.id if record.manage_information_ids else ''
|
||||
title_deed = record.title_information_ids[0].title_certificate if record.title_information_ids else ''
|
||||
record.company_id = company_id
|
||||
record.title_deed = title_deed
|
||||
record.precinct_id = precinct_id.id if precinct_id else ''
|
||||
if record.manage_information_ids:
|
||||
record.manage_information_ids[0].precinct_id = precinct_id.id if precinct_id else ''
|
||||
|
||||
|
||||
class YuthonPropertyWater(models.Model):
|
||||
_name = 'yuthon.property.water'
|
||||
@@ -417,7 +416,7 @@ class ManageInformationLine(models.Model):
|
||||
|
||||
yuthon_property_id = fields.Many2one('yuthon.property', string="关联物业信息")
|
||||
purpose_id = fields.Many2one('yuthon.resource.purpose', string="管理类型")
|
||||
precinct_id = fields.Many2one(related='yuthon_property_id.precinct_id',string="所属片区", readonly=False)
|
||||
precinct_id = fields.Many2one('yuthon.precinct.message', string="所属片区", readonly=False)
|
||||
tenure_type = fields.Selection([('self', '自有'), ('agency', '代管')], string='权属类型')
|
||||
management_area = fields.Float(string="管理面积", digits=(16, 4))
|
||||
rent_area = fields.Float(string="可租面积", digits=(16, 4))
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
<field name="yuthon_property_id" column_invisible="1"/>
|
||||
<field name="company_id" required="1"/>
|
||||
<field name="tenure_type"/>
|
||||
<field name="admin_id"/>
|
||||
<field name="admin_id" column_invisible="1"/>
|
||||
<field name="precinct_id"/>
|
||||
<field name="purpose_id"/>
|
||||
<field name="management_area"/>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models, fields, api, exceptions, _
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
class PropertyManagement(models.Model):
|
||||
@@ -33,6 +34,7 @@ class PropertyManagement(models.Model):
|
||||
admin_id_all = fields.Many2one('res.users', string="管理员")
|
||||
precinct_id = fields.Many2one('yuthon.precinct.message', string="所属片区")
|
||||
tenure_type = fields.Selection([('self', '自有'), ('agency', '代管')], string='权属类型')
|
||||
start_time = fields.Date(string="生效日期", default=lambda self: fields.Date.today())
|
||||
|
||||
def _get_default_name_title(self):
|
||||
return self._description if self._description else self._name
|
||||
@@ -40,6 +42,11 @@ class PropertyManagement(models.Model):
|
||||
name_title = fields.Char(default=_get_default_name_title)
|
||||
document_ids = fields.Many2many('ir.attachment', string="附件")
|
||||
|
||||
@api.onchange('precinct_id')
|
||||
def _onchange_precinct_id(self):
|
||||
if self.precinct_id:
|
||||
self.admin_id_all = self.precinct_id.employee_id.user_id.id
|
||||
|
||||
@api.onchange('is_issues')
|
||||
def _onchange_is_issues(self):
|
||||
if self.is_issues:
|
||||
@@ -93,7 +100,6 @@ class PropertyManagement(models.Model):
|
||||
|
||||
# 直接从关联的上一条记录获取值(如果存在)
|
||||
prev_info = line.information_line_id
|
||||
precinct_id1 = prev_info.precinct_id.id
|
||||
# 创建新的信息行记录,从prev_info获取缺失的值
|
||||
info_line_vals = {
|
||||
'yuthon_property_id': line.property_id.id,
|
||||
@@ -104,12 +110,11 @@ class PropertyManagement(models.Model):
|
||||
'rent_area': prev_info.rent_area if prev_info else 0.0,
|
||||
'admin_id': record.admin_id_all.id if record.admin_id_all else prev_info.admin_id.id,
|
||||
'company_id': record.company_id.id if record.company_id else prev_info.company_id.id if prev_info else False,
|
||||
'start_time': fields.Date.today(),
|
||||
'start_time': record.start_time,
|
||||
}
|
||||
|
||||
prev_info.end_date = record.start_time - timedelta(days=1)
|
||||
# 创建新记录
|
||||
self.env['manage.information.line'].create(info_line_vals)
|
||||
prev_info.precinct_id = precinct_id1
|
||||
record.write({'is_line': True})
|
||||
|
||||
def put_property_management(self):
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
</h1>
|
||||
</div>
|
||||
<group>
|
||||
<field name="state" invisible="1"/>
|
||||
<field name="work_end" invisible="1"/>
|
||||
<field name="user_id" invisible="1"/>
|
||||
<field name="department_id" invisible="1"/>
|
||||
@@ -62,7 +63,7 @@
|
||||
<field name="document_ids" widget="preview_many2many"/>
|
||||
</group>
|
||||
<group string="原管理信息"/>
|
||||
<button type="object" class="btn btn-primary" name="put_property_management" string="批量增加物业信息"/>
|
||||
<button type="object" class="btn btn-primary" name="put_property_management" string="批量增加物业信息" invisible="state != '申请人'"/>
|
||||
<group string=" " invisible="is_line">
|
||||
<field name="management_line2_ids" string=" ">
|
||||
<tree editable="bottom" create="False">
|
||||
@@ -70,7 +71,7 @@
|
||||
<field name="property_id"/>
|
||||
<field name="company_id" required="1"/>
|
||||
<field name="tenure_type"/>
|
||||
<field name="admin_id_all"/>
|
||||
<field name="admin_id_all" column_invisible="1"/>
|
||||
<field name="precinct_id"/>
|
||||
<field name="purpose_id"/>
|
||||
<field name="information_line_id" column_invisible="1"/>
|
||||
@@ -91,7 +92,7 @@
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<group col="5">
|
||||
<group col="6">
|
||||
<group>
|
||||
<field name="company_id"/>
|
||||
</group>
|
||||
@@ -99,7 +100,7 @@
|
||||
<field name="tenure_type"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="admin_id_all" domain="[('employee_id.user_role_id.name', '=', '片管员')]"/>
|
||||
<field name="admin_id_all" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="precinct_id"/>
|
||||
@@ -107,6 +108,9 @@
|
||||
<group>
|
||||
<field name="purpose_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="start_time"/>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user