Skip to content
Snippets Groups Projects

[REL] 14.0.2.0.0

Merged Daniil Digtyar Vasilieva requested to merge release/14.0.1.1.14 into 14.0
1 file
+ 6
3
Compare changes
  • Side-by-side
  • Inline
@@ -36,11 +36,14 @@ class Inscription(models.Model):
matching_tables = self.project_id.selfconsumption_id.distribution_table_ids.filtered(
lambda table: table.state in ('validated', 'process', 'active')
)
return matching_tables
matching_assignations = matching_tables.mapped('supply_point_assignation_ids').filtered(
lambda assignation: assignation.supply_point_id.partner_id == self.partner_id
)
return matching_assignations
def get_matching_supply_assignations_to_remove(self):
supply_point_assignations = self.env['energy_selfconsumption.supply_point_assignation'].search([
('distribution_table_id.selfconsumption_project_id.inscription_ids.partner_id', '=', self.partner_id.id),
('supply_point_id.partner_id', '=', self.partner_id.id),
('selfconsumption_project_id', '=', self.project_id.id),
('distribution_table_id.state', '=', 'draft')
])
@@ -49,7 +52,7 @@ class Inscription(models.Model):
def unlink(self):
matching_assignations = self.has_matching_supply_assignations()
if len(matching_assignations) > 0:
table_states = ', '.join(matching_assignations.mapped('state'))
table_states = ', '.join(matching_assignations.distribution_table_id.mapped('state'))
raise ValidationError(_("The inscription cannot be deleted. It is related to a distribution table with state: {table_state}").format(table_state=table_states))
supply_point_assignations = self.get_matching_supply_assignations_to_remove()
if supply_point_assignations:
Loading