From 3cfdf1140489f362f259f1620d8f41834fb8f452 Mon Sep 17 00:00:00 2001 From: trisdoan Date: Wed, 24 Apr 2024 14:14:34 +0700 Subject: [PATCH] [IMP] pos_product_label: improve print_product_labels --- pos_product_label/README.rst | 4 +++ pos_product_label/models/pos_session.py | 25 ++++++++++--------- pos_product_label/readme/CONTRIBUTORS.rst | 4 +++ .../static/description/index.html | 5 +++- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/pos_product_label/README.rst b/pos_product_label/README.rst index 10e474f115..9ab990c1b9 100644 --- a/pos_product_label/README.rst +++ b/pos_product_label/README.rst @@ -71,6 +71,10 @@ Contributors * Iván Todorovich +* [Trobz](https://www.trobz.com): + + * Tri Doan + Maintainers ~~~~~~~~~~~ diff --git a/pos_product_label/models/pos_session.py b/pos_product_label/models/pos_session.py index e8f5b323cd..f8850a38c3 100644 --- a/pos_product_label/models/pos_session.py +++ b/pos_product_label/models/pos_session.py @@ -8,6 +8,17 @@ class PosSession(models.Model): _inherit = "pos.session" + def _prepare_product_label_layout_data(self, data): + vals = { + "product_ids": [Command.set(data["product_ids"])], + "custom_quantity": data["custom_quantity"], + "print_format": data["print_format"], + "extra_html": ( + plaintext2html(data["extra_html"]) if data.get("extra_html") else False + ), + } + return vals + def print_product_labels(self, data): """Print product labels from the POS. @@ -19,18 +30,8 @@ def print_product_labels(self, data): - print_format: str - extra_html: str """ - wizard = self.env["product.label.layout"].create( - { - "product_ids": [Command.set(data["product_ids"])], - "custom_quantity": data["custom_quantity"], - "print_format": data["print_format"], - "extra_html": ( - plaintext2html(data["extra_html"]) - if data.get("extra_html") - else False - ), - } - ) + vals = self._prepare_product_label_layout_data(data) + wizard = self.env["product.label.layout"].create(vals) if data.get("pos_quantity") == "order": wizard = wizard.with_context( force_label_qty_by_product=data.get("order_quantity_by_product", {}) diff --git a/pos_product_label/readme/CONTRIBUTORS.rst b/pos_product_label/readme/CONTRIBUTORS.rst index a1e0a83952..094cffc06c 100644 --- a/pos_product_label/readme/CONTRIBUTORS.rst +++ b/pos_product_label/readme/CONTRIBUTORS.rst @@ -1,3 +1,7 @@ * `Camptocamp `_ * Iván Todorovich + +* [Trobz](https://www.trobz.com): + + * Tri Doan diff --git a/pos_product_label/static/description/index.html b/pos_product_label/static/description/index.html index cc8b75d1e3..d53bb1317b 100644 --- a/pos_product_label/static/description/index.html +++ b/pos_product_label/static/description/index.html @@ -1,4 +1,3 @@ - @@ -418,6 +417,10 @@

Contributors

  • Iván Todorovich <ivan.todorovich@camptocamp.com>
  • +
  • [Trobz](https://www.trobz.com): +