From 8c99920ce8feaacfa18c5392fb0c765c8c1d7160 Mon Sep 17 00:00:00 2001 From: houssine Date: Tue, 2 Apr 2019 19:28:00 +0200 Subject: [PATCH] [FIX] set default value to the first share if no default one is defined --- easy_my_coop/controllers/main.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/easy_my_coop/controllers/main.py b/easy_my_coop/controllers/main.py index a3b1f6f..821de6b 100644 --- a/easy_my_coop/controllers/main.py +++ b/easy_my_coop/controllers/main.py @@ -139,6 +139,8 @@ class WebsiteSubscription(http.Controller): if product.default_share_product is True: values['share_product_id'] = product.id break + if not values.get('share_product_id', False) and products: + values['share_product_id'] = products[0].id if not values.get('country_id'): if company.default_country_id: values['country_id'] = company.default_country_id.id @@ -173,8 +175,15 @@ class WebsiteSubscription(http.Controller): 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, 'force_min_qty': product.force_min_qty}} + product_template = request.env['product.template'] + product = product_template.sudo().browse(int(share_product_id)) + 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',