Files
gzth/yuthon_property_approval/models/property_evaluate_application.py
T
zhou 3991181ccd Merge branch 'dev' into dev_zhou
# Conflicts:
#	yuthon_property/models/yuthon_property.py
2025-03-13 16:00:51 +08:00

111 lines
6.0 KiB
Python

from odoo import models, fields, api, _
from odoo.exceptions import UserError, ValidationError
class PropertyEvaluateApplication(models.Model):
_name = 'property.evaluate.application'
_description = '物业评估申请'
_inherit = ['soong.workflow.mixin', 'mail.thread.main.attachment', 'mail.activity.mixin']
name = fields.Char(string='标题')
code = fields.Char(string='编号', required=True, copy=False,
default=lambda self: self.env['ir.sequence'].next_by_code('yuthon_property_code'))
main_text = fields.Html(string='正文')
users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
department_id = fields.Many2one(related='users_id.employee_id.department_id', string="部门")
is_issues = fields.Boolean(string='是否上会')
issues_result = fields.Html(string="会议结果")
related_issues_id = fields.Many2one('issue.library', string="关联议题")
is_experts = fields.Boolean(string="是否需要专家评审")
notice_documents_ids = fields.Many2many('ir.attachment', string='议题附件')
evaluate_application_ids = fields.One2many('evaluate.application.line', 'property_message_id', string='物业信息明细行')
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
default='normal')
active = fields.Boolean('Active', default=True, tracking=True)
def _get_default_name_title(self):
return self._description if self._description else self._name
name_title = fields.Char(default=_get_default_name_title)
def put_property_record(self):
form_id = self.env.ref('yuthon_property_approval.views_property_record_form').id
property_list = []
for record in self.evaluate_application_ids:
property_list.append([0, 0, {'name': record.name,
'owner_id': record.owner_id.id,
'assessment_category':record.assessment_category,
'evaluation_area': record.evaluation_area,
'registered_use': record.registered_use,
'current_status': record.current_status,
'last_hand_rent_price': record.last_hand_rent_price,
'rental_conditions': record.rental_conditions,
'remarks': record.remarks,}])
return {
'name': '提交物业备案审批',
'view_mode': 'form',
'res_model': 'property.record',
'type': 'ir.actions.act_window',
'views': [(form_id, 'form')],
"context": {
'default_evaluate_application_ids':property_list
}
}
@api.onchange('is_issues')
def _onchange_is_issues(self):
if self.is_issues:
issue_id = self.env['issue.library'].create({'name': self.name})
self.related_issues_id = issue_id.id
workflow_record_id = self.env["soong.workflow.record"].search(
[("res_model", "=", self._name), ("res_id", "=", self.id)])
self.env['issue.library.approval.line'].create({
'issue_library_id': issue_id.id,
'workflow_record_id': workflow_record_id.id,
'approval_type': workflow_record_id.workflow_id.id,
'code': self.code,
'approval_date': fields.Datetime.now(),
})
class EvaluateApplicationLine(models.Model):
_name = 'evaluate.application.line'
_description = '物业信息明细行'
property_message_id = fields.Many2one('property.evaluate.application', string='关联评估申请')
premises_id = fields.Many2one('yuthon.premises.setting', string="楼盘")
owner_id = fields.Many2one('yuthon.owner.message', string="权属人")
assessment_category = fields.Selection([('rent_money', '租金'), ('value', '价值')], string="评估类别")
registered_id = fields.Many2one('yuthon.purpose.evidence', string='证载用途')
registered_id2 = fields.Many2one('yuthon.purpose.evidence', string='设定用途')
purpose_id = fields.Many2one('yuthon.resource.purpose', string="管理类型")
rent_id = fields.Many2one('rent.free.setting', string="办法")
start_lease_period = fields.Selection(selection=[(str(i), str(i)) for i in range(1, 7)], string='租期开始', default='1')
end_lease_period = fields.Selection(selection=[(str(i), str(i)) for i in range(1, 7)], string='租期结束', default='6')
annual_increase_percentage = fields.Float(string='每年递增(%)', igits=(6, 2))
property_ids = fields.Many2many('yuthon.property', string="物业集合")
rental_conditions = fields.Text(string='出租条件')
current_status = fields.Date(string='现状(合同到期日)')
evaluation_area = fields.Float(string='评估面积(m²)')
remarks = fields.Text(string='备注')
property_floor = fields.Integer(string="楼层")
units = fields.Char(string="单元")
last_hand_rent_price = fields.Float(string='上一手历史租金单价(元/m²•月)')
gov_rent_price = fields.Float(string='政府租金参考价')
evaluation_rent_price = fields.Float(string='评估散租单价(元/m²•月)')
evaluation_rent_total = fields.Float(string='评估总价(元•月,散租)')
evaluation_whole_rent_price = fields.Float(string='评估整租单价(元/m² •月)')
evaluation_whole_rent_total = fields.Float(string='评估总价(元•月,整租)')
def application_detail(self):
return {
"name": _("物业"),
"type": "ir.actions.act_window",
"view_mode": "form",
"res_model": "yuthon.property",
"views": [[self.env.ref('yuthon_property.yuthon_property_tree').id, "tree"]],
"domain": [('ids', 'in', self.property_ids)]
}