:param edi_dicts: list of edi_dict
"""
+ module_obj =self.pool.get('ir.module.module')
res = []
for edi_document in edi_documents:
- model = edi_document.get('__model')
- assert model, _('model should be provided in EDI Dict')
- model_obj = self.pool.get(model)
- record_id = model_obj.edi_import(cr, uid, edi_document, context=context)
- res.append((model,record_id))
+ module = edi_document.get('__module')
+ module_id = module_obj.search(cr, uid, [('name','=',module),('state','=','installed')])
- if not module_id:
- raise Exception("The document you are trying to import requires the OpenERP" +module+ "application")
- else:
++ if module_id:
+ model = edi_document.get('__model')
+ assert model, _('model should be provided in EDI Dict')
+ model_obj = self.pool.get(model)
+ record_id = model_obj.edi_import(cr, uid, edi_document, context=context)
+ res.append((model,record_id))
++ else:
++ raise osv.except_osv(_('Invalid action !'),
++ _('The document you are trying to import requires the OpenERP' +module+ 'application.'))
return res
def deserialize(self, edi_document_string):
_defaults = {
'active': lambda *a: 1,
'customer': lambda *a: 1,
+ 'address': [{'type': 'default'}],
'category_id': _default_category,
'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'res.partner', context=c),
- 'opt_out' : False
+ 'opt_out' : True
}
+
def copy(self, cr, uid, id, default={}, context={}):
name = self.read(cr, uid, [id], ['name'])[0]['name']
default.update({'name': name+ _(' (copy)'), 'events':[]})
import openerp.sql_db as sql_db
import openerp.tools as tools
import openerp.modules
- import locale
- import logging
- from cStringIO import StringIO
- import threading
class edi(netsvc.ExportService):
- def exp_get_edi_document(self, edi_token, db_name=None):
+ def exp_get_edi_document(self, edi_token, db_name):
res = None
- if not db_name:
- db_name = getattr(threading.currentThread(), 'dbname', None)
if db_name:
cr = pooler.get_db(db_name).cursor()
else: