添加功能

This commit is contained in:
李鹏宇
2025-09-18 16:10:45 +08:00
parent d8836f416a
commit 903ee66c93
4 changed files with 26 additions and 11 deletions
+1 -6
View File
@@ -39,14 +39,9 @@
<field name="name_title" readonly="1"/>
</h1>
</div>
<div class="oe_title">
<label for="name"/>
<h1>
<field name="name"/>
</h1>
</div>
<group col="2">
<group>
<field name="name"/>
<field name="users_id" options="{'no_create': True}"/>
<field name="days" invisible="1"/>
<field name="employee_id" invisible="1" force_save="1"/>
@@ -11,7 +11,6 @@ class PropertyLeaseRenewal(models.Model):
_rec_name = 'name'
name = fields.Char(string='标题')
reason_application = fields.Text(string="申请事由")
user_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user)
department_id = fields.Many2one(related='user_id.department_id', string="部门")
company_id = fields.Many2one(related='user_id.company_id', string="公司")
@@ -87,5 +86,15 @@ class PropertyLeaseRenewal(models.Model):
'actual_end_time': rec.early_quitting_date})
rec.hide = True
@api.onchange('contract_id', 'renewal_type')
def _onchange_name(self):
if self.contract_id and self.renewal_type:
renewal_type_text = dict(self._fields['renewal_type'].selection).get(self.renewal_type, '')
self.name = f"{self.contract_id.name} + {renewal_type_text}"
elif self.contract_id:
self.name = self.contract_id.property_name
else:
self.name = False
class PropertyEarlyQuitting(models.Model):
_name = 'property.early.quitting'
@@ -39,7 +39,6 @@
<field name="renewal_type" widget="radio"/>
<field name="company_id" invisible="1"/>
<field name="department_id" invisible="1"/>
<field name="reason_application"/>
<field name="work_end" invisible="1"/>
</group>
<group string="原租赁合同信息" col="3">
@@ -214,13 +214,25 @@ class PropertyRentalWizard(models.Model):
date_field = datetime(year, month, 1).date()
date_field_year_month = date_field.strftime('%Y-%m')
# 获取当月第一天和最后一天
first_day = datetime.strptime(date_field_year_month, '%Y-%m').date() # 当月第一天
last_day = (first_day + relativedelta(months=1, days=-1)) # 当月最后一天
first_day = datetime.strptime(date_field_year_month, '%Y-%m').date()
last_day = first_day + relativedelta(months=1) - relativedelta(days=1)
records = self.env['property.lease.contract'].search([
('actual_start_time', '<=', last_day),
('actual_end_time', '>=', first_day),
('contract_code', '=', 'SWZ2020-001')
])
for record in records:
filtered_records = [
rec for rec in records
if not (
rec.cycle_mode == 'fixed_monthly'
# 条件2:实际开始日期的日是1号
and getattr(rec.actual_start_time, 'day', None) != 1
# 条件3:实际结束日期的年月等于目标年月
and getattr(rec.actual_end_time, 'year', None) == year
and getattr(rec.actual_end_time, 'month', None) == month
)
]
for record in filtered_records:
date_data = {
'five': 5,
'fifteen': 15,