From 872b4de22c0087e0df719ad612f073b293545cef Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Thu, 3 Oct 2013 17:24:51 +0530 Subject: [PATCH 1/3] [FIX] issue when we add product which is service with another stockable in SO with invoice on delivery and when after delivery we create invoice service type produc is not there in invoice line bzr revid: tpa@tinyerp.com-20131003115451-bdjaw60s6bat98ra --- addons/sale_stock/stock.py | 14 +++++++++++++- addons/sale_stock/test/picking_order_policy.yml | 12 +++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/addons/sale_stock/stock.py b/addons/sale_stock/stock.py index b69a8a27ef6..bd08ce7d707 100644 --- a/addons/sale_stock/stock.py +++ b/addons/sale_stock/stock.py @@ -114,10 +114,22 @@ class stock_picking(osv.osv): def _invoice_hook(self, cursor, user, picking, invoice_id): sale_obj = self.pool.get('sale.order') + order_line_obj = self.pool.get('sale.order.line') + invoice_obj = self.pool.get('account.invoice') + invoice_line_obj = self.pool.get('account.invoice.line') if picking.sale_id: sale_obj.write(cursor, user, [picking.sale_id.id], { 'invoice_ids': [(4, invoice_id)], - }) + }) + for sale_line in picking.sale_id.order_line: + if sale_line.product_id.type == 'service' and not sale_line.invoiced: + vals = order_line_obj._prepare_order_line_invoice_line(cursor, user, sale_line, False) + vals['invoice_id'] = invoice_id + invoice_line_id = invoice_line_obj.create(cursor, user, vals) + order_line_obj.write(cursor, user, [sale_line.id], { + 'invoice_lines': [(6, 0, [invoice_line_id])], + }) + invoice_obj.button_compute(cursor, user, [invoice_id]) return super(stock_picking, self)._invoice_hook(cursor, user, picking, invoice_id) # Redefinition of the new field in order to update the model stock.picking.out in the orm diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml index 09a8b73ffee..18f66d11e29 100644 --- a/addons/sale_stock/test/picking_order_policy.yml +++ b/addons/sale_stock/test/picking_order_policy.yml @@ -1,5 +1,15 @@ - In order to test process of the Sale Order, +- + Add SO line with service type product in SO to check flow which contain service type product in SO(BUG#1167330). +- + !record {model: sale.order.line, id: sale_order_1}: + name: 'On Site Assistance' + product_id: product.product_product_2 + product_uom_qty: 1.0 + product_uom: 1 + price_unit: 150.0 + order_id: sale.sale_order_6 - First I check the total amount of the Quotation before Approved. - @@ -62,7 +72,7 @@ assert picking.partner_id.id == sale_order.partner_shipping_id.id,"Shipping Address is not correspond with sale order." assert picking.note == sale_order.note,"Note is not correspond with sale order." assert picking.invoice_state == (sale_order.order_policy=='picking' and '2binvoiced') or 'none',"Invoice policy is not correspond with sale order." - assert len(picking.move_lines) == len(sale_order.order_line), "Total move of delivery order are not corresposning with total sale order lines." + assert len(picking.move_lines) == len(sale_order.order_line) - 1, "Total move of delivery order are not corresposning with total sale order lines." location_id = sale_order.shop_id.warehouse_id.lot_stock_id.id output_id = sale_order.shop_id.warehouse_id.lot_output_id.id for move in picking.move_lines: From 1db5d4ccd66e1909d1ba79accf5fcd6d01d8a5e4 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 4 Oct 2013 18:37:19 +0530 Subject: [PATCH 2/3] [IMP] remove call of button_compute method. bzr revid: tpa@tinyerp.com-20131004130719-qnnhhv0j3j6gj5yz --- addons/sale_stock/stock.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/sale_stock/stock.py b/addons/sale_stock/stock.py index bd08ce7d707..2ec0a7c60fb 100644 --- a/addons/sale_stock/stock.py +++ b/addons/sale_stock/stock.py @@ -115,7 +115,6 @@ class stock_picking(osv.osv): def _invoice_hook(self, cursor, user, picking, invoice_id): sale_obj = self.pool.get('sale.order') order_line_obj = self.pool.get('sale.order.line') - invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') if picking.sale_id: sale_obj.write(cursor, user, [picking.sale_id.id], { @@ -129,7 +128,6 @@ class stock_picking(osv.osv): order_line_obj.write(cursor, user, [sale_line.id], { 'invoice_lines': [(6, 0, [invoice_line_id])], }) - invoice_obj.button_compute(cursor, user, [invoice_id]) return super(stock_picking, self)._invoice_hook(cursor, user, picking, invoice_id) # Redefinition of the new field in order to update the model stock.picking.out in the orm From f21a86f584f263875ee30d2dfe6969992ec74052 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 9 Oct 2013 11:39:49 +0530 Subject: [PATCH 3/3] [IMP] revert the code of revision no 9440. bzr revid: tpa@tinyerp.com-20131009060949-odzzqredsdyhlo2y --- addons/sale_stock/stock.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/sale_stock/stock.py b/addons/sale_stock/stock.py index 2ec0a7c60fb..bd08ce7d707 100644 --- a/addons/sale_stock/stock.py +++ b/addons/sale_stock/stock.py @@ -115,6 +115,7 @@ class stock_picking(osv.osv): def _invoice_hook(self, cursor, user, picking, invoice_id): sale_obj = self.pool.get('sale.order') order_line_obj = self.pool.get('sale.order.line') + invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') if picking.sale_id: sale_obj.write(cursor, user, [picking.sale_id.id], { @@ -128,6 +129,7 @@ class stock_picking(osv.osv): order_line_obj.write(cursor, user, [sale_line.id], { 'invoice_lines': [(6, 0, [invoice_line_id])], }) + invoice_obj.button_compute(cursor, user, [invoice_id]) return super(stock_picking, self)._invoice_hook(cursor, user, picking, invoice_id) # Redefinition of the new field in order to update the model stock.picking.out in the orm