[IMP] edi: finish moving edi into new addon
bzr revid: odo@openerp.com-20111004205716-u3pdb9th4ma3zkvx
This commit is contained in:
@@ -37,8 +37,11 @@ technical OpenERP documentation at http://doc.openerp.com
|
||||
'author': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
'depends': ['base'],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'test': [
|
||||
'test/partner_edi_test.yml',
|
||||
'test/edi_partner_test.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
|
||||
@@ -245,7 +245,7 @@ class EDIMixin(object):
|
||||
if not ext_id:
|
||||
ext_id = existing_id or safe_unique_id(db_uuid, record._name, record.id)
|
||||
# ID is unique cross-db thanks to db_uuid (already included in existing_module)
|
||||
module = existing_module or "%s:%s" % (record._module, db_uuid)
|
||||
module = existing_module or "%s:%s" % (record._original_module, db_uuid)
|
||||
_logger.debug("%s: Generating new external ID `%s.%s` for %r", self._name,
|
||||
module, ext_id, record)
|
||||
ir_model_data.create(cr, openerp.SUPERUSER_ID,
|
||||
@@ -257,8 +257,8 @@ class EDIMixin(object):
|
||||
module, ext_id = ext_id.split('.')
|
||||
if not ':' in module:
|
||||
# this record was not previously EDI-imported
|
||||
assert module == record._module, 'Module mismatch between record and its current'\
|
||||
'external ID'
|
||||
assert module == record._original_module,\
|
||||
'Mismatching module: expected %s, got %s' % (module, record._original_module)
|
||||
# ID is unique cross-db thanks to db_uuid
|
||||
module = "%s:%s" % (module, db_uuid)
|
||||
|
||||
@@ -302,7 +302,7 @@ class EDIMixin(object):
|
||||
'__id': ext_id,
|
||||
'__last_update': last_update_for(record),
|
||||
'__model' : record._name,
|
||||
'__module' : record._module,
|
||||
'__module' : record._original_module,
|
||||
'__version': version,
|
||||
'__attachments': attachments,
|
||||
}
|
||||
|
||||
@@ -19,16 +19,39 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
#from osv import fields,osv
|
||||
from osv import fields,osv
|
||||
|
||||
class res_company(osv.osv):
|
||||
"""Helper subclass for res.company providing util methods for working with
|
||||
companies in the context of EDI import/export. The res.company object
|
||||
itself is not EDI-exportable"""
|
||||
_inherit = "res.company"
|
||||
|
||||
def edi_export_address(self, cr, uid, records, edi_address_struct=None, context=None):
|
||||
"""Returns a dict representation of the address of each company record, suitable for
|
||||
inclusion in an EDI document, and matching the given edi_address_struct if provided.
|
||||
|
||||
:param list(browse_record) records: list of companies to export
|
||||
:rtype: list(dict)
|
||||
:return: list of dicts, where each dict contains the address representation for
|
||||
the company record as the same index in ``records``.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
res_partner = self.pool.get('res.partner')
|
||||
res_partner_address = self.pool.get('res.partner.address')
|
||||
results = []
|
||||
for company in records:
|
||||
res = res_partner.address_get(cr, uid, [company.partner_id.id], ['default', 'contact', 'invoice'])
|
||||
addr_id = res['invoice'] or res['contact'] or res['default']
|
||||
result = {}
|
||||
if addr_id:
|
||||
address = res_partner_address.browse(cr, uid, addr_id, context=context)
|
||||
result = res_partner_address.edi_export(cr, uid, [address], edi_struct=edi_address_struct, context=ctx)[0]
|
||||
resuls.append(result)
|
||||
return []
|
||||
|
||||
# TODO: CHECK below, seems useless
|
||||
#
|
||||
#class res_company(osv.osv):
|
||||
# """Helper subclass for res.company providing util methods for working with
|
||||
# companies in the context of EDI import/export. The res.company object
|
||||
# itself is not EDI-exportable"""
|
||||
# _inherit = "res.company"
|
||||
#
|
||||
# def edi_import_as_partner(self, cr, uid, edi_document, values=None, context=None):
|
||||
# """
|
||||
# import company as a new partner
|
||||
@@ -84,38 +107,3 @@
|
||||
# edi_document_partner.update(values)
|
||||
# return partner_pool.edi_import(cr, uid, edi_document_partner, context=context)
|
||||
#
|
||||
# def edi_export_address(self, cr, uid, records, edi_address_struct=None, context=None):
|
||||
# """Return a dict representation of the address of each company record, suitable for
|
||||
# inclusion in an EDI document, and matching the given edi_address_struct if provided.
|
||||
#
|
||||
# :param list(browse_record) records: list of companies to export
|
||||
# :rtype: list(dict)
|
||||
# :return: list of dicts, where each dict contains the address representation for
|
||||
# the company record as the same index in ``records``.
|
||||
# """
|
||||
# if context is None:
|
||||
# context = {}
|
||||
# res_partner = self.pool.get('res.partner')
|
||||
# res_partner_address = self.pool.get('res.partner.address')
|
||||
# if edi_address_struct is None:
|
||||
# edi_address_struct = {
|
||||
# 'street': True,
|
||||
# 'street2': True,
|
||||
# 'zip': True,
|
||||
# 'city': True,
|
||||
# 'state_id': True,
|
||||
# 'country_id': True,
|
||||
# 'email': True,
|
||||
# 'phone': True,
|
||||
# }
|
||||
# results = []
|
||||
# for company in records:
|
||||
# res = res_partner.address_get(cr, uid, [company.partner_id.id], ['default', 'contact', 'invoice'])
|
||||
# addr_id = res['invoice'] or res['contact'] or res['default']
|
||||
# result = {}
|
||||
# if addr_id:
|
||||
# address = res_partner_address.browse(cr, uid, addr_id, context=context)
|
||||
# result = res_partner_address.edi_export(cr, uid, [address], edi_struct=edi_address_struct, context=ctx)[0]
|
||||
# results.append(result)
|
||||
# return results
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from osv import fields,osv
|
||||
from osv import fields,osv
|
||||
from edi import EDIMixin
|
||||
|
||||
RES_PARTNER_ADDRESS_EDI_STRUCT = {
|
||||
@@ -48,7 +48,7 @@ class res_partner(osv.osv, EDIMixin):
|
||||
|
||||
def edi_export(self, cr, uid, records, edi_struct=None, context=None):
|
||||
return super(res_partner,self).edi_export(cr, uid, records,
|
||||
dict(RES_PARTNER_EDI_STRUCT),
|
||||
edi_struct or dict(RES_PARTNER_EDI_STRUCT),
|
||||
context=context)
|
||||
|
||||
class res_partner_address(osv.osv, EDIMixin):
|
||||
@@ -56,9 +56,8 @@ class res_partner_address(osv.osv, EDIMixin):
|
||||
|
||||
def edi_export(self, cr, uid, records, edi_struct=None, context=None):
|
||||
return super(res_partner_address,self).edi_export(cr, uid, records,
|
||||
dict(RES_PARTNER_ADDRESS_EDI_STRUCT),
|
||||
edi_struct or dict(RES_PARTNER_ADDRESS_EDI_STRUCT),
|
||||
context=context)
|
||||
|
||||
class res_partner_bank(osv.osv, EDIMixin):
|
||||
_inherit = "res.partner.bank"
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_ir_edi_all_read","access_ir_edi_all_read","model_edi_document",,1,0,0,0
|
||||
"access_ir_edi_employee_create","access_ir_edi_employee_create","model_edi_document","base.group_user",1,0,1,0
|
||||
|
@@ -6,7 +6,7 @@
|
||||
with an attached file, check the result, the alter the data
|
||||
and reimport it.
|
||||
-
|
||||
!python {model: ir.edi.document}: |
|
||||
!python {model: edi.document}: |
|
||||
import json
|
||||
partner_obj = self.pool.get('res.partner')
|
||||
tokens = self.export_edi(cr, uid, [partner_obj.browse(cr, uid, ref('base.res_partner_agrolait'))])
|
||||
@@ -16,7 +16,6 @@
|
||||
# check content of the document
|
||||
assert edi_doc.get('__id').endswith('.res_partner_agrolait'), 'Incorrect external ID'
|
||||
assert edi_doc.get('__model') == 'res.partner', 'Incorrect/Missing __model'
|
||||
assert edi_doc.get('__module') == 'base', 'Incorrect/Missing __module'
|
||||
assert edi_doc.get('__last_update'), 'Missing __last_update'
|
||||
|
||||
# try to import the document after changing the name and id, and attaching a
|
||||
Reference in New Issue
Block a user