diff --git a/product_catalog_aeroo_report/product_catalog.py b/product_catalog_aeroo_report/product_catalog.py
index 7dc379e8..e0273fc0 100755
--- a/product_catalog_aeroo_report/product_catalog.py
+++ b/product_catalog_aeroo_report/product_catalog.py
@@ -9,28 +9,35 @@ class product_catalog_report(models.Model):
name = fields.Char(
'Name',
required=True
- )
+ )
products_order = fields.Char(
'Products Order Sintax',
help='for eg. name desc', required=False
- )
+ )
categories_order = fields.Char(
'Categories Order Sintax',
help='for eg. name desc',
- )
+ )
include_sub_categories = fields.Boolean(
'Include Subcategories?',
- )
+ )
only_with_stock = fields.Boolean(
'Only With Stock Products?',
- )
+ )
+ product_type = fields.Selection(
+ [('product.template', 'Product Template'),
+ ('product.product', 'Product')], 'Product Type',
+ required=True
+ )
report_xml_id = fields.Many2one(
'ir.actions.report.xml',
'Report XML',
- domain=[('report_type','=','aeroo'),('model','=','product.product')],
- context={'default_report_type': 'aeroo', 'default_model': 'product.product'},
+ domain=[('report_type', '=', 'aeroo'),
+ ('model', '=', 'product.product')],
+ context={'default_report_type': 'aeroo',
+ 'default_model': 'product.product'},
required=True
- )
+ )
category_ids = fields.Many2many(
'product.category',
'product_catalog_report_categories',
@@ -38,14 +45,14 @@ class product_catalog_report(models.Model):
'category_id',
'Product Categories',
required=True
- )
+ )
pricelist_ids = fields.Many2many(
'product.pricelist',
'product_catalog_report_pricelists',
'product_catalog_report_id',
'pricelist_id',
'Pricelist',
- )
+ )
@api.multi
def generate_report(self):
@@ -54,13 +61,13 @@ def generate_report(self):
self.ensure_one()
context = self._context.copy()
-
category_ids = self.category_ids.ids
if self.include_sub_categories:
category_ids = self.env['product.category'].search(
- [('id', 'child_of', category_ids)]).ids
+ [('id', 'child_of', category_ids)]).ids
context['category_ids'] = category_ids
+ context['product_type'] = self.product_type
context['pricelist_ids'] = self.pricelist_ids.ids
context['products_order'] = self.products_order
context['categories_order'] = self.categories_order
diff --git a/product_catalog_aeroo_report/product_catalog.xml b/product_catalog_aeroo_report/product_catalog.xml
index 8f3127f2..59106279 100755
--- a/product_catalog_aeroo_report/product_catalog.xml
+++ b/product_catalog_aeroo_report/product_catalog.xml
@@ -36,6 +36,7 @@
+
diff --git a/product_catalog_aeroo_report/report/.~lock.product_catalog_simple.odt# b/product_catalog_aeroo_report/report/.~lock.product_catalog_simple.odt#
new file mode 100644
index 00000000..029dea0a
--- /dev/null
+++ b/product_catalog_aeroo_report/report/.~lock.product_catalog_simple.odt#
@@ -0,0 +1 @@
+,nico,nico,07.04.2015 13:08,file:///home/nico/.config/libreoffice/4;
\ No newline at end of file
diff --git a/product_catalog_aeroo_report/report/product_catalog_parser.py b/product_catalog_aeroo_report/report/product_catalog_parser.py
index 69538a6b..9c392237 100755
--- a/product_catalog_aeroo_report/report/product_catalog_parser.py
+++ b/product_catalog_aeroo_report/report/product_catalog_parser.py
@@ -8,20 +8,24 @@
class Parser(report_sxw.rml_parse):
-
def __init__(self, cr, uid, name, context):
super(Parser, self).__init__(cr, uid, name, context)
lang = context.get('lang', 'es_ES')
+ self.product_type = context.get('product_type', 'product.product')
pricelist_ids = context.get('pricelist_ids', [])
pricelists = self.pool['product.pricelist'].browse(
- cr, uid, pricelist_ids, context=context)
+ cr, uid, pricelist_ids, context=context)
categories_order = context.get('categories_order', '')
# Get categories ordered
- categories = self.pool['product.category']
+ category_type = context.get('category_type', False)
+ if category_type == 'public_category':
+ categories = self.pool['product.public.category']
+ else:
+ categories = self.pool['product.category']
category_ids = context.get('category_ids', [])
category_ids = categories.search(
cr, uid, [('id', 'in', category_ids)],
@@ -30,14 +34,13 @@ def __init__(self, cr, uid, name, context):
cr, uid, category_ids, context=context)
products = self.get_products(category_ids, context=context)
-
company_id = self.pool['res.users'].browse(
cr, uid, [uid])[0].company_id
-
self.localcontext.update({
'lang': lang,
'categories': categories,
'products': products,
+ 'product_type': self.product_type,
'company_logo': company_id.logo,
'pricelists': pricelists,
'today': time.localtime(),
@@ -48,11 +51,13 @@ def __init__(self, cr, uid, name, context):
})
def field_value_get(self, product, field, context=None):
- # TODO hacer funcioal esto en el reporte ods. El problema es que deberiamos usar export_data en vez de read para poder elegir que ver del padre, por ejemplo "categ_id/name"
+ # TODO hacer funcioal esto en el reporte ods. El problema es que
+ # deberiamos usar export_data en vez de read para poder elegir que ver
+ # del padre, por ejemplo "categ_id/name"
if not context:
context = {}
- product_obj = self.pool.get('product.product')
+ product_obj = self.pool.get(self.product_type)
field_value = product_obj.read(
self.cr, self.uid, [product.id], [field], context=context)
return field_value[0].get(field, '')
@@ -61,11 +66,10 @@ def get_price(self, product, pricelist, context=None):
if not context:
context = {}
context['pricelist'] = pricelist.id
-
- product_obj = self.pool.get('product.product')
- price = product_obj._product_price(
- self.cr, self.uid, [product.id], False, False, context=context)
- return price.get(product.id, 0.0)
+ product_obj = self.pool[self.product_type]
+ price = product_obj.browse(
+ self.cr, self.uid, [product.id], context=context).price
+ return price
def get_products(self, category_ids, context=None):
if not isinstance(category_ids, list):
@@ -75,13 +79,17 @@ def get_products(self, category_ids, context=None):
context = {}
order = context.get('products_order', '')
only_with_stock = context.get('only_with_stock', False)
-
- domain = [('categ_id', 'in', category_ids)]
+ category_type = context.get('category_type', False)
+ if category_type == 'public_category':
+ domain = [('public_categ_ids', 'in', category_ids)]
+ else:
+ domain = [('categ_id', 'in', category_ids)]
if only_with_stock:
- domain.append(('qty_available','>',0))
+ domain.append(('qty_available', '>', 0))
- product_ids = self.pool.get('product.product').search(self.cr, self.uid, domain, order=order, context=context)
+ product_ids = self.pool[self.product_type].search(
+ self.cr, self.uid, domain, order=order, context=context)
- products = self.pool.get('product.product').browse(
+ products = self.pool[self.product_type].browse(
self.cr, self.uid, product_ids, context=context)
return products
diff --git a/product_catalog_aeroo_report/report/product_catalog_simple.odt b/product_catalog_aeroo_report/report/product_catalog_simple.odt
index 044f1d6d..92a1d02d 100755
Binary files a/product_catalog_aeroo_report/report/product_catalog_simple.odt and b/product_catalog_aeroo_report/report/product_catalog_simple.odt differ
diff --git a/report_category_public/__init__.py b/report_category_public/__init__.py
new file mode 100755
index 00000000..82657b06
--- /dev/null
+++ b/report_category_public/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+import product_catalog
\ No newline at end of file
diff --git a/report_category_public/__openerp__.py b/report_category_public/__openerp__.py
new file mode 100755
index 00000000..1a53cc30
--- /dev/null
+++ b/report_category_public/__openerp__.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+{
+ 'name': 'Report Category Public',
+ 'version': '1.0',
+ 'category': 'Aeroo Reporting',
+ 'sequence': 14,
+ 'summary': '',
+ 'description': """
+Report Category Public
+============================
+ """,
+ 'author': 'ADHOC',
+ 'website': 'www.adhoc.com.ar',
+ 'images': [
+ ],
+ 'depends': [
+ 'website_sale',
+ 'product_catalog_aeroo_report',
+ ],
+ 'data': ['product_catalog.xml'
+ ],
+ 'demo': [
+ ],
+ 'test': [
+ ],
+ 'installable': True,
+ 'auto_install': True,
+ 'application': False,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/report_category_public/product_catalog.py b/report_category_public/product_catalog.py
new file mode 100755
index 00000000..5d8f79c9
--- /dev/null
+++ b/report_category_public/product_catalog.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+from openerp import fields, models, api
+
+
+class product_catalog_report(models.Model):
+ _inherit = 'product.product_catalog_report'
+
+ category_type = fields.Selection(
+ [('public_category', 'Public Category'),
+ ('accounting_category', 'Accounting Category')], 'Category Type',
+ required=True
+ )
+ public_category_ids = fields.Many2many(
+ 'product.public.category',
+ 'product_catalog_report_categories_public',
+ 'product_catalog_report_id',
+ 'category_id',
+ 'Product Categories Public',
+ required=True
+ )
+
+ @api.multi
+ def generate_report(self):
+ """ Print the catalog
+ """
+ self.ensure_one()
+
+ context = self._context.copy()
+ if self.category_type == 'public_category':
+ category_ids = self.public_category_ids.ids
+ if self.include_sub_categories:
+ category_ids = self.env['product.public.category'].search(
+ [('id', 'child_of', category_ids)]).ids
+ else:
+ category_ids = self.category_ids.ids
+ if self.include_sub_categories:
+ category_ids = self.env['product.category'].search(
+ [('id', 'child_of', category_ids)]).ids
+
+ context['category_ids'] = category_ids
+ context['category_type'] = self.category_type
+ context['product_type'] = self.product_type
+ context['pricelist_ids'] = self.pricelist_ids.ids
+ context['products_order'] = self.products_order
+ context['categories_order'] = self.categories_order
+ context['only_with_stock'] = self.only_with_stock
+
+ return self.env['report'].with_context(context).get_action(
+ self, self.report_xml_id.report_name)
diff --git a/report_category_public/product_catalog.xml b/report_category_public/product_catalog.xml
new file mode 100755
index 00000000..c7d4f348
--- /dev/null
+++ b/report_category_public/product_catalog.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ Product Catalog Public Reports
+ product.product_catalog_report
+
+
+
+
+
+
+
+
+
+
+
+
+