[IMP] website_*_sale: add kwargs parameter to _website_product_id_change() method

PURPOSE

Before this commit we had to pass parameters through the context to get
them to the _website_product_id_change() method.
After this commit we can pass the parameters through the kwargs parameter.

LINKS

Task-2318655
Closes : odoo/odoo#71104
This commit is contained in:
Patrick Hoste
2021-09-02 14:14:31 +00:00
parent eb0ebc077a
commit 0eaecf062c
3 changed files with 7 additions and 7 deletions
@@ -17,12 +17,12 @@ class SaleOrder(models.Model):
domain.append(('event_ticket_id', '=', self.env.context.get("event_ticket_id")))
return self.env['sale.order.line'].sudo().search(domain)
def _website_product_id_change(self, order_id, product_id, qty=0):
def _website_product_id_change(self, order_id, product_id, qty=0, **kwargs):
order = self.env['sale.order'].sudo().browse(order_id)
if self._context.get('pricelist') != order.pricelist_id.id:
self = self.with_context(pricelist=order.pricelist_id.id)
values = super(SaleOrder, self)._website_product_id_change(order_id, product_id, qty=qty)
values = super(SaleOrder, self)._website_product_id_change(order_id, product_id, qty=qty, **kwargs)
event_ticket_id = None
if self.env.context.get("event_ticket_id"):
event_ticket_id = self.env.context.get("event_ticket_id")
+3 -3
View File
@@ -102,7 +102,7 @@ class SaleOrder(models.Model):
return self.env['sale.order.line'].sudo().search(domain)
def _website_product_id_change(self, order_id, product_id, qty=0):
def _website_product_id_change(self, order_id, product_id, qty=0, **kwargs):
order = self.sudo().browse(order_id)
product_context = dict(self.env.context)
product_context.setdefault('lang', order.partner_id.lang)
@@ -201,7 +201,7 @@ class SaleOrder(models.Model):
product_id = product.id
values = self._website_product_id_change(self.id, product_id, qty=1)
values = self._website_product_id_change(self.id, product_id, qty=1, **kwargs)
# add no_variant attributes that were not received
for ptav in combination.filtered(lambda ptav: ptav.attribute_id.create_variant == 'no_variant' and ptav not in received_no_variant_values):
@@ -260,7 +260,7 @@ class SaleOrder(models.Model):
else:
# update line
no_variant_attributes_price_extra = [ptav.price_extra for ptav in order_line.product_no_variant_attribute_value_ids]
values = self.with_context(no_variant_attributes_price_extra=tuple(no_variant_attributes_price_extra))._website_product_id_change(self.id, product_id, qty=quantity)
values = self.with_context(no_variant_attributes_price_extra=tuple(no_variant_attributes_price_extra))._website_product_id_change(self.id, product_id, qty=quantity, **kwargs)
order = self.sudo().browse(self.id)
if self.pricelist_id.discount_policy == 'with_discount' and not self.env.context.get('fixed_price'):
product_context.update({
@@ -35,8 +35,8 @@ class SaleOrder(models.Model):
values['warning'] = self.warning_stock
return values
def _website_product_id_change(self, order_id, product_id, qty=0):
res = super(SaleOrder, self)._website_product_id_change(order_id, product_id, qty=qty)
def _website_product_id_change(self, order_id, product_id, qty=0, **kwargs):
res = super(SaleOrder, self)._website_product_id_change(order_id, product_id, qty=qty, **kwargs)
product = self.env['product.product'].browse(product_id)
res['customer_lead'] = product.sale_delay
return res