Skip to content

Commit

Permalink
[IMP] pos_product_label: improve print_product_labels
Browse files Browse the repository at this point in the history
  • Loading branch information
trisdoan committed May 19, 2024
1 parent ffa9ef0 commit 3cfdf11
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
4 changes: 4 additions & 0 deletions pos_product_label/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ Contributors

* Iván Todorovich <[email protected]>

* [Trobz](https://www.trobz.com):

* Tri Doan <[email protected]>

Maintainers
~~~~~~~~~~~

Expand Down
25 changes: 13 additions & 12 deletions pos_product_label/models/pos_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
class PosSession(models.Model):
_inherit = "pos.session"

def _prepare_product_label_layout_data(self, data):
vals = {

Check warning on line 12 in pos_product_label/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_product_label/models/pos_session.py#L12

Added line #L12 was not covered by tests
"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

Check warning on line 20 in pos_product_label/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_product_label/models/pos_session.py#L20

Added line #L20 was not covered by tests

def print_product_labels(self, data):
"""Print product labels from the POS.
Expand All @@ -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)

Check warning on line 34 in pos_product_label/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_product_label/models/pos_session.py#L33-L34

Added lines #L33 - L34 were not covered by tests
if data.get("pos_quantity") == "order":
wizard = wizard.with_context(
force_label_qty_by_product=data.get("order_quantity_by_product", {})
Expand Down
4 changes: 4 additions & 0 deletions pos_product_label/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* `Camptocamp <https://www.camptocamp.com>`_

* Iván Todorovich <[email protected]>

* [Trobz](https://www.trobz.com):

* Tri Doan <[email protected]>
5 changes: 4 additions & 1 deletion pos_product_label/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -418,6 +417,10 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Iván Todorovich &lt;<a class="reference external" href="mailto:ivan.todorovich&#64;camptocamp.com">ivan.todorovich&#64;camptocamp.com</a>&gt;</li>
</ul>
</li>
<li>[Trobz](<a class="reference external" href="https://www.trobz.com">https://www.trobz.com</a>):<ul>
<li>Tri Doan &lt;<a class="reference external" href="mailto:tridm&#64;trobz.com">tridm&#64;trobz.com</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down

0 comments on commit 3cfdf11

Please sign in to comment.