[IMP]purchase: Improve the code for merge the PO

bzr revid: dbr@tinyerp.com-20111024094013-l0w4ai5m6e0rke17
This commit is contained in:
DBR (OpenERP)
2011-10-24 15:10:13 +05:30
parent df15ee1d75
commit 2f56916e6f
3 changed files with 15 additions and 21 deletions
+2 -2
View File
@@ -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': [
+11 -17
View File
@@ -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"
+2 -2
View File
@@ -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)