diff options
| author | Raphael Collet <rco@odoo.com> | 2020-04-07 13:51:30 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-05-18 09:51:43 +0000 |
| commit | ea3e39506a2b360545ec0cd1d3235e69ad16ea6c (patch) | |
| tree | 9d103c7a40911c988e1a3cbecfd8d6a76a3a9a85 /addons/website | |
| parent | 2e56191c8b86d05bbce17790de8a4732c0478013 (diff) | |
[IMP] models: use slots for BaseModel
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>
Diffstat (limited to 'addons/website')
| -rw-r--r-- | addons/website/models/ir_ui_view.py | 4 | ||||
| -rw-r--r-- | addons/website/models/website.py | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index 8fa24631d26..4b6cd55551b 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -405,10 +405,6 @@ class View(models.Model): func = getattr(values['main_object'], 'get_backend_menu_id', False) values['backend_menu_id'] = func and func() or self.env.ref('website.menu_website_configuration').id - # Fallback incase main_object dont't inherit 'website.seo.metadata' - if not hasattr(values['main_object'], 'get_website_meta'): - values['main_object'].get_website_meta = lambda: {} - if self._context != new_context: self = self.with_context(new_context) return super(View, self)._render(values, engine=engine, minimal_qcontext=minimal_qcontext) diff --git a/addons/website/models/website.py b/addons/website/models/website.py index e079d6f12d2..41565fb031a 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -1011,3 +1011,8 @@ class BaseModel(models.AbstractModel): return self.website_id._get_http_domain() else: return super(BaseModel, self).get_base_url() + + def get_website_meta(self): + # dummy version of 'get_website_meta' above; this is a graceful fallback + # for models that don't inherit from 'website.seo.metadata' + return {} |
