[Fix] edi :remove res_partner_address from edi
bzr revid: sbh@tinyerp.com-20120301095955-i6atov37xb3lztlb
This commit is contained in:
@@ -75,7 +75,7 @@ class account_invoice(osv.osv, EDIMixin):
|
||||
"""Exports a supplier or customer invoice"""
|
||||
edi_struct = dict(edi_struct or INVOICE_EDI_STRUCT)
|
||||
res_company = self.pool.get('res.company')
|
||||
res_partner_address = self.pool.get('res.partner.address')
|
||||
res_partner_address = self.pool.get('res.partner')
|
||||
edi_doc_list = []
|
||||
for invoice in records:
|
||||
# generate the main report
|
||||
@@ -125,7 +125,6 @@ class account_invoice(osv.osv, EDIMixin):
|
||||
# the desired company among the user's allowed companies
|
||||
|
||||
self._edi_requires_attributes(('company_id','company_address','type'), edi_document)
|
||||
res_partner_address = self.pool.get('res.partner.address')
|
||||
res_partner = self.pool.get('res.partner')
|
||||
|
||||
# imported company = new partner
|
||||
@@ -144,10 +143,10 @@ class account_invoice(osv.osv, EDIMixin):
|
||||
address_info = edi_document.pop('company_address')
|
||||
address_info['partner_id'] = (src_company_id, src_company_name)
|
||||
address_info['type'] = 'invoice'
|
||||
address_id = res_partner_address.edi_import(cr, uid, address_info, context=context)
|
||||
address_id = res_partner.edi_import(cr, uid, address_info, context=context)
|
||||
|
||||
# modify edi_document to refer to new partner
|
||||
partner_address = res_partner_address.browse(cr, uid, address_id, context=context)
|
||||
partner_address = res_partner.browse(cr, uid, address_id, context=context)
|
||||
edi_document['partner_id'] = (src_company_id, src_company_name)
|
||||
edi_document.pop('partner_address', False) # ignored
|
||||
edi_document['address_invoice_id'] = self.edi_m2o(cr, uid, partner_address, context=context)
|
||||
|
||||
@@ -37,13 +37,12 @@ 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')
|
||||
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 +51,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_m2m(cr, uid,
|
||||
res_partner_bank.browse(cr, uid, bank_ids, context=context),
|
||||
context=context)
|
||||
return result
|
||||
|
||||
@@ -25,8 +25,12 @@ from edi import EDIMixin
|
||||
from openerp import SUPERUSER_ID
|
||||
from tools.translate import _
|
||||
|
||||
RES_PARTNER_ADDRESS_EDI_STRUCT = {
|
||||
|
||||
RES_PARTNER_EDI_STRUCT = {
|
||||
'name': True,
|
||||
'ref': True,
|
||||
'lang': True,
|
||||
'website': True,
|
||||
'email': True,
|
||||
'street': True,
|
||||
'street2': True,
|
||||
@@ -39,13 +43,6 @@ RES_PARTNER_ADDRESS_EDI_STRUCT = {
|
||||
'mobile': True,
|
||||
}
|
||||
|
||||
RES_PARTNER_EDI_STRUCT = {
|
||||
'name': True,
|
||||
'ref': True,
|
||||
'lang': True,
|
||||
'website': True,
|
||||
'address': RES_PARTNER_ADDRESS_EDI_STRUCT
|
||||
}
|
||||
|
||||
class res_partner(osv.osv, EDIMixin):
|
||||
_inherit = "res.partner"
|
||||
@@ -55,8 +52,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
|
||||
@@ -79,18 +74,18 @@ class res_partner_address(osv.osv, EDIMixin):
|
||||
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),
|
||||
return super(res_partner,self).edi_export(cr, uid, records,
|
||||
edi_struct or dict(RES_PARTNER_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)
|
||||
address_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)
|
||||
import_ctx = dict((context or {}),
|
||||
default_partner_id=address.partner_id.id,
|
||||
default_partner_id=address.id,
|
||||
default_state=self._get_bank_type(cr, uid, context))
|
||||
for ext_bank_id, bank_name in edi_bank_ids:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user