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

[IMP] energy_selfconsumption: create contract template

parent a5c440a7
No related branches found
No related tags found
2 merge requests!253[REL] Release 06/11/23,!211[IMP] energy_selfconsumption: invoicing acquired power
import logging
from odoo import _, api, fields, models
from odoo import _, fields, models
logger = logging.getLogger(__name__)
......@@ -42,4 +42,35 @@ class ContractGenerationWizard(models.TransientModel):
}
)
journal_id = self.env["account.journal"].search(
[("company_id", "=", self.env.company.id), ("type", "=", "sale")], limit=1
)
if not journal_id:
raise UserWarning(_("Accounting Journal not found."))
contract_template = self.env["contract.template"].create(
{
"name": _("Contract Template - %s") % self.selfconsumption_id.name,
"company_id": self.env.company.id,
"contract_type": "sale",
"journal_id": journal_id.id,
"contract_line_ids": [
(
0,
0,
{
"product_id": product_id.id,
"company_id": self.env.company.id,
"qty_type": "fixed",
"quantity": 1,
"recurring_interval": self.recurring_interval,
"recurring_rule_type": self.recurring_rule_type,
"recurring_invoicing_type": "post-paid",
"name": _("Energy produced"),
},
)
],
}
)
return True
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