From 5c476513068813e676ab9e2a63c55ee9a45b67e1 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 20 Apr 2016 11:00:35 +0200 Subject: [PATCH] [FIX] sale: allow to import quotations without lines description When importing a quotation, if the lines `name`, `price_unit`, `product_uom` or `tax_id` are not specified, but the product is, retrieve them from the product `on_change` This was the case in Odoo 8.0, it was done as well in the override `create` method of `sale.order.line` opw-675434 --- addons/sale/sale.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index c64676331f4..c9cdc6a5507 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -601,6 +601,13 @@ class SaleOrderLine(models.Model): @api.model def create(self, values): + onchange_fields = ['name', 'price_unit', 'product_uom', 'tax_id'] + if values.get('order_id') and values.get('product_id') and any(f not in values for f in onchange_fields): + line = self.new(values) + line.product_id_change() + for field in onchange_fields: + if field not in values: + values[field] = line._fields[field].convert_to_write(line[field]) line = super(SaleOrderLine, self).create(values) if line.state == 'sale': if (not line.order_id.project_id and