def get_counters(self, cr, uid, ids, context=None): r = {} for fp in self.browse(cr, uid, ids): event_result = do_event('get_counters', {'name': fp.name}, session_id=fp.session_id, printer_id=fp.name) r[fp.id] = event_result.pop() if event_result else False return r
def _update_(self, cr, uid, force=True, context=None): cr.execute('SELECT COUNT(*) FROM %s' % self._table) count = cr.fetchone()[0] if not force and count > 0: return if count > 0: cr.execute('DELETE FROM %s' % self._table) t_fp_obj = self.pool.get('fpoc.fiscal_printer') R = do_event('list_printers', control=True) w_wfp_ids = [] i = 0 for resp in R: if not resp: continue for p in resp['printers']: if t_fp_obj.search(cr, uid, [("name", "=", p['name'])]): pass else: values = { 'name': p['name'], 'protocol': p['protocol'], 'model': p['model'], 'serialNumber': p['serialNumber'], 'session_id': p['sid'], 'user_id': p['uid'], } pid = self.create(cr, uid, values)
def _get_field(self, cr, uid, ids, field_name, args, context): r = {} for fp in self.browse(cr, uid, ids): r[fp.id] = {fn: False for fn in field_name} event_result = do_event('read_attributes', {'name': fp.name}, session_id=fp.session_id, printer_id=fp.name) event_result = event_result.pop() if event_result else {} if event_result and 'attributes' in event_result: attrs = event_result['attributes'] r[fp.id]['header'] = '\n'.join([ attrs[k] for k in _header_lines if k in attrs and attrs[k] ]) r[fp.id]['footer'] = '\n'.join([ attrs[k] for k in _footer_lines if k in attrs and attrs[k] ]) for fn in field_name: if fn in attrs: if fn in ['tasaIVA', 'maxMonto']: r[fp.id][fn] = float(attrs[fn]) / 100. elif fn in ['fechaFiscalizacion']: line = attrs[fn] r[fp.id][fn] = "20{2}-{1}-{0}".format(*[ line[i:i + 2] for i in range(0, len(line), 2) ]) else: r[fp.id][fn] = attrs[fn] return r
def _update_(self, cr, uid, force=True, context=None): cr.execute('SELECT COUNT(*) FROM %s' % self._table) count = cr.fetchone()[0] if not force and count > 0: return if count > 0: cr.execute('DELETE FROM %s' % self._table) t_fp_obj = self.pool.get('fpoc.fiscal_printer') R = do_event('list_printers', control=True) w_wfp_ids = [] i = 0 for resp in R: if not resp: continue for p in resp['printers']: if t_fp_obj.search(cr, uid, [("name", "=", p['name'])]): pass else: values = { 'name': p['name'], 'protocol': p['protocol'], 'model': p.get('model', 'undefined'), 'serialNumber': p.get('serialNumber', 'undefined'), 'session_id': p['sid'], 'user_id': p['uid'], } pid = self.create(cr, uid, values)
def cancel_fiscal_ticket(self, cr, uid, ids, context=None): fparms = {} r = {} for fp in self.browse(cr, uid, ids): fparms['name'] = fp.name event_result = do_event('cancel_fiscal_ticket', fparms, session_id=fp.session_id, printer_id=fp.name) r[fp.id] = event_result.pop() if event_result else False return r
def get_state(self, cr, uid, ids, context=None): r = {} for fp in self.browse(cr, uid, ids): try: event_result = do_event('get_status', {'name': fp.name}, session_id=fp.session_id, printer_id=fp.name) except DenialService, m: raise osv.except_osv(_('Connectivity Error'), m) r[fp.id] = event_result.pop() if event_result else False
def make_fiscal_ticket(self, cr, uid, ids, options={}, ticket={}, context=None): fparms = {} r = {} for fp in self.browse(cr, uid, ids): fparms['name'] = fp.name fparms['options'] = options fparms['ticket'] = ticket event_result = do_event('make_fiscal_ticket', fparms, session_id=fp.session_id, printer_id=fp.name) r[fp.id] = event_result.pop() if event_result else False return r
def make_fiscal_refund_ticket(self, cr, uid, ids, options={}, ticket={}, context=None): fparms = {} r = {} for fp in self.browse(cr, uid, ids): fparms['name'] = fp.name fparms['options'] = options fparms['ticket'] = ticket #import pdb;pdb.set_trace() #event_result = do_event('make_fiscal_ticket', fparms, event_result = do_event('make_ticket_notacredito', fparms, session_id=fp.session_id, printer_id=fp.name) r[fp.id] = event_result.pop() if event_result else False return r
def _put_field(self, cr, uid, ids, field_name, field_value, arg, context): fp = self.browse(cr, uid, ids) data = { 'name': fp.name, 'attributes': {} } if (field_name == 'header'): lines = field_value.split('\n')[:len(_header_lines)] if field_value else [] lines = lines + (len(_header_lines) - len(lines)) * [''] data['attributes'].update(dict(zip(_header_lines, lines))) if (field_name == 'footer'): lines = field_value.split('\n')[:len(_footer_lines)] if field_value else [] lines = lines + (len(_footer_lines) - len(lines)) * [''] data['attributes'].update(dict(zip(_footer_lines, lines))) event_result = do_event('write_attributes', data, session_id=fp.session_id, printer_id=fp.name) return True
def _put_field(self, cr, uid, ids, field_name, field_value, arg, context): fp = self.browse(cr, uid, ids) data = { 'name': fp.name, 'attributes': {} } if (field_name == 'header'): lines = field_value.split('\n')[:len(_header_lines)] lines = lines + (len(_header_lines) - len(lines)) * [''] data['attributes'].update(dict(zip(_header_lines, lines))) if (field_name == 'footer'): lines = field_value.split('\n')[:len(_footer_lines)] lines = lines + (len(_footer_lines) - len(lines)) * [''] data['attributes'].update(dict(zip(_footer_lines, lines))) event_result = do_event('write_attributes', data, session_id=fp.session_id, printer_id=fp.name) return True
def _get_field(self, cr, uid, ids, field_name, args, context): r = {} for fp in self.browse(cr, uid, ids): r[fp.id] = { fn: False for fn in field_name } event_result = do_event('read_attributes', {'name': fp.name}, session_id=fp.session_id, printer_id=fp.name) event_result = event_result.pop() if event_result else {} if event_result and 'attributes' in event_result: attrs = event_result['attributes'] r[fp.id]['header'] = '\n'.join([ attrs[k] for k in _header_lines if k in attrs and attrs[k] ]) r[fp.id]['footer'] = '\n'.join([ attrs[k] for k in _footer_lines if k in attrs and attrs[k] ]) for fn in field_name: if fn in attrs: if fn in ['tasaIVA', 'maxMonto']: r[fp.id][fn] = float(attrs[fn])/100. elif fn in ['fechaFiscalizacion']: line = attrs[fn] r[fp.id][fn] = "20{2}-{1}-{0}".format(*[line[i:i+2] for i in range(0, len(line), 2)]) else: r[fp.id][fn] = attrs[fn] return r
def update_printers(self, cr, uid, ids, context=None): r = do_event('info', {}) return True
def shift_change(self, cr, uid, ids, context=None): for fp in self.browse(cr, uid, ids): do_event('shift_change', {'name': fp.name}, session_id=fp.session_id, printer_id=fp.name) return True
def cancel_fiscal_ticket(self, cr, uid, ids, context=None): for fp in self.browse(cr, uid, ids): do_event('cancel_fiscal_ticket', {'name': fp.name}, session_id=fp.session_id, printer_id=fp.name) return True
def close_fiscal_journal(self, cr, uid, ids, context=None): for fp in self.browse(cr, uid, ids): do_event('close_fiscal_journal', {'name': fp.name}, session_id=fp.session_id, printer_id=fp.name) return True
def cut_paper(self, cr, uid, ids, context=None): for fp in self.browse(cr, uid, ids): do_event('cut_paper', {'name': fp.name}, session_id=fp.session_id, printer_id=fp.name) return True
def large_test(self, cr, uid, ids, context=None): for fp in self.browse(cr, uid, ids): do_event('large_test', {'name': fp.name}, session_id=fp.session_id, printer_id=fp.name) return True