Skip to content
Snippets Groups Projects
Commit 21400337 authored by Goffin Simon's avatar Goffin Simon
Browse files

[FIX] sale_management: No discount displayed in option products


[FIRST ISSUE]

Steps to reproduce the bug:

- Create a pricelist PL with 50% reduction on all products.
- Create a SO with PL
- Add an optional product P

Bug:

 The price is correct for P  but the discount displayed was 0%.

[SECOND ISSUE]

Steps to reproduce the bug:

- Add the option line to the order

Bug:

A new line was create for P in the SO with the correct price but the discount was not displayed

PS: The discount field on the model sale.order.option has been implemented to add a new discount
to the displayed price unit of the option. But it has not been implemented to show the discount computed with
the pricelist.

opw:2186470

closes odoo/odoo#44703

Signed-off-by: default avatarSimon Goffin (sig) <sig@openerp.com>
parent 0eb8e26e
No related branches found
No related tags found
No related merge requests found
......@@ -173,14 +173,15 @@ class SaleOrderOption(models.Model):
if not self.product_id:
return
product = self.product_id.with_context(lang=self.order_id.partner_id.lang)
self.price_unit = product.list_price
self.name = product.get_product_multiline_description_sale()
self.uom_id = self.uom_id or product.uom_id
pricelist = self.order_id.pricelist_id
if pricelist and product:
partner_id = self.order_id.partner_id.id
self.price_unit = pricelist.with_context(uom=self.uom_id.id).get_product_price(product, self.quantity, partner_id)
domain = {'uom_id': [('category_id', '=', self.product_id.uom_id.category_id.id)]}
# To compute the dicount a so line is created in cache
values = self._get_values_to_add_to_order()
new_sol = self.env['sale.order.line'].new(values)
new_sol._onchange_discount()
self.discount = new_sol.discount
self.price_unit = new_sol._get_display_price(product)
return {'domain': domain}
@api.multi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment