[FIX] edi,sale,purchase: fix EDI import of SO/PO, now compatible again with 6.1, and correct wrt. partners import (vs old addresses)
bzr revid: odo@openerp.com-20121018152129-s22uozt77s37urp1
This commit is contained in:
parent
48cfc1bb02
commit
e0fcab1f62
|
@ -126,6 +126,7 @@
|
|||
invoice_new = self.browse(cr, uid, invoice_id)
|
||||
|
||||
# check bank info on partner
|
||||
assert invoice_new.partner_id.supplier, "Imported partner should be a supplier, as we just imported the document as a supplier invoice"
|
||||
assert len(invoice_new.partner_id.bank_ids) == 1, "Expected 1 bank entry related to partner"
|
||||
bank_info = invoice_new.partner_id.bank_ids[0]
|
||||
assert bank_info.acc_number == "Sample bank: 70-123465789-156113", 'Expected "Sample bank: 70-123465789-156113", got %s' % bank_info.acc_number
|
||||
|
@ -233,6 +234,7 @@
|
|||
invoice_new = self.browse(cr, uid, invoice_id)
|
||||
|
||||
# check bank info on partner
|
||||
assert invoice_new.partner_id.supplier, "Imported partner should be a supplier, as we just imported the document as a supplier invoice"
|
||||
assert len(invoice_new.partner_id.bank_ids) == 1, "Expected 1 bank entry related to partner"
|
||||
bank_info = invoice_new.partner_id.bank_ids[0]
|
||||
assert bank_info.acc_number == "Sample bank: 123465789-156113", 'Expected "Sample bank: 123465789-156113", got %s' % bank_info.acc_number
|
||||
|
|
|
@ -91,22 +91,26 @@ class purchase_order(osv.osv, EDIMixin):
|
|||
# the desired company among the user's allowed companies
|
||||
|
||||
self._edi_requires_attributes(('company_id','company_address'), edi_document)
|
||||
res_partner_obj = self.pool.get('res.partner')
|
||||
res_partner = self.pool.get('res.partner')
|
||||
|
||||
# imported company_address = new partner address
|
||||
_, src_company_name = edi_document.pop('company_id')
|
||||
address_info = edi_document.pop('company_address')
|
||||
address_info['customer'] = True
|
||||
if 'name' not in address_info:
|
||||
address_info['name'] = src_company_name
|
||||
address_id = res_partner_obj.edi_import(cr, uid, address_info, context=context)
|
||||
xid, company_name = edi_document.pop('company_id')
|
||||
# Retrofit address info into a unified partner info (changed in v7 - used to keep them separate)
|
||||
company_address_edi = edi_document.pop('company_address')
|
||||
company_address_edi['name'] = company_name
|
||||
company_address_edi['is_company'] = True
|
||||
company_address_edi['__import_model'] = 'res.partner'
|
||||
company_address_edi['__id'] = xid # override address ID, as of v7 they should be the same anyway
|
||||
if company_address_edi.get('logo'):
|
||||
company_address_edi['image'] = company_address_edi.pop('logo')
|
||||
company_address_edi['supplier'] = True
|
||||
partner_id = res_partner.edi_import(cr, uid, company_address_edi, context=context)
|
||||
|
||||
# modify edi_document to refer to new partner/address
|
||||
partner_address = res_partner_obj.browse(cr, uid, address_id, context=context)
|
||||
edi_document.pop('partner_address', False) # ignored
|
||||
edi_document['partner_id'] = self.edi_m2o(cr, uid, partner_address, context=context)
|
||||
|
||||
return address_id
|
||||
# modify edi_document to refer to new partner
|
||||
partner = res_partner.browse(cr, uid, partner_id, context=context)
|
||||
partner_edi_m2o = self.edi_m2o(cr, uid, partner, context=context)
|
||||
edi_document['partner_id'] = partner_edi_m2o
|
||||
edi_document.pop('partner_address', None) # ignored, that's supposed to be our own address!
|
||||
return partner_id
|
||||
|
||||
def _edi_get_pricelist(self, cr, uid, partner_id, currency, context=None):
|
||||
# TODO: refactor into common place for purchase/sale, e.g. into product module
|
||||
|
|
|
@ -34,29 +34,29 @@
|
|||
edi_doc = self.generate_edi(cr, uid, [order])
|
||||
assert isinstance(json.loads(edi_doc)[0], dict), 'EDI doc should be a JSON dict'
|
||||
-
|
||||
Then I import a sample EDI document of a sale order
|
||||
Then I import a sample EDI document of a sale order (v7.0)
|
||||
-
|
||||
!python {model: edi.edi}: |
|
||||
purchase_order_pool = self.pool.get('purchase.order')
|
||||
edi_document = {
|
||||
"__id": "sale:724f93ec-ddd0-11e0-88ec-701a04e25543.sale_order_test",
|
||||
"__id": "sale:724f9v70-dv70-1v70-8v70-701a04e25v70.sale_order_test",
|
||||
"__module": "sale",
|
||||
"__model": "sale.order",
|
||||
"__import_module": "purchase",
|
||||
"__import_model": "purchase.order",
|
||||
"__version": [6,1,0],
|
||||
"__version": [7,0,0],
|
||||
"name": "SO008",
|
||||
"currency": {
|
||||
"__id": "base:724f93ec-ddd0-11e0-88ec-701a04e25543.EUR",
|
||||
"__id": "base:724f9v70-dv70-1v70-8v70-701a04e25v70.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_id": ["sale:724f9v70-dv70-1v70-8v70-701a04e25v70.res_partner_test22", "Junjun wala"],
|
||||
"partner_address": {
|
||||
"__id": "base:724f93ec-ddd0-11e0-88ec-701a04e25543.res_partner_address_7wdsjasdjh",
|
||||
"__id": "base:724f9v70-dv70-1v70-8v70-701a04e25v70.res_partner_address_7wdsjasdjh",
|
||||
"__module": "base",
|
||||
"__model": "res.partner",
|
||||
"phone": "(+32).81.81.37.00",
|
||||
|
@ -65,48 +65,48 @@
|
|||
"zip": "1367",
|
||||
"country_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.be", "Belgium"],
|
||||
},
|
||||
"company_id": ["base:724f93ec-ddd0-11e0-88ec-701a04e25543.main_company", "Supplier S.A."],
|
||||
"company_id": ["base:724f9v70-dv70-1v70-8v70-701a04e25v70.main_company", "Supplier S.A."],
|
||||
"company_address": {
|
||||
"__id": "base:724f93ec-ddd0-11e0-88ec-701a04e25543.main_address",
|
||||
"__id": "base:724f9v70-dv70-1v70-8v70-701a04e25v70.main_address",
|
||||
"__module": "base",
|
||||
"__model": "res.partner",
|
||||
"city": "Gerompont",
|
||||
"zip": "1367",
|
||||
"country_id": ["base:724f93ec-ddd0-11e0-88ec-701a04e25543.be", "Belgium"],
|
||||
"country_id": ["base:724f9v70-dv70-1v70-8v70-701a04e25v70.be", "Belgium"],
|
||||
"phone": "(+32).81.81.37.00",
|
||||
"street": "Chaussee de Namur 40",
|
||||
"street2": "mailbox 34",
|
||||
"bank_ids": [
|
||||
["base:724f93ec-ddd0-11e0-88ec-701a04e25543.res_partner_bank-XiwqnxKWzGbp","Guys bank: 123477777-156113"]
|
||||
["base:724f9v70-dv70-1v70-8v70-701a04e25v70.res_partner_bank-XiwqnxKWzGbp","Guys bank: 123477777-156113"]
|
||||
],
|
||||
},
|
||||
"order_line": [{
|
||||
"__id": "sale:724f93ec-ddd0-11e0-88ec-701a04e25543.sale_order_line-LXEqeuI-SSP0",
|
||||
"__id": "sale:724f9v70-dv70-1v70-8v70-701a04e25v70.sale_order_line-LXEqeuI-SSP0",
|
||||
"__module": "sale",
|
||||
"__model": "sale.order.line",
|
||||
"__import_module": "purchase",
|
||||
"__import_model": "purchase.order.line",
|
||||
"name": "PC Assemble SC234",
|
||||
"product_uom": ["product:724f93ec-ddd0-11e0-88ec-701a04e25543.product_uom_unit", "Unit"],
|
||||
"product_uom": ["product:724f9v70-dv70-1v70-8v70-701a04e25v70.product_uom_unit", "Unit"],
|
||||
"product_qty": 1.0,
|
||||
"date_planned": "2011-09-30",
|
||||
"sequence": 10,
|
||||
"price_unit": 150.0,
|
||||
"product_id": ["product:724f93ec-ddd0-11e0-88ec-701a04e25543.product_product_3", "[PCSC234] PC Assemble SC234"],
|
||||
"product_id": ["product:724f9v70-dv70-1v70-8v70-701a04e25v70.product_product_3", "[PCSC234] PC Assemble SC234"],
|
||||
},
|
||||
{
|
||||
"__id": "sale:724f93ec-ddd0-11e0-88ec-701a04e25543.sale_order_line-LXEqeadasdad",
|
||||
"__id": "sale:724f9v70-dv70-1v70-8v70-701a04e25v70.sale_order_line-LXEqeadasdad",
|
||||
"__module": "sale",
|
||||
"__model": "sale.order.line",
|
||||
"__import_module": "purchase",
|
||||
"__import_model": "purchase.order.line",
|
||||
"name": "PC on Demand",
|
||||
"product_uom": ["product:724f93ec-ddd0-11e0-88ec-701a04e25543.product_uom_unit", "Unit"],
|
||||
"product_uom": ["product:724f9v70-dv70-1v70-8v70-701a04e25v70.product_uom_unit", "Unit"],
|
||||
"product_qty": 10.0,
|
||||
"sequence": 11,
|
||||
"date_planned": "2011-09-15",
|
||||
"price_unit": 20.0,
|
||||
"product_id": ["product:724f93ec-ddd0-11e0-88ec-701a04e25543.product_product_5", "[PC-DEM] PC on Demand"],
|
||||
"product_id": ["product:724f9v70-dv70-1v70-8v70-701a04e25v70.product_product_5", "[PC-DEM] PC on Demand"],
|
||||
}],
|
||||
}
|
||||
new_purchase_order_id = purchase_order_pool.edi_import(cr, uid, edi_document, context=context)
|
||||
|
@ -114,6 +114,7 @@
|
|||
order_new = purchase_order_pool.browse(cr, uid, new_purchase_order_id)
|
||||
|
||||
# check bank info on partner
|
||||
assert order_new.partner_id.supplier, "Imported partner should be a supplier, as we just imported the document as a purchase order"
|
||||
assert len(order_new.partner_id.bank_ids) == 1, "Expected 1 bank entry related to partner"
|
||||
bank_info = order_new.partner_id.bank_ids[0]
|
||||
assert bank_info.acc_number == "Guys bank: 123477777-156113", 'Expected "Guys bank: 123477777-156113", got %s' % bank_info.acc_number
|
||||
|
@ -133,3 +134,104 @@
|
|||
assert purchase_line.product_qty == 10 , "product qty is not same"
|
||||
else:
|
||||
raise AssertionError('unknown order line: %s' % purchase_line)
|
||||
-
|
||||
"Then I import a sample EDI document of a sale order (v6.1 - to test backwards compatibility)"
|
||||
-
|
||||
!python {model: edi.edi}: |
|
||||
purchase_order_pool = self.pool.get('purchase.order')
|
||||
edi_document = {
|
||||
"__id": "sale:724f93ec-ddd0-11e0-88ec-701a04e25543.sale_order_test",
|
||||
"__module": "sale",
|
||||
"__model": "sale.order",
|
||||
"__import_module": "purchase",
|
||||
"__import_model": "purchase.order",
|
||||
"__version": [6,1,0],
|
||||
"name": "SO08v61",
|
||||
"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": {
|
||||
"__id": "base:724f93ec-ddd0-11e0-88ec-701a04e25543.res_partner_address_7wdsjasdjh",
|
||||
"__module": "base",
|
||||
"__model": "res.partner.address",
|
||||
"phone": "(+32).81.81.37.00",
|
||||
"street": "Chaussee de Namur 40",
|
||||
"city": "Gerompont",
|
||||
"zip": "1367",
|
||||
"country_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.be", "Belgium"],
|
||||
},
|
||||
"company_id": ["base:724f93ec-ddd0-11e0-88ec-701a04e25543.main_company", "Supplier S.A."],
|
||||
"company_address": {
|
||||
"__id": "base:724f93ec-ddd0-11e0-88ec-701a04e25543.main_address",
|
||||
"__module": "base",
|
||||
"__model": "res.partner.address",
|
||||
"city": "Gerompont",
|
||||
"zip": "1367",
|
||||
"country_id": ["base:724f93ec-ddd0-11e0-88ec-701a04e25543.be", "Belgium"],
|
||||
"phone": "(+32).81.81.37.00",
|
||||
"street": "Chaussee de Namur 40",
|
||||
"street2": "mailbox 34",
|
||||
"bank_ids": [
|
||||
["base:724f93ec-ddd0-11e0-88ec-701a04e25543.res_partner_bank-XiwqnxKWzGbp","Another bank: 123477700-156113"]
|
||||
],
|
||||
},
|
||||
"order_line": [{
|
||||
"__id": "sale:724f93ec-ddd0-11e0-88ec-701a04e25543.sale_order_line-LXEqeuI-SSP0",
|
||||
"__module": "sale",
|
||||
"__model": "sale.order.line",
|
||||
"__import_module": "purchase",
|
||||
"__import_model": "purchase.order.line",
|
||||
"name": "Basic PC",
|
||||
"product_uom": ["product:724f93ec-ddd0-11e0-88ec-701a04e25543.product_uom_unit", "PCE"],
|
||||
"product_qty": 1.0,
|
||||
"date_planned": "2011-09-30",
|
||||
"sequence": 10,
|
||||
"price_unit": 150.0,
|
||||
"product_id": ["product:724f93ec-ddd0-11e0-88ec-701a04e25543.product_product_pc1", "[PC1] Basic PC"],
|
||||
},
|
||||
{
|
||||
"__id": "sale:724f93ec-ddd0-11e0-88ec-701a04e25543.sale_order_line-LXEqeadasdad",
|
||||
"__module": "sale",
|
||||
"__model": "sale.order.line",
|
||||
"__import_module": "purchase",
|
||||
"__import_model": "purchase.order.line",
|
||||
"name": "Medium PC",
|
||||
"product_uom": ["product:724f93ec-ddd0-11e0-88ec-701a04e25543.product_uom_unit", "PCE"],
|
||||
"product_qty": 10.0,
|
||||
"sequence": 11,
|
||||
"date_planned": "2011-09-15",
|
||||
"price_unit": 20.0,
|
||||
"product_id": ["product:724f93ec-ddd0-11e0-88ec-701a04e25543.product_product_pc3", "[PC3] Medium PC"],
|
||||
}],
|
||||
}
|
||||
new_purchase_order_id = purchase_order_pool.edi_import(cr, uid, edi_document, context=context)
|
||||
assert new_purchase_order_id, 'Purchase order import failed'
|
||||
order_new = purchase_order_pool.browse(cr, uid, new_purchase_order_id)
|
||||
|
||||
# check bank info on partner
|
||||
assert order_new.partner_id.supplier, "Imported partner should be a supplier, as we just imported the document as a purchase order"
|
||||
assert len(order_new.partner_id.bank_ids) == 1, "Expected 1 bank entry related to partner"
|
||||
bank_info = order_new.partner_id.bank_ids[0]
|
||||
assert bank_info.acc_number == "Another bank: 123477700-156113", 'Expected "Another bank: 123477700-156113", got %s' % bank_info.acc_number
|
||||
|
||||
assert order_new.pricelist_id.name == 'Default Purchase Pricelist' , "Default Purchase Pricelist was not automatically assigned"
|
||||
assert order_new.amount_total == 350, "Amount total is not same"
|
||||
assert order_new.amount_untaxed == 350, "untaxed amount is not same"
|
||||
assert len(order_new.order_line) == 2, "Purchase order lines number mismatch"
|
||||
for purchase_line in order_new.order_line:
|
||||
if purchase_line.name == 'Basic PC':
|
||||
assert purchase_line.product_uom.name == "PCE" , "uom is not same"
|
||||
assert purchase_line.price_unit == 150 , "unit price is not same, got %s, expected 150"%(purchase_line.price_unit,)
|
||||
assert purchase_line.product_qty == 1 , "product qty is not same"
|
||||
elif purchase_line.name == 'Medium PC':
|
||||
assert purchase_line.product_uom.name == "PCE" , "uom is not same"
|
||||
assert purchase_line.price_unit == 20 , "unit price is not same, got %s, expected 20"%(purchase_line.price_unit,)
|
||||
assert purchase_line.product_qty == 10 , "product qty is not same"
|
||||
else:
|
||||
raise AssertionError('unknown order line: %s' % purchase_line)
|
|
@ -88,34 +88,36 @@ class sale_order(osv.osv, EDIMixin):
|
|||
edi_doc_list.append(edi_doc)
|
||||
return edi_doc_list
|
||||
|
||||
|
||||
def _edi_import_company(self, cr, uid, edi_document, context=None):
|
||||
# TODO: for multi-company setups, we currently import the document in the
|
||||
# user's current company, but we should perhaps foresee a way to select
|
||||
# the desired company among the user's allowed companies
|
||||
|
||||
self._edi_requires_attributes(('company_id','company_address'), edi_document)
|
||||
res_partner_obj = self.pool.get('res.partner')
|
||||
res_partner = self.pool.get('res.partner')
|
||||
|
||||
# imported company_address = new partner address
|
||||
_, src_company_name = edi_document.pop('company_id')
|
||||
xid, company_name = edi_document.pop('company_id')
|
||||
# Retrofit address info into a unified partner info (changed in v7 - used to keep them separate)
|
||||
company_address_edi = edi_document.pop('company_address')
|
||||
company_address_edi['name'] = company_name
|
||||
company_address_edi['is_company'] = True
|
||||
company_address_edi['__import_model'] = 'res.partner'
|
||||
company_address_edi['__id'] = xid # override address ID, as of v7 they should be the same anyway
|
||||
if company_address_edi.get('logo'):
|
||||
company_address_edi['image'] = company_address_edi.pop('logo')
|
||||
company_address_edi['customer'] = True
|
||||
partner_id = res_partner.edi_import(cr, uid, company_address_edi, context=context)
|
||||
|
||||
address_info = edi_document.pop('company_address')
|
||||
address_info['supplier'] = True
|
||||
if 'name' not in address_info:
|
||||
address_info['name'] = src_company_name
|
||||
# modify edi_document to refer to new partner
|
||||
partner = res_partner.browse(cr, uid, partner_id, context=context)
|
||||
partner_edi_m2o = self.edi_m2o(cr, uid, partner, context=context)
|
||||
edi_document['partner_id'] = partner_edi_m2o
|
||||
edi_document['partner_invoice_id'] = partner_edi_m2o
|
||||
edi_document['partner_shipping_id'] = partner_edi_m2o
|
||||
|
||||
address_id = res_partner_obj.edi_import(cr, uid, address_info, context=context)
|
||||
edi_document.pop('partner_address', None) # ignored, that's supposed to be our own address!
|
||||
return partner_id
|
||||
|
||||
# modify edi_document to refer to new partner/address
|
||||
partner_address = res_partner_obj.browse(cr, uid, address_id, context=context)
|
||||
edi_document.pop('partner_address', False) # ignored
|
||||
address_edi_m2o = self.edi_m2o(cr, uid, partner_address, context=context)
|
||||
edi_document['partner_id'] = address_edi_m2o
|
||||
edi_document['partner_invoice_id'] = address_edi_m2o
|
||||
edi_document['partner_shipping_id'] = address_edi_m2o
|
||||
|
||||
return address_id
|
||||
|
||||
def _edi_get_pricelist(self, cr, uid, partner_id, currency, context=None):
|
||||
# TODO: refactor into common place for purchase/sale, e.g. into product module
|
||||
|
|
|
@ -32,64 +32,64 @@
|
|||
edi_doc = self.generate_edi(cr, uid, [so])
|
||||
assert isinstance(json.loads(edi_doc)[0], dict), 'EDI doc should be a JSON dict'
|
||||
-
|
||||
Then I import a sample EDI document of a purchase order
|
||||
"Then I import a sample EDI document of a purchase order (v7.0)"
|
||||
-
|
||||
!python {model: edi.edi}: |
|
||||
sale_order_pool = self.pool.get('sale.order')
|
||||
edi_document = {
|
||||
"__id": "purchase:5af1272e-dd26-11e0-b65e-701a04e25543.purchase_order_test",
|
||||
"__id": "purchase:5af12v70-dv70-1v70-bv70-701a04e25v70.purchase_order_test",
|
||||
"__module": "purchase",
|
||||
"__model": "purchase.order",
|
||||
"__import_module": "sale",
|
||||
"__import_model": "sale.order",
|
||||
"__version": [6,1,0],
|
||||
"__version": [7,0,0],
|
||||
"name": "PO00011",
|
||||
"date_order": "2011-09-12",
|
||||
"currency": {
|
||||
"__id": "base:5af1272e-dd26-11e0-b65e-701a04e25543.EUR",
|
||||
"__id": "base:5af12v70-dv70-1v70-bv70-701a04e25v70.EUR",
|
||||
"__module": "base",
|
||||
"__model": "res.currency",
|
||||
"code": "EUR",
|
||||
"symbol": "€",
|
||||
},
|
||||
"company_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.main_company", "Client S.A."],
|
||||
"company_id": ["base:5af12v70-dv70-1v70-bv70-701a04e25v70.main_company", "Client S.A."],
|
||||
"company_address": {
|
||||
"__id": "base:5af1272e-dd26-11e0-b65e-701a04e25543.some_address",
|
||||
"__id": "base:5af12v70-dv70-1v70-bv70-701a04e25v70.some_address",
|
||||
"__module": "base",
|
||||
"__model": "res.partner",
|
||||
"phone": "(+32).81.81.37.00",
|
||||
"street": "Chaussee de Namur 40",
|
||||
"city": "Gerompont",
|
||||
"zip": "1367",
|
||||
"country_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.be", "Belgium"],
|
||||
"country_id": ["base:5af12v70-dv70-1v70-bv70-701a04e25v70.be", "Belgium"],
|
||||
"bank_ids": [
|
||||
["base:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_bank-adaWadsadasdDJzGbp","Ladies bank: 032465789-156113"]
|
||||
["base:5af12v70-dv70-1v70-bv70-701a04e25v70.res_partner_bank-adaWadsadasdDJzGbp","Ladies bank: 032465789-156113"]
|
||||
],
|
||||
},
|
||||
"partner_id": ["purchase:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_test20", "jones white"],
|
||||
"partner_id": ["purchase:5af12v70-dv70-1v70-bv70-701a04e25v70.res_partner_test20", "jones white"],
|
||||
"order_line": [{
|
||||
"__id": "purchase:5af1272e-dd26-11e0-b65e-701a04e25543.purchase_order_line-AlhsVDZGoKvJ",
|
||||
"__id": "purchase:5af12v70-dv70-1v70-bv70-701a04e25v70.purchase_order_line-AlhsVDZGoKvJ",
|
||||
"__module": "purchase",
|
||||
"__model": "purchase.order.line",
|
||||
"__import_module": "sale",
|
||||
"__import_model": "sale.order.line",
|
||||
"name": "PC Assemble SC234",
|
||||
"price_unit": 150.0,
|
||||
"product_id": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_product_3", "[PCSC234] PC Assemble SC234"],
|
||||
"product_id": ["product:5af12v70-dv70-1v70-bv70-701a04e25v70.product_product_3", "[PCSC234] PC Assemble SC234"],
|
||||
"product_qty": 1.0,
|
||||
"product_uom": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_uom_unit", "Unit"],
|
||||
"product_uom": ["product:5af12v70-dv70-1v70-bv70-701a04e25v70.product_uom_unit", "Unit"],
|
||||
},
|
||||
{
|
||||
"__id": "purchase:5af1272e-dd26-11e0-b65e-701a04e25543.purchase_order_line-Alsads33e",
|
||||
"__id": "purchase:5af12v70-dv70-1v70-bv70-701a04e25v70.purchase_order_line-Alsads33e",
|
||||
"__module": "purchase",
|
||||
"__model": "purchase.order.line",
|
||||
"__import_module": "sale",
|
||||
"__import_model": "sale.order.line",
|
||||
"name": "PC on Demand",
|
||||
"price_unit": 100.0,
|
||||
"product_id": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_product_5", "[PC-DEM] PC on Demand"],
|
||||
"product_id": ["product:5af12v70-dv70-1v70-bv70-701a04e25v70.product_product_5", "[PC-DEM] PC on Demand"],
|
||||
"product_qty": 2.0,
|
||||
"product_uom": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_uom_unit", "Unit"],
|
||||
"product_uom": ["product:5af12v70-dv70-1v70-bv70-701a04e25v70.product_uom_unit", "Unit"],
|
||||
}],
|
||||
}
|
||||
new_sale_order_id = sale_order_pool.edi_import(cr, uid, edi_document, context=context)
|
||||
|
@ -97,6 +97,7 @@
|
|||
order_new = sale_order_pool.browse(cr, uid, new_sale_order_id)
|
||||
|
||||
# check bank info on partner
|
||||
assert order_new.partner_id.customer, "Imported partner should be a customer, as we just imported the document as a sale order"
|
||||
assert len(order_new.partner_id.bank_ids) == 1, "Expected 1 bank entry related to partner"
|
||||
bank_info = order_new.partner_id.bank_ids[0]
|
||||
assert bank_info.acc_number == "Ladies bank: 032465789-156113", 'Expected "Ladies bank: 032465789-156113", got %s' % bank_info.acc_number
|
||||
|
@ -116,3 +117,103 @@
|
|||
assert sale_line.product_uom_qty == 2 , "product qty is not same"
|
||||
else:
|
||||
raise AssertionError('unknown order line: %s' % sale_line)
|
||||
-
|
||||
"Then I import a sample EDI document of a purchase order (v6.1 - to test backwards compatibility)"
|
||||
-
|
||||
!python {model: edi.document}: |
|
||||
sale_order_pool = self.pool.get('sale.order')
|
||||
edi_document = {
|
||||
"__id": "purchase:5af1272e-dd26-11e0-b65e-701a04e25543.purchase_order_test",
|
||||
"__module": "purchase",
|
||||
"__model": "purchase.order",
|
||||
"__import_module": "sale",
|
||||
"__import_model": "sale.order",
|
||||
"__version": [6,1,0],
|
||||
"name": "PO00011-v61",
|
||||
"date_order": "2011-09-12",
|
||||
"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",
|
||||
"__module": "base",
|
||||
"__model": "res.partner.address",
|
||||
"phone": "(+32).81.81.37.00",
|
||||
"street": "Chaussee de Namur 40",
|
||||
"city": "Gerompont",
|
||||
"zip": "1367",
|
||||
"country_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.be", "Belgium"],
|
||||
"bank_ids": [
|
||||
["base:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_bank-adaWadsadasdDJzGbp","Ladies bank: 032465789-156113"]
|
||||
],
|
||||
},
|
||||
"partner_id": ["purchase:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_test20", "jones white"],
|
||||
"partner_address": {
|
||||
"__id": "base:5af1272e-dd26-11e0-b65e-701a04e25543.res_partner_address_7wdsjasdjh",
|
||||
"__module": "base",
|
||||
"__model": "res.partner.address",
|
||||
"phone": "(+32).81.81.37.00",
|
||||
"street": "Chaussee de Namur 40",
|
||||
"city": "Gerompont",
|
||||
"zip": "1367",
|
||||
"country_id": ["base:5af1272e-dd26-11e0-b65e-701a04e25543.be", "Belgium"],
|
||||
},
|
||||
"order_line": [{
|
||||
"__id": "purchase:5af1272e-dd26-11e0-b65e-701a04e25543.purchase_order_line-AlhsVDZGoKvJ",
|
||||
"__module": "purchase",
|
||||
"__model": "purchase.order.line",
|
||||
"__import_module": "sale",
|
||||
"__import_model": "sale.order.line",
|
||||
"name": "Basic PC",
|
||||
"date_planned": "2011-09-30",
|
||||
"price_unit": 150.0,
|
||||
"product_id": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_product_pc1", "[PC1] Basic PC"],
|
||||
"product_qty": 1.0,
|
||||
"product_uom": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_uom_unit", "PCE"],
|
||||
},
|
||||
{
|
||||
"__id": "purchase:5af1272e-dd26-11e0-b65e-701a04e25543.purchase_order_line-Alsads33e",
|
||||
"__module": "purchase",
|
||||
"__model": "purchase.order.line",
|
||||
"__import_module": "sale",
|
||||
"__import_model": "sale.order.line",
|
||||
"name": "Medium PC",
|
||||
"date_planned": "2011-09-15",
|
||||
"price_unit": 100.0,
|
||||
"product_id": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_product_pc3", "[PC3] Medium PC"],
|
||||
"product_qty": 2.0,
|
||||
"product_uom": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_uom_unit", "PCE"],
|
||||
}],
|
||||
}
|
||||
new_sale_order_id = sale_order_pool.edi_import(cr, uid, edi_document, context=context)
|
||||
assert new_sale_order_id, 'Sale order import failed'
|
||||
order_new = sale_order_pool.browse(cr, uid, new_sale_order_id)
|
||||
|
||||
# check bank info on partner
|
||||
assert order_new.partner_id.customer, "Imported partner should be a customer, as we just imported the document as a sale order"
|
||||
assert len(order_new.partner_id.bank_ids) == 1, "Expected 1 bank entry related to partner"
|
||||
bank_info = order_new.partner_id.bank_ids[0]
|
||||
assert bank_info.acc_number == "Ladies bank: 032465789-156113", 'Expected "Ladies bank: 032465789-156113", got %s' % bank_info.acc_number
|
||||
|
||||
assert order_new.pricelist_id.name == 'Public Pricelist' , "Public Price list was not automatically assigned"
|
||||
assert order_new.amount_total == 350, "Amount total is wrong"
|
||||
assert order_new.amount_untaxed == 350, "Untaxed amount is wrong"
|
||||
assert len(order_new.order_line) == 2, "Sale order lines mismatch"
|
||||
for sale_line in order_new.order_line:
|
||||
if sale_line.name == 'Basic PC':
|
||||
assert sale_line.delay == 18 , "incorrect delay: got %s, expected 18"%(sale_line.delay,)
|
||||
assert sale_line.product_uom.name == "PCE" , "uom is not same"
|
||||
assert sale_line.price_unit == 150 , "unit price is not same, got %s, expected 150"%(sale_line.price_unit,)
|
||||
assert sale_line.product_uom_qty == 1 , "product qty is not same"
|
||||
elif sale_line.name == 'Medium PC':
|
||||
assert sale_line.delay == 3 , "incorrect delay: got %s, expected 3"%(sale_line.delay,)
|
||||
assert sale_line.product_uom.name == "PCE" , "uom is not same"
|
||||
assert sale_line.price_unit == 100 , "unit price is not same, got %s, expected 100"%(sale_line.price_unit,)
|
||||
assert sale_line.product_uom_qty == 2 , "product qty is not same"
|
||||
else:
|
||||
raise AssertionError('unknown order line: %s' % sale_line)
|
Loading…
Reference in New Issue