Skip to content
Snippets Groups Projects

[IMP] energy_selfconsumption: send invoicing reminder for energy delivered projects.

Merged emanuel buzey requested to merge feature/IMP_send_invoicing_reminder into dev
5 files
+ 144
9
Compare changes
  • Side-by-side
  • Inline
Files
5
  • Merge branch 'feature/IMP_energy_selfconsumption_invoicing_energy_delivered' into 'feature/IMP_send_invoicing_reminder'
    
    # Conflicts:
    #   energy_selfconsumption/__manifest__.py
    #   energy_selfconsumption/models/contract.py
    #   energy_selfconsumption/views/contract_views.xml
    #   energy_selfconsumption/wizards/invoicing_wizard.py
    #   energy_selfconsumption/wizards/invoicing_wizard_views.xml
@@ -18,6 +18,43 @@ 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):
"""
We create the wizard first, so it triggers the constraint of the contract_ids
:return: Window action with the wizard already created
"""
wizard_id = self.env["energy_selfconsumption.invoicing.wizard"].create(
{"contract_ids": [(6, 0, self.ids)]}
)
action = self.env.ref(
"energy_selfconsumption.invoicing_wizard_act_window"
).read()[0]
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):
Loading