From 139d26114c1578c641dddd32213607d605e58fa3 Mon Sep 17 00:00:00 2001 From: Denis Leemann Date: Tue, 14 Feb 2017 16:45:23 +0100 Subject: [PATCH] Add suggested products in SO --- HISTORY.rst | 2 ++ .../specific_sale/models/sale_order.py | 24 +++++++++++++++++++ odoo/migration.yml | 1 + 3 files changed, 27 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 661b83d0b1f..80165cf775d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -21,6 +21,8 @@ latest (unreleased) **Features and Improvements** +* Add product options on SO + **Bugfixes** **Build** diff --git a/odoo/local-src/specific_sale/models/sale_order.py b/odoo/local-src/specific_sale/models/sale_order.py index 2261b54d2dd..f63ec99d7e1 100644 --- a/odoo/local-src/specific_sale/models/sale_order.py +++ b/odoo/local-src/specific_sale/models/sale_order.py @@ -54,3 +54,27 @@ def onchange_opportunity_id(self): ), 'project_market_id': self.opportunity_id.project_market_id.id, }) + + @api.onchange('order_line') + def onchange_order_line(self): + order_line = self.order_line + option_lines = [] + for line in order_line: + if line.product_id: + for product in line.product_id.optional_product_ids: + if self.pricelist_id: + price = self.pricelist_id.with_context( + uom=product.uom_id.id).get_product_price( + product, 1, False) + else: + price = product.list_price + data = { + 'product_id': product.id, + 'name': product.name, + 'quantity': 1, + 'uom_id': product.uom_id.id, + 'price_unit': price, + 'discount': 0, + } + option_lines.append((0, 0, data)) + self.options = option_lines diff --git a/odoo/migration.yml b/odoo/migration.yml index f9fdd45c4ec..9fcd3599e90 100644 --- a/odoo/migration.yml +++ b/odoo/migration.yml @@ -80,3 +80,4 @@ migration: - l10n_jp - l10n_us - l10n_de_skr03 + - website_sale