| 112 | | #testataScontrinoTable |
| 113 | | # if "testata_scontrino.id_magazzino" in str(testataScontrinoTable.c): |
| 114 | | # print "OOOOOOOOOOOOOOOOOOOOO" |
| 115 | | |
| 116 | | """ Rivediamo la struttura della testata vendita al dettaglio per gestire |
| 117 | | anche una definizione dei magazzini, dei punti cassa e possibilmente |
| 118 | | anche del cassiere che ha effettuato la vendita """ |
| 119 | | |
| 120 | | #if "testata_scontrino.id_magazzino" not in testatascontrinoTable.c: |
| 121 | | # print "OKOKOKOKOKO NN CE" |
| 122 | | try: |
| 123 | | comando = 'ALTER TABLE %s ADD COLUMN id_magazzino integer ;' % tabella4 |
| 124 | | session.connection().execute(text(comando)) |
| 125 | | session.commit() |
| 126 | | # session.flush() |
| 127 | | except: |
| 128 | | session.rollback() |
| 129 | | print "LACOLONNA ID_MAGAZZINO C'E" |
| 130 | | |
| 131 | | #if "id_magazzino" in testatascontrinoTable.c: |
| 132 | | try: |
| 133 | | stri="""ALTER TABLE %s |
| 134 | | ADD CONSTRAINT testata_scontrino_id_magazzino_id_fkey FOREIGN KEY (id_magazzino) |
| 135 | | REFERENCES %s (id) MATCH SIMPLE |
| 136 | | ON UPDATE CASCADE ON DELETE RESTRICT;""" %(tabella4,tabella5) |
| 137 | | session.execute(text(stri)) |
| 138 | | session.commit() |
| 139 | | except: |
| 140 | | session.rollback() |
| 141 | | print "ADD ID MAGAZZINO fallito" |
| 142 | | |
| 143 | | |
| 144 | | |
| 145 | | try: |
| 146 | | comando = 'ALTER TABLE %s ADD COLUMN id_ccardtype integer ;' % tabella4 |
| 147 | | session.connection().execute(text(comando)) |
| 148 | | session.commit() |
| 149 | | # session.flush() |
| 150 | | except: |
| 151 | | session.rollback() |
| 152 | | print "LACOLONNA ID_CCARDTYPE C'E" |
| 153 | | |
| 154 | | #if "id_magazzino" in testatascontrinoTable.c: |
| 155 | | try: |
| 156 | | stri="""ALTER TABLE %s |
| 157 | | ADD CONSTRAINT testata_scontrino_id_ccardtype_id_fkey FOREIGN KEY (id_ccardtype) |
| 158 | | REFERENCES %s (id) MATCH SIMPLE |
| 159 | | ON UPDATE CASCADE ON DELETE SET NULL;""" %(tabella4,tabella9) |
| 160 | | session.execute(text(stri)) |
| 161 | | session.commit() |
| 162 | | except: |
| 163 | | session.rollback() |
| 164 | | print "ADD ID CCardType fallito" |
| 165 | | |
| 166 | | try: |
| 167 | | comando = 'ALTER TABLE %s ADD COLUMN id_pos integer ;' % tabella4 |
| 168 | | session.connection().execute(text(comando)) |
| 169 | | session.commit() |
| 170 | | # session.flush() |
| 171 | | except: |
| 172 | | session.rollback() |
| 173 | | print "LACOLONNA ID_POS C'E" |
| 174 | | |
| 175 | | |
| 176 | | try: |
| 177 | | stri="""ALTER TABLE %s |
| 178 | | ADD CONSTRAINT testata_scontrino_id_pos_id_fkey FOREIGN KEY (id_pos) |
| 179 | | REFERENCES %s (id) MATCH SIMPLE |
| 180 | | ON UPDATE CASCADE ON DELETE RESTRICT;""" %(tabella4,tabella6) |
| 181 | | session.execute(text(stri)) |
| 182 | | session.commit() |
| 183 | | except: |
| 184 | | session.rollback() |
| 185 | | print "ADD FK ID POS fallito" |
| 186 | | |
| 187 | | |
| 188 | | """ AGGIUNGO LA FK ID_USER NELLA TABELLA TESTATA SCONTRINO""" |
| 189 | | try: |
| 190 | | comando = 'ALTER TABLE %s ADD COLUMN id_user integer ;' % tabella4 |
| 191 | | session.connection().execute(text(comando)) |
| 192 | | session.commit() |
| 193 | | # session.flush() |
| 194 | | except: |
| 195 | | session.rollback() |
| 196 | | print "LACOLONNA ID_USER C'E" |
| 197 | | |
| 198 | | #if "id_magazzino" in testatascontrinoTable.c: |
| 199 | | try: |
| 200 | | stri="""ALTER TABLE %s |
| 201 | | ADD CONSTRAINT testata_scontrino_id_user_id_fkey FOREIGN KEY (id_user) |
| 202 | | REFERENCES %s (id) MATCH SIMPLE |
| 203 | | ON UPDATE CASCADE ON DELETE RESTRICT;""" %(tabella4,tabella7) |
| 204 | | session.execute(text(stri)) |
| 205 | | session.commit() |
| 206 | | except: |
| 207 | | session.rollback() |
| 208 | | print "ADD FK ID USER fallito" |
| 209 | | |
| 210 | | try: |
| 211 | | stri="""ALTER TABLE %s |
| 212 | | ADD CONSTRAINT sconto_riga_scontrino_id_fkey FOREIGN KEY (id) |
| 213 | | REFERENCES %s (id) MATCH SIMPLE |
| 214 | | ON UPDATE CASCADE ON DELETE DELETE;"""%(tabella,tabella2) |
| 215 | | session.execute(text(stri)) |
| 216 | | session.commit() |
| 217 | | except: |
| 218 | | session.rollback() |
| 219 | | print "ADD FK SCONTO RIGA SCONTRINO fallito" |
| 220 | | |
| 221 | | |
| 222 | | """ AGGIUNGO LA FK ID_MAGAZZINO NELLA TABELLA CHIUSURA FISCALE""" |
| 223 | | |
| 224 | | try: |
| 225 | | comando = 'ALTER TABLE %s ADD COLUMN id_magazzino integer ;' % tabella8 |
| 226 | | session.connection().execute(text(comando)) |
| 227 | | session.commit() |
| 228 | | except: |
| 229 | | session.rollback() |
| 230 | | print "LA COLONNA ID_MAGAZZINO C'E" |
| 231 | | |
| 232 | | try: |
| 233 | | stri="""ALTER TABLE %s |
| 234 | | ADD CONSTRAINT chiusura_fiscale_id_magazzino_id_fkey FOREIGN KEY (id_magazzino) |
| 235 | | REFERENCES %s (id) MATCH SIMPLE |
| 236 | | ON UPDATE CASCADE ON DELETE RESTRICT;""" %(tabella8,tabella5) |
| 237 | | session.execute(text(stri)) |
| 238 | | session.commit() |
| 239 | | except: |
| 240 | | session.rollback() |
| 241 | | print "ADD FK ID MAGAZZINO fallito" |
| 242 | | |
| 243 | | """ AGGIUNGO LA FK ID_POS NELLA TABELLA CHIUSURA FISCALE""" |
| 244 | | |
| 245 | | try: |
| 246 | | comando = 'ALTER TABLE %s ADD COLUMN id_pos integer ;' % tabella8 |
| 247 | | session.connection().execute(text(comando)) |
| 248 | | session.commit() |
| 249 | | except: |
| 250 | | session.rollback() |
| 251 | | print "LA COLONNA ID_pos C'E" |
| 252 | | |
| 253 | | try: |
| 254 | | stri="""ALTER TABLE %s |
| 255 | | ADD CONSTRAINT chiusura_fiscale_id_pos_id_fkey FOREIGN KEY (id_pos) |
| 256 | | REFERENCES %s (id) MATCH SIMPLE |
| 257 | | ON UPDATE CASCADE ON DELETE RESTRICT;""" %(tabella8,tabella6) |
| 258 | | session.execute(text(stri)) |
| 259 | | session.commit() |
| 260 | | except: |
| 261 | | session.rollback() |
| 262 | | print "ADD FK ID POS fallito" |
| 263 | | |
| 264 | | try: |
| 265 | | stri = 'ALTER TABLE %s DROP CONSTRAINT chiusura_fiscale_data_chiusura_key'%tabella8 |
| 266 | | session.execute(stri) |
| 267 | | session.commit() |
| 268 | | except: |
| 269 | | session.rollback() |
| 270 | | print " LA UNIQUE e' già stata tolta" |
| 271 | | |
| 272 | | try: |
| 273 | | stri = 'ALTER TABLE %s ADD CONSTRAINT chiusura_fiscale_data_chiusura_key'%tabella8 |
| 274 | | session.execute(stri) |
| 275 | | session.commit() |
| 276 | | except: |
| 277 | | session.rollback() |
| 278 | | print " LA UNIQUE e' già stata tolta" |
| 279 | | |
| 280 | | |
| 281 | | if not hasattr(conf.VenditaDettaglio,"migrazione_sincro_effettuata") or conf.VenditaDettaglio.migrazione_sincro_effettuata =="no": |
| 282 | | #if "ciccio" == "pluto": |
| 283 | | msg = """ATTENZIONE, per qualche giorno l'avvio del pg2 |
| 284 | | potrebbe essere lento ( anche qualche minuto): |
| 285 | | Il rallentamento Ú solo di chi usa il modulo di |
| 286 | | vendita al dettaglio, ed Ú dovuto ad un aggiornamento/modifica |
| 287 | | del database per facilitare e rendere coerente |
| 288 | | la sincronizzazione di una sede centrale con i punti vendita |
| 289 | | Se il Promogest parte correttamente ed il modulo funziona vi |
| 290 | | invitiamo a contattarci al numero verde 800 034561 per disabilitare |
| 291 | | l'aggiornamento grazie. |
| 292 | | Ci scusiamo per l'inconveniente. |
| 293 | | """ |
| 294 | | dialog = gtk.MessageDialog(None, |
| 295 | | gtk.DIALOG_MODAL |
| 296 | | | gtk.DIALOG_DESTROY_WITH_PARENT, |
| 297 | | gtk.MESSAGE_INFO, gtk.BUTTONS_OK, |
| 298 | | msg) |
| 299 | | dialog.run() |
| 300 | | dialog.destroy() |
| 301 | | |
| 302 | | ####################### sezione deciata allo sconto riga scontrino .... ############## |
| 303 | | |
| 304 | | from promogest.modules.VenditaDettaglio.dao.ScontoScontrino import ScontoScontrino |
| 305 | | from promogest.modules.VenditaDettaglio.dao.ScontoRigaScontrino import ScontoRigaScontrino |
| 306 | | from promogest.modules.VenditaDettaglio.dao.ScontoTestataScontrino import ScontoTestataScontrino |
| 307 | | from promogest.dao.Sconto import Sconto |
| 308 | | |
| 309 | | dati_sconto = params["session"].query(scontoRigaScontrinoTable.c.id).all() |
| 310 | | cc = None |
| 311 | | # print dati_sconto |
| 312 | | if dati_sconto: |
| 313 | | for dato in dati_sconto: |
| 314 | | riga = Sconto().getRecord(id=dato[0]) |
| 315 | | test = ScontoScontrino().getRecord(id=dato[0]) |
| 316 | | if not test: |
| 317 | | cc = ScontoScontrino() |
| 318 | | cc.id = dato[0] |
| 319 | | cc.valore= riga.valore |
| 320 | | cc.tipo_sconto = riga.tipo_sconto |
| 321 | | session.add(cc) |
| 322 | | else: |
| 323 | | continue |
| 324 | | try: |
| 325 | | session.commit() |
| 326 | | except: |
| 327 | | session.rollback() |
| 328 | | print "GIA FATTO" |
| 329 | | |
| 330 | | try: |
| 331 | | stri="""ALTER TABLE %s |
| 332 | | ADD CONSTRAINT sconto_riga_scontrino_id_fkey FOREIGN KEY (id) |
| 333 | | REFERENCES %s (id) MATCH SIMPLE |
| 334 | | ON UPDATE CASCADE ON DELETE CASCADE;"""%(tabella,tabella2) |
| 335 | | session.execute(text(stri)) |
| 336 | | session.commit() |
| 337 | | except: |
| 338 | | print "ADD fallito" |
| 339 | | |
| 340 | | #################### sezione sconto testata scontrino ########################## |
| 341 | | |
| 342 | | try: |
| 343 | | stri = 'ALTER TABLE %s DROP CONSTRAINT sconto_testata_scontrino_id_fkey'%tabella3 |
| 344 | | session.connection().execute(stri) |
| 345 | | session.commit() |
| 346 | | except: |
| 347 | | session.rollback() |
| 348 | | print "drop fallito" |
| 349 | | |
| 350 | | dati_sconto2 = params["session"].query(scontoTestataScontrinoTable.c.id).all() |
| 351 | | cc2 = None |
| 352 | | if dati_sconto2: |
| 353 | | for dato in dati_sconto2: |
| 354 | | riga = Sconto().getRecord(id=dato[0]) |
| 355 | | test = ScontoScontrino().getRecord(id=dato[0]) |
| 356 | | if not test: |
| 357 | | cc = ScontoScontrino() |
| 358 | | cc.id = dato[0] |
| 359 | | cc.valore= riga.valore |
| 360 | | cc.tipo_sconto = riga.tipo_sconto |
| 361 | | session.add(cc) |
| 362 | | try: |
| 363 | | session.commit() |
| 364 | | except: |
| 365 | | session.rollback() |
| 366 | | print "GIA FATTO" |
| 367 | | |
| 368 | | try: |
| 369 | | stri= """ALTER TABLE %s |
| 370 | | ADD CONSTRAINT sconto_testata_scontrino_id_fkey FOREIGN KEY (id) |
| 371 | | REFERENCES %s (id) MATCH SIMPLE |
| 372 | | ON UPDATE CASCADE ON DELETE CASCADE;"""%(tabella3,tabella2) |
| 373 | | session.execute(text(stri)) |
| 374 | | session.commit() |
| 375 | | except: |
| 376 | | session.rollback() |
| 377 | | print "ADD fallito" |
| 378 | | |
| 379 | | |
| 380 | | ################################## sistemo la sequence ....che resta sfasata a causa degli inserimenti ..... ################Ã |
| 381 | | try: |
| 382 | | command = "SELECT setval( '%s',(SELECT max(id)+1 FROM %s));" %(params["schema"]+".sconto_scontrino_id_seq",params["schema"] +".sconto_scontrino") |
| 383 | | session.execute(text(command)) |
| 384 | | session.commit() |
| 385 | | except: |
| 386 | | session.rollback() |
| 387 | | print "PURE QUESTO FATTO" |
| | 112 | ##testataScontrinoTable |
| | 113 | ## if "testata_scontrino.id_magazzino" in str(testataScontrinoTable.c): |
| | 114 | ## print "OOOOOOOOOOOOOOOOOOOOO" |
| | 115 | |
| | 116 | # """ Rivediamo la struttura della testata vendita al dettaglio per gestire |
| | 117 | # anche una definizione dei magazzini, dei punti cassa e possibilmente |
| | 118 | # anche del cassiere che ha effettuato la vendita """ |
| | 119 | |
| | 120 | # #if "testata_scontrino.id_magazzino" not in testatascontrinoTable.c: |
| | 121 | # # print "OKOKOKOKOKO NN CE" |
| | 122 | # try: |
| | 123 | # comando = 'ALTER TABLE %s ADD COLUMN id_magazzino integer ;' % tabella4 |
| | 124 | # session.connection().execute(text(comando)) |
| | 125 | # session.commit() |
| | 126 | # # session.flush() |
| | 127 | # except: |
| | 128 | # session.rollback() |
| | 129 | # print "LACOLONNA ID_MAGAZZINO C'E" |
| | 130 | |
| | 131 | # #if "id_magazzino" in testatascontrinoTable.c: |
| | 132 | # try: |
| | 133 | # stri="""ALTER TABLE %s |
| | 134 | # ADD CONSTRAINT testata_scontrino_id_magazzino_id_fkey FOREIGN KEY (id_magazzino) |
| | 135 | # REFERENCES %s (id) MATCH SIMPLE |
| | 136 | # ON UPDATE CASCADE ON DELETE RESTRICT;""" %(tabella4,tabella5) |
| | 137 | # session.execute(text(stri)) |
| | 138 | # session.commit() |
| | 139 | # except: |
| | 140 | # session.rollback() |
| | 141 | # print "ADD ID MAGAZZINO fallito" |
| | 142 | |
| | 143 | |
| | 144 | |
| | 145 | # try: |
| | 146 | # comando = 'ALTER TABLE %s ADD COLUMN id_ccardtype integer ;' % tabella4 |
| | 147 | # session.connection().execute(text(comando)) |
| | 148 | # session.commit() |
| | 149 | # # session.flush() |
| | 150 | # except: |
| | 151 | # session.rollback() |
| | 152 | # print "LACOLONNA ID_CCARDTYPE C'E" |
| | 153 | |
| | 154 | # #if "id_magazzino" in testatascontrinoTable.c: |
| | 155 | # try: |
| | 156 | # stri="""ALTER TABLE %s |
| | 157 | # ADD CONSTRAINT testata_scontrino_id_ccardtype_id_fkey FOREIGN KEY (id_ccardtype) |
| | 158 | # REFERENCES %s (id) MATCH SIMPLE |
| | 159 | # ON UPDATE CASCADE ON DELETE SET NULL;""" %(tabella4,tabella9) |
| | 160 | # session.execute(text(stri)) |
| | 161 | # session.commit() |
| | 162 | # except: |
| | 163 | # session.rollback() |
| | 164 | # print "ADD ID CCardType fallito" |
| | 165 | |
| | 166 | # try: |
| | 167 | # comando = 'ALTER TABLE %s ADD COLUMN id_pos integer ;' % tabella4 |
| | 168 | # session.connection().execute(text(comando)) |
| | 169 | # session.commit() |
| | 170 | # # session.flush() |
| | 171 | # except: |
| | 172 | # session.rollback() |
| | 173 | # print "LACOLONNA ID_POS C'E" |
| | 174 | |
| | 175 | |
| | 176 | # try: |
| | 177 | # stri="""ALTER TABLE %s |
| | 178 | # ADD CONSTRAINT testata_scontrino_id_pos_id_fkey FOREIGN KEY (id_pos) |
| | 179 | # REFERENCES %s (id) MATCH SIMPLE |
| | 180 | # ON UPDATE CASCADE ON DELETE RESTRICT;""" %(tabella4,tabella6) |
| | 181 | # session.execute(text(stri)) |
| | 182 | # session.commit() |
| | 183 | # except: |
| | 184 | # session.rollback() |
| | 185 | # print "ADD FK ID POS fallito" |
| | 186 | |
| | 187 | |
| | 188 | # """ AGGIUNGO LA FK ID_USER NELLA TABELLA TESTATA SCONTRINO""" |
| | 189 | # try: |
| | 190 | # comando = 'ALTER TABLE %s ADD COLUMN id_user integer ;' % tabella4 |
| | 191 | # session.connection().execute(text(comando)) |
| | 192 | # session.commit() |
| | 193 | # # session.flush() |
| | 194 | # except: |
| | 195 | # session.rollback() |
| | 196 | # print "LACOLONNA ID_USER C'E" |
| | 197 | |
| | 198 | # #if "id_magazzino" in testatascontrinoTable.c: |
| | 199 | # try: |
| | 200 | # stri="""ALTER TABLE %s |
| | 201 | # ADD CONSTRAINT testata_scontrino_id_user_id_fkey FOREIGN KEY (id_user) |
| | 202 | # REFERENCES %s (id) MATCH SIMPLE |
| | 203 | # ON UPDATE CASCADE ON DELETE RESTRICT;""" %(tabella4,tabella7) |
| | 204 | # session.execute(text(stri)) |
| | 205 | # session.commit() |
| | 206 | # except: |
| | 207 | # session.rollback() |
| | 208 | # print "ADD FK ID USER fallito" |
| | 209 | |
| | 210 | # try: |
| | 211 | # stri="""ALTER TABLE %s |
| | 212 | # ADD CONSTRAINT sconto_riga_scontrino_id_fkey FOREIGN KEY (id) |
| | 213 | # REFERENCES %s (id) MATCH SIMPLE |
| | 214 | # ON UPDATE CASCADE ON DELETE DELETE;"""%(tabella,tabella2) |
| | 215 | # session.execute(text(stri)) |
| | 216 | # session.commit() |
| | 217 | # except: |
| | 218 | # session.rollback() |
| | 219 | # print "ADD FK SCONTO RIGA SCONTRINO fallito" |
| | 220 | |
| | 221 | |
| | 222 | # """ AGGIUNGO LA FK ID_MAGAZZINO NELLA TABELLA CHIUSURA FISCALE""" |
| | 223 | |
| | 224 | # try: |
| | 225 | # comando = 'ALTER TABLE %s ADD COLUMN id_magazzino integer ;' % tabella8 |
| | 226 | # session.connection().execute(text(comando)) |
| | 227 | # session.commit() |
| | 228 | # except: |
| | 229 | # session.rollback() |
| | 230 | # print "LA COLONNA ID_MAGAZZINO C'E" |
| | 231 | |
| | 232 | # try: |
| | 233 | # stri="""ALTER TABLE %s |
| | 234 | # ADD CONSTRAINT chiusura_fiscale_id_magazzino_id_fkey FOREIGN KEY (id_magazzino) |
| | 235 | # REFERENCES %s (id) MATCH SIMPLE |
| | 236 | # ON UPDATE CASCADE ON DELETE RESTRICT;""" %(tabella8,tabella5) |
| | 237 | # session.execute(text(stri)) |
| | 238 | # session.commit() |
| | 239 | # except: |
| | 240 | # session.rollback() |
| | 241 | # print "ADD FK ID MAGAZZINO fallito" |
| | 242 | |
| | 243 | # """ AGGIUNGO LA FK ID_POS NELLA TABELLA CHIUSURA FISCALE""" |
| | 244 | |
| | 245 | # try: |
| | 246 | # comando = 'ALTER TABLE %s ADD COLUMN id_pos integer ;' % tabella8 |
| | 247 | # session.connection().execute(text(comando)) |
| | 248 | # session.commit() |
| | 249 | # except: |
| | 250 | # session.rollback() |
| | 251 | # print "LA COLONNA ID_pos C'E" |
| | 252 | |
| | 253 | # try: |
| | 254 | # stri="""ALTER TABLE %s |
| | 255 | # ADD CONSTRAINT chiusura_fiscale_id_pos_id_fkey FOREIGN KEY (id_pos) |
| | 256 | # REFERENCES %s (id) MATCH SIMPLE |
| | 257 | # ON UPDATE CASCADE ON DELETE RESTRICT;""" %(tabella8,tabella6) |
| | 258 | # session.execute(text(stri)) |
| | 259 | # session.commit() |
| | 260 | # except: |
| | 261 | # session.rollback() |
| | 262 | # print "ADD FK ID POS fallito" |
| | 263 | |
| | 264 | # try: |
| | 265 | # stri = 'ALTER TABLE %s DROP CONSTRAINT chiusura_fiscale_data_chiusura_key'%tabella8 |
| | 266 | # session.execute(stri) |
| | 267 | # session.commit() |
| | 268 | # except: |
| | 269 | # session.rollback() |
| | 270 | # print " LA UNIQUE e' già stata tolta" |
| | 271 | |
| | 272 | # try: |
| | 273 | # stri = 'ALTER TABLE %s ADD CONSTRAINT chiusura_fiscale_data_chiusura_key'%tabella8 |
| | 274 | # session.execute(stri) |
| | 275 | # session.commit() |
| | 276 | # except: |
| | 277 | # session.rollback() |
| | 278 | # print " LA UNIQUE e' già stata tolta" |
| | 279 | |
| | 280 | |
| | 281 | #if not hasattr(conf.VenditaDettaglio,"migrazione_sincro_effettuata") or conf.VenditaDettaglio.migrazione_sincro_effettuata =="no": |
| | 282 | ##if "ciccio" == "pluto": |
| | 283 | # msg = """ATTENZIONE, per qualche giorno l'avvio del pg2 |
| | 284 | #potrebbe essere lento ( anche qualche minuto): |
| | 285 | #Il rallentamento Ú solo di chi usa il modulo di |
| | 286 | #vendita al dettaglio, ed Ú dovuto ad un aggiornamento/modifica |
| | 287 | #del database per facilitare e rendere coerente |
| | 288 | #la sincronizzazione di una sede centrale con i punti vendita |
| | 289 | #Se il Promogest parte correttamente ed il modulo funziona vi |
| | 290 | #invitiamo a contattarci al numero verde 800 034561 per disabilitare |
| | 291 | #l'aggiornamento grazie. |
| | 292 | #Ci scusiamo per l'inconveniente. |
| | 293 | # """ |
| | 294 | # dialog = gtk.MessageDialog(None, |
| | 295 | # gtk.DIALOG_MODAL |
| | 296 | # | gtk.DIALOG_DESTROY_WITH_PARENT, |
| | 297 | # gtk.MESSAGE_INFO, gtk.BUTTONS_OK, |
| | 298 | # msg) |
| | 299 | # dialog.run() |
| | 300 | # dialog.destroy() |
| | 301 | |
| | 302 | # ####################### sezione deciata allo sconto riga scontrino .... ############## |
| | 303 | |
| | 304 | # from promogest.modules.VenditaDettaglio.dao.ScontoScontrino import ScontoScontrino |
| | 305 | # from promogest.modules.VenditaDettaglio.dao.ScontoRigaScontrino import ScontoRigaScontrino |
| | 306 | # from promogest.modules.VenditaDettaglio.dao.ScontoTestataScontrino import ScontoTestataScontrino |
| | 307 | # from promogest.dao.Sconto import Sconto |
| | 308 | |
| | 309 | # dati_sconto = params["session"].query(scontoRigaScontrinoTable.c.id).all() |
| | 310 | # cc = None |
| | 311 | ## print dati_sconto |
| | 312 | # if dati_sconto: |
| | 313 | # for dato in dati_sconto: |
| | 314 | # riga = Sconto().getRecord(id=dato[0]) |
| | 315 | # test = ScontoScontrino().getRecord(id=dato[0]) |
| | 316 | # if not test: |
| | 317 | # cc = ScontoScontrino() |
| | 318 | # cc.id = dato[0] |
| | 319 | # cc.valore= riga.valore |
| | 320 | # cc.tipo_sconto = riga.tipo_sconto |
| | 321 | # session.add(cc) |
| | 322 | # else: |
| | 323 | # continue |
| | 324 | # try: |
| | 325 | # session.commit() |
| | 326 | # except: |
| | 327 | # session.rollback() |
| | 328 | # print "GIA FATTO" |
| | 329 | |
| | 330 | # try: |
| | 331 | # stri="""ALTER TABLE %s |
| | 332 | # ADD CONSTRAINT sconto_riga_scontrino_id_fkey FOREIGN KEY (id) |
| | 333 | # REFERENCES %s (id) MATCH SIMPLE |
| | 334 | # ON UPDATE CASCADE ON DELETE CASCADE;"""%(tabella,tabella2) |
| | 335 | # session.execute(text(stri)) |
| | 336 | # session.commit() |
| | 337 | # except: |
| | 338 | # print "ADD fallito" |
| | 339 | |
| | 340 | # #################### sezione sconto testata scontrino ########################## |
| | 341 | |
| | 342 | # try: |
| | 343 | # stri = 'ALTER TABLE %s DROP CONSTRAINT sconto_testata_scontrino_id_fkey'%tabella3 |
| | 344 | # session.connection().execute(stri) |
| | 345 | # session.commit() |
| | 346 | # except: |
| | 347 | # session.rollback() |
| | 348 | # print "drop fallito" |
| | 349 | |
| | 350 | # dati_sconto2 = params["session"].query(scontoTestataScontrinoTable.c.id).all() |
| | 351 | # cc2 = None |
| | 352 | # if dati_sconto2: |
| | 353 | # for dato in dati_sconto2: |
| | 354 | # riga = Sconto().getRecord(id=dato[0]) |
| | 355 | # test = ScontoScontrino().getRecord(id=dato[0]) |
| | 356 | # if not test: |
| | 357 | # cc = ScontoScontrino() |
| | 358 | # cc.id = dato[0] |
| | 359 | # cc.valore= riga.valore |
| | 360 | # cc.tipo_sconto = riga.tipo_sconto |
| | 361 | # session.add(cc) |
| | 362 | # try: |
| | 363 | # session.commit() |
| | 364 | # except: |
| | 365 | # session.rollback() |
| | 366 | # print "GIA FATTO" |
| | 367 | |
| | 368 | # try: |
| | 369 | # stri= """ALTER TABLE %s |
| | 370 | # ADD CONSTRAINT sconto_testata_scontrino_id_fkey FOREIGN KEY (id) |
| | 371 | # REFERENCES %s (id) MATCH SIMPLE |
| | 372 | # ON UPDATE CASCADE ON DELETE CASCADE;"""%(tabella3,tabella2) |
| | 373 | # session.execute(text(stri)) |
| | 374 | # session.commit() |
| | 375 | # except: |
| | 376 | # session.rollback() |
| | 377 | # print "ADD fallito" |
| | 378 | |
| | 379 | |
| | 380 | # ################################## sistemo la sequence ....che resta sfasata a causa degli inserimenti ..... ################Ã |
| | 381 | # try: |
| | 382 | # command = "SELECT setval( '%s',(SELECT max(id)+1 FROM %s));" %(params["schema"]+".sconto_scontrino_id_seq",params["schema"] +".sconto_scontrino") |
| | 383 | # session.execute(text(command)) |
| | 384 | # session.commit() |
| | 385 | # except: |
| | 386 | # session.rollback() |
| | 387 | # print "PURE QUESTO FATTO" |