product_stock_picking.py 1017 B

12345678910111213141516171819202122232425262728
  1. # -*- coding: utf-8 -*-
  2. from openerp import tools, models, api
  3. from openerp.osv import osv, fields
  4. class product_order_line(osv.osv):
  5. _name = "product.order.line"
  6. _description = "product.order.line"
  7. _auto = False
  8. _columns = {
  9. 'product_id': fields.many2one('product.product','product'),
  10. 'product_qty': fields.float(string='Cantidad', readonly=True),
  11. 'partner_id' : fields.many2one('res.partner',string='Partner'),
  12. }
  13. _order = 'id asc'
  14. def init(self, cr):
  15. tools.sql.drop_view_if_exists(cr, 'product_order_line')
  16. cr.execute("""
  17. CREATE OR REPLACE VIEW product_order_line as (
  18. SELECT row_number() over (ORDER BY so.partner_id)as id,
  19. sol.product_id as product_id,
  20. sum(sol.product_uom_qty) as product_qty,
  21. so.partner_id as partner_id
  22. FROM sale_order_line sol
  23. inner join sale_order so on(so.id = sol.order_id)
  24. GROUP BY sol.product_id, so.partner_id)
  25. """)