From 0f43032b82c22a69332b6a01b9d277776a2d644b Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 18 Feb 2013 15:51:00 +0100 Subject: [PATCH 1/5] [FIX] search: when count=True, execute main query as a subquery to avoid side effects with offset and limit bzr revid: rco@openerp.com-20130218145100-4q24j8ko9j9elwpw --- openerp/osv/orm.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index ebde4c17a51..f43b0d27d3b 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -4870,12 +4870,16 @@ class BaseModel(object): limit_str = limit and ' limit %d' % limit or '' offset_str = offset and ' offset %d' % offset or '' where_str = where_clause and (" WHERE %s" % where_clause) or '' + query_str = 'SELECT "%s".id FROM ' % self._table + from_clause + where_str + order_by + limit_str + offset_str if count: - cr.execute('SELECT count("%s".id) FROM ' % self._table + from_clause + where_str + limit_str + offset_str, where_clause_params) - res = cr.fetchall() - return res[0][0] - cr.execute('SELECT "%s".id FROM ' % self._table + from_clause + where_str + order_by + limit_str + offset_str, where_clause_params) + # /!\ the main query must be executed as a subquery, otherwise + # offset and limit apply to the result of count()! + cr.execute('SELECT count(*) FROM (%s) AS res' % query_str, where_clause_params) + res = cr.fetchone() + return res[0] + + cr.execute(query_str, where_clause_params) res = cr.fetchall() # TDE note: with auto_join, we could have several lines about the same result From 7daccf507424617412cf4b8fc3b4e1ed2fc89171 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 20 Feb 2013 09:27:07 +0100 Subject: [PATCH 2/5] [IMP] product: re-enabled the multi variant feature bzr revid: qdp-launchpad@openerp.com-20130220082707-x6r4pwcscmymkrz2 --- addons/product/product_view.xml | 44 +++++++++++++++++++++++++------- addons/sale/res_config.py | 3 +++ addons/sale/res_config_view.xml | 4 +++ addons/stock/res_config.py | 3 --- addons/stock/res_config_view.xml | 4 --- 5 files changed, 42 insertions(+), 16 deletions(-) diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml index 3e360594b19..6c82b4a2027 100644 --- a/addons/product/product_view.xml +++ b/addons/product/product_view.xml @@ -38,7 +38,6 @@ - @@ -90,11 +89,6 @@ - - - - - @@ -615,6 +609,7 @@ + product.variant.form product.product @@ -623,7 +618,7 @@ - + @@ -631,22 +626,53 @@ - product.variant.tree product.product - + + + + + + Product Variants + ir.actions.act_window + + product.product + form + tree,form,kanban + + + +

+ Click to define a new variant of product. +

+
+
+ + + tree + + + + + + form + + + + + product.template.product.tree product.template diff --git a/addons/sale/res_config.py b/addons/sale/res_config.py index a693fd11024..9a9f093a7b4 100644 --- a/addons/sale/res_config.py +++ b/addons/sale/res_config.py @@ -55,6 +55,9 @@ Example: 10% for retailers, promotion of 5 EUR on this product, etc."""), 'group_discount_per_so_line': fields.boolean("Allow setting a discount on the sales order lines", implied_group='sale.group_discount_per_so_line', help="Allows you to apply some discount per sales order line."), + 'group_product_variant': fields.boolean("Support multiple variants per products ", + implied_group='product.group_product_variant', + help="""Allow to manage several variants per product. As an example, if you sell T-Shirts, for the same "Linux T-Shirt", you may have variants on sizes or colors; S, M, L, XL, XXL."""), 'module_warning': fields.boolean("Allow configuring alerts by customer or products", help="""Allow to configure notification on products and trigger them when a user wants to sale a given product or a given customer. Example: Product: this product is deprecated, do not purchase more than 5. diff --git a/addons/sale/res_config_view.xml b/addons/sale/res_config_view.xml index b150fb276b7..9d5b5d071fc 100644 --- a/addons/sale/res_config_view.xml +++ b/addons/sale/res_config_view.xml @@ -69,6 +69,10 @@