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

[IMP] added intelligent button to show distritbution tables

parent 01761c7d
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
......@@ -10,12 +10,30 @@ class Selfconsumption(models.Model):
}
_description = "Self-consumption Energy Project"
def _compute_distribution_table_count(self):
for record in self:
record.distribution_table_count = len(record.distribution_table_ids)
project_id = fields.Many2one(
"energy_project.project", required=True, ondelete="cascade"
)
code = fields.Char(string="CAU")
power = fields.Float(string="Generation Power (kWh)")
distribution_table_id = fields.Many2one('energy_selfconsumption.distribution_table')
distribution_table_ids = fields.One2many('energy_selfconsumption.distribution_table', 'selfconsumption_project_id',
readonly=True)
distribution_table_count = fields.Integer(compute=_compute_distribution_table_count)
def get_distribution_tables(self):
self.ensure_one()
return {
'type': 'ir.actions.act_window',
'name': 'Distribution Tables',
'view_mode': 'tree,form',
'res_model': 'energy_selfconsumption.distribution_table',
'domain': [('selfconsumption_project_id', '=', self.id)],
'context': {'create': True, 'default_selfconsumption_project_id': self.id},
}
def set_activation(self):
for record in self:
......
......@@ -28,6 +28,13 @@
/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button" type="object" name="get_distribution_tables"
icon="fa-table" context="{'default_owner_id': id}"
attrs="{'invisible': [('state', '==', 'draft')]}">
<field string="Distribution Tables" name="distribution_table_count" widget="statinfo"/>
</button>
</div>
<widget
name="web_ribbon"
text="Archived"
......
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