This restricts the attributes of a BaseModel instance to `env`, `_ids` and `_prefetch_ids`. This way, one can only assign fields on a record; other assignments are programming errors. This also reduces the memory footprint of records from 168 to 64 bytes (-62%), and makes their instanciation faster. closes odoo/odoo#51075 Related: odoo/enterprise#10529 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
13 lines
330 B
Python
13 lines
330 B
Python
# -*- coding: utf-8 -*-
|
|
from odoo.tests import common
|
|
|
|
|
|
class TestAttributes(common.TransactionCase):
|
|
|
|
def test_we_cannot_add_attributes(self):
|
|
Model = self.env['test_new_api.category']
|
|
instance = Model.create({'name': 'Foo'})
|
|
|
|
with self.assertRaises(AttributeError):
|
|
instance.unknown = 42
|