[IMP] edi: use the new EDIfied res.currency for so/po/invoice EDI

bzr revid: odo@openerp.com-20111024144407-3begj09gvfijpel9
This commit is contained in:
Olivier Dony 2011-10-24 16:44:07 +02:00
parent 02a5880d3c
commit 1ab22b86cc
6 changed files with 42 additions and 13 deletions

View File

@ -54,7 +54,7 @@ INVOICE_EDI_STRUCT = {
'date_due': True,
'partner_id': True,
'payment_term': True,
'currency_id': True, # TODO: should perhaps include sample rate + rounding
#custom: currency_id
'invoice_line': INVOICE_LINE_EDI_STRUCT,
'tax_line': INVOICE_TAX_LINE_EDI_STRUCT,
}
@ -77,6 +77,8 @@ class account_invoice(osv.osv, EDIMixin):
'company_address': res_company.edi_export_address(cr, uid, invoice.company_id, context=context),
'company_paypal_account': invoice.company_id.paypal_account,
'partner_address': res_partner_address.edi_export(cr, uid, [invoice.address_invoice_id], context=context)[0],
'currency': self.pool.get('res.currency').edi_export(cr, uid, [invoice.currency_id], context=context),
#'company_logo': #TODO
})
edi_doc_list.append(edi_doc)
@ -169,7 +171,14 @@ class account_invoice(osv.osv, EDIMixin):
"""
if context is None:
context = {}
self._edi_requires_attributes(('company_id','company_address','type','invoice_line'), edi_document)
self._edi_requires_attributes(('company_id','company_address','type','invoice_line','currency'), edi_document)
# extract currency info
res_currency = self.pool.get('res.currency')
currency_info = edi_document.pop('currency')
currency_id = res_currency.edi_import(cr, uid, currency_info, context=context)
currency = res_currency.browse(cr, uid, currency_id)
edi_document['currency_id'] = self.edi_m2o(cr, uid, currency, context=context)
# change type: out_invoice'<->'in_invoice','out_refund'<->'in_refund'
invoice_type = edi_document['type']

View File

@ -65,7 +65,13 @@
"street": "Chaussee de Namur 40"
},
"company_id": ["account:b22acf7a-ddcd-11e0-a4db-701a04e25543.res_company_test11", "Thomson pvt. ltd."],
"currency_id": ["base:b22acf7a-ddcd-11e0-a4db-701a04e25543.EUR", "EUR (€)"],
"currency": {
"__id": "base:b22acf7a-ddcd-11e0-a4db-701a04e25543.EUR",
"__module": "base",
"__model": "res.currency",
"code": "EUR",
"symbol": "€",
},
"partner_id": ["account:b22acf7a-ddcd-11e0-a4db-701a04e25543.res_partner_test20", "Junjun wala"],
"partner_address": {
"__id": "base:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_address_7wdsjasdjh",

View File

@ -79,7 +79,8 @@ class purchase_order(osv.osv, EDIMixin):
'company_paypal_account': order.company_id.paypal_account,
'partner_address': res_partner_address.edi_export(cr, uid, [order.partner_address_id], context=context)[0],
'currency_id': self.edi_m2o(cr, uid, order.pricelist_id.currency_id, context=context),
'currency': self.pool.get('res.currency').edi_export(cr, uid, [order.pricelist_id.currency_id],
context=context)[0],
#'company_logo': #TODO
})
edi_doc_list.append(edi_doc)
@ -152,15 +153,15 @@ class purchase_order(osv.osv, EDIMixin):
return self.edi_m2o(cr, uid, location, context=context)
def edi_import(self, cr, uid, edi_document, context=None):
self._edi_requires_attributes(('company_id','company_address','order_line','date_order','currency_id'), edi_document)
self._edi_requires_attributes(('company_id','company_address','order_line','date_order','currency'), edi_document)
#import company as a new partner
partner_id = self.edi_import_company(cr, uid, edi_document, context=context)
# currency for rounding the discount calculations and for the pricelist
currency_id, currency_name = edi_document.pop('currency_id')
currency_id = self.edi_import_relation(cr, uid, 'res.currency', currency_name, currency_id, context=context)
res_currency = self.pool.get('res.currency')
currency_info = edi_document.pop('currency')
currency_id = res_currency.edi_import(cr, uid, currency_info, context=context)
order_currency = res_currency.browse(cr, uid, currency_id)
partner_ref = edi_document.pop('partner_ref', False)

View File

@ -47,7 +47,13 @@
"__import_model": "purchase.order",
"__version": [6,1,0],
"name": "SO008",
"currency_id": ["base:724f93ec-ddd0-11e0-88ec-701a04e25543.EUR", "EUR (€)"],
"currency": {
"__id": "base:724f93ec-ddd0-11e0-88ec-701a04e25543.EUR",
"__module": "base",
"__model": "res.currency",
"code": "EUR",
"symbol": "€",
},
"date_order": "2011-09-13",
"partner_id": ["sale:724f93ec-ddd0-11e0-88ec-701a04e25543.res_partner_test22", "Junjun wala"],
"partner_address": {

View File

@ -79,7 +79,8 @@ class sale_order(osv.osv, EDIMixin):
'company_paypal_account': order.company_id.paypal_account,
'partner_address': res_partner_address.edi_export(cr, uid, [order.partner_order_id], context=context)[0],
'currency_id': self.edi_m2o(cr, uid, order.pricelist_id.currency_id, context=context),
'currency': self.pool.get('res.currency').edi_export(cr, uid, [order.pricelist_id.currency_id],
context=context)[0],
'partner_ref': order.client_order_ref or False,
'notes': order.note or False,
#TODO: company_logo
@ -150,15 +151,15 @@ class sale_order(osv.osv, EDIMixin):
return self.edi_m2o(cr, uid, pricelist, context=context)
def edi_import(self, cr, uid, edi_document, context=None):
self._edi_requires_attributes(('company_id','company_address','order_line','date_order','currency_id'), edi_document)
self._edi_requires_attributes(('company_id','company_address','order_line','date_order','currency'), edi_document)
#import company as a new partner
partner_id = self._edi_import_company(cr, uid, edi_document, context=context)
# currency for rounding the discount calculations and for the pricelist
currency_id, currency_name = edi_document.pop('currency_id')
currency_id = self.edi_import_relation(cr, uid, 'res.currency', currency_name, currency_id, context=context)
res_currency = self.pool.get('res.currency')
currency_info = edi_document.pop('currency')
currency_id = res_currency.edi_import(cr, uid, currency_info, context=context)
order_currency = res_currency.browse(cr, uid, currency_id)
date_order = edi_document['date_order']

View File

@ -45,7 +45,13 @@
"__version": [6,1,0],
"name": "PO00011",
"date_order": "2011-09-12",
"currency_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.EUR", "EUR (€)"],
"currency": {
"__id": "base:5af1272e-dd26-11e0-b65e-701a04e25543.EUR",
"__module": "base",
"__model": "res.currency",
"code": "EUR",
"symbol": "€",
},
"company_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.main_company", "Client S.A."],
"company_address": {
"__id": "base:5af1272e-dd26-11e0-b65e-701a04e25543.some_address",