Exemple #1
0
 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
Exemple #2
0
 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)
Exemple #3
0
 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
Exemple #4
0
 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)
Exemple #5
0
 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
Exemple #6
0
 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
Exemple #7
0
 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
Exemple #8
0
 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
Exemple #9
0
 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
Exemple #10
0
 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
Exemple #11
0
    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
Exemple #12
0
 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
Exemple #13
0
 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 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
Exemple #15
0
 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
Exemple #16
0
 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
Exemple #17
0
 def update_printers(self, cr, uid, ids, context=None):
     r = do_event('info', {})
     return True
Exemple #18
0
 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
Exemple #19
0
 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
Exemple #20
0
 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
Exemple #21
0
 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
Exemple #22
0
 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
Exemple #23
0
 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
Exemple #24
0
 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
Exemple #25
0
 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
Exemple #26
0
 def update_printers(self, cr, uid, ids, context=None):
     r = do_event('info', {})
     return True
Exemple #27
0
 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
Exemple #28
0
 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