From eb8d33985e1b2fe5533fac3a09e0051b2d2759d8 Mon Sep 17 00:00:00 2001 From: Florent THOMAS Date: Thu, 7 Mar 2019 23:11:42 +0100 Subject: [PATCH] FIX-sale-bad-uom-computation --- .../models/account_analytic_account.py | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/contract_sale_generation/models/account_analytic_account.py b/contract_sale_generation/models/account_analytic_account.py index 79405fd7..3f0487c5 100644 --- a/contract_sale_generation/models/account_analytic_account.py +++ b/contract_sale_generation/models/account_analytic_account.py @@ -22,19 +22,29 @@ class AccountAnalyticAccount(models.Model): sale_line = self.env['sale.order.line'].new({ 'order_id': order_id, 'product_id': line.product_id.id, - 'product_qty': line.quantity, - 'product_uom_qty': line.quantity, - 'product_uom': line.uom_id.id, }) # Get other sale line values from product onchange sale_line.product_id_change() - sale_line_vals = sale_line._convert_to_write(sale_line._cache) # Insert markers - name = self._insert_markers(line.name) + name = line.name + contract = line.analytic_account_id + if 'old_date' in self.env.context and 'next_date' in self.env.context: + lang_obj = self.env['res.lang'] + lang = lang_obj.search( + [('code', '=', contract.partner_id.lang)]) + date_format = lang.date_format or '%m/%d/%Y' + name = self._insert_markers( + line, self.env.context['old_date'], + self.env.context['next_date'], date_format) + + sale_line_vals = sale_line._convert_to_write(sale_line._cache) sale_line_vals.update({ 'name': name, 'discount': line.discount, 'price_unit': line.price_unit, + 'product_qty': line.quantity, + 'product_uom_qty': line.quantity, + 'product_uom': line.uom_id.id, }) return sale_line_vals