credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #01271
[Merge] lp:~sebastien.beau/openobject-server/autoload into lp:openobject-server
You have been requested to review the proposed merge of lp:~sebastien.beau/openobject-server/autoload into lp:openobject-server.
For more details, see:
https://code.launchpad.net/~sebastien.beau/openobject-server/autoload/+merge/84512
Hi
I propose a new feature for the server.
Indeed I have some module like "product_gift" that should do not have the same behaviour if an other module is installed in this case magentoerpconnect.
Indeed If magentoerpconnect is installed I want to load the mapping file automatically.
http://bazaar.launchpad.net/~openerp-commiter/openobject-addons/trunk-extra-addons/revision/5506.1.13
Yes I can create a third module that depend of magentoerpconnect and product_gift but If I chose this option I should create one module for magento, one for prestashop, one for spree one for... And this module will only have 3 line of code so not great solution.
Waht do you think?
Have a nice day
--
https://code.launchpad.net/~sebastien.beau/openobject-server/autoload/+merge/84512
Your team OpenERP Framework Experts is requested to review the proposed merge of lp:~sebastien.beau/openobject-server/autoload into lp:openobject-server.
=== modified file 'openerp/modules/loading.py'
--- openerp/modules/loading.py 2011-12-01 15:31:56 +0000
+++ openerp/modules/loading.py 2011-12-05 17:52:27 +0000
@@ -119,6 +119,22 @@
init mode.
"""
+ # If you create an "autoload" folder in your module, with subfolder the name of an other module.
+ # OpenERP will automatically load the xml or csv file of this subfolder if the module is installed
+ if kind == 'update_xml':
+ mapping_dir = os.path.join(get_module_path(module_name), 'autoload')
+ exist = os.path.exists(mapping_dir)
+ if exist:
+ for mapping_module in osutil.listdir(mapping_dir):
+ cr.execute("select id from ir_module_module where name = '%s' and state in ('installed', 'to_update');"%mapping_module)
+ res = cr.fetchall()
+ if res:
+ mapping_module_dir = os.path.join(mapping_dir, mapping_module)
+ files = osutil.listdir(mapping_module_dir, recursive=True)
+ for file in files:
+ if file[-4:] in ['.csv', '.xml']:
+ package.data['update_xml'].append('autoload/%s/%s'%(mapping_module,file))
+
for filename in package.data[kind]:
logger.info("module %s: loading %s", module_name, filename)
_, ext = os.path.splitext(filename)