[IMP]purchase: Improve the code
merge_order.yml Improve test cases for the new order lines bzr revid: dbr@tinyerp.com-20111024111452-sxc1g91rmn9jzkd6
This commit is contained in:
parent
2f56916e6f
commit
fd8fb0a5a5
|
@ -10,19 +10,33 @@
|
|||
assert order3.state == 'cancel', "Merged order should be canceled"
|
||||
assert order7.state == 'cancel', "Merged order should be canceled"
|
||||
|
||||
def merge(lines, line):
|
||||
res = {'product_id': line.product_id.id,'product_qty': line.product_qty}
|
||||
def merged_data(lines):
|
||||
product_id =[]
|
||||
product_uom = []
|
||||
res = {}
|
||||
for line in lines:
|
||||
if res.get('product_id') == line.product_id.id:
|
||||
product_qty = res.get('product_qty') + line.product_qty
|
||||
res.update({'product_qty': product_qty})
|
||||
product_id.append(line.product_id.id)
|
||||
product_uom.append(line.product_uom.id)
|
||||
res.update({'product_ids': product_id,'product_uom':product_uom})
|
||||
return res
|
||||
|
||||
for order in self.browse(cr, uid, new_id.keys()):
|
||||
total_new_qty = [x.product_qty for x in order.order_line]
|
||||
total_new_qty = sum(total_new_qty)
|
||||
|
||||
assert total_new_qty == total_qty,"product quantities are not correspond"
|
||||
|
||||
|
||||
assert order.partner_id == order3.partner_id ,"partner is not correspond"
|
||||
assert order.partner_address_id == order3.partner_address_id ,"Partner address is not correspond"
|
||||
assert order.warehouse_id == order3.warehouse_id or order7.warehouse_id,"Warehouse is not correspond"
|
||||
assert order.state == 'draft',"New created order state should be in draft"
|
||||
assert order.pricelist_id == order3.pricelist_id,"Price list is not correspond"
|
||||
assert order.date_order == order3.date_order ,"Date of order is not correspond"
|
||||
assert order.location_id == order3.location_id ,"Location is not correspond"
|
||||
n_product_data = merged_data(order.order_line)
|
||||
o_product_data= merged_data(order3.order_line)
|
||||
o_pro_data = merged_data(order7.order_line)
|
||||
|
||||
assert n_product_data == o_product_data or o_pro_data,"product data are not correspond"
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue