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

111 lines
6.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from email.policy import default
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='标题', default='物业评估申请')
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="是否需要专家评审")
documents_ids = fields.Many2many('ir.attachment', string='议题附件')
property_ids = fields.One2many('yuthon.property.line', 'property_message_id' ,string='物业信息明细行')
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
default='normal')
active = fields.Boolean('Active', default=True, tracking=True)
date_assessment = fields.Date(string='评估基准日')
evaluation_company_id = fields.Many2one('evaluation.company', string='评估公司')
quote = fields.Float(string='报价')
service_money = fields.Float(string='评估服务费总额')
pay_time = fields.Date(string='支付时间')
pay_way = fields.Char(string='支付方式')
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])])
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 YuhtonPropertyLine(models.Model):
_name = 'yuthon.property.line'
_description = '物业信息评估明细'
property_message_id = fields.Many2one('property.evaluate.application', string='关联评估申请')
property_evaluation_id = fields.Many2one('property.evaluation.plan', string="关联物业评估方案")
property_ids = fields.Many2many(related='property_evaluation_id.property_ids', string="物业信息")
owner_id = fields.Many2one('yuthon.owner.message', related='property_evaluation_id.owner_id', string="权属人")
assessment_category = fields.Selection(related='property_evaluation_id.assessment_category', string="评估类别")
lease_period = fields.Integer(related='property_evaluation_id.lease_period', string='租期期限(<=)')
registered_id = fields.Many2one(related='property_evaluation_id.registered_id', string='证载用途')
registered_id2 = fields.Many2one(related='property_evaluation_id.registered_id2', string='设定用途')
annual_increase_percentage = fields.Float(related='property_evaluation_id.annual_increase_percentage', string='每年递增(%)', igits=(6, 2))
purpose_id = fields.Many2one('yuthon.resource.purpose', string="管理类型")
evaluation_area = fields.Float(related='property_evaluation_id.evaluation_area', string='评估面积(m²)')
rent_id = fields.Many2one('rent.free.setting', string="办法")
remarks = fields.Text(related='property_evaluation_id.remake', string='备注')
def application_detail(self):
return {
"name": "物业",
"type": "ir.actions.act_window",
"view_mode": "tree",
"res_model": "yuthon.property",
"target": "new",
"domain": [('id', 'in', self.property_ids.ids)],
}
class EvaluateApplicationLine(models.Model):
_name = 'evaluate.application.line'