diff --git a/soong_workflow/wizard/soong_workflow_comment_wizard.py b/soong_workflow/wizard/soong_workflow_comment_wizard.py index 0174882ee..7314015da 100644 --- a/soong_workflow/wizard/soong_workflow_comment_wizard.py +++ b/soong_workflow/wizard/soong_workflow_comment_wizard.py @@ -399,12 +399,11 @@ class SoongWorkflowCommentWizard(models.TransientModel): action_id = self.env['ir.actions.act_window'].search([('res_model', '=', self.res_model)])[0] url = f'https://oa.thtzjt.com/web?login={employee.user_id.login}&oauth_uid={employee.wecom_userid}#id={record_id.id}&cids=2&action={action_id.id}&model={record_id._name}&view_type=form&menu_id=10104' self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', - user_id=employee.wecom_userid, + user_id='18562027762', title=record_id._description, description="标题: {}\n".format( record_id.name) + self.env.user.name + ' ' + str( - fields.Datetime.now() + timedelta( - hours=8)), + fields.Datetime.now() + timedelta(hours=8)), url=url, btntxt="查看详情") else: # 串审模式 (沿用原有逻辑) # 查找下一个节点 diff --git a/yuthon_hr_attendance/__manifest__.py b/yuthon_hr_attendance/__manifest__.py index d5ca80ef8..8c91aec25 100644 --- a/yuthon_hr_attendance/__manifest__.py +++ b/yuthon_hr_attendance/__manifest__.py @@ -19,6 +19,7 @@ 'security/planning_group.xml', 'data/hr_attendance_time.xml', 'data/mothly_report_time.xml', + 'data/create_attendance_every_day.xml', 'data/attendance_code_data.xml', 'data/attendance_time_data.xml', 'data/attendance_month_date.xml', diff --git a/yuthon_hr_attendance/data/attendance_month_date.xml b/yuthon_hr_attendance/data/attendance_month_date.xml index 702206b17..54380a6ce 100644 --- a/yuthon_hr_attendance/data/attendance_month_date.xml +++ b/yuthon_hr_attendance/data/attendance_month_date.xml @@ -36,9 +36,23 @@ months 1 - + + -1 + + + + + + 每天生成出勤数据 + + code + model.create_attendance_data_holiday() + + + 1 + days -1 - \ No newline at end of file + diff --git a/yuthon_hr_attendance/data/create_attendance_every_day.xml b/yuthon_hr_attendance/data/create_attendance_every_day.xml new file mode 100644 index 000000000..6a4360b70 --- /dev/null +++ b/yuthon_hr_attendance/data/create_attendance_every_day.xml @@ -0,0 +1,18 @@ + + + + + + 每天生成出勤数据 + + code + model.create_attendance_data_holiday() + + + 1 + days + -1 + + + + diff --git a/yuthon_hr_attendance/models/hr_attendance.py b/yuthon_hr_attendance/models/hr_attendance.py index 79e73b59a..5ddd8ddea 100644 --- a/yuthon_hr_attendance/models/hr_attendance.py +++ b/yuthon_hr_attendance/models/hr_attendance.py @@ -58,6 +58,75 @@ class HrAttendance(models.Model): workflow_id = fields.Many2one('soong.workflow.record', string="流程") is_month = fields.Boolean(string="是否为本月数据", compute='_compute_month_status', store=True) is_last_month = fields.Boolean(string="是否为上月数据", compute='_compute_month_status', store=True) + is_holiday = fields.Boolean(string="是否是假期") + + def create_attendance_data_holiday(self): + """ + 定时任务create_attendance_data_holiday + :return: + """ + att_ids = self.sudo().env['hr.attendance'] + employee_ids = self.sudo().env['hr.employee'].search([]) + self_date_time = fields.Date.today() + start_date1 = fields.Date.today() - timedelta(days=7) + start_date3 = fields.Date.today() - timedelta(days=5) + start_date5 = fields.Date.today() - timedelta(days=3) + + start_date6 = fields.Date.today() - timedelta(days=2) + start_date66 = fields.Date.today() - timedelta(days=6) + start_date7 = fields.Date.today() - timedelta(days=1) + # 补充假期橙色逻辑 + for emp in employee_ids: + test1 = att_ids.search([('current_data', '=', self_date_time), ('employee_id', '=', emp.id)]) + test2 = att_ids.search([('current_data', '=', start_date1), ('employee_id', '=', emp.id)]) + test3 = att_ids.search([('current_data', '=', start_date3), ('employee_id', '=', emp.id)]) + test4 = att_ids.search([('current_data', '=', start_date5), ('employee_id', '=', emp.id)]) + test5 = att_ids.search([('current_data', '=', start_date6), ('employee_id', '=', emp.id)]) + test6 = att_ids.search([('current_data', '=', start_date7), ('employee_id', '=', emp.id)]) + test7 = att_ids.search([('current_data', '=', start_date66), ('employee_id', '=', emp.id)]) + if not test1: + att_ids.create({ + 'employee_id': emp.id, + 'current_data': self_date_time, + }) + if not test2: + att_ids.create({ + 'employee_id': emp.id, + 'current_data': start_date1, + }) + if not test3: + att_ids.create({ + 'employee_id': emp.id, + 'current_data': start_date3, + }) + if not test4: + att_ids.create({ + 'employee_id': emp.id, + 'current_data': start_date5, + }) + if emp.company_id.name == '集团本部': + test5.write({ + 'absenteeism_card': False, + 'is_no_card': False, + 'is_abnormal': False, + 'is_warning': False, + }) + test6.write({ + 'absenteeism_card': False, + 'is_no_card': False, + 'is_abnormal': False, + 'is_warning': False, + }) + test7.write({ + 'absenteeism_card': False, + 'is_no_card': False, + 'is_abnormal': False, + 'is_warning': False, + }) + + + + def state_fix(self): for att in self.env["hr.attendance"].browse(self._context.get('active_ids', self._context.get('active_id'))): @@ -65,7 +134,7 @@ class HrAttendance(models.Model): 'is_early_card': False, 'is_late_card': False, 'is_abnormal': False, - 'is_warning':False, + 'is_warning': False, 'absenteeism_card': False}) @api.depends('is_no_card', 'is_early_card', 'is_late_card', 'is_abnormal', 'absenteeism_card') diff --git a/yuthon_hr_attendance/views/hr_attendance_views.xml b/yuthon_hr_attendance/views/hr_attendance_views.xml index 295844633..27ae37f87 100644 --- a/yuthon_hr_attendance/views/hr_attendance_views.xml +++ b/yuthon_hr_attendance/views/hr_attendance_views.xml @@ -22,7 +22,7 @@ - + @@ -41,6 +41,7 @@ + diff --git a/yuthon_property/__manifest__.py b/yuthon_property/__manifest__.py index 897708bce..a501d2acc 100644 --- a/yuthon_property/__manifest__.py +++ b/yuthon_property/__manifest__.py @@ -87,7 +87,7 @@ ], }, 'demo': [], - 'depends': ['mail', 'documents'], + 'depends': ['mail', 'documents', 'yuthon_issue'], 'installable': True, 'application': True, } diff --git a/yuthon_property/models/property_meter_archives.py b/yuthon_property/models/property_meter_archives.py index 45a803711..c01c976ce 100644 --- a/yuthon_property/models/property_meter_archives.py +++ b/yuthon_property/models/property_meter_archives.py @@ -100,17 +100,17 @@ class PropertyMeterArchives(models.Model): record.archives_state = 'stop' - @api.onchange('current_read', 'last_read') - def _onchange_current_meter(self): - for record in self: - if record.current_read > record.last_read: - record.current_meter = record.current_read - record.last_read - else: - if record.maximum_count > 0: - max_value = 10 ** record.maximum_count - 1 - record.current_meter = max_value - record.last_read + record.current_read - else: - record.current_meter = 0 + # @api.onchange('current_read', 'last_read') + # def _onchange_current_meter(self): + # for record in self: + # if record.current_read > record.last_read: + # record.current_meter = record.current_read - record.last_read + # else: + # if record.maximum_count > 0: + # max_value = 10 ** record.maximum_count - 1 + # record.current_meter = max_value - record.last_read + record.current_read + # else: + # record.current_meter = 0 @api.onchange('yuthon_property_ids') def _onchange_property(self): @@ -172,17 +172,19 @@ class MeterArchivesLine(models.Model): epitope_values_id = fields.Many2one('yuthon.epitope.values', string='表位置') lessee_id = fields.Many2one('property.tenant.information', string='承租方') yuthon_property_ids = fields.Many2many('yuthon.property', string='物业信息') - last_meter = fields.Date(string='上次抄表日期') - last_dosage = fields.Float(string='上次用量', compute="compute_meter_values") - last_read = fields.Float(string='上次读数', compute="compute_meter_values") + last_meter = fields.Date(string='上次抄表日期', compute="_compute_last") + last_dosage = fields.Float(string='上次用量', store=True, group_operator=None, compute="_compute_last") + last_read = fields.Float(string='上次读数', store=True, group_operator=None, compute="_compute_last") meter_date = fields.Date(string='任务日期') - current_meter = fields.Float(string='本次用量', compute='compute_meter_values') - current_read = fields.Float(string='本次读数') + + current_meter = fields.Float(string='本次用量', store=True, group_operator=None) + + current_read = fields.Float(string='本次读数', group_operator=None) unit_number = fields.Char(string='单元编号/用途') - gauge_magnification = fields.Integer(string='仪表倍率', readonly=True, default=1) + gauge_magnification = fields.Integer(string='仪表倍率', readonly=True, default=1, group_operator=None) last_reading_time = fields.Date(string="最后读数时间") - receivables = fields.Float(string="应收", compute='_compute_receivables', store=True) - unit = fields.Float(string='当月单价') + receivables = fields.Float(string="应收", compute='_compute_receivables', store=True, group_operator=None) + unit = fields.Float(string='当月单价', group_operator=None) line_loss = fields.Float(string="线损", default=0.02) type = fields.Selection([('public', '公共'), ('fees', '收费')], string='类型') start_time = fields.Date(string="安装日期") @@ -198,8 +200,7 @@ class MeterArchivesLine(models.Model): def _compute_receivables(self): for record in self: if record.line_loss and record.current_meter and record.unit: - record.receivables = record.current_meter * record.unit * ( - 1 + record.line_loss) * record.gauge_magnification + record.receivables = record.current_meter * record.unit * (1 + record.line_loss) * record.gauge_magnification def update_meter(self): current_year = datetime.now().year @@ -213,43 +214,36 @@ class MeterArchivesLine(models.Model): domain.append(('id', 'in', active_ids)) unread_meter_lines = self.env['meter.archives.line'].search(domain) if unread_meter_lines: - unread_meter_lines.write({ - 'state': 'reading' - }) + unread_meter_lines.write({'state': 'reading'}) - @api.depends('current_read', 'last_read', 'meter_date', 'maximum_count', 'archives_id') - def compute_meter_values(self): - """合并计算当前用量和上次用量""" - for line in self: - if line.current_read >= line.last_read: - line.current_meter = line.current_read - line.last_read - else: - if line.current_read != 0: - if line.maximum_count > 0: - max_value = 10 ** line.maximum_count - 1 - line.current_meter = max_value - line.last_read + line.current_read + @api.depends('archives_id', 'last_dosage', 'last_read', 'last_meter', 'current_meter', 'current_read', 'maximum_count') + def _compute_last(self): + """ + 上次用量,读数,超标日期 + :return: + """ + for i in self: + last_id = self.env['meter.archives.line'].search([('meter_date', '<', i.meter_date), ('archives_id', '=', i.archives_id.id)]).sorted('meter_date') + if last_id: + i.last_dosage = last_id[-1].current_meter + i.last_read = last_id[-1].current_read + i.last_meter = last_id[-1].meter_date + if i.current_read >= i.last_read: + i.current_meter = i.current_read - i.last_read + else: + if i.current_read != 0: + if i.maximum_count > 0: + max_value = 10 ** i.maximum_count - 1 + i.current_meter = max_value - i.last_read + i.current_read + else: + i.current_meter = 0 else: - line.current_meter = 0 - else: - line.current_meter = 0 - - lines = self.search([ - ('unit_number', '=', line.unit_number), - ('meter_date', '!=', False) - ], order='meter_date asc') - - if line in lines: - idx = lines.ids.index(line.id) - if idx > 0: - prev_line = lines[idx - 1] - line.last_dosage = prev_line.current_meter - line.last_read = prev_line.current_read - else: - line.last_read = 0 - line.last_dosage = 0.0 + i.current_meter = 0 else: - line.last_read = 0 - line.last_dosage = 0.0 + i.last_dosage = 0 + i.last_read = 0 + i.last_meter = i.meter_date + i.current_meter = 0 @api.onchange('yuthon_property_ids') def onchange_lessee_id(self): @@ -264,7 +258,3 @@ class MeterArchivesLine(models.Model): self._context.get('active_ids', self._context.get('active_id'))) for record in meter_ids: record.onchange_lessee_id() - -class PropertyElectricReading(models.Model): - _name = 'property.electric.reading' - current_meter = fields.Float(string='本次用量', tracking=True) diff --git a/yuthon_property/models/property_meter_water.py b/yuthon_property/models/property_meter_water.py index 7be6af519..b37d6f218 100644 --- a/yuthon_property/models/property_meter_water.py +++ b/yuthon_property/models/property_meter_water.py @@ -3,6 +3,10 @@ from odoo.exceptions import UserError, ValidationError from datetime import datetime +class PropertyElectricReading(models.Model): + _name = 'property.electric.reading' + + class PropertyMeterWater(models.Model): _name = 'property.meter.water' _description = '水表库' @@ -84,9 +88,9 @@ class PropertyMeterWater(models.Model): record.water_state = 'use' def button_water_state(self): - archives_ids = self.env["property.meter.water"].browse( + water_ids = self.env["property.meter.water"].browse( self._context.get('active_ids', self._context.get('active_id'))) - for record in archives_ids: + for record in water_ids: record.water_state = 'stop' @api.onchange('yuthon_property_ids') @@ -136,15 +140,17 @@ class MeterWaterLine(models.Model): epitope_values_id = fields.Many2one('yuthon.epitope.values', string='表位置') lessee_id = fields.Many2one('property.tenant.information', string='承租方') yuthon_property_ids = fields.Many2many('yuthon.property', string='物业信息') - last_meter = fields.Date(string='上次抄表日期') - last_dosage = fields.Float(string='上次用量', compute="compute_meter_values") - last_read = fields.Float(string='上次读数') + last_meter = fields.Date(string='上次抄表日期', compute="_compute_last") + last_dosage = fields.Float(string='上次用量', store=True, group_operator=None, compute="_compute_last") + last_read = fields.Float(string='上次读数', store=True, group_operator=None, compute="_compute_last") meter_date = fields.Date(string='任务日期') - current_meter = fields.Float(string='本次用量', readonly=True, compute='compute_meter_values') + + current_meter = fields.Float(string='本次用量', store=True, compute="compute_meter_values", group_operator=None) + current_read = fields.Float(string='本次读数', group_operator=None) unit_number = fields.Char(string='单元编号/用途') - unit = fields.Float(string='当月单价') - receivables = fields.Float(string="应收", compute='_compute_receivables', store=True) + unit = fields.Float(string='当月单价', group_operator=None) + receivables = fields.Float(string="应收", compute='_compute_receivables', store=True, group_operator=None) gauge_magnification = fields.Integer(string='仪表倍率', readonly=True, default=1, group_operator=None) last_reading_time = fields.Date(string="最后读数时间") type = fields.Selection([('public', '公共'), ('fees', '收费')], string='类型') @@ -185,39 +191,36 @@ class MeterWaterLine(models.Model): 'state': 'reading' }) - @api.depends('current_read', 'last_read', 'meter_date', 'maximum_count', 'water_id') - def compute_meter_values(self): - """合并计算当前用量和上次用量""" - for line in self: - if line.current_read >= line.last_read: - line.current_meter = line.current_read - line.last_read - else: - if line.current_read != 0: - if line.maximum_count > 0: - max_value = 10 ** line.maximum_count - 1 - line.current_meter = max_value - line.last_read + line.current_read + @api.depends('water_id', 'last_dosage', 'last_read', 'last_meter', 'current_meter', 'current_read', + 'maximum_count') + def _compute_last(self): + """ + 上次用量,读数,超标日期 + :return: + """ + for i in self: + last_id = self.env['meter.archives.line'].search( + [('meter_date', '<', i.meter_date), ('water_id', '=', i.water_id.id)]).sorted('meter_date') + if last_id: + i.last_dosage = last_id[-1].current_meter + i.last_read = last_id[-1].current_read + i.last_meter = last_id[-1].meter_date + if i.current_read >= i.last_read: + i.current_meter = i.current_read - i.last_read + else: + if i.current_read != 0: + if i.maximum_count > 0: + max_value = 10 ** i.maximum_count - 1 + i.current_meter = max_value - i.last_read + i.current_read + else: + i.current_meter = 0 else: - line.current_meter = 0 - else: - line.current_meter = 0 - - lines = self.search([ - ('unit_number', '=', line.unit_number), - ('meter_date', '!=', False) - ], order='meter_date asc') - - if line in lines: - idx = lines.ids.index(line.id) - if idx > 0: - prev_line = lines[idx - 1] - line.last_dosage = prev_line.current_meter - line.last_read = prev_line.current_read - else: - line.last_read = 0 - line.last_dosage = 0.0 + i.current_meter = 0 else: - line.last_read = 0 - line.last_dosage = 0.0 + i.last_dosage = 0 + i.last_read = 0 + i.last_meter = i.meter_date + i.current_meter = 0 @api.onchange('yuthon_property_ids') def onchange_lessee_id(self): @@ -231,8 +234,4 @@ class MeterWaterLine(models.Model): meter_ids = self.env["meter.water.line"].browse( self._context.get('active_ids', self._context.get('active_id'))) for record in meter_ids: - record.onchange_lessee_id() - -class PropertyWaterReading(models.Model): - _name = 'property.water.reading' - current_meter = fields.Float(string='本次用量', tracking=True) \ No newline at end of file + record.onchange_lessee_id() \ No newline at end of file diff --git a/yuthon_property/models/yuthon_property.py b/yuthon_property/models/yuthon_property.py index 3c23d2def..68c182492 100644 --- a/yuthon_property/models/yuthon_property.py +++ b/yuthon_property/models/yuthon_property.py @@ -93,6 +93,7 @@ class YuthonProperty(models.Model): annual_increase_percentage = fields.Float(string='递增百分比', igits=(6, 2)) annual_increase_amount = fields.Float(string='递增金额', igits=(6, 2)) rent_unit = fields.Float(string='租金单价', igits=(6, 2)) + property_type = fields.Selection([('property', '物业'), ('guanggao', '广告位'), ('guanzi', '管子间')], string="资产类型", default='property') def update_mange(self): property_ids = self.env['yuthon.property'].search([('name', 'ilike', '天河商贸大厦')]) diff --git a/yuthon_property/views/yuthon_property_views.xml b/yuthon_property/views/yuthon_property_views.xml index 01aaef891..1eba399cf 100644 --- a/yuthon_property/views/yuthon_property_views.xml +++ b/yuthon_property/views/yuthon_property_views.xml @@ -20,6 +20,7 @@ +