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

[FIX] hw_drivers: support for TM-U escpos printer models #126689

Conversation

lse-odoo
Copy link
Contributor

@lse-odoo lse-odoo commented Jun 28, 2023

Before this commit:
When printing a receipt with an epson printers models TM-U2X0 (like TM-U220), random characters will be printed instead of the receipt.
image

This happened as a picture of the receipt is sent to the IoT box, but the TM-U2X0 models does not support all "Bit Image commands". We currently use the GS v 0 one which is not supported by this printer models. See:
https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=94

In addition, of that, the command itself is obsolete.

After this commit:
The support for another command "ESC *" is added which is not obsolete and supported by TM-U2X0 models.

Notes:

Due to the drawbacks, making it the default way to print would be a bad idea. As such, we can configure the mode (with other parameters) using particular name for the printer (which can be done by adding it manually with cups).

The options are:

  • IMC = Image Mode Column
  • LDV = Low Density Vertical
  • LDH = Low Density Horizontal
  • SCALE<XX> = Image Scale in percentage (for instance SCALE50 is half the size of the receipt printer)
    In the case of the TM-U220 on which the fix was tested the name could be set as TM-U220_IMC_LDV_LDH which would give:
    image
    (the picture goes off of the receipt horizontally)

or TM-U220_IMC_LDH which would give:
image
( fully fit on the receipt but text is hard to read)

opw-3351084,3341907

@robodoo
Copy link
Contributor

robodoo commented Jun 28, 2023

Pull request status dashboard

@lse-odoo lse-odoo requested a review from qle-odoo June 28, 2023 12:44
@lse-odoo
Copy link
Contributor Author

@qle-odoo
Could you review it please ?

Also, I was willing to have a way for the user to control if they would prefer to use ESC or GV. I thought maybe a particular suffix at the end of the printer name (like "-force-raster") in case new model of printer that does not support GV are used. I tried to modify the name of the printer using IoT cups, but on odoo service restart, the printer name lose the modified name to get back it's previous name.
What do you think ?
Little reminder: GV is obsolete so will likely not be featured in new printers of the brand, see:
https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=94

@C3POdoo C3POdoo requested a review from a team June 28, 2023 12:59
@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Jun 28, 2023
def format_escpos_bit_image_column(self, im):
""" prints with the `ESC *`-command """

def extract_columns_from_picture(im):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a function into another one ?

def format_escpos(self, im):
# GS v 0 incompatible with TM-U2x0 models according to:
# https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=94
must_use_column = "TM-U2" in self.device_name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True if device_name is correctly setted.
Another way to know if a printer need to use column to print ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, please re-read my message above:

Also, I was willing to have a way for the user to control if they would prefer to use ESC or GV. I thought maybe a particular suffix at the end of the printer name (like "-force-raster") in case new model of printer that does not support GV are used. I tried to modify the name of the printer using IoT cups, but on odoo service restart, the printer name lose the modified name to get back it's previous name.
What do you think ?
Little reminder: GV is obsolete so will likely not be featured in new printers of the brand, see:
https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=94

Another way to know if a printer need to use column to print ?

In theory they can all used it, but as it is slower and the quality is bad, the questions is rather do we have a way to know if GS v 0 is not supported. On this i don't think there is a way to know except checking the table of compatibility.
This was the reason why I was willing to make it "an option" so that the client have a way to force the column printing if necessary (see previous paragraph)

@lse-odoo lse-odoo force-pushed the 15.0-iot-escpos-support-tm-u2x0-models-lse branch 2 times, most recently from 6eb9853 to 1f4bb06 Compare July 18, 2023 15:08
@lse-odoo lse-odoo force-pushed the 15.0-iot-escpos-support-tm-u2x0-models-lse branch 4 times, most recently from 8e6a662 to 15a9c79 Compare July 27, 2023 08:43
width_pixels, height_pixels = im.size
TOP = 0
for left in range(0, width_pixels, line_height):
box = (left, TOP, left + line_height, TOP + height_pixels)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace "TOP" by 0?


# Parse the printer name to get the needed parameters
# The separator need to not be filtered by `get_identifier`
separator = '_'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary extra variable "separator" only used once

@lse-odoo lse-odoo force-pushed the 15.0-iot-escpos-support-tm-u2x0-models-lse branch from 15a9c79 to d6ce160 Compare August 1, 2023 13:40
@lse-odoo
Copy link
Contributor Author

lse-odoo commented Aug 1, 2023

@Ysoroko thanks for the feedback, should be good to go now :)

Copy link
Contributor

@caburj caburj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm asking for minor changes. Make sure to test high vertical density with other printers, because as you said, you made some recent refactoring.

Don't forget to properly document the configuration based on the name of the printer.

addons/hw_drivers/iot_handlers/drivers/PrinterDriver.py Outdated Show resolved Hide resolved
options = self.device_name.split('_')
for option in options:
option = option.upper()
if option == 'IMC':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we think of more "complex"-looking name for these configuration strings? The current choices feel like they can be easily part of existing (default) printer names.

Copy link
Contributor

@caburj caburj Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proposal: <PrinterName>__IMC_LDV_LDH_SCALE70__

The idea is to isolate the options from the name of the printer.

<printername>__<options>__

@lse-odoo lse-odoo force-pushed the 15.0-iot-escpos-support-tm-u2x0-models-lse branch 3 times, most recently from c4d50d6 to c2be1f0 Compare August 8, 2023 11:38
Before this commit:
When printing a receipt with an epson printers models TM-U2X0 (like
TM-U220), random characters will be printed instead of the receipt.

This happened as a picture of the receipt is sent to the IoT box, but
the TM-U2X0 models does not support all "Bit Image commands". We
currently use the GS v 0 one which is not supported by this printer
models. See:
https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=94

In addition, of that, the command itself is obsolete.

After this commit:
The support for another command "ESC *" is added which is not obsolete
and supported by TM-U2X0 models.

Notes:
 - Compared to "GS v 0", the receipt printed with "ESC *" is worst:
  - It take longer to print (5 seconds vs 1 second)
  - There is consistently some thin "empty white lines"
 - Most of the code is inspired from `python-escpos`:
 https://github.com/python-escpos/python-escpos/blob/master/src/escpos/escpos.py

Due to the drawbacks, making it the default way to print would be a bad
idea. As such, we can configure the mode (with other parameters) using
particular name for the printer (which can be done by adding it manually
 with cups)

opw-3351084,3341907
@lse-odoo lse-odoo force-pushed the 15.0-iot-escpos-support-tm-u2x0-models-lse branch from c2be1f0 to d6b9aa7 Compare August 8, 2023 11:59
Copy link
Contributor

@caburj caburj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

robodoo r+

robodoo pushed a commit that referenced this pull request Aug 8, 2023
Before this commit:
When printing a receipt with an epson printers models TM-U2X0 (like
TM-U220), random characters will be printed instead of the receipt.

This happened as a picture of the receipt is sent to the IoT box, but
the TM-U2X0 models does not support all "Bit Image commands". We
currently use the GS v 0 one which is not supported by this printer
models. See:
https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=94

In addition, of that, the command itself is obsolete.

After this commit:
The support for another command "ESC *" is added which is not obsolete
and supported by TM-U2X0 models.

Notes:
 - Compared to "GS v 0", the receipt printed with "ESC *" is worst:
  - It take longer to print (5 seconds vs 1 second)
  - There is consistently some thin "empty white lines"
 - Most of the code is inspired from `python-escpos`:
 https://github.com/python-escpos/python-escpos/blob/master/src/escpos/escpos.py

Due to the drawbacks, making it the default way to print would be a bad
idea. As such, we can configure the mode (with other parameters) using
particular name for the printer (which can be done by adding it manually
 with cups)

opw-3351084,3341907

closes #126689

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
lse-odoo added a commit to odoo/documentation that referenced this pull request Aug 8, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Signed-off-by: Loan (LSE) <lse@odoo.com>
@robodoo robodoo temporarily deployed to merge August 8, 2023 16:15 Inactive
@robodoo robodoo closed this Aug 8, 2023
@qle-odoo
Copy link
Contributor

@lse-odoo can we merge please ??

StraubCreative pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>
Signed-off-by: StraubCreative <zst@odoo.com>
StraubCreative pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>
Signed-off-by: StraubCreative <zst@odoo.com>
StraubCreative pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>
Signed-off-by: StraubCreative <zst@odoo.com>
robodoo pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

closes #5367

Signed-off-by: StraubCreative <zst@odoo.com>
Signed-off-by: Zachary Straub (zst) <zst@odoo.com>
fw-bot pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

Signed-off-by: StraubCreative <zst@odoo.com>
X-original-commit: 974c59f
fw-bot pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

Signed-off-by: StraubCreative <zst@odoo.com>
X-original-commit: 974c59f
fw-bot pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

Signed-off-by: StraubCreative <zst@odoo.com>
X-original-commit: 974c59f
fw-bot pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

Signed-off-by: StraubCreative <zst@odoo.com>
X-original-commit: 974c59f
fw-bot pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

Signed-off-by: StraubCreative <zst@odoo.com>
X-original-commit: 974c59f
fw-bot pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

Signed-off-by: StraubCreative <zst@odoo.com>
X-original-commit: 974c59f
fw-bot pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

Signed-off-by: StraubCreative <zst@odoo.com>
X-original-commit: 974c59f
robodoo pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

closes #6065

X-original-commit: 974c59f
Signed-off-by: StraubCreative <zst@odoo.com>
Signed-off-by: Zachary Straub (zst) <zst@odoo.com>
robodoo pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

closes #6064

X-original-commit: 974c59f
Signed-off-by: StraubCreative <zst@odoo.com>
Signed-off-by: Zachary Straub (zst) <zst@odoo.com>
robodoo pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

closes #6062

X-original-commit: 974c59f
Signed-off-by: StraubCreative <zst@odoo.com>
Signed-off-by: Zachary Straub (zst) <zst@odoo.com>
robodoo pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

closes #6061

X-original-commit: 974c59f
Signed-off-by: StraubCreative <zst@odoo.com>
Signed-off-by: Zachary Straub (zst) <zst@odoo.com>
robodoo pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

closes #6060

X-original-commit: 974c59f
Signed-off-by: StraubCreative <zst@odoo.com>
Signed-off-by: Zachary Straub (zst) <zst@odoo.com>
robodoo pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

closes #6059

X-original-commit: 974c59f
Signed-off-by: StraubCreative <zst@odoo.com>
Signed-off-by: Zachary Straub (zst) <zst@odoo.com>
robodoo pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

closes #6063

X-original-commit: 974c59f
Signed-off-by: StraubCreative <zst@odoo.com>
Signed-off-by: Zachary Straub (zst) <zst@odoo.com>
robodoo pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

closes #6065

X-original-commit: 974c59f
Signed-off-by: StraubCreative <zst@odoo.com>
Signed-off-by: Zachary Straub (zst) <zst@odoo.com>
robodoo pushed a commit to odoo/documentation that referenced this pull request Oct 7, 2023
Documentation regarding the fix:
odoo/odoo#126689

opw-3351084,3341907

Authored by: lse-odoo <lse@odoo.com>
Co-authored by: tiku-odoo <tiku@odoo.com>
Co-authored by: Felicious <feku@odoo.com>
Co-authored by: jero-odoo <jero@odoo.com>

closes #6065

X-original-commit: 974c59f
Signed-off-by: StraubCreative <zst@odoo.com>
Signed-off-by: Zachary Straub (zst) <zst@odoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants