mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[MIG] product_contract: Migration to 14.0
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.fields import Date
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
@@ -39,7 +39,7 @@ class TestSaleOrder(TransactionCase):
|
||||
],
|
||||
}
|
||||
)
|
||||
self.product1.with_context(force_company=self.sale.company_id.id).write(
|
||||
self.product1.with_company(self.sale.company_id).write(
|
||||
{
|
||||
"is_contract": True,
|
||||
"default_qty": 12,
|
||||
@@ -48,7 +48,7 @@ class TestSaleOrder(TransactionCase):
|
||||
"property_contract_template_id": self.contract_template1.id,
|
||||
}
|
||||
)
|
||||
self.product2.with_context(force_company=self.sale.company_id.id).write(
|
||||
self.product2.with_company(self.sale.company_id).write(
|
||||
{
|
||||
"is_contract": True,
|
||||
"property_contract_template_id": self.contract_template2.id,
|
||||
@@ -116,26 +116,16 @@ class TestSaleOrder(TransactionCase):
|
||||
other_company = self.env["res.company"].create(
|
||||
{"name": "other company", "parent_id": self.sale.company_id.id}
|
||||
)
|
||||
self.sale.company_id = other_company
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
self.sale.company_id = other_company
|
||||
self.sale.action_confirm()
|
||||
|
||||
def test_change_sale_company_2(self):
|
||||
"""Contract company must be the sale order company."""
|
||||
self.assertTrue(self.sale.company_id)
|
||||
other_company = self.env["res.company"].create(
|
||||
{"name": "other company", "parent_id": self.sale.company_id.id}
|
||||
)
|
||||
self.product1.with_context(
|
||||
force_company=other_company.id
|
||||
).property_contract_template_id = self.contract_template1
|
||||
self.product2.with_context(
|
||||
force_company=other_company.id
|
||||
).property_contract_template_id = self.contract_template2
|
||||
self.sale.company_id = other_company
|
||||
self.sale.action_confirm()
|
||||
contracts = self.sale.order_line.mapped("contract_id")
|
||||
self.assertEqual(contracts.mapped("company_id"), other_company)
|
||||
self.assertEqual(contracts.mapped("company_id"), self.sale.company_id)
|
||||
|
||||
def test_sale_order_invoice_status(self):
|
||||
"""
|
||||
@@ -353,7 +343,7 @@ class TestSaleOrder(TransactionCase):
|
||||
def test_order_lines_with_the_same_contract_template(self):
|
||||
"""It should create one contract with two lines grouped by contract
|
||||
template"""
|
||||
self.product2.with_context(force_company=self.sale.company_id.id).write(
|
||||
self.product2.with_company(self.sale.company_id).write(
|
||||
{
|
||||
"is_contract": True,
|
||||
"property_contract_template_id": self.contract_template1.id,
|
||||
|
||||
Reference in New Issue
Block a user