Browse Source

[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.
pull/1/head
houssine 7 years ago
parent
commit
a2d8171a32
  1. 4
      easy_my_coop/controllers/main.py
  2. 6
      easy_my_coop/models/product.py

4
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

6
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
product_templates = self.env['product.template'].search([('is_share','=',True), ('display_on_website','=',True),('by_individual','=',True)])
return product_templates
Loading…
Cancel
Save