添加功能

This commit is contained in:
李鹏宇
2026-03-11 17:03:05 +08:00
parent 9c5f027de9
commit 4a64e67658
4 changed files with 58 additions and 7 deletions
@@ -110,7 +110,7 @@
<!-- 退回意见退回类型 -->
<field name="return_link_id" invisible="node_btn_name != '退回'" string="退回节点"
domain="[('link_type', '=', 'return'), ('workflow_record_id', '=', workflow_record_id)]"
options="{'no_open': True}" widget="radio" force_save="1"/>
options="{'no_open': True, 'fg_color': 'red'}" widget="radio" force_save="1"/>
</group>
<group>
<label for="is_this_company" string="本公司"/>
@@ -65,7 +65,12 @@ class PropertyAccountsReceivable(models.Model):
def _onchange_contract_id(self):
"""选择合同时自动填充税率"""
if self.contract_id and self.contract_id.tax_rate:
self.tax = float(self.contract_id.tax_rate.name)
tax_str = self.contract_id.tax_rate.name.strip()
tax_str_clean = tax_str.replace('%', '')
if tax_str_clean.replace('.', '', 1).isdigit():
self.tax = float(tax_str_clean)
else:
self.tax = 0.0
def action_update_tax_from_contract(self):
"""批量更新税率:从合同获取正确税率"""
@@ -589,8 +589,8 @@ class PropertyAccountsReceivable(models.Model):
is_penalty = fields.Boolean(string='是否违约金', default=True, compute = '_compute_is_penalty', store=True)
management_area = fields.Float(related='contract_id.total_area', string='面积')
title_deed = fields.Char(string="产权证号", compute='_compute_title_deed')
lessee_id = fields.Many2one(related='contract_id.lessee_id', string='承租方', store=True)
company_id = fields.Many2one(related='contract_id.lessor_id', string="出租方公司", store=True)
lessee_id = fields.Many2one('property.tenant.information', string='承租方', store=True, compute='_compute_lessee_id')
company_id = fields.Many2one('yuthon.property.company', string="出租方公司", store=True, compute='_compute_lessee_id')
# company_id1 = fields.Many2one(related='contract_id.admin_id.company_id', string="管理员公司", store=True)
company_id2 = fields.Many2one("res.company", string="公司", compute='_compute_company_id2', store=True)
contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
@@ -662,6 +662,42 @@ class PropertyAccountsReceivable(models.Model):
}
}
def update_compute_lessee_id(self):
rent_ids = self.env["property.accounts.receivable"].browse(
self._context.get('active_ids', self._context.get('active_id')))
for rent in rent_ids:
rent._compute_lessee_id()
@api.depends('contract_id', 'due_date')
def _compute_lessee_id(self):
for record in self:
record.lessee_id = False
record.company_id = False
if not record.contract_id:
continue
lessee_lines = record.contract_id.lessee_line
valid_lessee_lines = lessee_lines.filtered(
lambda line:
line.start_date and
line.start_date <= record.due_date and #
(not line.end_date or line.end_date >= record.due_date)
)
if valid_lessee_lines and len(valid_lessee_lines) > 0:
record.lessee_id = valid_lessee_lines[0].lessee_id
else:
record.lessee_id = record.contract_id.lessee_id or False
lessor_lines = record.contract_id.lessor_line
valid_lessor_lines = lessor_lines.filtered(
lambda line:
line.start_date and
line.start_date <= record.due_date and
(not line.end_date or line.end_date >= record.due_date)
)
if valid_lessor_lines and len(valid_lessor_lines) > 0:
record.company_id = valid_lessor_lines[0].lessor_id
else:
record.company_id = record.contract_id.lessor_id
@api.depends('contract_id', 'due_date')
def compute_tenure_type(self):
@@ -1069,7 +1105,7 @@ class PropertyRentList(models.Model):
due_date_end = fields.Date.to_string(theoretical_end)
# 创建应收记录
self.env['property.accounts.receivable'].create({
accounts_id = self.env['property.accounts.receivable'].create({
'contract_id': contract.id if contract else False,
'lessee_id': contract.lessee_id.id if contract and contract.lessee_id else None,
'original_amount': rec.original_amount,
@@ -1082,6 +1118,7 @@ class PropertyRentList(models.Model):
'management_type_id': management_type.id,
})
rec.is_push = True
accounts_id._compute_lessee_id()
self.reconcile_with_bank_statements(rec)
def batch_push_rent(self):
@@ -1136,7 +1173,7 @@ class PropertyDepositList(models.Model):
management_type_id = self.env['yuthon.management.type'].search([('name', '=', '押金')], limit=1)
if not management_type_id:
management_type_id = self.env['yuthon.management.type'].create({'name': '押金'})
self.env['property.accounts.receivable'].create({
accounts_id = self.env['property.accounts.receivable'].create({
'contract_id': rec.contract_id.id,
'due_date' :rec.due_date + relativedelta(months=1),
'due_date_end': None,
@@ -1146,6 +1183,7 @@ class PropertyDepositList(models.Model):
'management_type_id':management_type_id.id,
'charging_range': f"{rec.due_date.strftime('%Y-%m-%d')} 到 {(rec.due_date + relativedelta(months=1)).strftime('%Y-%m-%d')}",
})
accounts_id._compute_lessee_id()
rec.is_push = True
def batch_push_deposit(self):
@@ -1230,7 +1268,7 @@ class PropertyManagementList(models.Model):
else:
due_date_end = fields.Date.to_string(theoretical_end)
self.env['property.accounts.receivable'].create({
accounts_id = self.env['property.accounts.receivable'].create({
'contract_id': rec.contract_id.id,
'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None,
'original_amount': rec.original_amount,
@@ -1240,6 +1278,7 @@ class PropertyManagementList(models.Model):
'create_time': datetime.now(),
'management_type_id': management_type_id.id,
})
accounts_id._compute_lessee_id()
rec.is_push = True
def batch_push_management(self):
@@ -653,6 +653,13 @@
<field name="state">code</field>
<field name="code">action = model.update_is_liquidated_damages()</field>
</record>
<record id="update_compute_lessee_id" model="ir.actions.server">
<field name="name">同步出租方和承租方</field>
<field name="model_id" ref="yuthon_property.model_property_accounts_receivable"/>
<field name="binding_model_id" ref="yuthon_property.model_property_accounts_receivable"/>
<field name="state">code</field>
<field name="code">action = model.update_compute_lessee_id()</field>
</record>
<record id="all_action_refuse_all" model="ir.actions.server">
<field name="name">批量退回</field>
<field name="model_id" ref="yuthon_property.model_property_accounts_receivable"/>