← Back to team overview

magentoerpconnect-community team mailing list archive

base_external_referentials: change in ir_model_data use: pay attention to upgrade!

 

Hello guys,

This is a change/feature that affect mostly the magentoerpconnect users
(they now have a list, see:
https://launchpad.net/~magentoerpconnect-community ) for now, but I'm also
sending that mail to the framework expert team so they gain awareness of
generic the base_external_referentials module (as we believe it's very
useful, we would rather like all ecommerce/other external systems to reuse
it instead of adding their own foreign keys and mappings and not being
multi-referential's) and what we just changed in it.

So we inform you that in last revision of the connector and dependent
modules, especially base_external_referentials, we made an important change.

Indeed, instead of the new ir_model_data external_referential_id to be a
normal foreign key field, it's now a computed field that infer the
referential from the ir_model_data module name, provided the name is
structured as follow:
extref.referential_name
in that case referential_name is used to match the referential by it's name.
In any case, we keep storing the referential key using store=True to allow
efficient SQL and easier backward compatibility.

Why we did that:
- ir_model_data has a unicity constraint upon its name: must have a unique
name per module. This was incompatible with the multi-referential usage
potentially!
- actually, the "module" field of ir_model_data already plays the role of
the referential reference. In our case we just want to add a referential
object with custom mapping and other properties, that's why we need an
external_referential_id key, but in any case, it should not be redundant
with the "module" key.
- doing this way has a better adherence to existing OpenERP import/export
feature. Indeed, once those tools let you specify or read the module (I talk
about that with Fabien and he said it was a possible evol), then you could
specify / read  the external referential using built'in features only.

How to migrate:
I'll hopefully come back and post the SQL command, but basically you should
update your ir_model_data of your entities that are sunch'ed with an
external referential in order to have the module name matching:
extref.referential_name instead of the old "base_external_referentials_keep"
dummy name.

PS: their is one more change I would like to make
in base_external_referentials: rather than introducing the
intermediary external_osv layer between osv.osv and business objects, I
think it would be better to monkey patch osv.osv directly. Well it's not the
worst monkey patching in the world as we would only add the external_osv
feature and not change existing features. The advantage of extending osv.osv
directly is that you wouldn't need anymore to have to code anything to have
OpenERP managing the multi-references of some entity, you could just open
your referential entity and add custom in/out external mappings as you like.
However, that new change will luckily be transparent for migrations and
updating the code will be trivial.

I think the framework expert list is the best place if you want to discuss
the architecture of base_external_referentials.

Best regards,


Raphaël Valyi
http://www.akretion.com

Follow ups