Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] [ADD] pos_product_label #1109

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions pos_product_label/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
=================
POS Product Label
=================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5217f4106aa43ecfb2135d79ed024b49dc510929a619defd7e8f0609e23c74b1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github
:target: https://github.com/OCA/pos/tree/16.0/pos_product_label
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_product_label
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Adds a "Print Labels" button to print the product labels for the ordered products.
The button opens a wizard that allows to configure the label layout and quantities.
The behavior is similar to the core "Print Labels" button in Stock Pickings.

.. image:: https://raw.githubusercontent.com/OCA/pos/16.0/pos_product_label/static/description/preview.png

**Table of contents**

.. contents::
:local:

Usage
=====

#. Add products to the order
#. Click on the "Print Labels" button
#. Choose the label layout and confirm

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_product_label%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* `Camptocamp <https://www.camptocamp.com>`_

* Iván Todorovich <[email protected]>

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

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-ivantodorovich| image:: https://github.com/ivantodorovich.png?size=40px
:target: https://github.com/ivantodorovich
:alt: ivantodorovich

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-ivantodorovich|

This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/16.0/pos_product_label>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions pos_product_label/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizards
22 changes: 22 additions & 0 deletions pos_product_label/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2023 Camptocamp SA (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "POS Product Label",
"summary": "Print product labels from the POS",
"version": "16.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["ivantodorovich"],
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
"category": "Point of Sale",
"depends": ["point_of_sale"],
"data": ["views/res_config_settings.xml"],
"assets": {
"point_of_sale.assets": [
"pos_product_label/static/src/**/*.js",
"pos_product_label/static/src/**/*.xml",
"pos_product_label/static/src/**/*.scss",
],
},
}
3 changes: 3 additions & 0 deletions pos_product_label/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import pos_config
from . import pos_session
from . import res_config_settings
14 changes: 14 additions & 0 deletions pos_product_label/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 Camptocamp SA (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class PosConfig(models.Model):
_inherit = "pos.config"

iface_product_label = fields.Boolean(
string="Print Product Labels",
help="Display a button to print Product Labels for ordered products",
default=True,
)
38 changes: 38 additions & 0 deletions pos_product_label/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2023 Camptocamp SA (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import Command, models
from odoo.tools import plaintext2html


class PosSession(models.Model):
_inherit = "pos.session"

def print_product_labels(self, data):
"""Print product labels from the POS.

:param data: dict with the following keys:
- pos_quantity: either 'order' or 'custom'
- order_quantity_by_product: dict of {product_id: quantity}
- product_ids: list of product ids
- custom_quantity: int
- print_format: str
- extra_html: str
"""
wizard = self.env["product.label.layout"].create(

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

View check run for this annotation

Codecov / codecov/patch

pos_product_label/models/pos_session.py#L22

Added line #L22 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
),
}
)
if data.get("pos_quantity") == "order":
wizard = wizard.with_context(

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

View check run for this annotation

Codecov / codecov/patch

pos_product_label/models/pos_session.py#L35

Added line #L35 was not covered by tests
force_label_qty_by_product=data.get("order_quantity_by_product", {})
)
return wizard.process()

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

View check run for this annotation

Codecov / codecov/patch

pos_product_label/models/pos_session.py#L38

Added line #L38 was not covered by tests
13 changes: 13 additions & 0 deletions pos_product_label/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 Camptocamp SA (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

iface_product_label = fields.Boolean(
related="pos_config_id.iface_product_label",
readonly=False,
)
3 changes: 3 additions & 0 deletions pos_product_label/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Camptocamp <https://www.camptocamp.com>`_

* Iván Todorovich <[email protected]>
5 changes: 5 additions & 0 deletions pos_product_label/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Adds a "Print Labels" button to print the product labels for the ordered products.
The button opens a wizard that allows to configure the label layout and quantities.
The behavior is similar to the core "Print Labels" button in Stock Pickings.

.. image:: ../static/description/preview.png
3 changes: 3 additions & 0 deletions pos_product_label/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#. Add products to the order
#. Click on the "Print Labels" button
#. Choose the label layout and confirm
Loading
Loading