添加功能
This commit is contained in:
@@ -156,13 +156,13 @@ class PropertyLeaseContract(models.Model):
|
||||
miscellaneous = fields.Text(string="其他约定")
|
||||
number = fields.Integer(string="次数", default=0)
|
||||
total_area = fields.Float(string="总面积", digits=(16, 4))
|
||||
not_received = fields.Float(string="未收")
|
||||
not_received = fields.Float(string="未收", compute="_compute_not_received", store=True)
|
||||
actual_receivable = fields.Float(string="实际应收")
|
||||
now_receivable = fields.Float(string="当期应收")
|
||||
total_receivable = fields.Float(string="总已收")
|
||||
comparison = fields.Selection([('outweigh', '大于'), ('equal', '等于'), ('less', '小于')], string="对比", compute='_compute_comparison')
|
||||
progress_percentage = fields.Float(string="合同进度", compute="_compute_progress_percentage")
|
||||
condition = fields.Selection([('new', '新建'), ('approval', '审批中'), ('cancel', '作废'), ('be_executed', '待执行'), ('executed', '已执行'), ('expired', '已终止'), ('advance', '提前终止')], string="状态", default='new')
|
||||
condition = fields.Selection([('new', '新建'), ('approval', '审批中'), ('cancel', '作废'), ('be_executed', '待执行'), ('executed', '已执行'), ('expired', '已终止')], string="状态", default='new')
|
||||
contract_type = fields.Selection([('lease_renewal', '续租'), ('interim', '临租'), ('new', '补充协议'), ('first', '首租')], string="合同类型", default='first')
|
||||
performance_bonds = fields.Float(string="经营履约保证金")
|
||||
utility_bills = fields.Float(string="水电费押金")
|
||||
@@ -213,6 +213,24 @@ class PropertyLeaseContract(models.Model):
|
||||
responsibility_book_name = fields.Char(string="安全生产责任书(住宅)名称", compute='_compute_attachment_names',
|
||||
store=True)
|
||||
|
||||
@api.depends()
|
||||
def _compute_not_received(self):
|
||||
not_reconciled_records = self.env['property.accounts.receivable'].search([
|
||||
('contract_id', '=', self.id),
|
||||
('is_reconciliation', '=', False)
|
||||
])
|
||||
self.not_received = sum(record.submitted for record in not_reconciled_records)
|
||||
|
||||
def update_not_received(self):
|
||||
contract_ids = self.env["property.lease.contract"].browse(
|
||||
self._context.get('active_ids', self._context.get('active_id')))
|
||||
for rec in contract_ids:
|
||||
not_reconciled_records = self.env['property.accounts.receivable'].search([
|
||||
('contract_id', '=', rec.id),
|
||||
('is_reconciliation', '=', False)
|
||||
])
|
||||
rec.not_received = sum(record.submitted for record in not_reconciled_records)
|
||||
|
||||
def update_admin_id(self):
|
||||
contract_ids = self.env["property.lease.contract"].browse(
|
||||
self._context.get('active_ids', self._context.get('active_id')))
|
||||
@@ -1310,6 +1328,17 @@ class PropertyLeaseContract(models.Model):
|
||||
actual_start = contract.actual_start_time
|
||||
actual_end = contract.actual_end_time
|
||||
term_end = contract.term_end_time
|
||||
effective_month = None
|
||||
if actual_end:
|
||||
# 获取实际结束日期所在月的最后一天
|
||||
last_day_of_month = calendar.monthrange(actual_end.year, actual_end.month)[1]
|
||||
if actual_end.day == last_day_of_month:
|
||||
# 如果是最后一天,生效月份为下月
|
||||
effective_month = fields.Date.to_date(f"{actual_end.year}-{actual_end.month}-{last_day_of_month}")
|
||||
else:
|
||||
# 如果不是最后一天,生效月份为当月
|
||||
effective_month = fields.Date.to_date(f"{actual_end.year}-{actual_end.month}-01")
|
||||
|
||||
# 根据时间条件更新状态
|
||||
if not actual_start or today < actual_start:
|
||||
# 待执行:实际开始时间未到或未设置
|
||||
@@ -1319,7 +1348,7 @@ class PropertyLeaseContract(models.Model):
|
||||
contract.contact_state = 'ing'
|
||||
elif today >= actual_end == term_end:
|
||||
contract.contact_state = 'complete'
|
||||
elif today >= actual_end < term_end:
|
||||
elif effective_month and today >= effective_month < term_end:
|
||||
contract.contact_state = 'terminate'
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
<field name="lessee_id"/>
|
||||
<field name="contract_id"/>
|
||||
<group expand="0" string="group_by">
|
||||
<filter name="group_admin_id" string="管理员" context="{'group_by':'admin_id'}"/>
|
||||
<filter name="group_due_date" string="应收日期" context="{'group_by':'due_date:month'}"/>
|
||||
<filter name="contract_id" string="合同" context="{'group_by':'contract_id'}"/>
|
||||
<filter name="group_property_id" string="物业" context="{'group_by':'property_id'}"/>
|
||||
<filter name="group_lessee_id" string="承租方" context="{'group_by':'lessee_id'}"/>
|
||||
@@ -63,7 +65,7 @@
|
||||
<field name="res_model">property.rent.list</field>
|
||||
<field name="view_mode">tree,search</field>
|
||||
<field name="domain">[('is_push', '=', False)]</field>
|
||||
<field name="context">{'group_by': ['admin_id', 'due_date:month']}</field>
|
||||
<field name="context">{'search_default_group_admin_id': True, 'search_default_group_due_date': True}</field>
|
||||
<field name="search_view_id" ref="yuthon_property_approval.view_property_rent_list_search"/>
|
||||
</record>
|
||||
<!--押金-->
|
||||
|
||||
@@ -859,6 +859,13 @@
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = model.all_end_approval()</field>
|
||||
</record>
|
||||
<record id="update_not_received" model="ir.actions.server">
|
||||
<field name="name">更新未收金额</field>
|
||||
<field name="model_id" ref="yuthon_property_approval.model_property_lease_contract"/>
|
||||
<field name="binding_model_id" ref="yuthon_property_approval.model_property_lease_contract"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = model.update_not_received()</field>
|
||||
</record>
|
||||
<record id="update_admin_id" model="ir.actions.server">
|
||||
<field name="name">同步更新管理员</field>
|
||||
<field name="model_id" ref="yuthon_property_approval.model_property_lease_contract"/>
|
||||
|
||||
Reference in New Issue
Block a user