[FIX] Purchase : stock moves assigned to purchase line
authorpso <>
Wed, 8 Jul 2009 14:02:12 +0000 (19:32 +0530)
committerJay (Open ERP) <jvo@tinyerp.com>
Wed, 8 Jul 2009 14:02:12 +0000 (19:32 +0530)
lp bug: https://launchpad.net/bugs/386513 fixed

bzr revid: jvo@tinyerp.com-20090708140212-81j8c86mlk594xpx

addons/purchase/purchase.py
addons/purchase/purchase_view.xml
addons/report_sale/report_sale.py

index 68bec40..e3b37cb 100644 (file)
@@ -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,
index 7411786..df971a8 100644 (file)
                         <page string="Notes">
                             <field colspan="4" name="notes" nolabel="1"/>
                         </page>
+                        <page string="History" groups="base.group_extended">
+                               <separator colspan="4" string="Stock Moves"/>
+                               <field colspan="4" name="move_ids" nolabel="1" widget="many2many"/>
+                        </page>                        
                     </notebook>
                 </form>
             </field>
index b26be94..c437522 100644 (file)
@@ -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
             )
         """)