Merge lp:~openerp-dev/openobject-addons/7.0-invoice-ondelivery-with-service-product-tpa into lp:openobject-addons/7.0

Proposed by Turkesh Patel (openERP)
Status: Merged
Merged at revision: 9721
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-invoice-ondelivery-with-service-product-tpa
Merge into: lp:openobject-addons/7.0
Diff against target: 57 lines (+24/-2)
2 files modified
sale_stock/stock.py (+13/-1)
sale_stock/test/picking_order_policy.yml (+11/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-invoice-ondelivery-with-service-product-tpa
Reviewer Review Type Date Requested Status
Joël Grand-Guillaume @ camptocamp (community) code review, tests Approve
OpenERP Core Team Pending
Review via email: mp+189068@code.launchpad.net

Description of the change

[FIX] sale_stock: bug#1167330
--> create a SO with one service and one stockable product. Invoice on delivery (second tab)
--> process the delivery. In the move you see only the product, it is ok.
--> create the invoice from the delivery.
--> right now, you see only the product. The service should be there.
[IMP] sale_stock: improved YML test case to cover this bug scenario.

To post a comment you must log in.
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Thanks for the fix Turkesh, LGTM !

Would be great to see this merged !

review: Approve (code review, tests)
Revision history for this message
Thibault Delavallée (OpenERP) (tde-openerp) wrote :

Merged into 7.0.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sale_stock/stock.py'
2--- sale_stock/stock.py 2013-04-11 14:56:36 +0000
3+++ sale_stock/stock.py 2013-10-29 13:35:36 +0000
4@@ -114,10 +114,22 @@
5
6 def _invoice_hook(self, cursor, user, picking, invoice_id):
7 sale_obj = self.pool.get('sale.order')
8+ order_line_obj = self.pool.get('sale.order.line')
9+ invoice_obj = self.pool.get('account.invoice')
10+ invoice_line_obj = self.pool.get('account.invoice.line')
11 if picking.sale_id:
12 sale_obj.write(cursor, user, [picking.sale_id.id], {
13 'invoice_ids': [(4, invoice_id)],
14- })
15+ })
16+ for sale_line in picking.sale_id.order_line:
17+ if sale_line.product_id.type == 'service' and not sale_line.invoiced:
18+ vals = order_line_obj._prepare_order_line_invoice_line(cursor, user, sale_line, False)
19+ vals['invoice_id'] = invoice_id
20+ invoice_line_id = invoice_line_obj.create(cursor, user, vals)
21+ order_line_obj.write(cursor, user, [sale_line.id], {
22+ 'invoice_lines': [(6, 0, [invoice_line_id])],
23+ })
24+ invoice_obj.button_compute(cursor, user, [invoice_id])
25 return super(stock_picking, self)._invoice_hook(cursor, user, picking, invoice_id)
26
27 # Redefinition of the new field in order to update the model stock.picking.out in the orm
28
29=== modified file 'sale_stock/test/picking_order_policy.yml'
30--- sale_stock/test/picking_order_policy.yml 2013-04-11 14:56:36 +0000
31+++ sale_stock/test/picking_order_policy.yml 2013-10-29 13:35:36 +0000
32@@ -1,6 +1,16 @@
33 -
34 In order to test process of the Sale Order,
35 -
36+ Add SO line with service type product in SO to check flow which contain service type product in SO(BUG#1167330).
37+-
38+ !record {model: sale.order.line, id: sale_order_1}:
39+ name: 'On Site Assistance'
40+ product_id: product.product_product_2
41+ product_uom_qty: 1.0
42+ product_uom: 1
43+ price_unit: 150.0
44+ order_id: sale.sale_order_6
45+-
46 First I check the total amount of the Quotation before Approved.
47 -
48 !assert {model: sale.order, id: sale.sale_order_6, string: The amount of the Quotation is not correctly computed}:
49@@ -62,7 +72,7 @@
50 assert picking.partner_id.id == sale_order.partner_shipping_id.id,"Shipping Address is not correspond with sale order."
51 assert picking.note == sale_order.note,"Note is not correspond with sale order."
52 assert picking.invoice_state == (sale_order.order_policy=='picking' and '2binvoiced') or 'none',"Invoice policy is not correspond with sale order."
53- assert len(picking.move_lines) == len(sale_order.order_line), "Total move of delivery order are not corresposning with total sale order lines."
54+ assert len(picking.move_lines) == len(sale_order.order_line) - 1, "Total move of delivery order are not corresposning with total sale order lines."
55 location_id = sale_order.shop_id.warehouse_id.lot_stock_id.id
56 output_id = sale_order.shop_id.warehouse_id.lot_output_id.id
57 for move in picking.move_lines: