diff --git a/yuthon_property/models/yuthon_property.py b/yuthon_property/models/yuthon_property.py index 48052d77d..a79d1d3de 100644 --- a/yuthon_property/models/yuthon_property.py +++ b/yuthon_property/models/yuthon_property.py @@ -156,6 +156,25 @@ class YuthonProperty(models.Model): for property_id in property_ids: property_id.compute_is_new() + def update_message(self): + property_ids = self.env["yuthon.property"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + for property_rec in property_ids: + if not property_rec.manage_information_ids: + continue + date_groups = {} + for line in property_rec.manage_information_ids: + date_key = line.start_time or 'no_date' + if date_key not in date_groups: + date_groups[date_key] = [] + date_groups[date_key].append(line.id) + ids_to_unlink = [] + for date_key, line_ids in date_groups.items(): + if len(line_ids) > 1: + ids_to_unlink.extend(line_ids[1:]) + if ids_to_unlink: + self.env['manage.information.line'].browse(ids_to_unlink).unlink() + @api.depends('manage_information_ids', 'manage_information_ids.start_time', 'manage_information_ids.end_date', 'is_done_split') def compute_is_new(self): diff --git a/yuthon_property/views/yuthon_property_views.xml b/yuthon_property/views/yuthon_property_views.xml index c81d7f92b..9635f43ae 100644 --- a/yuthon_property/views/yuthon_property_views.xml +++ b/yuthon_property/views/yuthon_property_views.xml @@ -476,6 +476,13 @@ code action = model.trigger_company_id() + + + 一次性 + + + code + action = model.update_message() 还原物业变更信息