[MOVE] website_sale: py files to models/
authorChristophe Matthieu <chm@openerp.com>
Mon, 14 Oct 2013 08:18:41 +0000 (10:18 +0200)
committerChristophe Matthieu <chm@openerp.com>
Mon, 14 Oct 2013 08:18:41 +0000 (10:18 +0200)
bzr revid: chm@openerp.com-20131014081841-k8iz2b67voezgue4

addons/website_sale/__init__.py
addons/website_sale/models/__init__.py [new file with mode: 0644]
addons/website_sale/models/product.py [new file with mode: 0644]
addons/website_sale/models/website_sale.py [new file with mode: 0644]
addons/website_sale/models/website_styles.py [new file with mode: 0644]
addons/website_sale/product.py [deleted file]
addons/website_sale/website_sale.py [deleted file]
addons/website_sale/website_styles.py [deleted file]

index c5e6825..9f86759 100644 (file)
@@ -1,4 +1,2 @@
 import controllers
-import website_styles
-import product
-import website_sale
+import models
diff --git a/addons/website_sale/models/__init__.py b/addons/website_sale/models/__init__.py
new file mode 100644 (file)
index 0000000..55583f5
--- /dev/null
@@ -0,0 +1,3 @@
+import website_styles
+import product
+import website_sale
\ No newline at end of file
diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py
new file mode 100644 (file)
index 0000000..04ebbea
--- /dev/null
@@ -0,0 +1,111 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import osv, fields
+
+
+class product_pricelist(osv.Model):
+    _inherit = "product.pricelist"
+    _columns = {
+        'code': fields.char('Promotionnal Code', size=64, translate=True),
+    }
+
+
+class product_template(osv.Model):
+    _inherit = "product.template"
+    _order = 'website_sequence desc, website_published, name'
+
+    def _website_url(self, cr, uid, ids, field_name, arg, context=None):
+        res = {}
+        base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
+        for prod in self.browse(cr, uid, ids, context=context):
+            res[prod.id] = "%s/shop/product/%s/" % (base_url, prod.product_variant_ids[0].id)
+        return res
+
+    _columns = {
+        'website_published': fields.boolean('Available in the website'),
+        'website_description': fields.html('Description for the website'),
+        'suggested_product_id': fields.many2one('product.template', 'Suggested For Product'),
+        'suggested_product_ids': fields.one2many('product.template', 'suggested_product_id', 'Suggested Products'),
+        'website_size_x': fields.integer('Size X'),
+        'website_size_y': fields.integer('Size Y'),
+        'website_style_ids' : fields.many2many('website.product.style','product_website_style_rel', 'product_id', 'style_id', 'Styles'),
+        'website_sequence': fields.integer('Sequence', help="Determine the display order in the Website E-commerce"),
+        'website_url': fields.function(_website_url, string="Website url"),
+    }
+    _defaults = {
+        'website_size_x': 1,
+        'website_size_y': 1,
+        'website_sequence': 1,
+        'website_published': False,
+    }
+
+    def set_sequence_top(self, cr, uid, ids, context=None):
+        cr.execute('SELECT MAX(website_sequence) FROM product_template')
+        max_sequence = cr.fetchone()[0] or 0
+        return self.write(cr, uid, ids, {'website_sequence': max_sequence + 1}, context=context)
+
+    def set_sequence_bottom(self, cr, uid, ids, context=None):
+        return self.write(cr, uid, ids, {'website_sequence': 0}, context=context)
+
+    def recommended_products(self, cr, uid, ids, context=None):
+        id = ids[0]
+        product_ids = []
+        query = """
+            SELECT      sol.product_id
+            FROM        sale_order_line as my
+            LEFT JOIN   sale_order_line as sol
+            ON          sol.order_id = my.order_id
+            WHERE       my.product_id in (%s)
+            AND         sol.product_id not in (%s)
+            GROUP BY    sol.product_id
+            ORDER BY    COUNT(sol.order_id) DESC
+            LIMIT 10
+        """
+        cr.execute(query, (id, id))
+        for p in cr.fetchall():
+            product_ids.append(p[0])
+
+        # search to apply access rules
+        product_ids = self.search(cr, uid, [("id", "in", product_ids)], limit=3)
+        return self.browse(cr, uid, product_ids)
+
+    def img(self, cr, uid, ids, field='image_small', context=None):
+        return "/website/image?model=%s&field=%s&id=%s" % (self._name, field, ids[0])
+
+
+class product_product(osv.Model):
+    _inherit = "product.product"
+
+    def _website_url(self, cr, uid, ids, field_name, arg, context=None):
+        res = {}
+        base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
+        for id in ids:
+            res[id] = "%s/shop/product/%s/" % (base_url, id)
+        return res
+
+    _columns = {
+        'website_url': fields.function(_website_url, string="Website url"),
+    }
+
+    def img(self, cr, uid, ids, field='image_small', context=None):
+        temp_id = self.browse(cr, uid, ids[0], context=context).product_tmpl_id.id
+        return "/website/image?model=product.template&field=%s&id=%s" % (field, temp_id)
diff --git a/addons/website_sale/models/website_sale.py b/addons/website_sale/models/website_sale.py
new file mode 100644 (file)
index 0000000..8d54048
--- /dev/null
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C)-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp import SUPERUSER_ID
+from openerp.osv import osv, fields
+
+class sale_order(osv.Model):
+    _inherit = "sale.order"
+
+    _columns = {
+        'website_session_id': fields.char('Session UUID4'),
+    }
+
+    def get_total_quantity(self, cr, uid, ids, context=None):
+        order = self.browse(cr, uid, ids[0], context=context)
+        return int(sum(l.product_uom_qty for l in (order.order_line or [])))
+
+
+class sale_order_line(osv.Model):
+    _inherit = "sale.order.line"
+
+    def _recalculate_product_values(self, cr, uid, ids, product_id=0, context=None):
+        if context is None:
+            context = {}
+        user_obj = self.pool.get('res.users')
+        product_id = product_id and int(product_id) or \
+            ids and self.browse(cr, uid, ids[0], context=context).product_id.id
+
+        return self.product_id_change(
+            cr, SUPERUSER_ID, ids,
+            pricelist=context.pop('pricelist'),
+            product=product_id,
+            partner_id=user_obj.browse(cr, SUPERUSER_ID, uid).partner_id.id,
+            context=context
+        )['value']
diff --git a/addons/website_sale/models/website_styles.py b/addons/website_sale/models/website_styles.py
new file mode 100644 (file)
index 0000000..0b5ee5a
--- /dev/null
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import osv, fields
+
+
+class website_product_style(osv.Model):
+    _name = "website.product.style"
+    _columns = {
+        'name' : fields.char('Style Name', required=True, translate=True),
+        'html_class': fields.char('HTML Classes', size=64),
+    }
diff --git a/addons/website_sale/product.py b/addons/website_sale/product.py
deleted file mode 100644 (file)
index 04ebbea..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as
-#    published by the Free Software Foundation, either version 3 of the
-#    License, or (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU Affero General Public License for more details.
-#
-#    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-
-from openerp.osv import osv, fields
-
-
-class product_pricelist(osv.Model):
-    _inherit = "product.pricelist"
-    _columns = {
-        'code': fields.char('Promotionnal Code', size=64, translate=True),
-    }
-
-
-class product_template(osv.Model):
-    _inherit = "product.template"
-    _order = 'website_sequence desc, website_published, name'
-
-    def _website_url(self, cr, uid, ids, field_name, arg, context=None):
-        res = {}
-        base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
-        for prod in self.browse(cr, uid, ids, context=context):
-            res[prod.id] = "%s/shop/product/%s/" % (base_url, prod.product_variant_ids[0].id)
-        return res
-
-    _columns = {
-        'website_published': fields.boolean('Available in the website'),
-        'website_description': fields.html('Description for the website'),
-        'suggested_product_id': fields.many2one('product.template', 'Suggested For Product'),
-        'suggested_product_ids': fields.one2many('product.template', 'suggested_product_id', 'Suggested Products'),
-        'website_size_x': fields.integer('Size X'),
-        'website_size_y': fields.integer('Size Y'),
-        'website_style_ids' : fields.many2many('website.product.style','product_website_style_rel', 'product_id', 'style_id', 'Styles'),
-        'website_sequence': fields.integer('Sequence', help="Determine the display order in the Website E-commerce"),
-        'website_url': fields.function(_website_url, string="Website url"),
-    }
-    _defaults = {
-        'website_size_x': 1,
-        'website_size_y': 1,
-        'website_sequence': 1,
-        'website_published': False,
-    }
-
-    def set_sequence_top(self, cr, uid, ids, context=None):
-        cr.execute('SELECT MAX(website_sequence) FROM product_template')
-        max_sequence = cr.fetchone()[0] or 0
-        return self.write(cr, uid, ids, {'website_sequence': max_sequence + 1}, context=context)
-
-    def set_sequence_bottom(self, cr, uid, ids, context=None):
-        return self.write(cr, uid, ids, {'website_sequence': 0}, context=context)
-
-    def recommended_products(self, cr, uid, ids, context=None):
-        id = ids[0]
-        product_ids = []
-        query = """
-            SELECT      sol.product_id
-            FROM        sale_order_line as my
-            LEFT JOIN   sale_order_line as sol
-            ON          sol.order_id = my.order_id
-            WHERE       my.product_id in (%s)
-            AND         sol.product_id not in (%s)
-            GROUP BY    sol.product_id
-            ORDER BY    COUNT(sol.order_id) DESC
-            LIMIT 10
-        """
-        cr.execute(query, (id, id))
-        for p in cr.fetchall():
-            product_ids.append(p[0])
-
-        # search to apply access rules
-        product_ids = self.search(cr, uid, [("id", "in", product_ids)], limit=3)
-        return self.browse(cr, uid, product_ids)
-
-    def img(self, cr, uid, ids, field='image_small', context=None):
-        return "/website/image?model=%s&field=%s&id=%s" % (self._name, field, ids[0])
-
-
-class product_product(osv.Model):
-    _inherit = "product.product"
-
-    def _website_url(self, cr, uid, ids, field_name, arg, context=None):
-        res = {}
-        base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
-        for id in ids:
-            res[id] = "%s/shop/product/%s/" % (base_url, id)
-        return res
-
-    _columns = {
-        'website_url': fields.function(_website_url, string="Website url"),
-    }
-
-    def img(self, cr, uid, ids, field='image_small', context=None):
-        temp_id = self.browse(cr, uid, ids[0], context=context).product_tmpl_id.id
-        return "/website/image?model=product.template&field=%s&id=%s" % (field, temp_id)
diff --git a/addons/website_sale/website_sale.py b/addons/website_sale/website_sale.py
deleted file mode 100644 (file)
index 8d54048..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Copyright (C)-2010 Tiny SPRL (<http://tiny.be>).
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as
-#    published by the Free Software Foundation, either version of the
-#    License, or (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU Affero General Public License for more details.
-#
-#    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-
-from openerp import SUPERUSER_ID
-from openerp.osv import osv, fields
-
-class sale_order(osv.Model):
-    _inherit = "sale.order"
-
-    _columns = {
-        'website_session_id': fields.char('Session UUID4'),
-    }
-
-    def get_total_quantity(self, cr, uid, ids, context=None):
-        order = self.browse(cr, uid, ids[0], context=context)
-        return int(sum(l.product_uom_qty for l in (order.order_line or [])))
-
-
-class sale_order_line(osv.Model):
-    _inherit = "sale.order.line"
-
-    def _recalculate_product_values(self, cr, uid, ids, product_id=0, context=None):
-        if context is None:
-            context = {}
-        user_obj = self.pool.get('res.users')
-        product_id = product_id and int(product_id) or \
-            ids and self.browse(cr, uid, ids[0], context=context).product_id.id
-
-        return self.product_id_change(
-            cr, SUPERUSER_ID, ids,
-            pricelist=context.pop('pricelist'),
-            product=product_id,
-            partner_id=user_obj.browse(cr, SUPERUSER_ID, uid).partner_id.id,
-            context=context
-        )['value']
diff --git a/addons/website_sale/website_styles.py b/addons/website_sale/website_styles.py
deleted file mode 100644 (file)
index 0b5ee5a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as
-#    published by the Free Software Foundation, either version 3 of the
-#    License, or (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU Affero General Public License for more details.
-#
-#    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-
-from openerp.osv import osv, fields
-
-
-class website_product_style(osv.Model):
-    _name = "website.product.style"
-    _columns = {
-        'name' : fields.char('Style Name', required=True, translate=True),
-        'html_class': fields.char('HTML Classes', size=64),
-    }