Skip to content
Snippets Groups Projects
Commit 99dddc1e authored by Daniil Digtyar Vasilieva's avatar Daniil Digtyar Vasilieva :call_me:
Browse files

[IMP] added decorator to indicate sum of coefficient to 1

parent ff3dbd77
No related branches found
No related tags found
3 merge requests!138Hotfix setup name error,!134Release v14.0.1.1.6,!126[IMP] Feature/add energy selfconsumption distribution table
......@@ -14,8 +14,14 @@ class DistributionTable(models.Model):
_name = 'energy_selfconsumption.distribution_table'
_description = 'Distribution Table'
@api.depends('supply_point_assignation_ids.coefficient')
def _compute_coefficient_is_valid(self):
for record in self:
record.coefficient_is_valid = sum(record.supply_point_assignation_ids.mapped('coefficient')) == 1
name = fields.Char()
selfconsumption_project_id = fields.Many2one('energy_selfconsumption.selfconsumption', required=True)
type = fields.Selection(TYPE_VALUES, default="fixed", required=True, string="Modality")
state = fields.Selection(STATE_VALUES, default="draft", required=True)
supply_point_assignation_ids = fields.One2many('energy_selfconsumption.supply_point_assignation', 'distribution_table_id')
coefficient_is_valid = fields.Boolean(compute=_compute_coefficient_is_valid, readonly=True, store=False)
\ No newline at end of file
......@@ -9,4 +9,4 @@ class SupplyPointAssignation(models.Model):
supply_point_id = fields.Many2one('energy_selfconsumption.supply_point', required=True)
coefficient = fields.Float(string='Distribution coefficient')
owner_id = fields.Many2one("res.partner", related='supply_point_id.owner_id')
table_coefficient_is_valid = fields.Boolean(related='distribution_table_id.coefficient_is_valid')
......@@ -33,13 +33,15 @@
mode="list"
context="{'default_distribution_table_id':id}"
>
<tree editable="bottom">
<tree editable="bottom"
decoration-success="table_coefficient_is_valid == True">
<field name="table_coefficient_is_valid" invisible="True"/>
<field
name="supply_point_id"
options="{'no_create': True}"
/>
<field name="owner_id"/>
<field name="coefficient"/>
<field name="coefficient" sum="True"/>
</tree>
</field>
</group>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment