Exemplo n.º 1
0
    def store_proto(self, cr, uid, ids, context=None):
        for schema in self.browse(cr, uid, ids):
            x = schema.registry_pb
            pbmsg = base64.b64decode(x)

            pbr = Registry()
            pbr.ParseFromString(pbmsg)

            registry_proto = pbmsg2proto(pbr, schema.settings_id.name)
            schema.write({"registry_proto": registry_proto})
Exemplo n.º 2
0
    def store_proto(self):
        for schema in self:
            x = schema.registry_pb
            pbmsg = base64.b64decode(x)

            pbr = Registry()
            pbr.ParseFromString(pbmsg)

            registry_proto = pbmsg2proto(pbr, schema.settings_id.name)
            schema.registry_proto = registry_proto
Exemplo n.º 3
0
    def store_pb(self, cr, uid, ids, context=None):
        for schema in self.browse(cr, uid, ids):

            pbmsg = google.protobuf.json_format.Parse(schema.registry_json,
                                                      Registry())

            x = base64.b64encode(pbmsg.SerializeToString())
            schema.write({"registry_pb": x})
Exemplo n.º 4
0
    def init_code(self, cr, uid, ids, context=None):
        import bitcoin
        for schema in self.browse(cr, uid, ids):
            x = schema.registry_pb
            pbmsg = base64.b64decode(x)

            pbr = Registry()
            pbr.ParseFromString(pbmsg)

            for m in pbr.models:
                cr.execute("select id from %s where code is Null" % m._table)
                for rec in cr.fetchall():
                    id_ = rec[0]
                    secret_key = bitcoin.random_key()
                    pub_key = bitcoin.privtopub(secret_key)
                    code = bitcoin.pubtoaddr(pub_key)
                    sql_update = "update %s set " % m._table
                    cr.execute(
                        sql_update + "code=%s,secret_key=%s where id=%s",
                        (code, secret_key, id_))
Exemplo n.º 5
0
    def add_code_column(self, cr, uid, ids, context=None):

        for schema in self.browse(cr, uid, ids):
            x = schema.registry_pb
            pbmsg = base64.b64decode(x)

            pbr = Registry()
            pbr.ParseFromString(pbmsg)

            for m in pbr.models:
                cols = odoo2proto.get_columns_from_db(cr, m._table)

                if 'code' not in cols:
                    cr.execute("ALTER TABLE %s ADD COLUMN code varchar" %
                               m._table)
                    #print cols
                #else:
                #    cr.execute("alter table %s drop column %s"%(m._table, 'code'))

                if 'secret_key' not in cols:
                    cr.execute("ALTER TABLE %s ADD COLUMN secret_key varchar" %
                               m._table)
Exemplo n.º 6
0
 def store_pb(self):
     for schema in self:
         pbmsg = google.protobuf.json_format.Parse(schema.registry_json,
                                                   Registry())
         x = base64.b64encode(pbmsg.SerializeToString())
         schema.registry_pb = x