12345678910111213141516171819202122232425262728 |
- # -*- coding: utf-8 -*-
- from openerp import tools, models, api
- from openerp.osv import osv, fields
- class product_order_line(osv.osv):
- _name = "product.order.line"
- _description = "product.order.line"
- _auto = False
- _columns = {
- 'product_id': fields.many2one('product.product','product'),
- 'product_qty': fields.float(string='Cantidad', readonly=True),
- 'partner_id' : fields.many2one('res.partner',string='Partner'),
- }
- _order = 'id asc'
- def init(self, cr):
- tools.sql.drop_view_if_exists(cr, 'product_order_line')
- cr.execute("""
- CREATE OR REPLACE VIEW product_order_line as (
- SELECT row_number() over (ORDER BY so.partner_id)as id,
- sol.product_id as product_id,
- sum(sol.product_uom_qty) as product_qty,
- so.partner_id as partner_id
- FROM sale_order_line sol
- inner join sale_order so on(so.id = sol.order_id)
- GROUP BY sol.product_id, so.partner_id)
- """)
|