diff options
| author | Gert Pellin <gpe@odoo.com> | 2019-05-13 09:48:43 +0000 |
|---|---|---|
| committer | Gert Pellin <gpe@odoo.com> | 2019-05-13 13:38:20 +0000 |
| commit | 928e91c624d227eecb90160fba92ed755806387b (patch) | |
| tree | fcbbfb5ce9b421fc0205d13501859423dc30dbb8 /addons/hw_escpos | |
| parent | 2a14eea095e9758eaba4d1bee1e0783c7a9c3304 (diff) | |
[FIX] hw_escpos: cashdrawer doesn't open
With some escpos printers the cash drawer did still not open after
previous fixes. One of the problemetic printers is the Epson TM-m30.
This fix will check the status of the drawer and try to open it up to 5
times. The fix is successfully tested with the TM-m30.
closes odoo/odoo#33328
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Diffstat (limited to 'addons/hw_escpos')
| -rw-r--r-- | addons/hw_escpos/escpos/escpos.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/addons/hw_escpos/escpos/escpos.py b/addons/hw_escpos/escpos/escpos.py index d278ede1787..de7e9121463 100644 --- a/addons/hw_escpos/escpos/escpos.py +++ b/addons/hw_escpos/escpos/escpos.py @@ -885,14 +885,23 @@ class Escpos: self._raw(PAPER_FULL_CUT) - def cashdraw(self, pin): - """ Send pulse to kick the cash drawer """ - if pin == 2: - self._raw(CD_KICK_2) - elif pin == 5: - self._raw(CD_KICK_5) - else: - raise CashDrawerError() + def cashdraw(self, pin, tries=5): + """ Send pulse to kick the cash drawer + + With some printers the drawer will not open after one pulse, for this reason we will check + the drawer status up to 'tries' times and send a new pulse if the drawer is still closed. If the + drawer status is open, we will stop sending pulses. + """ + for i in range(tries): + if pin == 2: + self._raw(CD_KICK_2) + elif pin == 5: + self._raw(CD_KICK_5) + else: + raise CashDrawerError() + + if i != tries - 1 and not self.get_printer_status()['printer']['drawer_pin_high']: + break def hw(self, hw): |
