From 30cb126dac8e6f4891f5348e4b0da33f834540af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Thu, 19 Dec 2024 17:25:22 +0800 Subject: [PATCH 01/13] pengyuthon wechat --- yuthon_property/models/yuthon_property.py | 4 +-- .../views/yuthon_property_views.xml | 5 ++- .../models/property_split_approval.py | 36 +++++++++---------- .../views/property_split_approval_views.xml | 5 ++- 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/yuthon_property/models/yuthon_property.py b/yuthon_property/models/yuthon_property.py index 17c222cb9..e9c2fbac7 100644 --- a/yuthon_property/models/yuthon_property.py +++ b/yuthon_property/models/yuthon_property.py @@ -59,8 +59,7 @@ class YuthonProperty(models.Model): description = fields.Html(string="描述") is_message_fee = fields.Boolean(string="管理费") message_standard_id = fields.Many2one('property.message.fee', string="管理费标准") - code = fields.Char(string="编号", - default=lambda self: self.env['ir.sequence'].next_by_code('property_message_code')) + code = fields.Char(string="编号", default=lambda self: self.env['ir.sequence'].next_by_code('property_message_code')) rental_unit_price = fields.Float(string="评估单价") address = fields.Text(string="物业地址") title_number = fields.Char(string="产权编号") @@ -240,6 +239,7 @@ class YuthonProperty(models.Model): 'default_property_merge_approval_line_ids':property_list }} + class YuthonPropertyWater(models.Model): _name = 'yuthon.property.water' _description = '水表' diff --git a/yuthon_property/views/yuthon_property_views.xml b/yuthon_property/views/yuthon_property_views.xml index 31ee8dc50..3d2f82b37 100644 --- a/yuthon_property/views/yuthon_property_views.xml +++ b/yuthon_property/views/yuthon_property_views.xml @@ -65,7 +65,7 @@ - + @@ -119,7 +119,7 @@ - + @@ -188,7 +188,6 @@ - diff --git a/yuthon_property_approval/models/property_split_approval.py b/yuthon_property_approval/models/property_split_approval.py index 1d634f660..d9cf22018 100644 --- a/yuthon_property_approval/models/property_split_approval.py +++ b/yuthon_property_approval/models/property_split_approval.py @@ -1,4 +1,5 @@ from odoo import models, fields, api, exceptions, _ +from odoo.exceptions import UserError class PropertySplitApproval(models.Model): @@ -6,8 +7,7 @@ class PropertySplitApproval(models.Model): _inherit = ['soong.workflow.mixin', 'mail.thread.main.attachment', 'mail.activity.mixin'] _description = '物业拆分审批' - code = fields.Char(string="编号", - default=lambda self: self.env['ir.sequence'].next_by_code('property_split_approval_code')) + code = fields.Char(string="编号", default=lambda self: self.env['ir.sequence'].next_by_code('property_split_approval_code')) 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="部门") property_id = fields.Many2one('yuthon.property', string='物业名称') @@ -23,25 +23,20 @@ class PropertySplitApproval(models.Model): reason = fields.Html(string="正文") notice_documents_ids = fields.Many2many('ir.attachment', string="附件") property_split_approval_line_ids = fields.One2many('property.split.approval.line', 'property_split_approval_id', string='关联物业拆分明细行') - split_quantity = fields.Integer(string='拆分数量') + split_quantity = fields.Integer(string='拆分数量', default=2) - #自由拆分 - @api.onchange('split_quantity') - def onchange_split_quantity(self): - self.property_split_approval_line_ids.unlink() - for i in range(self.split_quantity): - self.property_split_approval_line_ids.create({ - 'property_split_approval_id': self.id, - 'split_property':self.property_id.name + '-'+str(i+1)}) - - # #平均拆分 - # def put_evaluation_splitting(self): - # for i in range(self.split_quantity): - # self.env['property.split.approval.line'].create({ - # 'property_split_approval_id': self.id, - # 'split_property': self.property_id.name + '-' + str(i + 1), - # 'split_building_area': self.property_id.building_area/self.split_quantity, - # 'split_rent_area': self.property_id.rent_area/self.split_quantity}) + def property_split_button(self): + if self.split_quantity < 2: + raise UserError('拆分数量必须是大于2') + if self.id.origin and self.property_id: + lines_to_create = [] + for i in range(self.split_quantity): + lines_to_create.append({ + 'property_split_approval_id': self.id.origin, + 'split_property': f"{self.property_id.name}-{i + 1}" + }) + self.property_split_approval_line_ids.unlink() + self.env['property.split.approval.line'].create(lines_to_create) def put_split_message(self): property_list = [] @@ -58,6 +53,7 @@ class PropertySplitApproval(models.Model): self.property_id.write({'is_done_split': True}) self.property_id.disassembly_information_ids = property_list + class PropertySplitApprovalLine(models.Model): _name = 'property.split.approval.line' _description = '物业拆分明细行' diff --git a/yuthon_property_approval/views/property_split_approval_views.xml b/yuthon_property_approval/views/property_split_approval_views.xml index ee45d488b..6efc855a8 100644 --- a/yuthon_property_approval/views/property_split_approval_views.xml +++ b/yuthon_property_approval/views/property_split_approval_views.xml @@ -37,6 +37,8 @@ + +