From 19c0a0699a90f87a7b0149335fe769a0fba8d401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Lodeiros?= Date: Wed, 14 Dec 2022 11:46:48 +0100 Subject: [PATCH] [FIX]pms_api_rest: patch invoice without lines in vals --- pms_api_rest/services/pms_invoice_service.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pms_api_rest/services/pms_invoice_service.py b/pms_api_rest/services/pms_invoice_service.py index 35167fa15..a2a4338cf 100644 --- a/pms_api_rest/services/pms_invoice_service.py +++ b/pms_api_rest/services/pms_invoice_service.py @@ -109,17 +109,19 @@ class PmsInvoiceService(Component): if previus_state == "posted": invoice.button_draft() if new_vals: + updated_invoice_lines_name = False # REVIEW: If invoice lines are updated (lines that already existed), # the _move_autocomplete_invoice_lines_write called accout.move write # method overwrite the move_lines dict and we lost the new name values, - # so, we need to save and rewrite it. + # so, we need to save and rewrite it. (core odoo methods) # 1- save send invoice line name values: - updated_invoice_lines_name = { - line[1]: line[2]["name"] - for line in new_vals["invoice_line_ids"] - if line[0] == 1 and "name" in line[2] - } + if new_vals.get("invoice_line_ids"): + updated_invoice_lines_name = { + line[1]: line[2]["name"] + for line in new_vals["invoice_line_ids"] + if line[0] == 1 and "name" in line[2] + } # 2- update invoice invoice.write(new_vals) # 3- rewrite invoice line name values: