From bd45e70f4f3e79d6da1aab6c2c2d6ed827aabc63 Mon Sep 17 00:00:00 2001
From: pso <>
Date: Wed, 8 Jul 2009 19:32:12 +0530
Subject: [PATCH] [FIX] Purchase : stock moves assigned to purchase line
lp bug: https://launchpad.net/bugs/386513 fixed
bzr revid: jvo@tinyerp.com-20090708140212-81j8c86mlk594xpx
---
addons/purchase/purchase.py | 4 ++--
addons/purchase/purchase_view.xml | 4 ++++
addons/report_sale/report_sale.py | 2 ++
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index 68bec40c4bc..e3b37cb4fe9 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -438,7 +438,7 @@ class purchase_order_line(osv.osv):
'taxes_id': fields.many2many('account.tax', 'purchase_order_taxe', 'ord_id', 'tax_id', 'Taxes'),
'product_uom': fields.many2one('product.uom', 'Product UOM', required=True),
'product_id': fields.many2one('product.product', 'Product', domain=[('purchase_ok','=',True)], change_default=True),
- 'move_id': fields.many2one('stock.move', 'Reservation', ondelete='set null'),
+ 'move_ids': fields.one2many('stock.move', 'purchase_line_id', 'Reservation', readonly=True, ondelete='set null'),
'move_dest_id': fields.many2one('stock.move', 'Reservation Destination', ondelete='set null'),
'price_unit': fields.float('Unit Price', required=True, digits=(16, int(config['price_accuracy']))),
'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal'),
@@ -455,7 +455,7 @@ class purchase_order_line(osv.osv):
def copy_data(self, cr, uid, id, default=None,context={}):
if not default:
default = {}
- default.update({'state':'draft', 'move_id':False})
+ default.update({'state':'draft', 'move_id':[]})
return super(purchase_order_line, self).copy_data(cr, uid, id, default, context)
def product_id_change(self, cr, uid, ids, pricelist, product, qty, uom,
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index 74117861d3d..df971a84b04 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -185,6 +185,10 @@
+
+
+
+
diff --git a/addons/report_sale/report_sale.py b/addons/report_sale/report_sale.py
index b26be94f816..c437522a3bb 100644
--- a/addons/report_sale/report_sale.py
+++ b/addons/report_sale/report_sale.py
@@ -60,6 +60,7 @@ class report_sale_order_product(osv.osv):
from sale_order s
right join sale_order_line l on (s.id=l.order_id)
left join product_uom u on (u.id=l.product_uom)
+ where l.product_uom_qty != 0
group by l.product_id, to_char(s.date_order, 'YYYY-MM-01'),s.state
)
""")
@@ -105,6 +106,7 @@ class report_sale_order_category(osv.osv):
left join product_product p on (p.id=l.product_id)
left join product_template t on (t.id=p.product_tmpl_id)
left join product_uom u on (u.id=l.product_uom)
+ where l.product_uom_qty != 0
group by t.categ_id, to_char(s.date_order, 'YYYY-MM-01'),s.state
)
""")