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
2 files
+ 14
17
Compare changes
  • Side-by-side
  • Inline
Files
2
import base64
from datetime import datetime
from odoo import _, fields, models
from odoo.exceptions import ValidationError
@@ -20,26 +21,24 @@ class Selfconsumption(models.Model):
for record in self:
record.inscription_count = len(record.inscription_ids)
def get_tables_to_use(self):
"""
Returns distribution tables in "process" or "active" state.
"""
process_tables = self.distribution_table_ids.filtered(
lambda table: table.state == "process"
)
active_tables = self.distribution_table_ids.filtered(
lambda table: table.state == "active"
)
return process_tables or active_tables
def _compute_report_distribution_table(self):
"""
This compute field gets the distribution table needed to generate the reports.
It prioritizes the table in process and then the active one. It can only be one of each.
"""
for record in self:
tables_to_use = record.get_tables_to_use()
record.report_distribution_table = tables_to_use or False
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_active
else:
record.report_distribution_table = False
project_id = fields.Many2one(
"energy_project.project", required=True, ondelete="cascade"
@@ -154,7 +153,7 @@ class Selfconsumption(models.Model):
).report_action(self)
def action_manager_partition_coefficient_report(self):
tables_to_use = self.get_tables_to_use()
tables_to_use = self.report_distribution_table
report_data = []
for table in tables_to_use:
Loading