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

[IMP] energy_selfconsumption: format name contract line from contract template line

parent 907a343f
No related branches found
No related tags found
1 merge request!243[IMP] energy_selfconsumption: invoicing integration fixes
Pipeline #62940 passed
This commit is part of merge request !228. Comments created here will be created in the context of that merge request.
......@@ -51,17 +51,16 @@ class ContractGenerationWizard(models.TransientModel):
)
# We use the next method from the contract model to update the contract fields with contract template
contract._onchange_contract_template_id()
# Now, we need to update the name field using the code and display_name fields
name = _("""CUPS: %s\nOwner: %s\nInvoicing period: #START# - #END#""") % (
supply_point_assignation.supply_point_id.code,
supply_point_assignation.supply_point_id.owner_id.display_name,
)
contract.contract_line_ids.write(
{
"name": name,
"supply_point_assignation_id": supply_point_assignation.id,
}
)
for contract_line_id in contract.contract_line_ids:
contract_line_id.write(
{
"name": contract_line_id.name.format(
code=supply_point_assignation.supply_point_id.code,
owner_id=supply_point_assignation.supply_point_id.owner_id.display_name,
),
"supply_point_assignation_id": supply_point_assignation.id,
}
)
# Update selfconsumption and distribution_table state
self.selfconsumption_id.write({"state": "active"})
self.selfconsumption_id.distribution_table_state("process", "active")
......
......@@ -89,7 +89,8 @@ class ContractGenerationWizard(models.TransientModel):
"company_id": self.env.company.id,
"qty_type": "variable",
"qty_formula_id": formula_contract_id.id,
"name": "",
# Values are formatted in contract_generation_wizard
"name": """CUPS: {code}\nOwner: {owner_id}\nInvoicing period: #START# - #END#""",
}
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