diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index 141dce0ca..f43e07579 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -143,18 +143,21 @@ class PropertyBankStatements(models.Model): contract_ids = fields.Many2many('property.lease.contract', string="租赁合同审批") property_name = fields.Text(string="物业名称", compute="compute_property_name", store=True) accounts_id = fields.Many2one('property.accounts.approval', string="关联生成应收审批单") - lessee_id = fields.Many2one('property.tenant.information', string='承租方', compute="_compute_property_employee_id") + lessee_ids = fields.Many2many('property.tenant.information', string='承租方', compute="_compute_property_employee_id") admin_id = fields.Many2one('res.users', string="片区管理员", compute="_compute_property_employee_id", store=True, index=True) @api.depends('contract_ids') def _compute_property_employee_id(self): - for emp in self: - if emp.contract_ids: - emp.admin_id = emp.contract_ids[0].admin_id.id - emp.lessee_id = emp.contract_ids[0].lessee_id.id - else: - emp.admin_id = False - emp.lessee_id = False + for record in self: + lessee_set = set() + if record.contract_ids: + for contract in record.contract_ids: + if contract.lessee_id: + lessee_set.add(contract.lessee_id.id) + record.admin_id = record.contract_ids[0].admin_id.id if record.contract_ids[0].admin_id else False + record.lessee_ids = [(6, 0, list(lessee_set))] if lessee_set else [(5, 0, 0)] + + def update_property_name(self): property_ids = self.env["property.bank.statements"].browse( diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml index d50d19062..e3fccab5c 100644 --- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml +++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml @@ -628,7 +628,7 @@ - +