From 8dd72576acef22b4df16fa4d1bfd77677f88d8d2 Mon Sep 17 00:00:00 2001 From: Andreas Osim Date: Fri, 14 Sep 2018 11:34:26 +0200 Subject: [PATCH] print serial_no on invoice if a product has serial_no_tracking --- .../models/account_invoice.py | 46 ++++++++++++++++++- .../dp_reports_account/reports/invoice.xml | 8 ++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/ext/custom-addons/dp_reports_account/models/account_invoice.py b/ext/custom-addons/dp_reports_account/models/account_invoice.py index 6afef74e..d354d342 100644 --- a/ext/custom-addons/dp_reports_account/models/account_invoice.py +++ b/ext/custom-addons/dp_reports_account/models/account_invoice.py @@ -1,7 +1,7 @@ # Copyright 2018-Today datenpol gmbh () # License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). -from odoo import api, models +from odoo import api, fields, models class AccountInvoice(models.Model): @@ -28,3 +28,47 @@ class AccountInvoice(models.Model): if sale_order: category['order_id'] = sale_order return res + +class AccountInvoiceLine(models.Model): + _inherit = "account.invoice.line" + + order_line_ids = fields.Many2many( + comodel_name='sale.order.line', + relation='sale_order_line_invoice_rel', + column1='invoice_line_id', + column2='order_line_id', + string='Order Lines', + readonly=True, + ) + + prod_lot_ids = fields.Many2many( + comodel_name='stock.production.lot', + compute='_compute_prod_lots', + string="Production Lots", + ) + + lot_formatted_note = fields.Html( + string='Formatted Note', + compute='_compute_line_lots', + ) + + @api.multi + def _compute_prod_lots(self): + for line in self: + if not line.order_line_ids: + return + line.prod_lot_ids = self.mapped( + 'order_line_ids.move_ids.move_line_ids.lot_id') + print('End') + + @api.multi + def _compute_line_lots(self): + for line in self: + if line.prod_lot_ids: + note = u'' + line.lot_formatted_note = note diff --git a/ext/custom-addons/dp_reports_account/reports/invoice.xml b/ext/custom-addons/dp_reports_account/reports/invoice.xml index 30ce88ad..6bf5d1b5 100644 --- a/ext/custom-addons/dp_reports_account/reports/invoice.xml +++ b/ext/custom-addons/dp_reports_account/reports/invoice.xml @@ -85,6 +85,8 @@ + @@ -182,6 +184,12 @@
+ + Serien Nr.: + + + +

Pos.