@@ -128,10 +128,22 @@ class YuthonProperty(models.Model):
|
||||
|
||||
def update_lessee_id(self):
|
||||
property_ids = self.env["yuthon.property"].browse(
|
||||
self._context.get('active_ids', self._context.get('active_id')))
|
||||
self._context.get('active_ids', [self._context.get('active_id')])
|
||||
)
|
||||
current_date = date.today()
|
||||
for rec in property_ids:
|
||||
if rec.property_contract_ids:
|
||||
rec.lessee_id = rec.property_contract_ids[-1].lessee_id
|
||||
valid_contracts = rec.property_contract_ids.filtered(lambda c:
|
||||
isinstance(c.start_time,
|
||||
date) and c.start_time <= current_date and
|
||||
(not c.end_date or (isinstance(c.end_date,
|
||||
date) and c.end_date > current_date))
|
||||
)
|
||||
|
||||
if valid_contracts:
|
||||
latest_contract = valid_contracts.sorted(key=lambda c: c.start_time, reverse=True)[0]
|
||||
rec.lessee_id = latest_contract.lessee_id
|
||||
else:
|
||||
rec.lessee_id = False
|
||||
|
||||
@api.onchange('property_contract_ids')
|
||||
def _onchange_property_contract_ids(self):
|
||||
|
||||
@@ -62,6 +62,7 @@ class PropertyContractLine(models.Model):
|
||||
})
|
||||
|
||||
|
||||
|
||||
class PropertyTenantLine(models.Model):
|
||||
_name = 'property.tenant.line'
|
||||
_description = '物业承租方合同明细行'
|
||||
|
||||
@@ -45,7 +45,7 @@ class PropertyReconciliationWizard(models.Model):
|
||||
rec.amount_reconciled = max(rec.bank_id.no_amount - sum(line.amount for line in rec.reconciliation_line_ids), 0)
|
||||
for line in rec.reconciliation_line_ids:
|
||||
if line.amount and line.collection_type != 'penalty':
|
||||
if (line.due_date.month >= rec.actual_date.month and line.due_date.year == line.due_date.year) or (line.due_date.year > rec.actual_date.year):
|
||||
if (line.due_date.month > rec.actual_date.month and line.due_date.year == line.due_date.year) or (line.due_date.year < rec.actual_date.year):
|
||||
if line.rent >= line.amount:
|
||||
due_date_str = fields.Date.to_date(line.due_date).strftime('%Y-%m')
|
||||
line.remake = f'补{due_date_str},欠{round(line.rent - line.amount, 2)}'
|
||||
@@ -55,7 +55,7 @@ class PropertyReconciliationWizard(models.Model):
|
||||
due_date_str = fields.Date.to_date(line.due_date).strftime('%Y-%m')
|
||||
line.remake = f'交{due_date_str},欠{round(line.rent - line.amount, 2)}'
|
||||
|
||||
if (line.due_date.month < rec.actual_date.month and line.due_date.year == line.due_date.year) or (line.due_date.year < rec.actual_date.year):
|
||||
if (line.due_date.month < rec.actual_date.month and line.due_date.year == line.due_date.year) or (line.due_date.year > rec.actual_date.year):
|
||||
if line.rent >= line.amount:
|
||||
due_date_str = fields.Date.to_date(line.due_date).strftime('%Y-%m')
|
||||
line.remake = str(rec.actual_date) + '预' + str(due_date_str) + ',欠' + str(round(line.rent - line.amount, 2))
|
||||
|
||||
Reference in New Issue
Block a user