Skip to content
Snippets Groups Projects
Commit b647fa85 authored by Enrico Stano's avatar Enrico Stano
Browse files

Merge branch 'feature/IMP_energy_selfconsumption_project_new_fields' into 'dev'

[IMP]energy_selfconsumption: selfconsumption project new fields and UI changes

See merge request !169
parents fc605b29 e479a318
No related branches found
No related tags found
2 merge requests!173Release 14.0.1.1.12,!169[IMP]energy_selfconsumption: selfconsumption project new fields and UI changes
Pipeline #36947 passed
......@@ -24,7 +24,7 @@ class Project(models.Model):
# address fields
street = fields.Char(required=True)
street2 = fields.Char(required=True)
street2 = fields.Char()
zip = fields.Char(change_default=True, required=True)
city = fields.Char(required=True)
state_id = fields.Many2one(
......@@ -35,5 +35,6 @@ class Project(models.Model):
required=True,
)
country_id = fields.Many2one(
"res.country", string="Country", ondelete="restrict", required=True
"res.country", string="Country", ondelete="restrict", required=True,
default=lambda self: self.env.ref('base.es')
)
......@@ -22,7 +22,9 @@ class Selfconsumption(models.Model):
"energy_project.project", required=True, ondelete="cascade"
)
code = fields.Char(string="CAU")
power = fields.Float(string="Generation Power (kWh)")
cil = fields.Char(string="CIL", help="Production facility code for liquidation purposes")
owner_id = fields.Many2one("res.partner", string="Owner", required=True, default=lambda self: self.env.company.partner_id)
power = fields.Float(string="Generation Power (kW)")
distribution_table_ids = fields.One2many('energy_selfconsumption.distribution_table', 'selfconsumption_project_id',
readonly=True)
distribution_table_count = fields.Integer(compute=_compute_distribution_table_count)
......@@ -59,6 +61,8 @@ class Selfconsumption(models.Model):
for record in self:
if not record.code:
raise ValidationError(_("Project must have a valid Code."))
if not record.cil:
raise ValidationError(_("Project must have a valid CIL."))
if not record.power or record.power <= 0:
raise ValidationError(_("Project must have a valid Generation Power."))
if not record.distribution_table_ids.filtered_domain([('state', '=', 'validated')]):
......
......@@ -66,10 +66,18 @@
name="code"
attrs="{'readonly': [('state', 'not in', ['draft', 'activation'])]}"
/>
<field
name="cil"
attrs="{'readonly': [('state', 'not in', ['draft', 'activation'])]}"
/>
<field
name="power"
attrs="{'readonly': [('state', 'not in', ['draft', 'activation'])]}"
/>
<field
name="owner_id"
attrs="{'readonly': [('state', 'not in', ['draft', 'activation'])]}"
/>
</group>
<group>
<span class="o_form_label o_td_label" name="address_name">
......@@ -110,6 +118,12 @@
<field name="arch" type="xml">
<tree string="Self-Consumption Projects">
<field name="name"/>
<field name="street"/>
<field name="street2"/>
<field name="state_id"/>
<field name="zip"/>
<field name="country_id"/>
<field name="power"/>
<field name="state"/>
</tree>
</field>
......
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