[IMP] improve the edi purchase order import and export testing
bzr revid: aar@tinyerp.com-20110830053453-ecsqohdm12kp6xao
This commit is contained in:
parent
40c2fd365e
commit
5ffef81c62
|
@ -59,6 +59,7 @@ Dashboard for purchase management that includes:
|
|||
'report/purchase_report_view.xml',
|
||||
'board_purchase_view.xml',
|
||||
'edi_purchase_order_data.xml',
|
||||
|
||||
],
|
||||
'test': [
|
||||
'test/purchase_from_order.yml',
|
||||
|
@ -67,7 +68,7 @@ Dashboard for purchase management that includes:
|
|||
'purchase_unit_test.xml',
|
||||
'test/procurement_buy.yml',
|
||||
'test/purchase_report.yml',
|
||||
#'test/edi_purchase_order.yml',
|
||||
'test/edi_purchase_order.yml',
|
||||
],
|
||||
'demo': ['purchase_demo.xml'],
|
||||
'installable': True,
|
||||
|
|
|
@ -118,14 +118,13 @@ class purchase_order(osv.osv, ir_edi.edi):
|
|||
invoice_line_pool = self.pool.get('account.invoice.line')
|
||||
account_pool = self.pool.get('account.account')
|
||||
stock = self.pool.get('stock.location')
|
||||
|
||||
tax_id = []
|
||||
account_id = []
|
||||
partner_id = None
|
||||
company_id = None
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
print edi_document
|
||||
# import company as a new partner, if type==in then supplier=1, else customer=1
|
||||
# partner_id field is modified to point to the new partner
|
||||
# company_address data used to add address to new partner
|
||||
|
@ -178,7 +177,6 @@ class purchase_order(osv.osv, ir_edi.edi):
|
|||
if document.has_key(key):
|
||||
del document[key]
|
||||
|
||||
print edi_document
|
||||
return super(purchase_order,self).edi_import(cr, uid, edi_document, context=context)
|
||||
|
||||
purchase_order()
|
||||
|
|
|
@ -45,7 +45,7 @@ Regards,
|
|||
<field name="template_language">mako</field>
|
||||
<field name="name">Mail Template of Purchase Order For EDI Document</field>
|
||||
<field name="model_int_name">purchase.order</field>
|
||||
<!--field name="reply_to">${object.user_id.email or ''}</field-->
|
||||
<field name="reply_to">${object.user_id.user_email or ''}</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,31 +1,46 @@
|
|||
-
|
||||
I Tesing of EDI functionality. First I export customer invoice from my company than import that invoice into customer company
|
||||
I create a partner which is a my customer
|
||||
-
|
||||
!record {model: res.partner, id: res_partner_test20}:
|
||||
name: jones white
|
||||
supplier: False
|
||||
customer: True
|
||||
opt_out: False
|
||||
-
|
||||
I create one Purchase Order
|
||||
-
|
||||
!record {model: purchase.order, id: purchase_order_test}:
|
||||
partner_id: res_partner_test22
|
||||
partner_address_id: base.res_partner_address_11
|
||||
location_id: stock.stock_location_3
|
||||
pricelist_id: 1
|
||||
order_line:
|
||||
- product_id: product.product_product_pc1
|
||||
product_uom_qty: 1.0
|
||||
product_uom: 1
|
||||
price_unit: 150.0
|
||||
name: 'basic pc'
|
||||
-
|
||||
I Open the sale order
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
|
||||
orders = self.browse(cr, uid, ref("purchase_order_test"))
|
||||
import netsvc
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'purchase.order',orders.id,'approved', cr)
|
||||
-
|
||||
!python {model: ir.edi.document}: |
|
||||
import json
|
||||
order_pool = self.pool.get('purchase.order')
|
||||
purchase_id = order_pool.search(cr, uid, [])
|
||||
orders = order_pool.browse(cr, uid, purchase_id)
|
||||
|
||||
if type(orders).__name__ == 'list':
|
||||
tokens = self.export_edi(cr, uid, orders)
|
||||
for token in tokens:
|
||||
document = self.get_document(cr, uid, token)
|
||||
document = json.loads(document)
|
||||
edi_doc = []
|
||||
for doc in document:
|
||||
doc.update({'__model': 'sale.order'})
|
||||
edi_doc.append(doc)
|
||||
a = self.import_edi(cr, uid, edi_document = json.dumps(edi_doc))
|
||||
else:
|
||||
tokens = self.export_edi(cr, uid, orders)
|
||||
for token in tokens:
|
||||
document = self.get_document(cr, uid, token)
|
||||
document = json.loads(document)
|
||||
edi_doc = []
|
||||
for doc in document:
|
||||
doc.update({'__model': 'sale.order'})
|
||||
edi_doc.append(doc)
|
||||
a = self.import_edi(cr, uid, edi_document = json.dumps(edi_doc))
|
||||
|
||||
|
||||
order_pool = self.pool.get('purchase.order')
|
||||
purchase_id = order_pool.search(cr, uid, ref("purchase_order_test"))
|
||||
orders = order_pool.browse(cr, uid, purchase_id)
|
||||
import json
|
||||
|
||||
tokens = self.export_edi(cr, uid, [orders])
|
||||
assert tokens, 'Token is not generated'
|
||||
document = self.get_document(cr, uid, tokens[0])
|
||||
document = json.loads(document)
|
||||
document[0]["__model"] = "purchase.order"
|
||||
document = json.dumps(document)
|
||||
a = self.import_edi(cr, uid, edi_document = document)
|
||||
|
||||
|
|
Loading…
Reference in New Issue