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

[FIX] energy_selfconsumption: update contract fields with _onchange_contract_template_id

parent ff1cecb8
No related branches found
No related tags found
3 merge requests!253[REL] Release 06/11/23,!228[IMP] energy_selfconsumption: integration invoicing,!211[IMP] energy_selfconsumption: invoicing acquired power
......@@ -48,31 +48,7 @@ class ContractGenerationWizard(models.TransientModel):
# Create contracts
for supply_point_assignation in distribution_id.supply_point_assignation_ids:
contract_lines = [
(
0,
0,
{
"product_id": product_id.id,
"automatic_price": True,
"company_id": self.env.company.id,
"qty_type": "variable",
"qty_formula_id": formula_contract_id.id,
"name": _(
"""CUPS: %s
Owner: %s
Invoicing period: #START# - #END#"""
)
% (
supply_point_assignation.supply_point_id.code,
supply_point_assignation.supply_point_id.owner_id.display_name,
),
"supply_point_assignation_id": supply_point_assignation.id,
},
)
]
self.env["contract.contract"].create(
contract = self.env["contract.contract"].create(
{
"name": _("Contract - %s - %s")
% (
......@@ -80,18 +56,15 @@ class ContractGenerationWizard(models.TransientModel):
supply_point_assignation.supply_point_id.partner_id.name,
),
"partner_id": supply_point_assignation.supply_point_id.partner_id.id,
"invoice_partner_id": supply_point_assignation.supply_point_id.partner_id.id,
"journal_id": journal_id.id,
"recurring_interval": self.selfconsumption_id.product_id.contract_template_id.recurring_interval,
"recurring_rule_type": self.selfconsumption_id.product_id.contract_template_id.recurring_rule_type,
"recurring_invoicing_type": "post-paid",
"date_start": fields.date.today(),
"company_id": self.env.company.id,
"contract_line_ids": contract_lines,
"project_id": self.selfconsumption_id.project_id.id,
"contract_template_id": self.selfconsumption_id.product_id.contract_template_id.id,
"recurring_interval": self.selfconsumption_id.product_id.contract_template_id.recurring_interval,
"recurring_rule_type": self.selfconsumption_id.product_id.contract_template_id.recurring_rule_type,
}
)
contract._onchange_contract_template_id()
# Update selfconsumption and distribution_table state
self.selfconsumption_id.write({"state": "active"})
self.selfconsumption_id.distribution_table_state("process", "active")
......
......@@ -79,6 +79,7 @@ class ContractGenerationWizard(models.TransientModel):
"contract_line_ids": contract_line,
"recurring_interval": self.recurrence_interval,
"recurring_rule_type": self.recurring_rule_type,
"recurring_invoicing_type": "post-paid",
}
def save_data_to_selfconsumption(self):
......
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