diff --git a/l10n_br_fiscal_comment_product_lot/data/prod_lot_fiscal_comment.xml b/l10n_br_fiscal_comment_product_lot/data/prod_lot_fiscal_comment.xml index 7ca3a09..d2d8898 100644 --- a/l10n_br_fiscal_comment_product_lot/data/prod_lot_fiscal_comment.xml +++ b/l10n_br_fiscal_comment_product_lot/data/prod_lot_fiscal_comment.xml @@ -2,7 +2,7 @@ Lote - LOTE: ${ lot } + ${ lot if lot else '' } fiscal l10n_br_fiscal.document.line.mixin diff --git a/l10n_br_fiscal_comment_product_lot/models/document_fiscal_line_mixin.py b/l10n_br_fiscal_comment_product_lot/models/document_fiscal_line_mixin.py index 0b2fb76..3badde7 100644 --- a/l10n_br_fiscal_comment_product_lot/models/document_fiscal_line_mixin.py +++ b/l10n_br_fiscal_comment_product_lot/models/document_fiscal_line_mixin.py @@ -1,3 +1,5 @@ +from collections import defaultdict + from odoo import models @@ -6,7 +8,28 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel): def __document_comment_vals(self): res = super(FiscalDocumentLineMixinMethods, self).__document_comment_vals() - res["lot"] = ", ".join( - self.account_line_ids.mapped("prod_lot_ids").mapped("name") - ) + + lot_info = [] + lot_quantities = defaultdict(float) + lot_uom = {} + + for line in self.account_line_ids: + line_lot_quantities = line.lots_grouped_by_quantity() + for lot_name, qty in line_lot_quantities.items(): + lot_quantities[lot_name] += qty + + if lot_name not in lot_uom: + lot_uom[lot_name] = ( + line.product_uom_id.code if line.product_uom_id else "" + ) + + for lot_name, qty in lot_quantities.items(): + lot_product_uom = lot_uom.get(lot_name, "") + lot_info.append(f"{lot_name}, {qty}, {lot_product_uom}") + + if lot_info: + res["lot"] = "LOTE(S): " + "; ".join(lot_info) + else: + res["lot"] = "" + return res diff --git a/l10n_br_fiscal_comment_product_lot/static/description/index.html b/l10n_br_fiscal_comment_product_lot/static/description/index.html index df81983..d081df4 100644 --- a/l10n_br_fiscal_comment_product_lot/static/description/index.html +++ b/l10n_br_fiscal_comment_product_lot/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle {