!3139 添加功能

Merge pull request !3139 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2025-06-07 07:37:27 +00:00
committed by Gitee
9 changed files with 88 additions and 136 deletions
@@ -15,6 +15,7 @@
<field name="documents_ids" optional="hide"/>
<group expand="0" string="审批分组">
<filter string="审批类型分组" name='group_by_approvals_group_id' context="{'group_by':'approvals_group_id'}"/>
<filter name="group_by_employee" string="我的流程" context="{'group_by': 'employee_ids.user_id'}"/>
</group>
</search>
</field>
@@ -118,8 +119,9 @@
<field name="type">ir.actions.act_window</field>
<field name="res_model">soong.workflow.record</field>
<field name="view_mode">tree,kanban,search</field>
<field name="domain">[('employee_ids.user_id', '=', uid), ('reclaim_state', '=', False)]</field>
<field name="domain">[('reclaim_state', '=', False)]</field>
<field name="search_view_id" ref="soong_workflow_record_search"/>
<field name="context">{'search_default_group_by_employee': True}</field>
</record>
<record id="soong_workflow_hr_employee_action" model="ir.actions.act_window">
<field name="name">人事相关流程</field>
+22 -11
View File
@@ -47,20 +47,22 @@ class GoApprovals(models.Model):
name_title = fields.Char(default=_get_default_name_title)
@api.onchange('is_day', 'is_hour')
def _onchange_role_selection(self):
if self.is_day and self.is_hour:
return {
'warning': {
'title': _('输入错误'),
'message': _('只能选择主角色或者角色组中的一个,不能同时选择。')
}
}
@api.onchange('start_day_selection', 'end_day_selection')
def _onchange_selection_fields(self):
for record in self:
if record.start_day_selection == 'afternoon' and record.end_day_selection == 'half':
raise ValidationError("当开始日期为下半天时,结束选择日期只能下半天。")
if record.start_day_selection == 'afternoon' and record.end_day_selection == 'afternoon':
record.hours = 4
record.days = 0.5
elif record.start_day_selection == 'half' and record.end_day_selection == 'afternoon':
record.hours = 8
record.days = 1
else:
record.hours = 0
record.days = 0
if record.statr_date == record.end_date:
if record.start_day_selection == 'afternoon' and record.end_day_selection == 'half':
raise ValidationError("当开始日期为下半天时,结束选择日期只能下半天。")
@api.onchange('date_start', 'date_end')
def _onchange_date_range(self):
@@ -98,4 +100,13 @@ class GoApprovals(models.Model):
else:
rec.name = f"{rec.users_id.name}外出"
@api.onchange('statr_date', 'end_date')
def _onchange_days(self):
for record in self:
if record.statr_date and record.end_date:
delta = record.end_date - record.statr_date
record.days = delta.days if delta.days >= 0 else 0 # 防止负数
else:
record.days = 0
+17 -14
View File
@@ -41,20 +41,23 @@
<field name="name_title" readonly="1"/>
</h1>
</div>
<group string="审批事项">
<field name="name"/>
<field name="work_end" invisible="1"/>
<field name="reason_application"/>
<field name="users_id"/>
<field name="employee_id" invisible="1"/>
<field name="shift_id" invisible="shift_name"/>
<field name="shift_name" invisible="shift_id"/>
<field name="is_attendance" invisible="1"/>
<field name="attendance_id" domain="[('employee_id', '=', employee_id), '|', '|', '|', '|', ('is_abnormal', '=', True), ('is_early_card', '=', True), ('is_late_card', '=', True), ('absenteeism_card', '=', True), ('is_no_card', '=', True)]" invisible="is_attendance"/>
<field name="attendance" invisible="not is_attendance"/>
<field name="replacement_time"/>
<field name="documents_ids" widget="preview_many2many"/>
</group>
<group col="2">
<group string="审批事项">
<field name="name"/>
<field name="work_end" invisible="1"/>
<field name="reason_application"/>
<field name="users_id"/>
<field name="employee_id" invisible="1"/>
<field name="shift_id" invisible="shift_name" readonly="1"/>
<field name="shift_name" invisible="shift_id" readonly="1"/>
<field name="is_attendance" invisible="1"/>
<field name="attendance_id" domain="[('employee_id', '=', employee_id), '|', '|', '|', '|', ('is_abnormal', '=', True), ('is_early_card', '=', True), ('is_late_card', '=', True), ('absenteeism_card', '=', True), ('is_no_card', '=', True)]" invisible="is_attendance"/>
<field name="attendance" invisible="not is_attendance"/>
<field name="replacement_time"/>
<field name="documents_ids" widget="preview_many2many"/>
</group>
<group/>
</group>
</sheet>
</form>
</field>
+7 -2
View File
@@ -63,8 +63,8 @@
<field name="end_date" invisible="not is_day"/>
</group>
<group>
<field name="start_day_selection" invisible="not is_day"/>
<field name="end_day_selection" invisible="not is_day"/>
<field name="start_day_selection" invisible="not is_day" string=" "/>
<field name="end_day_selection" invisible="not is_day" string=" "/>
</group>
</group>
<group>
@@ -72,12 +72,17 @@
<field name="date_end" invisible="not is_hour"/>
<field name="reason_application"/>
<field name="documents_ids" widget="preview_many2many"/>
</group>
<group col="2">
<group>
<field name="employee_ids" widget="many2many_tags" options="{'no_create': True}"/>
<field name="is_issues" invisible="is_issues == False"/>
<field name="meal"/>
<field name="details"/>
<field name="department_id" invisible="1"/>
</group>
<group/>
</group>
</sheet>
</form>
</field>
@@ -64,8 +64,8 @@
<field name="end_time"/>
</group>
<group>
<field name="start_week"/>
<field name="end_week"/>
<field name="start_week" string=" "/>
<field name="end_week" string=" "/>
</group>
<group>
<button name="open_record" type="object" string="考勤记录" class="oe_highlight"/>
@@ -41,80 +41,4 @@ class PropertyAccountsReceivable(models.Model):
last_update_time = fields.Datetime(string='最后修改时间')
def unlink(self):
return super().unlink()
def style_excel(self):
# 定义样式,可根据需要修改
report_no_style = xlwt.XFStyle()
report_title_style = xlwt.XFStyle()
style_white = xlwt.XFStyle()
report_borders_style = xlwt.XFStyle()
# 设置样式属性,例如字体、边框等
# 这里简单示例,可根据实际需求完善
font = xlwt.Font()
font.bold = True
report_title_style.font = font
borders = xlwt.Borders()
borders.left = xlwt.Borders.THIN
borders.right = xlwt.Borders.THIN
borders.top = xlwt.Borders.THIN
borders.bottom = xlwt.Borders.THIN
report_borders_style.borders = borders
return [report_no_style, report_title_style, style_white, report_borders_style]
def download_template_with_data(self):
# 获取当前记录
record = self
# 通用样式
workbook = xlwt.Workbook() # 创建一个工作簿
worksheet = workbook.add_sheet('Sheet1') # 为工作簿添加一个页签
report_no_style = self.style_excel()[0]
report_title_style = self.style_excel()[1]
style_white = self.style_excel()[2]
report_borders_style = self.style_excel()[3]
# 这里假设从当前记录中获取数据,可根据实际模型字段修改
report_data = record
# 设置列宽
for col in range(0, 7):
worksheet.col(col).width = 3000
# 写入表头
header = ['字段1', '字段2', '字段3', '字段4', '字段5', '字段6', '字段7']
for col, value in enumerate(header):
worksheet.write(0, col, value, report_borders_style)
# 写入数据行
# 假设模型中有多个相关记录,可根据实际情况修改
row = 1
for record in self:
worksheet.write(row, 0, record.lessee_id.name, report_borders_style)
# worksheet.write(row, 1, record.field2, report_borders_style)
# worksheet.write(row, 2, record.field3, report_borders_style)
# worksheet.write(row, 3, record.field4, report_borders_style)
# worksheet.write(row, 4, record.field5, report_borders_style)
# worksheet.write(row, 5, record.field6, report_borders_style)
# worksheet.write(row, 6, record.field7, report_borders_style)
row += 1
# 保存文件
template_path = get_module_resource('yuthon_property', 'static', 'tmpl', 'fapiaojibenxinxi.xlsx')
workbook.save(template_path)
# # 导出动作
# action = {
# 'type': 'ir.actions.act_url', # 表示将执行一个客户端动作。
# 'tag': 'self',
# 'context': dict({
# 'url': 'yuthon_property/static/tmpl/fapiaojibenxinxi.xlsx',
# 'module': 'yuthon_property', # 指定模块名称
# 'content_type': 'application/vnd.ms-excel'
# }, **self._context)
# }
# return action
return super().unlink()
@@ -78,6 +78,9 @@ class PropertyBankStatements(models.Model):
water_ids = self.env['property.water.list'].search([('lessee_id', '=', tenant_id.id)])
# 应收电费
electricity_ids = self.env['property.tariff.list'].search([('lessee_id', '=', tenant_id.id)])
# 应收违约金
penalty_ids = self.env['property.penalty.list'].search([('lessee_id', '=', tenant_id.id)])
def create_reconciliation_vals(ids, collection_type_val):
"""
@@ -87,7 +90,6 @@ class PropertyBankStatements(models.Model):
"""
nonlocal total_rent_month
vals_list = []
# 特殊处理:押金类型需要去重相同合同的记录
if collection_type_val == 'deposit':
# 使用字典来跟踪已处理的合同ID
@@ -143,6 +145,30 @@ class PropertyBankStatements(models.Model):
all_vals.extend(create_reconciliation_vals(water_ids, 'water_fee'))
all_vals.extend(create_reconciliation_vals(electricity_ids, 'electricity_fee'))
# 处理违约金(关键新增逻辑)
transaction_date = record.transaction_time # 银行流水交易时间
if transaction_date:
# 查找违约金记录中 start_date <= 交易时间 <= end_date 的记录
penalty_records = penalty_ids.filtered(
lambda p: p.start_date and p.end_date and
p.start_date <= transaction_date and
p.end_date >= transaction_date
)
for penalty in penalty_records:
# 计算违约金金额(original_amount - deduction_amount)
penalty_amount = (penalty.original_amount or 0) - (penalty.deduction_amount or 0)
if penalty_amount > 0:
vals = {
'property_id': penalty.property_id.id if penalty.property_id else False,
'contract_id': penalty.contract_id.id if penalty.contract_id else False,
'rent_month': penalty_amount,
'rent': penalty_amount,
'collection_type': 'penalty', # 新增违约金类型
'due_date': penalty.due_date if penalty.due_date else False,
}
total_rent_month -= penalty_amount
all_vals.append((0, 0, vals))
return all_vals, total_rent_month
return [], 0
@@ -237,31 +263,12 @@ class PropertyAccountsReceivable(models.Model):
penalty = fields.Float(string="违约金")
penalty_date = fields.Date(string="违约金日期")
@api.model
def write(self, vals):
# 当修改 penalty_date 时,自动将 is_reconciliation 设置为 True
if 'penalty_date' in vals:
vals['is_reconciliation'] = True
return super(PropertyAccountsReceivable, self).write(vals)
@api.onchange('penalty_date')
def _onchange_penalty_date(self):
for record in self:
if record.create_time and record.penalty_date:
create_time = record.create_time
dt = datetime.strptime(str(create_time), '%Y-%m-%d').date()
new_month = dt.month + 1
new_year = dt.year
if new_month > 12:
new_month = 1
new_year += 1
new_date = dt.replace(year=new_year, month=new_month, day=1)
penalty_date = datetime.strptime(str(record.penalty_date), '%Y-%m-%d').date()
if penalty_date.year == datetime.now().year - 1:
raise UserWarning("选择的日期为去年的年份,请重新选择!")
days_difference = (penalty_date - new_date).days
penalty = days_difference * record.difference_amount
record.write({'penalty': penalty})
record.write({
'is_reconciliation': True
})
def all_penalty_date(self):
receivable_ids= self.env["property.accounts.receivable"].browse(self._context.get('active_ids', self._context.get('active_id')))
+3 -3
View File
@@ -37,7 +37,7 @@ class YuthonWillTask(models.Model):
('20', '20:00'), ('20.5', '20:30'),
('21', '21:00'), ('21.5', '21:30'),
('22', '22:00'), ('22.5', '22:30'),
('23', '23:00'), ('23.5', '23:30')], string='开始时间')
('23', '23:00'), ('23.5', '23:30')], string='开始时间', default='9')
request_hour_to = fields.Selection([
('0', '12:00'), ('0.5', '12:30'),
@@ -63,7 +63,7 @@ class YuthonWillTask(models.Model):
('20', '20:00'), ('20.5', '20:30'),
('21', '21:00'), ('21.5', '21:30'),
('22', '22:00'), ('22.5', '22:30'),
('23', '23:00'), ('23.5', '23:30')], string='结束时间')
('23', '23:00'), ('23.5', '23:30')], string='结束时间', default='18')
priority = fields.Selection([('general', '不紧急不重要'), ('important', '重要不紧急'),
('urgent', '紧急不重要'), ('very_urgent', '重要且紧急')], string='优先级')
@@ -81,7 +81,7 @@ class YuthonWillTask(models.Model):
task_time_ids = fields.Many2many('yuthon.task.time', string='提醒')
document_ids = fields.Many2many('ir.attachment', string="附件")
address = fields.Char(string='地点')
start_date = fields.Date(string='开始日期', default=fields.Datetime.today())
start_date = fields.Date(string='开始日期', default=fields.Date.today)
task_state = fields.Selection([('will', '待办'), ('done', '已办'), ('cancel', '取消')], default='will', string='状态', store=True)
@api.onchange('employee_ids', 'user_id')
@@ -57,11 +57,11 @@
<label for="start_date"/>
<div class="d-inline-flex w-100">
<field name="start_date" string="日期:" class="me-2"
style="max-width: 5rem !important;"/>
style="max-width: 8rem !important;"/>
<field name="request_hour_from" string=" " class="ms-2"
style="max-width: 5rem !important;"/>至
style="max-width: 4rem !important;"/>至
<field name="request_hour_to" string=" " class="ms-2"
style="max-width: 5rem !important;"/>
style="max-width: 4rem !important;"/>
</div>
</group>
<group>