Files
gzth/yuthon_property_approval/models/property_record.py
T
2025-08-04 14:48:59 +08:00

95 lines
5.2 KiB
Python

# -*- coding: utf-8 -*-
# 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
class PropertyRecord(models.Model):
_name = 'property.record'
_description = '物业备案审批'
_inherit = ['mail.thread.main.attachment', 'mail.activity.mixin', 'soong.workflow.mixin']
_rec_name = 'name'
name = fields.Char(string='标题')
code = fields.Char(string="编号", default=lambda self: self.env['ir.sequence'].next_by_code('property_record_code'))
other_company_id = fields.Many2one('res.company', string="评估单位")
evaluation_code = fields.Char(string="评估编号")
evaluation_way = fields.Char(string='评估方法')
base_date = fields.Date(string="基准日")
is_issues = fields.Boolean(string='是否上会')
issues_result = 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="部门")
related_issues_id = fields.Many2one('issue.library', string="关联议题")
expert_review_time = fields.Date(string="专家评审时间")
documents_ids = fields.Many2many('ir.attachment', string='议题附件')
evaluate_application_ids = fields.One2many('evaluated.application.line', 'yuthon_property_evaluated_id',
string='关联物业信息明细行')
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
default='normal')
active = fields.Boolean('Active', default=True, tracking=True)
work_end = fields.Boolean(string="结束")
def _get_default_name_title(self):
return self._description if self._description else self._name
name_title = fields.Char(default=_get_default_name_title)
self_users_ids = fields.Many2many('res.users', string="当前经办人", default=lambda self: [(6, 0, [self.env.user.id])])
@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(),
})
def button_meeting(self):
property_record_ids = self.env["property.record"].browse(
self._context.get('active_ids', self._context.get('active_id')))
form_id = self.env.ref('yuthon_property_approval.view_property_meeting_approval_form').id
return {
"type": "ir.actions.act_window",
"name": "物业出租申报会议审批表",
"res_model": "property.meeting.approval",
"views": [[form_id, "form"]],
}
class EvaluatedApplicationLine(models.Model):
_name = 'evaluated.application.line'
_description = '物业信息明细行(已评估)'
_rec_name = 'property_id'
yuthon_property_evaluated_id = fields.Many2one('property.record', string='关联评估备案表(已评估)')
property_id = fields.Many2one('yuthon.property', 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='证载用途')
purpose_id = fields.Many2one('yuthon.resource.purpose', string="管理类型")
rental_conditions = fields.Text(string='出租条件')
current_status = fields.Date(string='现状(合同到期日)')
evaluation_area = fields.Float(string='评估面积(m²)')
remarks = fields.Text(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='评估总价(元•月,整租)')
property_state = fields.Selection([('to', '待评估'), ('done', '已评估'), ('ing', '评估中'),
('ing_handover', '移交中'), ('done_handover', '已移交'),
('filing', '备案中'), ('net', '挂网'), ('signing', '签约中'),
('signed', '已备案'), ('leased', '已出租'), ('idle', '闲置')], string='状态',
default='to')