From 9917e057e23d00e30402ae4e8008d37470485b4b Mon Sep 17 00:00:00 2001 From: Connor Christian Date: Fri, 4 Dec 2020 16:50:10 -0500 Subject: [PATCH] [FIX] account_invoice_margin: refactored to safely index into a list and rename variable H4936 --- account_invoice_margin/models/account_invoice.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/account_invoice_margin/models/account_invoice.py b/account_invoice_margin/models/account_invoice.py index dcebe9f2..ff7cd3b8 100644 --- a/account_invoice_margin/models/account_invoice.py +++ b/account_invoice_margin/models/account_invoice.py @@ -31,10 +31,10 @@ class AccountMoveLine(models.Model): @api.model_create_multi def create(self, vals): - line = super(AccountMoveLine, self).create(vals) - if 'purchase_price' not in vals[0]: - line.product_id_change_margin() - return line + lines = super(AccountMoveLine, self).create(vals) + if vals and 'purchase_price' not in vals[0]: + lines.product_id_change_margin() + return lines @api.depends('product_id', 'purchase_price', 'quantity', 'price_unit', 'price_subtotal') def _product_margin(self):