From a2d8171a32a467901ac18e38502f8500e2cd4bdf Mon Sep 17 00:00:00 2001 From: houssine Date: Thu, 4 May 2017 17:29:49 +0200 Subject: [PATCH] [FIX] fix sending product.template id when working with product.product in the whole process. This was raising some glitch when product.template and produc.product doesn't have the same id. issue encountered on a demo database. --- easy_my_coop/controllers/main.py | 4 ++++ easy_my_coop/models/product.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/easy_my_coop/controllers/main.py b/easy_my_coop/controllers/main.py index 9075758..452b6ed 100644 --- a/easy_my_coop/controllers/main.py +++ b/easy_my_coop/controllers/main.py @@ -151,6 +151,10 @@ class WebsiteSubscription(http.Controller): values["firstname"] = firstname values["birthdate"] = datetime.datetime.strptime(kwargs.get("birthdate"), "%d/%m/%Y").date() + if kwargs.get("share_product_id"): + product_id = kwargs.get("share_product_id") + product = request.env['product.template'].sudo().browse(int(product_id)).product_variant_ids[0] + values["share_product_id"] = product.id #check the subscription's amount company = request.website.company_id max_amount = company.subscription_maximum_amount diff --git a/easy_my_coop/models/product.py b/easy_my_coop/models/product.py index dca6dc3..055af68 100644 --- a/easy_my_coop/models/product.py +++ b/easy_my_coop/models/product.py @@ -16,7 +16,7 @@ class ProductTemplate(models.Model): @api.multi def get_web_share_products(self, is_company): if is_company == True: - ids = self.env['product.template'].search([('is_share','=',True), ('display_on_website','=',True),('by_company','=',True)]) + product_templates = self.env['product.template'].search([('is_share','=',True), ('display_on_website','=',True),('by_company','=',True)]) else: - ids = self.env['product.template'].search([('is_share','=',True), ('display_on_website','=',True),('by_individual','=',True)]) - return ids \ No newline at end of file + product_templates = self.env['product.template'].search([('is_share','=',True), ('display_on_website','=',True),('by_individual','=',True)]) + return product_templates