[MIG] test_documentation_examples: convert code to the new API
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import inheritance
|
||||
import extension
|
||||
import delegation
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import inheritance
|
||||
from . import extension
|
||||
from . import delegation
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
{
|
||||
'name': "Documentation examples test",
|
||||
'description': """
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from openerp import models, fields
|
||||
from odoo import models, fields
|
||||
|
||||
class Child0(models.Model):
|
||||
_name = 'delegation.child0'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from openerp import models, fields
|
||||
from odoo import models, fields
|
||||
|
||||
class Extension0(models.Model):
|
||||
_name = 'extension.0'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from openerp import models, fields
|
||||
from odoo import models, fields
|
||||
|
||||
class Inheritance0(models.Model):
|
||||
_name = 'inheritance.0'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import test_inheritance, test_extension, test_delegation
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from openerp.tests import common
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
class TestDelegation(common.TransactionCase):
|
||||
|
||||
@@ -17,16 +19,8 @@ class TestDelegation(common.TransactionCase):
|
||||
record = self.record
|
||||
|
||||
# children fields can be looked up on the parent record directly
|
||||
self.assertEqual(
|
||||
record.field_0
|
||||
,
|
||||
0
|
||||
)
|
||||
self.assertEqual(
|
||||
record.field_1
|
||||
,
|
||||
1
|
||||
)
|
||||
self.assertEqual(record.field_0, 0)
|
||||
self.assertEqual(record.field_1, 1)
|
||||
|
||||
def test_swap_child(self):
|
||||
env = self.env
|
||||
@@ -35,23 +29,11 @@ class TestDelegation(common.TransactionCase):
|
||||
record.write({
|
||||
'child0_id': env['delegation.child0'].create({'field_0': 42}).id
|
||||
})
|
||||
self.assertEqual(
|
||||
record.field_0
|
||||
,
|
||||
42
|
||||
)
|
||||
self.assertEqual(record.field_0, 42)
|
||||
|
||||
def test_write(self):
|
||||
record = self.record
|
||||
|
||||
record.write({'field_1': 4})
|
||||
self.assertEqual(
|
||||
record.field_1
|
||||
,
|
||||
4
|
||||
)
|
||||
self.assertEqual(
|
||||
record.child1_id.field_1
|
||||
,
|
||||
4
|
||||
)
|
||||
self.assertEqual(record.field_1, 4)
|
||||
self.assertEqual(record.child1_id.field_1, 4)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from openerp.tests import common
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
class TestBasicInheritance(common.TransactionCase):
|
||||
def test_extend_fields(self):
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from openerp.tests import common
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
class TestBasicInheritance(common.TransactionCase):
|
||||
def test_inherit_method(self):
|
||||
@@ -8,17 +10,5 @@ class TestBasicInheritance(common.TransactionCase):
|
||||
a = env['inheritance.0'].create({'name': 'A'})
|
||||
b = env['inheritance.1'].create({'name': 'B'})
|
||||
|
||||
self.assertEqual(
|
||||
a.call()
|
||||
,
|
||||
"""
|
||||
This is model 0 record A
|
||||
""".strip()
|
||||
)
|
||||
self.assertEqual(
|
||||
b.call()
|
||||
,
|
||||
"""
|
||||
This is model 1 record B
|
||||
""".strip()
|
||||
)
|
||||
self.assertEqual(a.call(), "This is model 0 record A")
|
||||
self.assertEqual(b.call(), "This is model 1 record B")
|
||||
|
||||
Reference in New Issue
Block a user