[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#45056 X-original-commit: bcb304bbad3d10ca5efc7411fff4c9efff8fa6b3 Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
@@ -202,13 +202,14 @@ 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)
|
||||
# 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)
|
||||
|
||||
def button_add_to_order(self):
|
||||
self.add_option_to_order()
|
||||
|
||||
Reference in New Issue
Block a user