From 70b44f56762b2af5942ea40ffaab0c5a1c7b453b Mon Sep 17 00:00:00 2001 From: houssine Date: Thu, 6 Apr 2017 18:03:29 +0200 Subject: [PATCH] [IMP] add the possibility to force the minimum quantity to subscribe on the share_type --- easy_my_coop/controllers/main.py | 2 +- easy_my_coop/models/product.py | 1 + easy_my_coop/static/src/js/easy_my_coop.js | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/easy_my_coop/controllers/main.py b/easy_my_coop/controllers/main.py index f3e21e7..9075758 100644 --- a/easy_my_coop/controllers/main.py +++ b/easy_my_coop/controllers/main.py @@ -99,7 +99,7 @@ class WebsiteSubscription(http.Controller): @http.route(['/subscription/get_share_product'], type='json', auth="public", methods=['POST'], website=True) def get_share_product(self, share_product_id, **kw): product = request.env['product.template'].sudo().browse(int(share_product_id)) - return {product.id: {'list_price':product.list_price,'min_qty':product.minimum_quantity}} + return {product.id: {'list_price':product.list_price,'min_qty':product.minimum_quantity,'force_min_qty':product.force_min_qty}} @http.route(['/subscription/subscribe_share'], type='http', auth="public", website=True) def share_subscription(self, **kwargs): diff --git a/easy_my_coop/models/product.py b/easy_my_coop/models/product.py index dee4170..dca6dc3 100644 --- a/easy_my_coop/models/product.py +++ b/easy_my_coop/models/product.py @@ -9,6 +9,7 @@ class ProductTemplate(models.Model): display_on_website = fields.Boolean(string='Display on website') default_share_product = fields.Boolean(string='Default share product') minimum_quantity = fields.Integer(string='Minimum quantity', default=1) + force_min_qty = fields.Boolean(String="Force minimum quantity?") by_company = fields.Boolean(string="Can be subscribed by companies?") by_individual = fields.Boolean(string="Can be subscribed by individuals?") diff --git a/easy_my_coop/static/src/js/easy_my_coop.js b/easy_my_coop/static/src/js/easy_my_coop.js index 110ce14..e87c61e 100644 --- a/easy_my_coop/static/src/js/easy_my_coop.js +++ b/easy_my_coop/static/src/js/easy_my_coop.js @@ -14,6 +14,9 @@ $(document).ready(function () { .then(function (data) { $('#share_price').text(data[share_product_id].list_price); $('input.js_quantity').val(data[share_product_id].min_qty); + if(data[share_product_id].force_min_qty == true){ + $('input.js_quantity').data("min",data[share_product_id].min_qty); + } $('input.js_quantity').change(); var $share_price = $('#share_price').text() $('input[name="total_parts"]').val($('input.js_quantity').val()*$share_price);