Skip to content
Snippets Groups Projects

[IMP] energy_selfconsumption: integration invoicing

All threads resolved!
1 file
+ 5
26
Compare changes
  • Side-by-side
  • Inline
@@ -50,30 +50,9 @@ class ContractGenerationWizard(models.TransientModel):
SomeException: When no distribution table in process of activation is found.
"""
# Create product
product_id = self.env["product.product"].create(
{
"name": _("Energy Acquired - %s") % (self.selfconsumption_id.name),
"lst_price": self.price_energy,
"company_id": self.env.company.id,
"must_have_dates": True,
}
)
# Create contract formula
formula_contract_id = self.env["contract.line.qty.formula"].create(
{
"name": _("Formula - %s") % (self.selfconsumption_id.name),
"code": """
days_timedelta = line.next_period_date_end - line.next_period_date_start
if days_timedelta:
# Add one so it counts the same day too (month = 29 + 1)
days_between = days_timedelta.days + 1
else:
days_between = 0
result = line.supply_point_assignation_id.distribution_table_id.selfconsumption_project_id.power * line.supply_point_assignation_id.coefficient * days_between
""",
}
product_id = self.selfconsumption_id.product_id
formula_contract_id = (
self.selfconsumption_id.contract_template_id.contract_line_ids.qty_formula_id
)
# Search accounting journal
@@ -155,6 +134,6 @@ result = line.supply_point_assignation_id.distribution_table_id.selfconsumption_
)
# Update selfconsumption and distribution_table state
self.selfconsumption_id.write({"state": "active"})
self.selfconsumption_id.distribution_table_state("process", "active")
# self.selfconsumption_id.write({"state": "active"})
# self.selfconsumption_id.distribution_table_state("process", "active")
return True
Loading