Browse Source

[FIX] - on upsel, contract line should stop day - 1

pull/208/head
sbejaoui 6 years ago
committed by Thomas Binsfeld
parent
commit
478c9b01ca
  1. 9
      product_contract/__manifest__.py
  2. 14
      product_contract/models/sale_order_line.py
  3. 2
      product_contract/tests/test_sale_order.py

9
product_contract/__manifest__.py

@ -7,15 +7,10 @@
'version': '12.0.1.0.0',
'category': 'Contract Management',
'license': 'AGPL-3',
'author': "LasLabs, "
"ACSONE SA/NV, "
"Odoo Community Association (OCA)",
'author': "LasLabs, " "ACSONE SA/NV, " "Odoo Community Association (OCA)",
'website': 'https://github.com/oca/contract',
'depends': ['product', 'contract_sale'],
'data': [
'views/product_template.xml',
'views/sale_order.xml',
],
'data': ['views/product_template.xml', 'views/sale_order.xml'],
'installable': True,
'application': False,
}

14
product_contract/models/sale_order_line.py

@ -2,6 +2,7 @@
# Copyright 2017 ACSONE SA/NV.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
@ -105,7 +106,8 @@ class SaleOrderLine(models.Model):
'discount': self.discount,
'date_end': self.date_end,
'date_start': self.date_start or fields.Date.today(),
'recurring_next_date': contract_line_env._compute_first_recurring_next_date(
'recurring_next_date':
contract_line_env._compute_first_recurring_next_date(
self.date_start or fields.Date.today(),
self.recurring_invoicing_type,
self.recurring_rule_type,
@ -117,8 +119,10 @@ class SaleOrderLine(models.Model):
'is_auto_renew': self.product_id.is_auto_renew,
'auto_renew_interval': self.product_id.auto_renew_interval,
'auto_renew_rule_type': self.product_id.auto_renew_rule_type,
'termination_notice_interval': self.product_id.termination_notice_interval,
'termination_notice_rule_type': self.product_id.termination_notice_rule_type,
'termination_notice_interval':
self.product_id.termination_notice_interval,
'termination_notice_rule_type':
self.product_id.termination_notice_rule_type,
'contract_id': contract.id,
'sale_order_line_id': self.id,
}
@ -133,7 +137,9 @@ class SaleOrderLine(models.Model):
)
contract_line |= new_contract_line
if rec.contract_line_id:
rec.contract_line_id.stop(rec.date_start)
rec.contract_line_id.stop(
rec.date_start - relativedelta(days=1)
)
rec.contract_line_id.successor_contract_line_id = (
new_contract_line
)

2
product_contract/tests/test_sale_order.py

@ -208,7 +208,7 @@ class TestSaleOrder(TransactionCase):
self.order_line1.onchange_product()
self.sale.action_confirm()
self.assertEqual(
self.contract_line.date_end, Date.to_date("2018-06-01")
self.contract_line.date_end, Date.to_date("2018-05-31")
)
self.assertFalse(self.contract_line.is_auto_renew)
new_contract_line = self.env['account.analytic.invoice.line'].search(

Loading…
Cancel
Save