report_productlist.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>. and pv.price_grid= True
  19. #
  20. ##############################################################################
  21. from openerp import tools
  22. from openerp.osv import fields, osv
  23. from datetime import datetime
  24. class report_productlist(osv.osv):
  25. _name = "report.productlist"
  26. _description = "Lista de Precios"
  27. _auto = False
  28. _rec_name = 'product_id'
  29. _columns = {
  30. 'product_id': fields.many2one('product.template', 'Producto', readonly=True),
  31. 'list_price': fields.char('Lista de Precio', readonly=True),
  32. 'price_surcharge': fields.float('Precio', readonly=True),
  33. 'company_id': fields.many2one('res.company', 'Compañia', readonly=True),
  34. }
  35. _order = 'product_id asc'
  36. def init(self, cr):
  37. tools.drop_view_if_exists(cr, 'report_productlist')
  38. cr.execute("""
  39. create or replace view report_productlist as (
  40. SELECT row_number() over (ORDER BY pl.id) as id,
  41. pt.id AS product_id,
  42. pv.name as list_price,
  43. pl.price_surcharge as price_surcharge,
  44. pt.company_id
  45. from product_pricelist_item pl
  46. LEFT JOIN product_template pt ON pt.id = pl.product_tmpl_id
  47. LEFT JOIN product_product po ON po.product_tmpl_id = pt.id
  48. LEFT JOIN product_pricelist_version pv ON pv.id = pl.price_version_id
  49. where po.name_template <> ''
  50. GROUP BY pl.id,
  51. pt.id,
  52. pv.name,
  53. pl.price_surcharge,
  54. pt.company_id)
  55. """)
  56. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: