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

Merge branch 'feature/delivered_energy_invoice_format' into 'NOT_MERGE/c2_implement_branch'

C2/ Implementation delivered_energy_invoice_format

See merge request !265
parents 079c39b3 e955bc96
No related branches found
No related tags found
1 merge request!265C2/ Implementation delivered_energy_invoice_format
Pipeline #68700 passed
......@@ -43,5 +43,6 @@
"wizards/define_invoicing_mode_wizard_view.xml",
"wizards/invoicing_wizard_views.xml",
"reports/selfconsumption_reports.xml",
"reports/energy_delivered_invoice_template.xml"
],
}
......@@ -6,3 +6,4 @@ from . import supply_point_assignation
from . import project
from . import contract
from . import product
from . import account_move
\ No newline at end of file
from odoo import models, fields
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
selfconsumption_id = fields.One2many(
'energy_selfconsumption.selfconsumption',
related="contract_line_id.contract_id.project_id.selfconsumption_id"
)
class AccountMove(models.Model):
_inherit = "account.move"
def _get_name_invoice_report(self):
self.ensure_one()
if self.invoice_line_ids.selfconsumption_id.invoicing_mode == 'energy_delivered':
return 'energy_selfconsumption.energy_delivered_invoice_template'
return super()._get_name_invoice_report()
\ No newline at end of file
......@@ -98,6 +98,7 @@ class Selfconsumption(models.Model):
help="Select the associated Energy Reseller",
)
def get_distribution_tables(self):
self.ensure_one()
return {
......
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template inherit_id="account.report_invoice_document" id="energy_delivered_invoice_template" primary="True">
<xpath expr="//th[@name='th_quantity']" position="replace">
<th name="th_total_installation_generation"><span>Total installation generation</span></th>
</xpath>
<xpath expr="//th[@name='th_total_installation_generation']" position="after">
<th name="th_partition_coefficient"><span>Partition coefficient</span></th>
</xpath>
<xpath expr="//th[@name='th_priceunit']" position="after">
<th name="th_import"><span>Import</span></th>
</xpath>
<xpath expr="//th[@name='th_taxes']" position="replace"></xpath>
<xpath expr="//th[@name='th_subtotal']" position="replace"></xpath>
<xpath expr="//th[@name='th_partition_coefficient']" position="after">
<th name="th_total_amount_invoiced"><span>Total amount invoiced</span></th>
</xpath>
<xpath expr="//td[@name='account_invoice_line_name']" position="after">
<td name="td_total_installation_generation">
<span t-field="line.selfconsumption_id.power" /><span> kWh</span>
</td>
</xpath>
<xpath expr="//td[@name='td_total_installation_generation']" position="after">
<td name="td_partition_coefficient">
<t t-foreach="line.selfconsumption_id.distribution_table_ids.supply_point_assignation_ids" t-as="assignation">
<t t-if="assignation.owner_id.name == line.partner_id.name">
<span t-field="assignation.coefficient"/>
</t>
</t>
</td>
</xpath>
<xpath expr="//span[@id='line_tax_ids']" position="replace"></xpath>
</template>
<template id="report_invoice_with_payments" inherit_id="account.report_invoice_with_payments">
<xpath expr='//t[@t-call="account.report_invoice_document"]' position="after">
<t t-if="o._get_name_invoice_report() == 'energy_selfconsumption.energy_delivered_invoice_template'"
t-call="energy_selfconsumption.energy_delivered_invoice_template" t-lang="lang"/>
</xpath>
</template>
</data>
</odoo>
......@@ -61,12 +61,15 @@ 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()
for contract_line_id in contract.contract_line_ids:
data = {"code": supply_point_assignation.supply_point_id.code, "owner_id": supply_point_assignation.supply_point_id.owner_id.display_name,}
# Each invoicing type has different data in the description column, so we need to check and modify
if self.selfconsumption_id.invoicing_mode == 'energy_delivered':
contract_line_id.name += """\nCAU: {cau}\n"""
data["cau"] = self.selfconsumption_id.code
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,
),
"name": contract_line_id.name.format(**data),
}
)
# Update selfconsumption and distribution_table state
......
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