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

[IMP] energy_selfconsumption: show last period dates

parent 34ba2ca2
No related branches found
No related tags found
No related merge requests found
Pipeline #65477 passed
This commit is part of merge request !247. Comments created here will be created in the context of that merge request.
......@@ -18,6 +18,14 @@ class Contract(models.Model):
supply_point_name = fields.Char(
related="supply_point_assignation_id.supply_point_id.name"
)
last_period_date_start = fields.Date(
string="Last Period Start",
readonly=True,
)
last_period_date_end = fields.Date(
string="Last Period End",
readonly=True,
)
def invoicing_wizard_action(self):
"""
......@@ -33,6 +41,21 @@ class Contract(models.Model):
action["res_id"] = wizard_id.id
return action
def _recurring_create_invoice(self, date_ref=False):
last_period_date_start = last_period_date_end = False
if len(self) > 1:
last_period_date_start = self[0].next_period_date_start
last_period_date_end = self[0].next_period_date_end
res = super()._recurring_create_invoice(date_ref=date_ref)
if res and last_period_date_start and last_period_date_end:
self.write(
{
"last_period_date_start": last_period_date_start,
"last_period_date_end": last_period_date_end,
}
)
return res
class ContractRecurrencyMixin(models.AbstractModel):
_inherit = "contract.recurrency.mixin"
......
......@@ -11,6 +11,8 @@
<field name="code" />
<field name="next_period_date_start" />
<field name="next_period_date_end" />
<field name="last_period_date_start" />
<field name="last_period_date_end" />
</tree>
</field>
......
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