The EDI documents will now be generated on demand and available from the Portal view of each document. Instead of getting a link to a statically generated EDI document, customers will receive a link to the portal access to the document. They will be able to signup on the portal the first time as well, provided they are using the secure token that was sent to them (i.e. the right link). The link to pay online will be available in the portal as well. Still much to do, this is a small first step, with edi.document renamed to edi.edi for consistency, as it will not persist any edi.document anymore. bzr revid: odo@openerp.com-20121011152008-bht7ub6woaex0a7u
66 lines
2.5 KiB
Python
66 lines
2.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
##############################################################################
|
|
#
|
|
# OpenERP, Open Source Business Applications
|
|
# Copyright (c) 2011 OpenERP S.A. <http://openerp.com>
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
##############################################################################
|
|
import logging
|
|
|
|
import openerp
|
|
import openerp.netsvc as netsvc
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
class edi(netsvc.ExportService):
|
|
|
|
def __init__(self, name="edi"):
|
|
netsvc.ExportService.__init__(self, name)
|
|
|
|
def _edi_dispatch(self, db_name, method_name, *method_args):
|
|
try:
|
|
registry = openerp.modules.registry.RegistryManager.get(db_name)
|
|
assert registry, 'Unknown database %s' % db_name
|
|
edi = registry['edi.edi']
|
|
cr = registry.db.cursor()
|
|
res = None
|
|
res = getattr(edi, method_name)(cr, *method_args)
|
|
cr.commit()
|
|
except Exception:
|
|
_logger.exception('Failed to execute EDI method %s with args %r.', method_name, method_args)
|
|
raise
|
|
finally:
|
|
cr.close()
|
|
return res
|
|
|
|
def exp_import_edi_document(self, db_name, uid, passwd, edi_document, context=None):
|
|
return self._edi_dispatch(db_name, 'import_edi', uid, edi_document, None)
|
|
|
|
def exp_import_edi_url(self, db_name, uid, passwd, edi_url, context=None):
|
|
return self._edi_dispatch(db_name, 'import_edi', uid, None, edi_url)
|
|
|
|
def dispatch(self, method, params):
|
|
if method in ['import_edi_document', 'import_edi_url']:
|
|
(db, uid, passwd ) = params[0:3]
|
|
openerp.service.security.check(db, uid, passwd)
|
|
else:
|
|
raise KeyError("Method not found: %s." % method)
|
|
fn = getattr(self, 'exp_'+method)
|
|
return fn(*params)
|
|
|
|
edi()
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|