diff --git a/addons/purchase/__openerp__.py b/addons/purchase/__openerp__.py index 72d317b6b20..afa60c04a6f 100644 --- a/addons/purchase/__openerp__.py +++ b/addons/purchase/__openerp__.py @@ -63,11 +63,11 @@ Dashboard for purchase management that includes: 'test/process/rfq2order2done.yml', 'test/process/generate_invoice_from_reception.yml', #'test/process/run_scheduler.yml', #TOFIX: Sequence of new generated order - #'test/process/merge_order.yml', #TOFIX: Sequence of new merged order + 'test/process/merge_order.yml', #TOFIX: Sequence of new merged order #'test/process/cancel_order.yml', #TOFIX: shipping exception after cancel shipment and also invoice exception after cancel invoice 'test/ui/print_report.yml', 'test/ui/onchange_events.yml', - #'test/ui/duplicate_order.yml', #TOFIX: Sequence of duplicated order + 'test/ui/duplicate_order.yml', #TOFIX: Sequence of duplicated order 'test/ui/delete_order.yml', ], 'demo': [ diff --git a/addons/purchase/test/process/merge_order.yml b/addons/purchase/test/process/merge_order.yml index ffd497231fd..e4eb120469e 100644 --- a/addons/purchase/test/process/merge_order.yml +++ b/addons/purchase/test/process/merge_order.yml @@ -5,29 +5,23 @@ new_id = self.do_merge(cr, uid, [ref('order_purchase3'), ref('order_purchase7')]) order3 = self.browse(cr, uid, ref('order_purchase3')) order7 = self.browse(cr, uid, ref('order_purchase7')) + total_qty = sum([x.product_qty for x in order3.order_line] + [x.product_qty for x in order7.order_line]) + assert order3.state == 'cancel', "Merged order should be canceled" assert order7.state == 'cancel', "Merged order should be canceled" - def merge(lines, product_id): - res = {} + def merge(lines, line): + res = {'product_id': line.product_id.id,'product_qty': line.product_qty} for line in lines: - if product_id == line.product_id.id: - res[product_id] += line.qty + if res.get('product_id') == line.product_id.id: + product_qty = res.get('product_qty') + line.product_qty + res.update({'product_qty': product_qty}) return res for order in self.browse(cr, uid, new_id.keys()): - assert order.partner_id and order3.partner_id and order7.partner_id, "Supplier are not corresponded" - total_lines = 0 - for line in order.lines: - qty3 = merge(order3.lines, line.product_id.id) - qty7 = merge(order7.lines, line.product_id.id) - qty = 0 - if line.product_id.id in qty3: - qty += qty3[line.product_id.id] - elif line.product_id.id in qty7: - qty += qty7[line.product_id.id] - else: - raise AssertionError('product line does not corresponding') - assert line.qty == qty, 'merged quantity is not proper' + 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" + diff --git a/addons/purchase/test/ui/duplicate_order.yml b/addons/purchase/test/ui/duplicate_order.yml index a6794b52350..b81f41d46c5 100644 --- a/addons/purchase/test/ui/duplicate_order.yml +++ b/addons/purchase/test/ui/duplicate_order.yml @@ -4,5 +4,5 @@ I duplicate order. - !python {model: purchase.order}: | - self.copy(cr, uid, ref('order_purchase1')) - + context.update({'active_id':ref('order_purchase1')}) + self.copy(cr, uid, ref('order_purchase1'), context)