Skip to content
Snippets Groups Projects

[IMP] selfconsumption: report ditribution report

Compare and
3 files
+ 264
28
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -21,6 +21,22 @@ class Selfconsumption(models.Model):
for record in self:
record.inscription_count = len(record.inscription_ids)
def _compute_report_distribution_table(self):
for record in self:
table_in_process = record.distribution_table_ids.filtered_domain(
[("state", "=", "process")]
)
table_in_active = record.distribution_table_ids.filtered_domain(
[("state", "=", "active")]
)
if table_in_process:
record.report_distribution_table = table_in_process
elif table_in_active:
record.report_distribution_table = table_in_process
else:
record.report_distribution_table = False
project_id = fields.Many2one(
"energy_project.project", required=True, ondelete="cascade"
)
@@ -40,6 +56,11 @@ class Selfconsumption(models.Model):
"selfconsumption_project_id",
readonly=True,
)
report_distribution_table = fields.Many2one(
"energy_selfconsumption.distribution_table",
compute=_compute_report_distribution_table,
readonly=True,
)
distribution_table_count = fields.Integer(compute=_compute_distribution_table_count)
inscription_ids = fields.One2many(
"energy_project.inscription", "project_id", readonly=True
@@ -124,6 +145,12 @@ class Selfconsumption(models.Model):
"energy_selfconsumption.selfconsumption_manager_authorization_report"
).report_action(self)
def action_power_sharing_agreement_report(self):
self.ensure_one()
return self.env.ref(
"energy_selfconsumption.power_sharing_agreement_report"
).report_action(self)
def action_manager_partition_coefficient_report(self):
report_data = []
process_tables = self.distribution_table_ids.filtered(
Loading