[FIX] removed res partner address code
bzr revid: jam@tinyerp.com-20120305060628-qlynpirl1e6fh5nb
This commit is contained in:
parent
88c25488a5
commit
09b0ecc8f9
|
@ -37,13 +37,13 @@ class res_company(osv.osv):
|
|||
an empty dict if no address can be found
|
||||
"""
|
||||
res_partner = self.pool.get('res.partner')
|
||||
res_partner_address = self.pool.get('res.partner.address')
|
||||
# res_partner_address = self.pool.get('res.partner.address')
|
||||
addresses = res_partner.address_get(cr, uid, [company.partner_id.id], ['default', 'contact', 'invoice'])
|
||||
addr_id = addresses['invoice'] or addresses['contact'] or addresses['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=context)[0]
|
||||
address = res_partner.browse(cr, uid, addr_id, context=context)
|
||||
result = res_partner.edi_export(cr, uid, [address], edi_struct=edi_address_struct, context=context)[0]
|
||||
if company.logo:
|
||||
result['logo'] = company.logo # already base64-encoded
|
||||
if company.paypal_account:
|
||||
|
@ -52,7 +52,7 @@ class res_company(osv.osv):
|
|||
res_partner_bank = self.pool.get('res.partner.bank')
|
||||
bank_ids = res_partner_bank.search(cr, uid, [('company_id','=',company.id),('footer','=',True)], context=context)
|
||||
if bank_ids:
|
||||
result['bank_ids'] = res_partner_address.edi_m2m(cr, uid,
|
||||
result['bank_ids'] = res_partner.edi_o2m(cr, uid,
|
||||
res_partner_bank.browse(cr, uid, bank_ids, context=context),
|
||||
context=context)
|
||||
return result
|
||||
|
|
|
@ -44,7 +44,18 @@ RES_PARTNER_EDI_STRUCT = {
|
|||
'ref': True,
|
||||
'lang': True,
|
||||
'website': True,
|
||||
'address': RES_PARTNER_ADDRESS_EDI_STRUCT
|
||||
# 'address': RES_PARTNER_ADDRESS_EDI_STRUCT
|
||||
# 'name': True,
|
||||
'email': True,
|
||||
'street': True,
|
||||
'street2': True,
|
||||
'zip': True,
|
||||
'city': True,
|
||||
'country_id': True,
|
||||
'state_id': True,
|
||||
'phone': True,
|
||||
'fax': True,
|
||||
'mobile': True,
|
||||
}
|
||||
|
||||
class res_partner(osv.osv, EDIMixin):
|
||||
|
@ -55,9 +66,6 @@ class res_partner(osv.osv, EDIMixin):
|
|||
edi_struct or dict(RES_PARTNER_EDI_STRUCT),
|
||||
context=context)
|
||||
|
||||
class res_partner_address(osv.osv, EDIMixin):
|
||||
_inherit = "res.partner.address"
|
||||
|
||||
def _get_bank_type(self, cr, uid, context=None):
|
||||
# first option: the "normal" bank type, installed by default
|
||||
res_partner_bank_type = self.pool.get('res.partner.bank.type')
|
||||
|
@ -65,7 +73,6 @@ class res_partner_address(osv.osv, EDIMixin):
|
|||
return self.pool.get('ir.model.data').get_object(cr, uid, 'base', 'bank_normal', context=context).code
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
# second option: create a new custom type for EDI or use it if already created, as IBAN type is
|
||||
# not always appropriate: we need a free-form bank type for max flexibility (users can correct
|
||||
# data manually after import)
|
||||
|
@ -78,19 +85,14 @@ class res_partner_address(osv.osv, EDIMixin):
|
|||
'code': label})
|
||||
return code
|
||||
|
||||
def edi_export(self, cr, uid, records, edi_struct=None, context=None):
|
||||
return super(res_partner_address,self).edi_export(cr, uid, records,
|
||||
edi_struct or dict(RES_PARTNER_ADDRESS_EDI_STRUCT),
|
||||
context=context)
|
||||
|
||||
def edi_import(self, cr, uid, edi_document, context=None):
|
||||
# handle bank info, if any
|
||||
edi_bank_ids = edi_document.pop('bank_ids', None)
|
||||
address_id = super(res_partner_address,self).edi_import(cr, uid, edi_document, context=context)
|
||||
contact_id = super(res_partner,self).edi_import(cr, uid, edi_document, context=context)
|
||||
if edi_bank_ids:
|
||||
address = self.browse(cr, uid, address_id, context=context)
|
||||
contacts = self.browse(cr, uid, contact_id, context=context)
|
||||
import_ctx = dict((context or {}),
|
||||
default_partner_id=address.partner_id.id,
|
||||
default_partner_id=contacts.partner_id.id,
|
||||
default_state=self._get_bank_type(cr, uid, context))
|
||||
for ext_bank_id, bank_name in edi_bank_ids:
|
||||
try:
|
||||
|
@ -101,5 +103,54 @@ class res_partner_address(osv.osv, EDIMixin):
|
|||
logging.getLogger('edi.res_partner').warning('Failed to import bank account using'
|
||||
'bank type: %s, ignoring', import_ctx['default_state'],
|
||||
exc_info=True)
|
||||
return address_id
|
||||
return contact_id
|
||||
|
||||
|
||||
#class res_partner_address(osv.osv, EDIMixin):
|
||||
# _inherit = "res.partner.address"
|
||||
|
||||
# def _get_bank_type(self, cr, uid, context=None):
|
||||
# # first option: the "normal" bank type, installed by default
|
||||
# res_partner_bank_type = self.pool.get('res.partner.bank.type')
|
||||
# try:
|
||||
# return self.pool.get('ir.model.data').get_object(cr, uid, 'base', 'bank_normal', context=context).code
|
||||
# except ValueError:
|
||||
# pass
|
||||
|
||||
# # second option: create a new custom type for EDI or use it if already created, as IBAN type is
|
||||
# # not always appropriate: we need a free-form bank type for max flexibility (users can correct
|
||||
# # data manually after import)
|
||||
# code, label = 'edi_generic', 'Generic Bank Type (auto-created for EDI)'
|
||||
# bank_code_ids = res_partner_bank_type.search(cr, uid, [('code','=',code)], context=context)
|
||||
# if not bank_code_ids:
|
||||
# logging.getLogger('edi.res_partner').info('Normal bank account type is missing, creating '
|
||||
# 'a generic bank account type for EDI.')
|
||||
# self.res_partner_bank_type.create(cr, SUPERUSER_ID, {'name': label,
|
||||
# 'code': label})
|
||||
# return code
|
||||
|
||||
# def edi_export(self, cr, uid, records, edi_struct=None, context=None):
|
||||
# return super(res_partner_address,self).edi_export(cr, uid, records,
|
||||
# edi_struct or dict(RES_PARTNER_ADDRESS_EDI_STRUCT),
|
||||
# context=context)
|
||||
|
||||
# def edi_import(self, cr, uid, edi_document, context=None):
|
||||
# # handle bank info, if any
|
||||
# edi_bank_ids = edi_document.pop('bank_ids', None)
|
||||
# address_id = super(res_partner_address,self).edi_import(cr, uid, edi_document, context=context)
|
||||
# if edi_bank_ids:
|
||||
# address = self.browse(cr, uid, address_id, context=context)
|
||||
# import_ctx = dict((context or {}),
|
||||
# default_partner_id=address.partner_id.id,
|
||||
# default_state=self._get_bank_type(cr, uid, context))
|
||||
# for ext_bank_id, bank_name in edi_bank_ids:
|
||||
# try:
|
||||
# self.edi_import_relation(cr, uid, 'res.partner.bank',
|
||||
# bank_name, ext_bank_id, context=import_ctx)
|
||||
# except osv.except_osv:
|
||||
# # failed to import it, try again with unrestricted default type
|
||||
# logging.getLogger('edi.res_partner').warning('Failed to import bank account using'
|
||||
# 'bank type: %s, ignoring', import_ctx['default_state'],
|
||||
# exc_info=True)
|
||||
# return address_id
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
Loading…
Reference in New Issue