From 060fe3329cd311f41bf6fa38343827fbd702e218 Mon Sep 17 00:00:00 2001 From: "ajay javiya (OpenERP)" Date: Tue, 10 Dec 2013 16:14:42 +0530 Subject: [PATCH] [ADD]:Recommendation of related product [IMP]: demo data bzr revid: aja@tinyerp.com-20131210104442-1yqigjiwszjowogp --- addons/website_sale/views/website_sale.xml | 2 +- addons/website_sale_quote/controllers/main.py | 19 +- addons/website_sale_quote/models/order.py | 22 ++ addons/website_sale_quote/sale_quote_demo.xml | 223 ++++++++---------- .../static/src/js/sale_quote.js | 12 +- .../views/website_sale_quote.xml | 59 +++-- 6 files changed, 163 insertions(+), 174 deletions(-) diff --git a/addons/website_sale/views/website_sale.xml b/addons/website_sale/views/website_sale.xml index 0335ac04e81..aafd9528a38 100644 --- a/addons/website_sale/views/website_sale.xml +++ b/addons/website_sale/views/website_sale.xml @@ -346,7 +346,7 @@
- +
diff --git a/addons/website_sale_quote/controllers/main.py b/addons/website_sale_quote/controllers/main.py index 591979703b4..8cf24433b54 100644 --- a/addons/website_sale_quote/controllers/main.py +++ b/addons/website_sale_quote/controllers/main.py @@ -55,15 +55,18 @@ class sale_quote(http.Controller): return request.redirect("/quote/%s" % token) @website.route(['/quote/update_line'], type='json', auth="public") - def update(self, line_id=None, qty=None, remove=False,unlink=False,**post): + def update(self, line_id=None, remove=False, unlink=False, order_id=None, **post): if unlink: request.registry.get('sale.order.line').unlink(request.cr, SUPERUSER_ID,[int(line_id)], context=request.context) + return else: - val = self._update_order_line(line_id=int(line_id), number=(remove and -1 or 1), qty=int(qty)) -# order = request.registry['website'].get_current_order(request.cr, request.uid, context=request.context) - return {} + val = self._update_order_line(line_id=int(line_id), number=(remove and -1 or 1)) + order = request.registry.get('sale.order').browse(request.cr, SUPERUSER_ID, order_id) + return [val , order.amount_total] - def _update_order_line(self,line_id, number,qty): - qty += number - request.registry.get('sale.order.line').write(request.cr, SUPERUSER_ID, [int(line_id)], {'product_uom_qty':(qty)}, context=request.context) - return qty + def _update_order_line(self,line_id, number): + order_line_obj = request.registry.get('sale.order.line') + order_line_val = order_line_obj.read(request.cr, SUPERUSER_ID, [int(line_id)], [], context=request.context)[0] + quantity = order_line_val['product_uom_qty'] + number + order_line_obj.write(request.cr, SUPERUSER_ID, [int(line_id)], {'product_uom_qty':(quantity)}, context=request.context) + return quantity diff --git a/addons/website_sale_quote/models/order.py b/addons/website_sale_quote/models/order.py index 1ad5607765e..7b685f50e00 100644 --- a/addons/website_sale_quote/models/order.py +++ b/addons/website_sale_quote/models/order.py @@ -85,3 +85,25 @@ class sale_order(osv.osv): def onchange_template_id(self, cr, uid,ids, template_id, context=None): data = self._get_sale_order_line(cr, uid, template_id, context) return {'value':data} + + def recommended_products(self, cr, uid, ids,context=None): + order_line = self.browse(cr, uid, ids[0], context=context).order_line + product_pool = self.pool.get('product.product') + product_ids = [] + for line in order_line: + 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, (line.product_id.id, line.product_id.id)) + for p in cr.fetchall(): + product_ids.append(p[0]) + product_ids = product_pool.search(cr, uid, [("id", "in", product_ids)], limit=3) + return product_pool.browse(cr, uid, product_ids) diff --git a/addons/website_sale_quote/sale_quote_demo.xml b/addons/website_sale_quote/sale_quote_demo.xml index 7817f0670e1..1095779cac8 100644 --- a/addons/website_sale_quote/sale_quote_demo.xml +++ b/addons/website_sale_quote/sale_quote_demo.xml @@ -1,7 +1,37 @@ + + Functional Training + + + 50000.0 + 750000.0 + service + + + Learn directly from our team and network of OpenERP experts. Choose from the available training sessions for a better functional understanding of OpenERP + + + + QF11 + + + Technical Training + + + 50000.0 + 0.0 + service + + + Learn directly from our team and network of OpenERP experts. Choose from the available training sessions for a better technical understanding of OpenERP + + + + QF12 + @@ -37,7 +67,18 @@

Have strong value added services as you can rely on 3000 existing modules to deliver what the customer needs in a short period of time. Grow with your existing customer base by continuously proposing new modules.

-
+
+ model.name.form + model.name + form + +
+ + + +
+
+
@@ -251,49 +292,42 @@ Gold Partner - + 1 1 12950.00 -
-
-
-
-

Why you'll love an iPad.

-

- Right from the start, there’s a lot to love about - iPad. It’s simple yet powerful. Thin and light yet - full-featured. It can do just about everything and - be just about anything. -

- And because it’s so easy to use, it’s easy to love. -

+
+
+
+
+

Online Training + Certification

+

These courses feature the same high quality course content found in our traditional classroom trainings, supplemented with modular sessions and cloud-based labs. Many of our online learning courses also include dozens of recorded webinars and live sessions by our senior instructors. At the end of the training, you can pass the OpenERP Certification exam in one of the 5000+ Pearson VUE test centers worldwide.

-
- +
+

Your advantages

+
    +
  • Modular approach applied to the learning method
  • +
  • New interactive learning experience
  • +
  • Lower training budget for the same quality courses
  • +
  • Better comfort to facilitate your learning process
  • +
-
-
-
-
-
-
- -
-
-

The full iPad experience.

-

There is less of it, but no less to it.

-

- Everything you love about iPad — the beautiful - screen, fast and fluid performance, FaceTime and - iSight cameras, thousands of amazing apps, 10-hour - battery life* — is everything you’ll love about - iPad mini, too. And you can hold it in one hand. -

-
+
+

Structure of the Training

+
+
+ +
+
+

There are three components to the training

+
    +
  • Videos with detailed demos
  • +
  • Hands-on exercises and their solutions
  • +
  • Live Q&A sessions with a trainer
  • +
@@ -303,107 +337,38 @@ Functional Training - + 1 1 00.00 -
-
-
-
-

Bose Mini Bluetooth Speaker.

-

- The Bose® SoundLink® mini is Bose's smallest portable Bluetooth speaker. Its ultra-compact size fits in the - palm of your hand, yet gives you full, natural sound wirelessly from your iPhone, iPad, or iPod. Grab it and go - full-featured. It can do just about everything and - experience music just about anywhere. -

- -
-
-

Characteristics

-
-
-
    -
  • Sleek, compact design
  • -
  • Efficient, high-quality audio
  • -
  • Remote control for power, volume, track seek
  • -
  • Auxiliary input for portable devices
  • -
  • Universal iPod docking station fits most iPod/iPhone models
  • -
  • Charges iPod/iPhone
  • -
  • Volume control on main system
  • -
-
-
- -
-
- -
+
+
+
+
+

Technical Training

+

This course is dedicated to partners, integrators and developers who need to have a grasp of the OpenERP development process. This course is for new developers or for IT professionals eager to learn more about the OpenERP's technical aspects. + This 5-day training takes place in the Headquarters of OpenERP, in Grand-Rosière (Belgium).

-
-
-
-
-
-

Plays where you play

-

- The SoundLink® Mini speaker is small and light enough - to tuck into your bag. It weighs in at just 1.5 pounds. - Its low profile lets you place it almost anywhere and - provides a low center of gravity that makes it nearly - impossible to tip over. -

-

- The rechargeable lithium-ion battery delivers up to seven hours of playtime. - And at home, you can listen even longer—the charging cradle lets - you listen while it charges. -

-
-
- -
-
-

Bluetooth connectivity

-

- The speaker has a range of about 30 feet, so you can enjoy - the sound you want without wires. It pairs easily with your - smartphone, iPad® or other Bluetooth device. - And it remembers the most recent six devices you've used, - so reconnecting is even simpler. -

-
-
+
+

Objectives

-
-
-
-
-
- -
-
-

More features.

-

- Charging cradle recharges the battery and serves as a convenient - home base for your speaker, and it lets you play while it charges. -

-

- Wall charger can be plugged into the cradle or directly into the speaker -

-

- Auxiliary port lets you connect other audio sources, like an MP3 player -

-

- USB port allows for software update to ensure ongoing Bluetooth device compatibility -

-

- Soft covers are available separately in blue, green or orange. Pick a color to match your style. -

-
+
+

Having attended this course, participants should be able to

+
    +
  • Videos with detailed demos
  • +
  • Hands-on exercises and their solutions
  • +
  • Live Q&A sessions with a trainer
  • +
+

Structure of the Training

+

There are three components to the training:

+
    +
  • Demo in class with the trainer
  • +
  • Hands-on exercises and their corresponding solutions
  • +
  • Q&A sessions
  • +
diff --git a/addons/website_sale_quote/static/src/js/sale_quote.js b/addons/website_sale_quote/static/src/js/sale_quote.js index 881b1862959..7a6e5e135e1 100644 --- a/addons/website_sale_quote/static/src/js/sale_quote.js +++ b/addons/website_sale_quote/static/src/js/sale_quote.js @@ -3,19 +3,21 @@ $(document).ready(function () { ev.preventDefault(); var $link = $(ev.currentTarget); var href = $link.attr("href"); - var qty = $link.attr("href").match(/qty=([0-9]+)/); + var order_id = $link.attr("href").match(/order_id=([0-9]+)/); var line_id = href.match(/update_line\/([0-9]+)/); console.log(line_id); openerp.jsonRpc("/quote/update_line/", 'call', { 'line_id': line_id[1], - 'qty': qty[1], + 'order_id':parseInt(order_id[1]), 'remove': $link.is('[href*="remove"]'), 'unlink': $link.is('[href*="unlink"]'), }) .then(function (data) { - location.reload(); -// $link.parent('.input-group:first').find('.js_line_qty').val(data[0]); -// $('[data-oe-model="sale.order"][data-oe-field="amount_total"]').replaceWith(data[1]); + if(!data){ + location.reload(); + } + $link.parents('.input-group:first').find('.js_quantity').val(data[0]); + $('[data-id="total_amount"]>span').html(data[1]); }); return false; }); diff --git a/addons/website_sale_quote/views/website_sale_quote.xml b/addons/website_sale_quote/views/website_sale_quote.xml index 25b79394393..b217bb4a548 100644 --- a/addons/website_sale_quote/views/website_sale_quote.xml +++ b/addons/website_sale_quote/views/website_sale_quote.xml @@ -117,13 +117,13 @@
- + - + - + @@ -133,45 +133,20 @@ - + - -   -
Subtotal
- -
- -
- -   - - -   -
Tax
- -
- - - - - -
- -   -  

Total

- +

- +

-   @@ -259,6 +234,7 @@
+
+