diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-05-16 18:19:49 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-05-16 18:19:49 +0200 |
| commit | 7b9aa21576798d7f8ffe2b2f73e403e276c4b39a (patch) | |
| tree | 68d438edff5535b124bac4d6f4e308341eaee122 /addons/hw_escpos | |
| parent | 3b3f85670f40231768a409e3aebb636ad6871b56 (diff) | |
| parent | cecb1ec77d56fefdab53f3ef0bdda9a9c51c14be (diff) | |
[MERGE] forward port branch saas-15 up to cecb1ec77d5
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 3573efb1d98..bc1c5e1842f 100644 --- a/addons/hw_escpos/escpos/escpos.py +++ b/addons/hw_escpos/escpos/escpos.py @@ -888,14 +888,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): |
