summaryrefslogtreecommitdiff
path: root/addons/website_sale/models
diff options
context:
space:
mode:
authorHiral Bhavsar <hbh@odoo.com>2019-10-11 13:21:54 +0000
committerHiral Bhavsar <hbh@odoo.com>2020-01-27 14:26:00 +0000
commit07d4bbb35bbb48112c07276ab8f35d53301d6cf7 (patch)
treee6c50d31326ad81b22f81314dc20d1b7ace938f5 /addons/website_sale/models
parentce02a0ba89a83952ff39041adb60713745957e6b (diff)
[FIX] sale_product_configurator, website_sale(_wishlist): fix multicompany issue
Currently, we are allowing to select the other company's product as an alternative product or accessory products on the product. For example, website: W1, W2 company: C1, C2 W1-> C1 W2-> C2 Product: P1 =========== company: C1 Product: P2 =========== company: C2 alternative product: P1 And this will give a traceback because we are going to use another company's products. And this is obviously a wrong behavior. That's why put a specific domain on the alternative, accessory and optional product fields to fix this multi-company issues. Now product wishlist will be also a company-specific. task-2070522 closes odoo/odoo#44011 X-original-commit: 800abfc7baa8461f6b7b5ece95fa7700d3cd872a Signed-off-by: Romain Derie <rdeodoo@users.noreply.github.com>
Diffstat (limited to 'addons/website_sale/models')
-rw-r--r--addons/website_sale/models/product.py5
-rw-r--r--addons/website_sale/models/sale_order.py3
2 files changed, 5 insertions, 3 deletions
diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py
index 944ff4b56e9..6103ad064c5 100644
--- a/addons/website_sale/models/product.py
+++ b/addons/website_sale/models/product.py
@@ -169,14 +169,15 @@ class ProductTemplate(models.Model):
_inherit = ["product.template", "website.seo.metadata", 'website.published.multi.mixin', 'rating.mixin']
_name = 'product.template'
_mail_post_access = 'read'
+ _check_company_auto = True
website_description = fields.Html('Description for the website', sanitize_attributes=False, translate=html_translate)
alternative_product_ids = fields.Many2many(
- 'product.template', 'product_alternative_rel', 'src_id', 'dest_id',
+ 'product.template', 'product_alternative_rel', 'src_id', 'dest_id', check_company=True,
string='Alternative Products', help='Suggest alternatives to your customer (upsell strategy). '
'Those products show up on the product page.')
accessory_product_ids = fields.Many2many(
- 'product.product', 'product_accessory_rel', 'src_id', 'dest_id', string='Accessory Products',
+ 'product.product', 'product_accessory_rel', 'src_id', 'dest_id', string='Accessory Products', check_company=True,
help='Accessories show up when the customer reviews the cart before payment (cross-sell strategy).')
website_size_x = fields.Integer('Size X', default=1)
website_size_y = fields.Integer('Size Y', default=1)
diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py
index 72e46666f35..73e52810c61 100644
--- a/addons/website_sale/models/sale_order.py
+++ b/addons/website_sale/models/sale_order.py
@@ -293,7 +293,8 @@ class SaleOrder(models.Model):
accessory_products |= line.product_id.accessory_product_ids.filtered(lambda product:
product.website_published and
product not in products and
- product._is_variant_possible(parent_combination=combination)
+ product._is_variant_possible(parent_combination=combination) and
+ (product.company_id == line.company_id or not product.company_id)
)
return random.sample(accessory_products, len(accessory_products))