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

[IMP] assign name to new distribution tables

parent bf402d10
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
......@@ -18,6 +18,7 @@
"security/ir.model.access.csv",
"security/ir_rule_data.xml",
"data/project_type_data.xml",
"data/ir_sequence_data.xml",
"views/selfconsumption_views.xml",
"views/supply_point_views.xml",
"views/res_partner_views.xml",
......
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<record id="distribution_table_sequence" model="ir.sequence">
<field name="name">Distribution Table Sequence</field>
<field name="code">energy_selfconsumption.distribution_table</field>
<field name="prefix">DT</field>
<field name="padding">3</field>
<field eval="1" name="number_next" />
<field eval="1" name="number_increment" />
</record>
</data>
</odoo>
......@@ -22,6 +22,7 @@ class DistributionTable(models.Model):
sum(record.supply_point_assignation_ids.mapped('coefficient')), 1.00000,
precision_rounding=0.00001)
name = fields.Char(readonly=True)
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)
......@@ -33,6 +34,11 @@ class DistributionTable(models.Model):
"res.company", default=lambda self: self.env.company, readonly=True
)
@api.model
def create(self, vals):
vals['name'] = self.env.ref('energy_selfconsumption.distribution_table_sequence', False).next_by_id()
return super(DistributionTable, self).create(vals)
@api.onchange('selfconsumption_project_id')
def _onchange_selfconsumption_project_id(self):
self.supply_point_assignation_ids = False
......
......@@ -72,6 +72,7 @@
<field name="model">energy_selfconsumption.distribution_table</field>
<field name="arch" type="xml">
<tree string="Distribution Table">
<field name="name"/>
<field name="selfconsumption_project_id"/>
<field name="create_date"/>
<field name="type"/>
......
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