From c25803235a6db9d54755bfca5ea417c322a9fcba Mon Sep 17 00:00:00 2001 From: Arnaud Baes Date: Wed, 21 Aug 2019 15:50:39 +0000 Subject: [PATCH] [FIX] repair: invoice creation from repair order Tracebacks caused by invalid values in invoice_line_vals. Since accountpocalypse, 'number' became 'name', and the invoice creation process in repair was forcing the repair name as invoice name. To keep the visibility of the information that a repair order was the source of the invoice, a field was added in the form view. TaskID: 2057443 closes odoo/odoo#35930 Signed-off-by: Laurent Smet --- addons/account/views/account_move_views.xml | 2 ++ addons/repair/models/repair.py | 12 ++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index 77a48763001..3e704a282cb 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -821,6 +821,8 @@ attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund'))]}"> + 0.0 and balance or 0.0, 'credit': balance < 0.0 and -balance or 0.0, }) else: - amount_currency = -invoice_line_vals['price_subtotal'] + amount_currency = -(operation.product_uom_qty * operation.price_unit) balance = currency._convert(amount_currency, self.company_id.currency_id, self.company_id, fields.Date.today()) invoice_line_vals.update({ 'amount_currency': amount_currency, @@ -381,7 +379,6 @@ class Repair(models.Model): raise UserError(_('No account defined for product "%s".') % fee.product_id.name) invoice_line_vals = { - 'type': 'out_invoice', 'name': name, 'account_id': account.id, 'quantity': fee.product_uom_qty, @@ -390,17 +387,16 @@ class Repair(models.Model): 'price_unit': fee.price_unit, 'product_id': fee.product_id.id, 'repair_fee_ids': [(4, fee.id)], - 'invoice_line_ids': [], } if currency == company.currency_id: - balance = -invoice_line_vals['price_subtotal'] + balance = -(fee.product_uom_qty * fee.price_unit) invoice_line_vals.update({ 'debit': balance > 0.0 and balance or 0.0, 'credit': balance < 0.0 and -balance or 0.0, }) else: - amount_currency = -invoice_line_vals['price_subtotal'] + amount_currency = -(fee.product_uom_qty * fee.price_unit) balance = currency._convert(amount_currency, self.company_id.currency_id, self.company_id, fields.Date.today()) invoice_line_vals.update({