From ff60ea1a9ce0095cf144ea55aa06ace80e975a74 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Thu, 16 Jan 2025 20:16:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_property_approval/__manifest__.py | 3 - yuthon_property_approval/models/__init__.py | 1 + .../models/inherit_yuthon_property.py | 449 ++++++++++++++++++ .../models/property_lease_contract.py | 434 ----------------- .../security/ir.model.access.csv | 1 + .../views/inherit_property_deposit_list.xml | 31 -- .../inherit_property_management_list.xml | 28 -- .../views/inherit_rent_list_views.xml | 323 ------------- .../views/inherit_yuthon_property_views.xml | 356 ++++++++++++++ 9 files changed, 807 insertions(+), 819 deletions(-) create mode 100644 yuthon_property_approval/models/inherit_yuthon_property.py delete mode 100644 yuthon_property_approval/views/inherit_property_deposit_list.xml delete mode 100644 yuthon_property_approval/views/inherit_property_management_list.xml delete mode 100644 yuthon_property_approval/views/inherit_rent_list_views.xml diff --git a/yuthon_property_approval/__manifest__.py b/yuthon_property_approval/__manifest__.py index 077342503..b112eb7e1 100644 --- a/yuthon_property_approval/__manifest__.py +++ b/yuthon_property_approval/__manifest__.py @@ -11,9 +11,6 @@ 'data/sale_renting_code_data.xml', 'data/property_contract_time.xml', 'security/ir.model.access.csv', - 'views/inherit_rent_list_views.xml', - 'views/inherit_property_management_list.xml', - 'views/inherit_property_deposit_list.xml', 'views/property_billing_confirmation.xml', 'views/property_approval_views.xml', 'views/property_business_confirm.xml', diff --git a/yuthon_property_approval/models/__init__.py b/yuthon_property_approval/models/__init__.py index 673da9b6e..3877c9a0d 100644 --- a/yuthon_property_approval/models/__init__.py +++ b/yuthon_property_approval/models/__init__.py @@ -37,3 +37,4 @@ from . import property_merge_approval from . import property_split_approval from . import property_intention_approval from . import property_transfer_approval +from . import inherit_yuthon_property diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py new file mode 100644 index 000000000..9a072bc55 --- /dev/null +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -0,0 +1,449 @@ +from datetime import datetime, timedelta, date +from odoo.tools.float_utils import float_round +from numpy.ma.core import default_filler + +from odoo import models, fields, api, exceptions, _ +from odoo.exceptions import UserError, ValidationError + +class YuthonProperty(models.Model): + _inherit = 'yuthon.property' + + property_contract_ids = fields.One2many('property.contract.line', 'yuthon_property_id', string="关联物业合同明细行") + +# 银行流水 +class PropertyBankStatements(models.Model): + _inherit = 'property.bank.statements' + + contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") + + +class PropertyBankLine(models.Model): + _inherit = 'property.bank.line' + + contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") + +# 应收账单 +class PropertyAccountsReceivable(models.Model): + _inherit = 'property.accounts.receivable' + + contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") + + def receivable_return(self): + model_type_data = { + '水费': 'property.water.list', + '电费': 'property.tariff.list', + '押金': 'property.deposit.list', + '租金': 'property.rent.list' + } + for rec in self: + model_type = model_type_data.get(rec.management_type_id.name) + if model_type: + model_id = self.env[model_type].search([('contract_id', '=', rec.contract_id.id)]) + if model_id: + model_id.write({'is_push': False}) + #删除原记录 + rec.unlink() + + def batch_receivable_return(self): + model_type_data = { + '水费': 'property.water.list', + '电费': 'property.tariff.list', + '押金': 'property.deposit.list', + '租金': 'property.rent.list' + } + archives_ids = self.env["property.accounts.receivable"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + for rec in archives_ids: + model_type = model_type_data.get(rec.management_type_id.name) + if model_type: + model_id = self.env[model_type].search([('contract_id', '=', rec.contract_id.id)]) + if model_id: + model_id.write({'is_push': False}) + rec.unlink() + +# 租金 +class PropertyRentList(models.Model): + _inherit = 'property.rent.list' + + contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") + + def push_rent(self): + for rec in self: + management_type_id = self.env['yuthon.management.type'].search([('name', '=', '租金')], limit=1) + if not management_type_id: + management_type_id = self.env['yuthon.management.type'].create({'name': '租金'}) + self.env['property.accounts.receivable'].create({ + 'contract_id': rec.contract_id.id, + 'property_id': rec.property_id.id, + 'lessee_id':rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'original_amount' : rec.original_amount, + 'due_date': rec.due_date, + 'create_time': datetime.now(), + 'management_type_id':management_type_id.id, + }) + rec.is_push = True + + def batch_push_rent(self): + archives_ids = self.env["property.rent.list"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + management_type_id = self.env['yuthon.management.type'].search([('name', '=', '租金')], limit=1) + for rec in archives_ids: + self.env['property.accounts.receivable'].create({ + 'contract_id': rec.contract_id.id, + 'property_id': rec.property_id.id, + 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'original_amount': rec.original_amount, + 'due_date': rec.due_date, + 'create_time': datetime.now(), + 'management_type_id': management_type_id.id, + }) + rec.is_push = True + +# 押金 +class PropertyDepositList(models.Model): + _inherit = 'property.deposit.list' + + contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") + deposit = fields.Float(related='contract_id.deposit', string="押金/履约保证金", store=True) + performance_bonds = fields.Float(related='contract_id.performance_bonds', string="经营履约保证金") + utility_bills = fields.Float(related='contract_id.utility_bills', string="水电费押金") + renovation_deposit = fields.Float(related='contract_id.renovation_deposit', string="装修押金") + aggregate = fields.Float(string="合计", store=True, compute='_compute_aggregate') + + def push_deposit(self): + for rec in self: + management_type_id = self.env['yuthon.management.type'].search([('name', '=', '押金')], limit=1) + if not management_type_id: + management_type_id = self.env['yuthon.management.type'].create({'name': '押金'}) + self.env['property.accounts.receivable'].create({ + 'contract_id': rec.contract_id.id, + 'property_id': rec.property_id.id, + 'lessee_id':rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'original_amount' : rec.aggregate, + 'create_time': datetime.now(), + 'management_type_id':management_type_id.id, + }) + rec.is_push = True + + def batch_push_deposit(self): + archives_ids = self.env["property.deposit.list"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + management_type_id = self.env['yuthon.management.type'].search([('name', '=', '押金')], limit=1) + for rec in archives_ids: + self.env['property.accounts.receivable'].create({ + 'contract_id': rec.contract_id.id, + 'property_id': rec.property_id.id, + 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'original_amount': rec.aggregate, + 'create_time': datetime.now(), + 'management_type_id': management_type_id.id, + }) + rec.is_push = True + + @api.depends('deposit', 'performance_bonds', 'utility_bills', 'renovation_deposit') + def _compute_aggregate(self): + for rec in self: + rec.aggregate = rec.deposit + rec.performance_bonds + rec.utility_bills + rec.renovation_deposit + +# 管理费 +class PropertyManagementList(models.Model): + _inherit = 'property.management.list' + + contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") + + def push_management(self): + for rec in self: + management_type_id = self.env['yuthon.management.type'].search([('name', '=', '管理费')], limit=1) + if not management_type_id: + management_type_id = self.env['yuthon.management.type'].create({'name': '管理费'}) + self.env['property.accounts.receivable'].create({ + 'contract_id': rec.contract_id.id, + 'property_id': rec.property_id.id, + 'lessee_id':rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'original_amount' : rec.original_amount, + 'due_date':rec.due_date, + 'create_time': datetime.now(), + 'management_type_id':management_type_id.id, + }) + rec.is_push = True + + def batch_push_management(self): + archives_ids = self.env["property.management.list"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + management_type_id = self.env['yuthon.management.type'].search([('name', '=', '电费')], limit=1) + for rec in archives_ids: + self.env['property.accounts.receivable'].create({ + 'contract_id': rec.contract_id.id, + 'property_id': rec.property_id.id, + 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'original_amount': rec.original_amount, + 'create_time': datetime.now(), + 'management_type_id': management_type_id.id, + }) + rec.is_push = True + +# 电费 +class PropertyTariffList(models.Model): + _inherit = 'property.tariff.list' + + contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") + + def push_tariff(self): + for rec in self: + management_type_id = self.env['yuthon.management.type'].search([('name', '=', '电费')], limit=1) + if not management_type_id: + management_type_id = self.env['yuthon.management.type'].create({'name': '电费'}) + self.env['property.accounts.receivable'].create({ + 'contract_id': rec.contract_id.id, + 'property_id': rec.property_id.id, + 'lessee_id':rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'original_amount' : rec.original_amount, + 'due_date': rec.due_date, + 'create_time': datetime.now(), + 'management_type_id':management_type_id.id, + }) + rec.is_push = True + + def batch_push_tariff(self): + archives_ids = self.env["property.tariff.list"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + management_type_id = self.env['yuthon.management.type'].search([('name', '=', '电费')], limit=1) + for rec in archives_ids: + self.env['property.accounts.receivable'].create({ + 'contract_id': rec.contract_id.id, + 'property_id': rec.property_id.id, + 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'original_amount': rec.original_amount, + 'due_date': rec.due_date, + 'create_time': datetime.now(), + 'management_type_id': management_type_id.id, + }) + rec.is_push = True + +# 水费 +class PropertyWaterList(models.Model): + _inherit = 'property.water.list' + + contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") + + def push_water(self): + for rec in self: + management_type_id = self.env['yuthon.management.type'].search([('name', '=', '水费')], limit=1) + if not management_type_id: + management_type_id = self.env['yuthon.management.type'].create({'name': '水费'}) + self.env['property.accounts.receivable'].create({ + 'contract_id': rec.contract_id.id, + 'property_id': rec.property_id.id, + 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'original_amount': rec.original_amount, + 'create_time': datetime.now(), + 'management_type_id': management_type_id.id, + }) + rec.is_push = True + + def batch_push_water(self): + archives_ids = self.env["property.water.list"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + management_type_id = self.env['yuthon.management.type'].search([('name', '=', '水费')], limit=1) + for rec in archives_ids: + self.env['property.accounts.receivable'].create({ + 'contract_id': rec.contract_id.id, + 'property_id': rec.property_id.id, + 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'original_amount': rec.original_amount, + 'create_time': datetime.now(), + 'management_type_id': management_type_id.id, + }) + rec.is_push = True + +# 电表抄表 +class PropertyElectricReading(models.Model): + _inherit = 'property.electric.reading' + + contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") + + def button_push_electric(self): + for rec in self: + if rec.is_push: + raise UserError("该抄表已经推送,不能重复推送") + self.env["property.tariff.list"].create({ + 'tariff_meter_number': rec.code, + 'property_id': rec.property_id.id if rec.property_id else None, + 'contract_id': rec.contract_id.id if rec.contract_id else None, + 'lessee_id':rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'fee_id': rec.fee_id.id if rec.fee_id else None, + 'due_date': rec.meter_date, + 'original_amount':rec.fee_id.amount * rec.dosage if rec.fee_id.amount else 0, + 'tariff_meter_reading': rec.dosage + }) + rec.write({ + 'is_push': True, + }) + def batch_reading_electric(self): + archives_ids = self.env["property.electric.reading"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + for record in archives_ids: + if record.is_push: + raise UserError(f"该{record.name}仪表已经推送,不能重复推送") + self.env["property.water.list"].create({ + 'tariff_meter_number': record.code, + 'property_id': record.property_id.id if record.property_id else None, + 'contract_id': record.contract_id.id if record.contract_id else None, + 'lessee_id': record.contract_id.lessee_id.id if record.contract_id.lessee_id else None, + 'fee_id': record.fee_id.id if record.fee_id else None, + 'due_date': record.meter_date, + 'original_amount': record.fee_id.amount * record.dosage if record.fee_id.amount else 0, + 'tariff_meter_reading': record.dosage + }) + record.write({ + 'is_push': True, + }) + +# 水表抄表 +class PropertyWaterReading(models.Model): + _inherit = 'property.water.reading' + + contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") + + def button_push_water(self): + for rec in self: + if rec.is_push: + raise UserError("该抄表已经推送,不能重复推送") + self.env["property.water.list"].create({ + 'water_meter_number': rec.code, + 'property_id': rec.property_id.id if rec.property_id else None, + 'fee_id': rec.fee_id.id if rec.fee_id else None, + 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'contract_id': rec.contract_id.id if rec.contract_id else None, + 'original_amount': rec.fee_id.amount * rec.dosage if rec.fee_id.amount else 0, + 'due_date': rec.meter_date, + 'water_meter_reading':rec.dosage + }) + rec.write({ + 'is_push': True, + }) + def batch_reading_water(self): + archives_ids = self.env["property.water.reading"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + for record in archives_ids: + if record.is_push: + raise UserError(f"该{record.name}仪表已经推送,不能重复推送") + self.env["property.water.list"].create({ + 'water_meter_number': record.code, + 'property_id': record.property_id.id if record.property_id else None, + 'contract_id': record.contract_id.id if record.contract_id else None, + 'lessee_id': record.contract_id.lessee_id.id if record.contract_id.lessee_id else None, + 'fee_id': record.fee_id.id if record.fee_id else None, + 'due_date': record.meter_date, + 'original_amount': record.fee_id.amount * record.dosage if record.fee_id.amount else 0, + 'water_meter_reading':record.dosage + }) + record.write({ + 'is_push': True, + }) + +# 电表库 +class PropertyMeterArchives(models.Model): + _inherit = 'property.meter.archives' + + contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") + + def batch_contract_association(self): + archives_ids = self.env["property.meter.archives"].browse(self._context.get('active_ids', self._context.get('active_id'))) + for record in archives_ids: + if record.yuthon_property_id.id: + contract_id = self.env["property.lease.contract.line"].search([('address_id', '=', record.yuthon_property_id.id)], limit=1) + if contract_id: + record.sudo().write({ + 'contract_id': contract_id.lease_id.id}) + + def button_reading_push(self): + for rec in self: + if rec.is_push: + raise UserError("该仪表已经推送,不能重复推送") + self.env["property.electric.reading"].create({ + 'code': rec.name, + 'property_id': rec.yuthon_property_id.id if rec.yuthon_property_id else None, + 'fee_id': rec.fee_id.id if rec.standards_id else None, + 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'ratio': rec.gauge_magnification, + 'position': rec.unit_number, + 'type': rec.type, + 'contract_id':rec.contract_id.id + }) + rec.write({ + 'is_push': True, + }) + + def batch_reading_push(self): + archives_ids = self.env["property.meter.archives"].browse(self._context.get('active_ids', self._context.get('active_id'))) + for record in archives_ids: + if record.is_push: + raise UserError(f"该{record.name}仪表已经推送,不能重复推送") + self.env["property.electric.reading"].create({ + 'code': record.name, + 'property_id': record.yuthon_property_id.id if record.yuthon_property_id else None, + 'fee_id': record.standards_id.id if record.standards_id else None, + 'lessee_id': record.contract_id.lessee_id.id if record.contract_id.lessee_id else None, + 'ratio': record.gauge_magnification, + 'position': record.unit_number, + 'type': record.type, + 'contract_id':record.contract_id.id + }) + record.write({ + 'is_push': True, + }) + +# 水表库 +class PropertyMeterWater(models.Model): + _inherit = 'property.meter.water' + + contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") + + def button_reading_water_push(self): + for rec in self: + if rec.is_push: + raise UserError(f"该仪表已经推送,不能重复推送") + self.env["property.water.reading"].create({ + 'code': rec.name , + 'property_id': rec.yuthon_property_id.id if rec.yuthon_property_id else None, + 'ratio': rec.gauge_magnification, + 'fee_id': rec.standards_id.id if rec.standards_id else None, + 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, + 'position': rec.unit_number , + 'type': rec.type, + 'contract_id': rec.contract_id.id + }) + rec.write({ + 'is_push': True, + }) + + def batch_reading_water_push(self): + water_ids = self.env["property.meter.water"].browse(self._context.get('active_ids', self._context.get('active_id'))) + for record in water_ids: + record.write({ + 'is_push': True, + }) + if record.is_push: + raise UserError(f"该{record.unit_number}仪表已经推送,不能重复推送") + self.env["property.water.reading"].create({ + 'code': record.name, + 'property_id': record.yuthon_property_id.id if record.yuthon_property_id else None, + 'fee_id': record.standards_id.id if record.standards_id else None, + 'lessee_id': record.contract_id.lessee_id.id if record.contract_id.lessee_id else None, + 'ratio': record.gauge_magnification, + 'position': record.unit_number, + 'type': record.type, + 'contract_id': record.contract_id.id + }) + + def batch_contract_association_water(self): + archives_ids = self.env["property.meter.water"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + for record in archives_ids: + if record.yuthon_property_id.id: + contract_id = self.env["property.lease.contract.line"].search( + [('address_id', '=', record.yuthon_property_id.id)], limit=1) + if contract_id: + record.sudo().write({ + 'contract_id': contract_id.lease_id.id}) diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index 9e2c2fe70..c7f47ecc6 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -11,440 +11,6 @@ from odoo import models, fields, api, exceptions, _ from odoo.exceptions import UserError, ValidationError -class PropertyAccountsReceivable(models.Model): - _inherit = 'property.accounts.receivable' - - contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - - def receivable_return(self): - model_type_data = { - '水费': 'property.water.list', - '电费': 'property.tariff.list', - '押金': 'property.deposit.list', - '租金': 'property.rent.list' - } - for rec in self: - model_type = model_type_data.get(rec.management_type_id.name) - if model_type: - model_id = self.env[model_type].search([('contract_id', '=', rec.contract_id.id)]) - if model_id: - model_id.write({'is_push': False}) - #删除原记录 - rec.unlink() - - def batch_receivable_return(self): - model_type_data = { - '水费': 'property.water.list', - '电费': 'property.tariff.list', - '押金': 'property.deposit.list', - '租金': 'property.rent.list' - } - archives_ids = self.env["property.accounts.receivable"].browse( - self._context.get('active_ids', self._context.get('active_id'))) - for rec in archives_ids: - model_type = model_type_data.get(rec.management_type_id.name) - if model_type: - model_id = self.env[model_type].search([('contract_id', '=', rec.contract_id.id)]) - if model_id: - model_id.write({'is_push': False}) - rec.unlink() - -class PropertyRentList(models.Model): - _inherit = 'property.rent.list' - - contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - - def push_rent(self): - for rec in self: - management_type_id = self.env['yuthon.management.type'].search([('name', '=', '租金')], limit=1) - if not management_type_id: - management_type_id = self.env['yuthon.management.type'].create({'name': '租金'}) - self.env['property.accounts.receivable'].create({ - 'contract_id': rec.contract_id.id, - 'property_id': rec.property_id.id, - 'lessee_id':rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'original_amount' : rec.original_amount, - 'due_date': rec.due_date, - 'create_time': datetime.now(), - 'management_type_id':management_type_id.id, - }) - rec.is_push = True - - def batch_push_rent(self): - archives_ids = self.env["property.rent.list"].browse( - self._context.get('active_ids', self._context.get('active_id'))) - management_type_id = self.env['yuthon.management.type'].search([('name', '=', '租金')], limit=1) - for rec in archives_ids: - self.env['property.accounts.receivable'].create({ - 'contract_id': rec.contract_id.id, - 'property_id': rec.property_id.id, - 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'original_amount': rec.original_amount, - 'due_date': rec.due_date, - 'create_time': datetime.now(), - 'management_type_id': management_type_id.id, - }) - rec.is_push = True - -class PropertyDepositList(models.Model): - _inherit = 'property.deposit.list' - - contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - deposit = fields.Float(related='contract_id.deposit', string="押金/履约保证金", store=True) - performance_bonds = fields.Float(related='contract_id.performance_bonds', string="经营履约保证金") - utility_bills = fields.Float(related='contract_id.utility_bills', string="水电费押金") - renovation_deposit = fields.Float(related='contract_id.renovation_deposit', string="装修押金") - aggregate = fields.Float(string="合计", store=True, compute='_compute_aggregate') - - def push_deposit(self): - for rec in self: - management_type_id = self.env['yuthon.management.type'].search([('name', '=', '押金')], limit=1) - if not management_type_id: - management_type_id = self.env['yuthon.management.type'].create({'name': '押金'}) - self.env['property.accounts.receivable'].create({ - 'contract_id': rec.contract_id.id, - 'property_id': rec.property_id.id, - 'lessee_id':rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'original_amount' : rec.aggregate, - 'create_time': datetime.now(), - 'management_type_id':management_type_id.id, - }) - rec.is_push = True - - def batch_push_deposit(self): - archives_ids = self.env["property.deposit.list"].browse( - self._context.get('active_ids', self._context.get('active_id'))) - management_type_id = self.env['yuthon.management.type'].search([('name', '=', '押金')], limit=1) - for rec in archives_ids: - self.env['property.accounts.receivable'].create({ - 'contract_id': rec.contract_id.id, - 'property_id': rec.property_id.id, - 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'original_amount': rec.aggregate, - 'create_time': datetime.now(), - 'management_type_id': management_type_id.id, - }) - rec.is_push = True - - @api.depends('deposit', 'performance_bonds', 'utility_bills', 'renovation_deposit') - def _compute_aggregate(self): - for rec in self: - rec.aggregate = rec.deposit + rec.performance_bonds + rec.utility_bills + rec.renovation_deposit - -class PropertyManagementList(models.Model): - _inherit = 'property.management.list' - - contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - - def push_management(self): - for rec in self: - management_type_id = self.env['yuthon.management.type'].search([('name', '=', '管理费')], limit=1) - if not management_type_id: - management_type_id = self.env['yuthon.management.type'].create({'name': '管理费'}) - self.env['property.accounts.receivable'].create({ - 'contract_id': rec.contract_id.id, - 'property_id': rec.property_id.id, - 'lessee_id':rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'original_amount' : rec.original_amount, - 'due_date':rec.due_date, - 'create_time': datetime.now(), - 'management_type_id':management_type_id.id, - }) - rec.is_push = True - - def batch_push_management(self): - archives_ids = self.env["property.management.list"].browse( - self._context.get('active_ids', self._context.get('active_id'))) - management_type_id = self.env['yuthon.management.type'].search([('name', '=', '电费')], limit=1) - for rec in archives_ids: - self.env['property.accounts.receivable'].create({ - 'contract_id': rec.contract_id.id, - 'property_id': rec.property_id.id, - 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'original_amount': rec.original_amount, - 'create_time': datetime.now(), - 'management_type_id': management_type_id.id, - }) - rec.is_push = True - -class YuthonProperty(models.Model): - _inherit = 'yuthon.property' - - property_contract_ids = fields.One2many('property.contract.line', 'yuthon_property_id', string="关联物业合同明细行") - - -class PropertyBankStatements(models.Model): - _inherit = 'property.bank.statements' - - contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - - -class PropertyBankLine(models.Model): - _inherit = 'property.bank.line' - - contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - - -class PropertyTariffList(models.Model): - _inherit = 'property.tariff.list' - - contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - - def push_tariff(self): - for rec in self: - management_type_id = self.env['yuthon.management.type'].search([('name', '=', '电费')], limit=1) - if not management_type_id: - management_type_id = self.env['yuthon.management.type'].create({'name': '电费'}) - self.env['property.accounts.receivable'].create({ - 'contract_id': rec.contract_id.id, - 'property_id': rec.property_id.id, - 'lessee_id':rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'original_amount' : rec.original_amount, - 'due_date': rec.due_date, - 'create_time': datetime.now(), - 'management_type_id':management_type_id.id, - }) - rec.is_push = True - - def batch_push_tariff(self): - archives_ids = self.env["property.tariff.list"].browse( - self._context.get('active_ids', self._context.get('active_id'))) - management_type_id = self.env['yuthon.management.type'].search([('name', '=', '电费')], limit=1) - for rec in archives_ids: - self.env['property.accounts.receivable'].create({ - 'contract_id': rec.contract_id.id, - 'property_id': rec.property_id.id, - 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'original_amount': rec.original_amount, - 'due_date': rec.due_date, - 'create_time': datetime.now(), - 'management_type_id': management_type_id.id, - }) - rec.is_push = True - - -class PropertyWaterList(models.Model): - _inherit = 'property.water.list' - - contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - - def push_water(self): - for rec in self: - management_type_id = self.env['yuthon.management.type'].search([('name', '=', '水费')], limit=1) - if not management_type_id: - management_type_id = self.env['yuthon.management.type'].create({'name': '水费'}) - self.env['property.accounts.receivable'].create({ - 'contract_id': rec.contract_id.id, - 'property_id': rec.property_id.id, - 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'original_amount': rec.original_amount, - 'create_time': datetime.now(), - 'management_type_id': management_type_id.id, - }) - rec.is_push = True - - def batch_push_water(self): - archives_ids = self.env["property.water.list"].browse( - self._context.get('active_ids', self._context.get('active_id'))) - management_type_id = self.env['yuthon.management.type'].search([('name', '=', '水费')], limit=1) - for rec in archives_ids: - self.env['property.accounts.receivable'].create({ - 'contract_id': rec.contract_id.id, - 'property_id': rec.property_id.id, - 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'original_amount': rec.original_amount, - 'create_time': datetime.now(), - 'management_type_id': management_type_id.id, - }) - rec.is_push = True - -class PropertyElectricReading(models.Model): - _inherit = 'property.electric.reading' - - contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - - def button_push_electric(self): - for rec in self: - if rec.is_push: - raise UserError("该抄表已经推送,不能重复推送") - self.env["property.tariff.list"].create({ - 'tariff_meter_number': rec.code, - 'property_id': rec.property_id.id if rec.property_id else None, - 'contract_id': rec.contract_id.id if rec.contract_id else None, - 'lessee_id':rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'fee_id': rec.fee_id.id if rec.fee_id else None, - 'due_date': rec.meter_date, - 'original_amount':rec.fee_id.amount * rec.dosage if rec.fee_id.amount else 0, - 'tariff_meter_reading': rec.dosage - }) - rec.write({ - 'is_push': True, - }) - def batch_reading_electric(self): - archives_ids = self.env["property.electric.reading"].browse( - self._context.get('active_ids', self._context.get('active_id'))) - for record in archives_ids: - if record.is_push: - raise UserError(f"该{record.name}仪表已经推送,不能重复推送") - self.env["property.water.list"].create({ - 'tariff_meter_number': record.code, - 'property_id': record.property_id.id if record.property_id else None, - 'contract_id': record.contract_id.id if record.contract_id else None, - 'lessee_id': record.contract_id.lessee_id.id if record.contract_id.lessee_id else None, - 'fee_id': record.fee_id.id if record.fee_id else None, - 'due_date': record.meter_date, - 'original_amount': record.fee_id.amount * record.dosage if record.fee_id.amount else 0, - 'tariff_meter_reading': record.dosage - }) - record.write({ - 'is_push': True, - }) -class PropertyWaterReading(models.Model): - _inherit = 'property.water.reading' - - contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - - def button_push_water(self): - for rec in self: - if rec.is_push: - raise UserError("该抄表已经推送,不能重复推送") - self.env["property.water.list"].create({ - 'water_meter_number': rec.code, - 'property_id': rec.property_id.id if rec.property_id else None, - 'fee_id': rec.fee_id.id if rec.fee_id else None, - 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'contract_id': rec.contract_id.id if rec.contract_id else None, - 'original_amount': rec.fee_id.amount * rec.dosage if rec.fee_id.amount else 0, - 'due_date': rec.meter_date, - 'water_meter_reading':rec.dosage - }) - rec.write({ - 'is_push': True, - }) - def batch_reading_water(self): - archives_ids = self.env["property.water.reading"].browse( - self._context.get('active_ids', self._context.get('active_id'))) - for record in archives_ids: - if record.is_push: - raise UserError(f"该{record.name}仪表已经推送,不能重复推送") - self.env["property.water.list"].create({ - 'water_meter_number': record.code, - 'property_id': record.property_id.id if record.property_id else None, - 'contract_id': record.contract_id.id if record.contract_id else None, - 'lessee_id': record.contract_id.lessee_id.id if record.contract_id.lessee_id else None, - 'fee_id': record.fee_id.id if record.fee_id else None, - 'due_date': record.meter_date, - 'original_amount': record.fee_id.amount * record.dosage if record.fee_id.amount else 0, - 'water_meter_reading':record.dosage - }) - record.write({ - 'is_push': True, - }) -class PropertyMeterArchives(models.Model): - _inherit = 'property.meter.archives' - - contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - - def batch_contract_association(self): - archives_ids = self.env["property.meter.archives"].browse(self._context.get('active_ids', self._context.get('active_id'))) - for record in archives_ids: - if record.yuthon_property_id.id: - contract_id = self.env["property.lease.contract.line"].search([('address_id', '=', record.yuthon_property_id.id)], limit=1) - if contract_id: - record.sudo().write({ - 'contract_id': contract_id.lease_id.id}) - - def button_reading_push(self): - for rec in self: - if rec.is_push: - raise UserError("该仪表已经推送,不能重复推送") - self.env["property.electric.reading"].create({ - 'code': rec.name, - 'property_id': rec.yuthon_property_id.id if rec.yuthon_property_id else None, - 'fee_id': rec.fee_id.id if rec.standards_id else None, - 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'ratio': rec.gauge_magnification, - 'position': rec.unit_number, - 'type': rec.type, - 'contract_id':rec.contract_id.id - }) - rec.write({ - 'is_push': True, - }) - - def batch_reading_push(self): - archives_ids = self.env["property.meter.archives"].browse(self._context.get('active_ids', self._context.get('active_id'))) - for record in archives_ids: - if record.is_push: - raise UserError(f"该{record.name}仪表已经推送,不能重复推送") - self.env["property.electric.reading"].create({ - 'code': record.name, - 'property_id': record.yuthon_property_id.id if record.yuthon_property_id else None, - 'fee_id': record.standards_id.id if record.standards_id else None, - 'lessee_id': record.contract_id.lessee_id.id if record.contract_id.lessee_id else None, - 'ratio': record.gauge_magnification, - 'position': record.unit_number, - 'type': record.type, - 'contract_id':record.contract_id.id - }) - record.write({ - 'is_push': True, - }) - - -class PropertyMeterWater(models.Model): - _inherit = 'property.meter.water' - - contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - - def button_reading_water_push(self): - for rec in self: - if rec.is_push: - raise UserError(f"该仪表已经推送,不能重复推送") - self.env["property.water.reading"].create({ - 'code': rec.name , - 'property_id': rec.yuthon_property_id.id if rec.yuthon_property_id else None, - 'ratio': rec.gauge_magnification, - 'fee_id': rec.standards_id.id if rec.standards_id else None, - 'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None, - 'position': rec.unit_number , - 'type': rec.type, - 'contract_id': rec.contract_id.id - }) - rec.write({ - 'is_push': True, - }) - - def batch_reading_water_push(self): - water_ids = self.env["property.meter.water"].browse(self._context.get('active_ids', self._context.get('active_id'))) - for record in water_ids: - record.write({ - 'is_push': True, - }) - if record.is_push: - raise UserError(f"该{record.unit_number}仪表已经推送,不能重复推送") - self.env["property.water.reading"].create({ - 'code': record.name, - 'property_id': record.yuthon_property_id.id if record.yuthon_property_id else None, - 'fee_id': record.standards_id.id if record.standards_id else None, - 'lessee_id': record.contract_id.lessee_id.id if record.contract_id.lessee_id else None, - 'ratio': record.gauge_magnification, - 'position': record.unit_number, - 'type': record.type, - 'contract_id': record.contract_id.id - }) - - def batch_contract_association_water(self): - archives_ids = self.env["property.meter.water"].browse( - self._context.get('active_ids', self._context.get('active_id'))) - for record in archives_ids: - if record.yuthon_property_id.id: - contract_id = self.env["property.lease.contract.line"].search( - [('address_id', '=', record.yuthon_property_id.id)], limit=1) - if contract_id: - record.sudo().write({ - 'contract_id': contract_id.lease_id.id}) - class PropertyContractLine(models.Model): _name = 'property.contract.line' _description = '物业合同明细行' diff --git a/yuthon_property_approval/security/ir.model.access.csv b/yuthon_property_approval/security/ir.model.access.csv index 4658e01f7..5159fa92f 100644 --- a/yuthon_property_approval/security/ir.model.access.csv +++ b/yuthon_property_approval/security/ir.model.access.csv @@ -65,3 +65,4 @@ access_property_subset_contract,property_subset_contract,model_property_subset_c access_property_contract_line,property_contract_line,model_property_contract_line,base.group_user,1,1,1,1 access_choose_property_wizard,choose_property_wizard,model_choose_property_wizard,base.group_user,1,1,1,1 access_property_rental_wizard,property_rental_wizard,model_property_rental_wizard,base.group_user,1,1,1,1 + diff --git a/yuthon_property_approval/views/inherit_property_deposit_list.xml b/yuthon_property_approval/views/inherit_property_deposit_list.xml deleted file mode 100644 index 9e2323ded..000000000 --- a/yuthon_property_approval/views/inherit_property_deposit_list.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - property.deposit.list.tree - property.deposit.list - - - - - - - - - -