@@ -154,8 +154,6 @@ class SoongWorkflowCommentWizard(models.TransientModel):
|
||||
for record in self:
|
||||
if not record.trans_link_id:
|
||||
continue
|
||||
available_links = self.env['trans.link'].search([])
|
||||
record.invalid_link_ids = available_links[1:]
|
||||
record_id = self.env[record.res_model].browse(record.res_id) if record.res_model and record.res_id else None
|
||||
for link in record.trans_link_id:
|
||||
employee_user_role_ids = self._get_approvers_for_link(link, record_id)
|
||||
|
||||
@@ -398,7 +398,7 @@ class PropertyLeaseContract(models.Model):
|
||||
'view_mode': 'form',
|
||||
}
|
||||
|
||||
@api.depends('contract_code', 'name', 'contract_type')
|
||||
@api.depends('contract_code', 'name', 'contract_type', 'property_name')
|
||||
def _compute_name(self):
|
||||
contract_dict = {
|
||||
'lease_renewal': '续租',
|
||||
|
||||
@@ -13,13 +13,12 @@ class PropertyPenaltyRelief(models.Model):
|
||||
_rec_name = 'name'
|
||||
|
||||
name = fields.Char(string='标题')
|
||||
reason = fields.Text(string="正文")
|
||||
reason = fields.Text(string="减免原因")
|
||||
users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
|
||||
department_id = fields.Many2one('hr.department', string="部门", related='users_id.employee_id.department_id')
|
||||
code = fields.Char(string="编号",
|
||||
default=lambda self: self.env['ir.sequence'].next_by_code('property_rent_relief_code'))
|
||||
property_documents_ids = fields.Many2many('documents.document', string="违约金减免文件")
|
||||
reason_abatement = fields.Char(string="减免原因")
|
||||
property_documents_ids = fields.Many2many('ir.attachment', string="违约金减免文件")
|
||||
contract_id = fields.Many2one('property.lease.contract', string="合同")
|
||||
lessee_id = fields.Many2one('property.tenant.information', string='承租方')
|
||||
property_id = fields.Many2one('yuthon.property', string='物业')
|
||||
@@ -53,6 +52,20 @@ class PropertyPenaltyRelief(models.Model):
|
||||
'approval_date': fields.Datetime.now(),
|
||||
})
|
||||
|
||||
@api.onchange('lessee_id')
|
||||
def _onchange_lessee_id(self):
|
||||
for record in self:
|
||||
if record.lessee_id:
|
||||
contract_id = self.env['property.lease.contract'].search([('lessee_id', '=', record.lessee_id.id)], limit=1)
|
||||
if contract_id:
|
||||
record.contract_id = contract_id.id
|
||||
|
||||
@api.onchange('contract_id')
|
||||
def _onchange_contract_id(self):
|
||||
for record in self:
|
||||
if record.contract_id.lease_ids:
|
||||
record.property_id = record.contract_id.lease_ids[0].address_id.id
|
||||
|
||||
|
||||
class PropertyPenaltyReliefLine(models.Model):
|
||||
_name = 'property.penalty.relief.line'
|
||||
@@ -93,7 +106,4 @@ class PropertyPenaltyReliefLine(models.Model):
|
||||
], limit=1)
|
||||
|
||||
if rental_record:
|
||||
record.rental_principal = rental_record.amount
|
||||
|
||||
|
||||
|
||||
record.rental_principal = rental_record.amount
|
||||
@@ -2,6 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import models, fields, api, exceptions, _
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
|
||||
class PropertyRentRelief(models.Model):
|
||||
@@ -11,7 +12,7 @@ class PropertyRentRelief(models.Model):
|
||||
_rec_name = 'name'
|
||||
|
||||
name = fields.Char(string='标题')
|
||||
reason = fields.Text(string="正文")
|
||||
reason = fields.Text(string="减免原因")
|
||||
code = fields.Char(string="编号",
|
||||
default=lambda self: self.env['ir.sequence'].next_by_code('property_penalty_relief_code'))
|
||||
users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
|
||||
@@ -22,7 +23,6 @@ class PropertyRentRelief(models.Model):
|
||||
is_issues = fields.Boolean(string='是否上会')
|
||||
issues_result = fields.Html(string="会议结果")
|
||||
related_issues_id = fields.Many2one('issue.library', string="关联议题")
|
||||
abatement_reason = fields.Text(string="减免原因")
|
||||
property_documents_ids = fields.Many2many('ir.document', string="附件")
|
||||
property_rent_relief_ids = fields.One2many('property.rent.relief.line', 'property_rent_relief_id', string="租金列表")
|
||||
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
|
||||
@@ -51,14 +51,58 @@ class PropertyRentRelief(models.Model):
|
||||
'approval_date': fields.Datetime.now(),
|
||||
})
|
||||
|
||||
@api.onchange('lessee_id')
|
||||
def _onchange_lessee_id(self):
|
||||
for record in self:
|
||||
contract_id = self.env['property.lease.contract'].search([('lessee_id', '=', record.lessee_id.id)], limit=1)
|
||||
if contract_id:
|
||||
record.contract_id = contract_id.id
|
||||
|
||||
@api.onchange('contract_id')
|
||||
def _onchange_contract_id(self):
|
||||
for record in self:
|
||||
if record.contract_id.lease_ids:
|
||||
record.property_id = record.contract_id.lease_ids[0].address_id.id
|
||||
|
||||
|
||||
class PropertyRentReliefLine(models.Model):
|
||||
_name = 'property.rent.relief.line'
|
||||
_description = '租金列表'
|
||||
|
||||
property_rent_relief_id = fields.Many2one('property.rent.relief', string="关联租金减免审批")
|
||||
rental_principal = fields.Float(string="租金本金")
|
||||
receivable_date = fields.Date(string="应收日期")
|
||||
penalty = fields.Float(string="违约金")
|
||||
deduction_amount = fields.Float(string="减免金额")
|
||||
lessee_id = fields.Many2one('property.tenant.information', string='承租方')
|
||||
property_id = fields.Many2one('yuthon.property', string='物业')
|
||||
contract_id = fields.Many2one('property.lease.contract', string="合同")
|
||||
penalty_id = fields.Many2one('property.accounts.receivable', string="违约金")
|
||||
rental_principal = fields.Float(string="租金本金", compute="_compute_rental_principal")
|
||||
start_time = fields.Date(related="penalty_id.due_date", string="应收开始", store=True)
|
||||
end_time = fields.Date(related="penalty_id.due_date_end", string="应收结束", store=True)
|
||||
penalty_amount = fields.Float(related="penalty_id.original_amount", string="违约金")
|
||||
penalty_relief = fields.Float(related="penalty_id.discount_amount", string="减免金额")
|
||||
|
||||
@api.depends('start_time', 'property_id', 'contract_id')
|
||||
def _compute_rental_principal(self):
|
||||
for record in self:
|
||||
# 初始化租金本金为0
|
||||
record.rental_principal = 0.0
|
||||
if not all([record.start_time, record.property_id, record.contract_id]):
|
||||
continue
|
||||
|
||||
# 计算上个月的第一天和最后一天
|
||||
start_date = fields.Date.from_string(record.start_time)
|
||||
first_day_of_last_month = (start_date.replace(day=1) - relativedelta(days=1)).replace(day=1)
|
||||
last_day_of_last_month = start_date.replace(day=1) - relativedelta(days=1)
|
||||
first_day_str = fields.Date.to_string(first_day_of_last_month)
|
||||
last_day_str = fields.Date.to_string(last_day_of_last_month)
|
||||
|
||||
rental_record = self.env['property.accounts.receivable'].search([
|
||||
('property_id', '=', record.property_id.id),
|
||||
('contract_id', '=', record.contract_id.id),
|
||||
('management_type_id.name', '=', '租金'),
|
||||
('due_date', '>=', first_day_str),
|
||||
('due_date', '<=', last_day_str)
|
||||
], limit=1)
|
||||
|
||||
if rental_record:
|
||||
record.rental_principal = rental_record.amount
|
||||
|
||||
|
||||
@@ -47,12 +47,12 @@
|
||||
<field name="name"/>
|
||||
<field name="reason"/>
|
||||
<field name="issues_result" invisible="is_issues == False"/>
|
||||
<field name="property_documents_ids" widget="many2many_tags"/>
|
||||
<field name="property_documents_ids" widget="preview_many2many"/>
|
||||
</group>
|
||||
<group string="物业信息">
|
||||
<field name="users_id" invisible="1"/>
|
||||
<field name="department_id" invisible="1"/>
|
||||
<field name="lessee_id" options="{'no_create': True}" required="1"/>
|
||||
<field name="lessee_id" options="{'no_create': True}" required="1" />
|
||||
<field name="contract_id" options="{'no_create': True}" required="1"/>
|
||||
<field name="property_id" options="{'no_create': True}" required="1"/>
|
||||
</group>
|
||||
@@ -84,9 +84,6 @@
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
<group>
|
||||
<field name="reason_abatement"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
@@ -51,27 +51,37 @@
|
||||
<field name="issues_result" invisible="is_issues == False"/>
|
||||
<field name="property_documents_ids" widget="many2many_tags"/>
|
||||
</group>
|
||||
<group col="2">
|
||||
<group>
|
||||
<field name="property_id" options="{'no_create': True}"/>
|
||||
<field name="abatement_reason"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="contract_id" options="{'no_create': True}"/>
|
||||
<field name="lessee_id" options="{'no_create': True}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="property_id" options="{'no_create': True}"/>
|
||||
<field name="contract_id" options="{'no_create': True}"/>
|
||||
<field name="lessee_id" options="{'no_create': True}"/>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="租金列表">
|
||||
<field name="property_rent_relief_ids" string=" ">
|
||||
<tree editable="bottom">
|
||||
<field name="property_rent_relief_id" column_invisible="1"/>
|
||||
<field name="rental_principal"/>
|
||||
<field name="receivable_date"/>
|
||||
<field name="penalty"/>
|
||||
<field name="deduction_amount"/>
|
||||
</tree>
|
||||
</field>
|
||||
context="{
|
||||
'default_property_id': property_id,
|
||||
'default_contract_id': contract_id,
|
||||
'default_lessee_id': lessee_id,
|
||||
}">
|
||||
<tree editable="bottom">
|
||||
<field name="property_rent_relief_id" column_invisible="1"/>
|
||||
<field name="lessee_id" column_invisible="1"/>
|
||||
<field name="property_id" column_invisible="1"/>
|
||||
<field name="contract_id" column_invisible="1"/>
|
||||
<field name="penalty_id"
|
||||
domain="[('property_id', '=', property_id),
|
||||
('contract_id', '=', contract_id),
|
||||
('lessee_id', '=', lessee_id),
|
||||
('is_reconciliation', '=', False),
|
||||
('management_type_id.name', '=', '违约金')]" options="{'no_create': True}"/>
|
||||
<field name="rental_principal"/>
|
||||
<field name="start_time"/>
|
||||
<field name="end_time"/>
|
||||
<field name="penalty_amount"/>
|
||||
<field name="penalty_relief"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
|
||||
Reference in New Issue
Block a user