Browse Source

[FIX] - include date_end in the period if the product is_autorenew

pull/208/head
sbejaoui 6 years ago
committed by Thomas Binsfeld
parent
commit
326ced58c9
  1. 15
      product_contract/models/sale_order_line.py
  2. 2
      product_contract/tests/test_sale_order.py

15
product_contract/models/sale_order_line.py

@ -79,6 +79,7 @@ class SaleOrderLine(models.Model):
rec.product_id.auto_renew_rule_type, rec.product_id.auto_renew_rule_type,
rec.product_id.auto_renew_interval, rec.product_id.auto_renew_interval,
) )
- relativedelta(days=1)
) )
@api.onchange('date_start') @api.onchange('date_start')
@ -88,11 +89,15 @@ class SaleOrderLine(models.Model):
if not rec.date_start: if not rec.date_start:
rec.date_end = False rec.date_end = False
else: else:
rec.date_end = rec.date_start + self.env[
'account.analytic.invoice.line'
].get_relative_delta(
rec.product_id.auto_renew_rule_type,
rec.product_id.auto_renew_interval,
rec.date_end = (
rec.date_start
+ self.env[
'account.analytic.invoice.line'
].get_relative_delta(
rec.product_id.auto_renew_rule_type,
rec.product_id.auto_renew_interval,
)
- relativedelta(days=1)
) )
@api.multi @api.multi

2
product_contract/tests/test_sale_order.py

@ -129,7 +129,7 @@ class TestSaleOrder(TransactionCase):
self.order_line1.recurring_invoicing_type, self.order_line1.recurring_invoicing_type,
self.product1.recurring_invoicing_type, self.product1.recurring_invoicing_type,
) )
self.assertEqual(self.order_line1.date_end, Date.to_date('2019-01-01'))
self.assertEqual(self.order_line1.date_end, Date.to_date('2018-12-31'))
def test_check_contract_sale_partner(self): def test_check_contract_sale_partner(self):
"""Can't link order line to a partner contract different then the """Can't link order line to a partner contract different then the

Loading…
Cancel
Save