mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[FIX] - on upsel, contract line should stop day - 1
This commit is contained in:
@@ -7,15 +7,10 @@
|
|||||||
'version': '12.0.1.0.0',
|
'version': '12.0.1.0.0',
|
||||||
'category': 'Contract Management',
|
'category': 'Contract Management',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'author': "LasLabs, "
|
'author': "LasLabs, " "ACSONE SA/NV, " "Odoo Community Association (OCA)",
|
||||||
"ACSONE SA/NV, "
|
|
||||||
"Odoo Community Association (OCA)",
|
|
||||||
'website': 'https://github.com/oca/contract',
|
'website': 'https://github.com/oca/contract',
|
||||||
'depends': ['product', 'contract_sale'],
|
'depends': ['product', 'contract_sale'],
|
||||||
'data': [
|
'data': ['views/product_template.xml', 'views/sale_order.xml'],
|
||||||
'views/product_template.xml',
|
|
||||||
'views/sale_order.xml',
|
|
||||||
],
|
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'application': False,
|
'application': False,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
# Copyright 2017 ACSONE SA/NV.
|
# Copyright 2017 ACSONE SA/NV.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# 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 import api, fields, models, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
@@ -105,20 +106,23 @@ class SaleOrderLine(models.Model):
|
|||||||
'discount': self.discount,
|
'discount': self.discount,
|
||||||
'date_end': self.date_end,
|
'date_end': self.date_end,
|
||||||
'date_start': self.date_start or fields.Date.today(),
|
'date_start': self.date_start or fields.Date.today(),
|
||||||
'recurring_next_date': contract_line_env._compute_first_recurring_next_date(
|
'recurring_next_date':
|
||||||
self.date_start or fields.Date.today(),
|
contract_line_env._compute_first_recurring_next_date(
|
||||||
self.recurring_invoicing_type,
|
self.date_start or fields.Date.today(),
|
||||||
self.recurring_rule_type,
|
self.recurring_invoicing_type,
|
||||||
self.recurring_interval,
|
self.recurring_rule_type,
|
||||||
),
|
self.recurring_interval,
|
||||||
|
),
|
||||||
'recurring_interval': self.recurring_interval,
|
'recurring_interval': self.recurring_interval,
|
||||||
'recurring_invoicing_type': self.recurring_invoicing_type,
|
'recurring_invoicing_type': self.recurring_invoicing_type,
|
||||||
'recurring_rule_type': self.recurring_rule_type,
|
'recurring_rule_type': self.recurring_rule_type,
|
||||||
'is_auto_renew': self.product_id.is_auto_renew,
|
'is_auto_renew': self.product_id.is_auto_renew,
|
||||||
'auto_renew_interval': self.product_id.auto_renew_interval,
|
'auto_renew_interval': self.product_id.auto_renew_interval,
|
||||||
'auto_renew_rule_type': self.product_id.auto_renew_rule_type,
|
'auto_renew_rule_type': self.product_id.auto_renew_rule_type,
|
||||||
'termination_notice_interval': self.product_id.termination_notice_interval,
|
'termination_notice_interval':
|
||||||
'termination_notice_rule_type': self.product_id.termination_notice_rule_type,
|
self.product_id.termination_notice_interval,
|
||||||
|
'termination_notice_rule_type':
|
||||||
|
self.product_id.termination_notice_rule_type,
|
||||||
'contract_id': contract.id,
|
'contract_id': contract.id,
|
||||||
'sale_order_line_id': self.id,
|
'sale_order_line_id': self.id,
|
||||||
}
|
}
|
||||||
@@ -133,7 +137,9 @@ class SaleOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
contract_line |= new_contract_line
|
contract_line |= new_contract_line
|
||||||
if rec.contract_line_id:
|
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 = (
|
rec.contract_line_id.successor_contract_line_id = (
|
||||||
new_contract_line
|
new_contract_line
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ class TestSaleOrder(TransactionCase):
|
|||||||
self.order_line1.onchange_product()
|
self.order_line1.onchange_product()
|
||||||
self.sale.action_confirm()
|
self.sale.action_confirm()
|
||||||
self.assertEqual(
|
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)
|
self.assertFalse(self.contract_line.is_auto_renew)
|
||||||
new_contract_line = self.env['account.analytic.invoice.line'].search(
|
new_contract_line = self.env['account.analytic.invoice.line'].search(
|
||||||
|
|||||||
Reference in New Issue
Block a user