78 lines
3.6 KiB
Python
78 lines
3.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import models, fields, api, exceptions, _
|
|
|
|
|
|
class PropertyConfirm(models.Model):
|
|
_name = 'property.confirm'
|
|
_description = '物业成交确认审批'
|
|
_inherit = ['soong.workflow.mixin', 'mail.thread.main.attachment', 'mail.activity.mixin']
|
|
_rec_name = 'name'
|
|
|
|
name = fields.Char(string='标题')
|
|
code = fields.Char(string="编号", default=lambda self: self.env['ir.sequence'].next_by_code('property_confirm_code'))
|
|
property_documents_ids = fields.Many2many('documents.document', string="物业成交确认文件")
|
|
lessee = fields.Char(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="部门")
|
|
active = fields.Boolean('Active', default=True, tracking=True)
|
|
work_end = fields.Boolean(string="结束")
|
|
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度', default='normal')
|
|
is_chapter = fields.Selection([('yes', '是'), ('no', '否')], string='是否用章', default='no')
|
|
property_name = fields.Char(string='物业信息')
|
|
handling_opinions = fields.Text(string="经办意见")
|
|
type_stamp_ids = fields.Many2many('seals.type.setting', string='用章类型', domain="['&', ('start_date', '<=', context_today()), '|', ('end_date', '=', False), ('end_date', '>=', context_today())]")
|
|
documents_ids = fields.Many2many('ir.attachment', string="附件")
|
|
lease_ids = fields.One2many('property.lease.contract.line', 'confirm_id', string="物业列表")
|
|
# 面积:下方物业明细行「可租面积(property_area)」的合计
|
|
property_area = fields.Float(string="面积", compute="_compute_property_area", digits=(16, 4))
|
|
# 租期年限(整型)
|
|
lease_term_years = fields.Integer(string="租期年限")
|
|
# 免租天数(整型)
|
|
rent_free_days = fields.Integer(string="免租天数")
|
|
# 每几年递增(整型,与递增百分比组合成「每 __ 年递增 __ %」)
|
|
increments_few_years = fields.Integer(string="每几年递增")
|
|
# 递增百分比
|
|
annual_increase_percentage = fields.Float(string="递增百分比", digits=(6, 2))
|
|
|
|
@api.depends('lease_ids', 'lease_ids.property_area')
|
|
def _compute_property_area(self):
|
|
# 汇总每条成交确认单下所有物业明细行的可租面积
|
|
for rec in self:
|
|
rec.property_area = sum(rec.lease_ids.mapped('property_area'))
|
|
|
|
def _get_default_name_title(self):
|
|
return '成交确认书'
|
|
|
|
name_title = fields.Char(default=_get_default_name_title)
|
|
|
|
@api.onchange('property_name')
|
|
def _onchange_property_name(self):
|
|
if self.property_name:
|
|
self.name = '成交确认书-' + self.property_name
|
|
else:
|
|
self.name = '成交确认书'
|
|
|
|
def choose_property_button(self):
|
|
return {
|
|
"type": "ir.actions.act_window",
|
|
"name": "批量选择物业信息",
|
|
"res_model": "choose.confirm.property.wizard",
|
|
"view_mode": "form",
|
|
"target": "new",
|
|
"context": {
|
|
'default_confirm_id': self.id,
|
|
}
|
|
}
|
|
|
|
|
|
class PropertyConfirm(models.Model):
|
|
_inherit = 'property.confirm'
|
|
|
|
def action_print_property_confirm(self):
|
|
"""打印成交确认书"""
|
|
self.ensure_one()
|
|
report = self.env.ref('yuthon_property_approval.action_property_confirm_report')
|
|
return report.report_action(self)
|