-
Notifications
You must be signed in to change notification settings - Fork 23.3k
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
[FIX] hw_drivers: support for TM-U escpos printer models #126689
Conversation
@qle-odoo 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. |
def format_escpos_bit_image_column(self, im): | ||
""" prints with the `ESC *`-command """ | ||
|
||
def extract_columns_from_picture(im): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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)
6eb9853
to
1f4bb06
Compare
8e6a662
to
15a9c79
Compare
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) |
There was a problem hiding this comment.
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 = '_' |
There was a problem hiding this comment.
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
15a9c79
to
d6ce160
Compare
@Ysoroko thanks for the feedback, should be good to go now :) |
the "name convention" might need documentation change. But where ? https://www.odoo.com/app/point-of-sale-hardware#:~:text=IoT%20Box%20Required%0AThermal%20printers%20using%20ESC/POS%20or%20Star%20protocol%20such%20as%20the%20EPSON%20TM%2DT20II. |
There was a problem hiding this 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.
options = self.device_name.split('_') | ||
for option in options: | ||
option = option.upper() | ||
if option == 'IMC': |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>__
c4d50d6
to
c2be1f0
Compare
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
c2be1f0
to
d6b9aa7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
robodoo r+
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>
Documentation regarding the fix: odoo/odoo#126689 opw-3351084,3341907 Signed-off-by: Loan (LSE) <lse@odoo.com>
@lse-odoo can we merge please ?? |
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>
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>
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>
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>
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
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
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
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
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
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
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
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>
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>
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>
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>
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>
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>
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>
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>
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>
Before this commit:
![image](https://private-user-images.githubusercontent.com/60775325/249479698-61154812-d0bb-4012-8702-e90ecbeeeb5d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkzMzc0MDgsIm5iZiI6MTcxOTMzNzEwOCwicGF0aCI6Ii82MDc3NTMyNS8yNDk0Nzk2OTgtNjExNTQ4MTItZDBiYi00MDEyLTg3MDItZTkwZWNiZWVlYjVkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI1VDE3MzgyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTAxMDU3MmViOGRjOGE3MDM5NWY0MTcxZDU4NzdmMWQ0OWY1Njg1ODg1Y2RlNDdlZDIxMTNhNTA2Nzc5OWU5ZGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ZsUEijn1OlR_ONd-EHt0G5KU-7KwCCwqWSR00UzvmCU)
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:
Most of the code is inspired from
python-escpos
. Using the library to print the receipt have the same drawback: https://github.com/python-escpos/python-escpos/blob/master/src/escpos/escpos.pyDue 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 ColumnLDV
= Low Density VerticalLDH
= Low Density HorizontalSCALE<XX>
= Image Scale in percentage (for instanceSCALE50
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:(the picture goes off of the receipt horizontally)
or
![image](https://private-user-images.githubusercontent.com/60775325/254312614-104e4450-9824-4354-b28f-5e6b278ce3a6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkzMzc0MDgsIm5iZiI6MTcxOTMzNzEwOCwicGF0aCI6Ii82MDc3NTMyNS8yNTQzMTI2MTQtMTA0ZTQ0NTAtOTgyNC00MzU0LWIyOGYtNWU2YjI3OGNlM2E2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI1VDE3MzgyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgwMWViOGFiOGE0YTYzMzhlMTNjYWQ2MjZhMGQxM2QwMjdmNGQ0ODNjN2QwODk3NDY0Yjg5NzhlMzA1MzI1YzImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.pZ04r-cISzob7sLdKdy5pW5ut9oy-n2GrdAr8tRG-_s)
TM-U220_IMC_LDH
which would give:( fully fit on the receipt but text is hard to read)
opw-3351084,3341907