[FIX] - Onchange contract line don't reste contract lines

[FIX] - Rename _get_invoiced_period to _get_period_to_invoice

[ADD] - Add stop_at_date_end to _get_period_to_invoice

[FIX] - Remove useless filter
This commit is contained in:
sbejaoui
2019-03-12 11:41:21 +01:00
committed by Francisco Ivan Anton Prieto
parent c9ef02df2b
commit 5248e17bab
5 changed files with 48 additions and 62 deletions

View File

@@ -486,7 +486,7 @@ class AccountAnalyticInvoiceLine(models.Model):
@api.multi
def _prepare_invoice_line(self, invoice_id=False):
self.ensure_one()
dates = self._get_invoiced_period(
dates = self._get_period_to_invoice(
self.last_date_invoiced, self.recurring_next_date
)
invoice_line_vals = {
@@ -515,7 +515,9 @@ class AccountAnalyticInvoiceLine(models.Model):
return invoice_line_vals
@api.multi
def _get_invoiced_period(self, last_date_invoiced, recurring_next_date):
def _get_period_to_invoice(
self, last_date_invoiced, recurring_next_date, stop_at_date_end=True
):
self.ensure_one()
first_date_invoiced = False
if not recurring_next_date:
@@ -540,8 +542,9 @@ class AccountAnalyticInvoiceLine(models.Model):
last_date_invoiced = recurring_next_date - relativedelta(
days=1
)
if self.date_end and self.date_end < last_date_invoiced:
last_date_invoiced = self.date_end
if stop_at_date_end:
if self.date_end and self.date_end < last_date_invoiced:
last_date_invoiced = self.date_end
return first_date_invoiced, last_date_invoiced, recurring_next_date
@api.multi
@@ -1078,3 +1081,10 @@ class AccountAnalyticInvoiceLine(models.Model):
_("Contract line must be canceled before delete")
)
return super(AccountAnalyticInvoiceLine, self).unlink()
@api.multi
def _get_quantity_to_invoice(
self, period_first_date, period_last_date, invoice_date
):
self.ensure_one()
return self.quantity