diff --git a/yuthon_property/models/property_accounts_receivable.py b/yuthon_property/models/property_accounts_receivable.py
index 971979220..f4c341030 100644
--- a/yuthon_property/models/property_accounts_receivable.py
+++ b/yuthon_property/models/property_accounts_receivable.py
@@ -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()
\ No newline at end of file
diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py
index d497f2427..bee31be23 100644
--- a/yuthon_property_approval/models/inherit_yuthon_property.py
+++ b/yuthon_property_approval/models/inherit_yuthon_property.py
@@ -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')))
diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py
index 4190be80c..a400e241e 100644
--- a/yuthon_will_task/models/yuthon_will_task.py
+++ b/yuthon_will_task/models/yuthon_will_task.py
@@ -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')
diff --git a/yuthon_will_task/views/yuthon_will_task_views.xml b/yuthon_will_task/views/yuthon_will_task_views.xml
index 9c0995bb0..4f60f9570 100644
--- a/yuthon_will_task/views/yuthon_will_task_views.xml
+++ b/yuthon_will_task/views/yuthon_will_task_views.xml
@@ -57,11 +57,11 @@
+ style="max-width: 8rem !important;"/>
至
+ style="max-width: 4rem !important;"/>至
+ style="max-width: 4rem !important;"/>