Skip to content
Snippets Groups Projects
Commit 37d2b0ba authored by Emanuel Buzey's avatar Emanuel Buzey Committed by Daniil Digtyar Vasilieva
Browse files

[FIX] energy_selfconsumption: save invoicing_mode and product_id

parent 58dcea08
No related branches found
No related tags found
2 merge requests!253[REL] Release 06/11/23,!211[IMP] energy_selfconsumption: invoicing acquired power
......@@ -85,7 +85,9 @@ class Selfconsumption(models.Model):
)
inscription_count = fields.Integer(compute=_compute_inscription_count)
contracts_count = fields.Integer(compute=_compute_contract_count)
invoicing_mode = fields.Char()
invoicing_mode = fields.Selection(INVOICING_VALUES, string="Invoicing Mode")
product_id = fields.Many2one("product.product", string="Product")
contract_template_id = fields.Many2one("contract.template")
def get_distribution_tables(self):
self.ensure_one()
......
......@@ -223,6 +223,20 @@
</div>
</group>
</group>
<notebook colspan="4">
<page
string="Invoicing Mode"
name="invoicing_mode"
autofocus="autofocus"
>
<group>
<field name="invoicing_mode" />
<field name="product_id" />
</group>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
......
......@@ -40,20 +40,11 @@ class ContractGenerationWizard(models.TransientModel):
"energy_selfconsumption.selfconsumption", readonly=True
)
def _get_invoicing_mode_value(self):
"""
This method return the invoicing_mode label.
"""
for mode_value, mode_label in self.INVOICING_VALUES:
if mode_value == self.invoicing_mode:
return _(mode_label)
return ""
def save_data_to_selfconsumption(self):
# Create product
self.env["product.product"].create(
product_id = self.env["product.product"].create(
{
"name": f"{self._get_invoicing_mode_value()} - {self.selfconsumption_id.name}",
"name": f"{self.invoicing_mode[1]} - {self.selfconsumption_id.name}",
"lst_price": self.price,
"company_id": self.env.company.id,
"project_id": self.selfconsumption_id.project_id.id,
......@@ -110,6 +101,13 @@ result = line.supply_point_assignation_id.distribution_table_id.selfconsumption_
}
)
self.selfconsumption_id.write(
{
"invoicing_mode": self.invoicing_mode,
"product_id": product_id,
}
)
return {
"type": "ir.actions.act_window_close",
}
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