Browse Source
[8.0][FIX][base_export_manager] Fix "Expected singleton" bug. (#521)
[8.0][FIX][base_export_manager] Fix "Expected singleton" bug. (#521)
[FIX][base_export_manager] Fix "Expected singleton" bug. If you had a field that got translated in more than 1 addon, you'd possibly getto this error: File "/opt/odoo/0079_ahk_openerp/oca/base_export_manager/models/ir_exports_line.py", line 105, in _compute_label field.name)), File "/opt/odoo/common/openerp/v8/openerp/fields.py", line 825, in __get__ record.ensure_one() File "/opt/odoo/common/openerp/v8/openerp/models.py", line 5355, in ensure_one raise except_orm("ValueError", "Expected singleton: %s" % self) except_orm: ('ValueError', 'Expected singleton: ir.translation(4899, 703976)') With this patch, now we let Odoo return the translated string by using its standard method to do so, so we have to care for less. * Move installation outside a data file. This makes the whole installation to be able to roll back if something goes wrong, instead of entering an error loop. * Include envorionment in its manager. * Add 4th field * Move to api.multi, refactoring some stuff. - Add some comments in complex parts. - Rename `onchange_name` to `_onchange_name` (guidelines). - Make `_compute_name`'s try block shorter and easier to understand. * Allow R/W of name directly in model. * Update tests to cover new behaviors.pull/22/head
Jairo Llopis
8 years ago
committed by
Pedro M. Baeza
10 changed files with 190 additions and 90 deletions
-
3base_export_manager/README.rst
-
1base_export_manager/__init__.py
-
0base_export_manager/__manifest__.py
-
6base_export_manager/data/ir_exports_data.xml
-
20base_export_manager/hooks.py
-
9base_export_manager/migrations/8.0.2.1.0/post-migrate.py
-
157base_export_manager/models/ir_exports_line.py
-
3base_export_manager/tests/__init__.py
-
53base_export_manager/tests/test_ir_exports_line.py
-
28base_export_manager/views/ir_exports.xml
@ -1,6 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
|
|||
<function model="ir.exports.line" name="_install_base_export_manager"/> |
|||
|
|||
</odoo> |
@ -0,0 +1,20 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from openerp import api, SUPERUSER_ID |
|||
|
|||
|
|||
def post_init_hook(cr, registry): |
|||
"""Loaded after installing the module. |
|||
|
|||
``ir.exports.line.name`` was before a char field, and now it is a computed |
|||
char field with stored values. We have to inverse it to avoid database |
|||
inconsistencies. |
|||
""" |
|||
with api.Environment.manage(): |
|||
env = api.Environment(cr, SUPERUSER_ID, {}) |
|||
env["ir.exports.line"].search([ |
|||
("field1_id", "=", False), |
|||
("export_id", "!=", False), |
|||
("name", "!=", False), |
|||
])._inverse_name() |
@ -0,0 +1,9 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
from openerp.addons.base_export_manager import post_init_hook |
|||
|
|||
|
|||
def migrate(cr, version): |
|||
"""When updating, now you need the post_init_hook.""" |
|||
post_init_hook(cr, None) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue