PageRenderTime 54ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/core/promogest/modules/VenditaDettaglio/ui/AnagraficaVenditaDettaglio.py

http://promogest.googlecode.com/
Python | 1167 lines | 1097 code | 34 blank | 36 comment | 52 complexity | e64bd51bbf8acd9bc8943f89c067ccd9 MD5 | raw file
Possible License(s): GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. # -*- coding: utf-8 -*-
  2. # Copyright (C) 2005, 2006, 2007 2008, 2009, 2010, 2011
  3. #by Promotux di Francesco Meloni snc - http://www.promotux.it/
  4. # Author: Francesco Meloni <francesco@promotux.it>
  5. # This file is part of Promogest.
  6. # Promogest is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 2 of the License, or
  9. # (at your option) any later version.
  10. # Promogest is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. # You should have received a copy of the GNU General Public License
  15. # along with Promogest. If not, see <http://www.gnu.org/licenses/>.
  16. from promogest.ui.utils import *
  17. from subprocess import *
  18. from datetime import datetime
  19. from promogest import Environment
  20. from promogest.ui.GladeWidget import GladeWidget
  21. from promogest.modules.VenditaDettaglio.dao.TestataScontrino import TestataScontrino
  22. from promogest.modules.VenditaDettaglio.dao.RigaScontrino import RigaScontrino
  23. from promogest.modules.VenditaDettaglio.dao.ScontoRigaScontrino import ScontoRigaScontrino
  24. from promogest.modules.VenditaDettaglio.dao.ScontoTestataScontrino import ScontoTestataScontrino
  25. from promogest.modules.VenditaDettaglio.dao.TestataScontrinoCliente import TestataScontrinoCliente
  26. from promogest.dao.Azienda import Azienda
  27. from promogest.dao.Articolo import Articolo
  28. from promogest.dao.Listino import Listino
  29. from promogest.dao.Setconf import SetConf
  30. from promogest.dao.ListinoArticolo import ListinoArticolo
  31. from GestioneScontrini import GestioneScontrini
  32. from GestioneChiusuraFiscale import GestioneChiusuraFiscale
  33. from venditaDettaglioUiPart import drawPart
  34. from VenditaDettaglioUtils import fillComboboxPos
  35. from promogest.ui.gtk_compat import *
  36. if hasattr(Environment.conf, "VenditaDettaglio"):
  37. if hasattr(Environment.conf.VenditaDettaglio,"backend") and\
  38. Environment.conf.VenditaDettaglio.backend.upper() =="OLIVETTI":
  39. from promogest.modules.VenditaDettaglio.lib.olivetti import ElaExecute
  40. # print "DRIVER OLIVETTI ANCORA DA FARE"
  41. DRIVER = "E"
  42. elif hasattr(Environment.conf.VenditaDettaglio,"backend") and\
  43. Environment.conf.VenditaDettaglio.backend.capitalize() == "DITRON" and\
  44. Environment.conf.VenditaDettaglio.disabilita_stampa == 'no':
  45. from promogest.modules.VenditaDettaglio.lib.ditron import Ditron
  46. DRIVER = "D"
  47. elif Environment.conf.VenditaDettaglio.disabilita_stampa == 'yes':
  48. DRIVER = None
  49. else:
  50. print "ERRORE NELLA DEFINIZIONE DEL BACKEND"
  51. from promogest.modules.VenditaDettaglio.lib.ditron import Ditron
  52. DRIVER = "D"
  53. elif setconf("VenditaDettaglio","disabilita_stampa"):
  54. DRIVER = None
  55. class AnagraficaVenditaDettaglio(GladeWidget):
  56. """ Frame per la gestione delle vendite a dettaglio """
  57. def __init__(self):
  58. GladeWidget.__init__(self, 'vendita_dettaglio_window',
  59. fileName='VenditaDettaglio/gui/vendita_dettaglio_window.glade',
  60. isModule=True)
  61. self.idPuntoCassa = None
  62. self.idMagazzino = None
  63. if not Environment.magazzino_pos:
  64. self.altreopzionishow()
  65. self.placeWindow(self.getTopLevel())
  66. self._currentRow = {}
  67. self._simboloPercentuale = '%'
  68. self._simboloEuro = '€'
  69. textStatusBar = " PromoGest - Vendita Dettaglio - by PromoTUX Informatica - www.promogest.me - info@promotux.it "
  70. context_id = self.vendita_dettaglio_statusbar.get_context_id("vendita_dettaglio_window")
  71. self.vendita_dettaglio_statusbar.push(context_id, textStatusBar)
  72. azienda = Azienda().getRecord(id=Environment.azienda)
  73. if azienda:
  74. self.logo_articolo.set_from_file(azienda.percorso_immagine)
  75. self.createPopupMenu()
  76. #nascondo i dati riga e le info aggiuntive
  77. self.dati_riga_frame.destroy()
  78. self.shop = Environment.shop
  79. # self.rowBoldFont = 'arial bold 12'
  80. self.rowBoldFont = 'arial 13'
  81. # self.rowBackGround = '#E6E6FF'
  82. self.rowBackGround = "#FFFFC0"
  83. self.draw()
  84. def altreopzionishow(self):
  85. fillComboboxMagazzini(self.ao_magazzino_combobox)
  86. if hasattr(Environment.conf, "VenditaDettaglio"):
  87. if hasattr(Environment.conf.VenditaDettaglio, "magazzino"):
  88. findComboboxRowFromStr(self.ao_magazzino_combobox, Environment.conf.VenditaDettaglio.magazzino,2)
  89. elif setconf("VenditaDettaglio", "magazzino_vendita"):
  90. findComboboxRowFromId(self.ao_magazzino_combobox, setconf("VenditaDettaglio", "magazzino_vendita"))
  91. else:
  92. messageInfo(msg="Selezionare un magazzino")
  93. fillComboboxPos(self.ao_punto_cassa_combobox)
  94. if hasattr(Environment.conf, "VenditaDettaglio"):
  95. if hasattr(Environment.conf.VenditaDettaglio, "puntocassa"):
  96. findComboboxRowFromStr(self.ao_punto_cassa_combobox, Environment.conf.VenditaDettaglio.puntocassa,2)
  97. elif setconf("VenditaDettaglio", "punto_cassa"):
  98. findComboboxRowFromId(self.ao_punto_cassa_combobox,setconf("VenditaDettaglio", "punto_cassa"))
  99. else:
  100. messageInfo(msg="Aggiungere e selezionare un punto cassa\ndal menu opzioni presente nella finestra di vendita ")
  101. self.altre_opzioni_dialog.set_transient_for(self.topLevelWindow)
  102. self.altre_opzioni_dialog.show_all()
  103. self.altre_opzioni_dialog.run()
  104. def draw(self):
  105. if DRIVER =="E":
  106. # self.apri_cassetto_button.set_active(True)
  107. self.apri_cassetto_button.set_sensitive(True)
  108. drawPart(self)
  109. def on_set_pv_pos_activate(self, item):
  110. self.altreopzionishow()
  111. def on_ao_annulla_button_clicked(self, button):
  112. self.altre_opzioni_dialog.hide()
  113. def on_ao_ok_button_clicked(self, button):
  114. self.idPuntoCassa = findIdFromCombobox(self.ao_punto_cassa_combobox)
  115. self.idMagazzino = findIdFromCombobox(self.ao_magazzino_combobox)
  116. strPuntoCassa = findStrFromCombobox(self.ao_punto_cassa_combobox,2)
  117. strMagazzino = findStrFromCombobox(self.ao_magazzino_combobox,2)
  118. if hasattr(Environment.conf, "VenditaDettaglio"):
  119. Environment.conf.VenditaDettaglio.puntocassa = strPuntoCassa
  120. Environment.conf.VenditaDettaglio.magazzino = strMagazzino
  121. Environment.conf.save()
  122. else:
  123. a = SetConf().select(section="VenditaDettaglio", key="punto_cassa")
  124. if a:
  125. a[0].value = self.idPuntoCassa
  126. a[0].persist()
  127. else:
  128. a = SetConf()
  129. a.section = "VenditaDettaglio"
  130. a.tipo_section ="Modulo"
  131. a.description = "punto cassa"
  132. a.tipo = "int"
  133. a.key = "punto_cassa"
  134. a.value = self.idPuntoCassa
  135. a.active = True
  136. a.persist()
  137. a = SetConf().select(section="VenditaDettaglio", key="magazzino_vendita")
  138. if a:
  139. a[0].value = self.idMagazzino
  140. a[0].persist()
  141. else:
  142. a = SetConf()
  143. a.section = "VenditaDettaglio"
  144. a.tipo_section ="Modulo"
  145. a.description = "magazzino ventta"
  146. a.tipo = "int"
  147. a.key = "magazzino_vendita"
  148. a.value = self.idMagazzino
  149. a.active = True
  150. a.persist()
  151. # if not self.idPuntoCassa:
  152. # obligatoryField(None, widget=None, msg="Punto Cassa Obbligatorio")
  153. # return
  154. if not self.idMagazzino:
  155. obligatoryField(None, widget=None, msg="Magazzino Obbligatorio")
  156. return
  157. self.altre_opzioni_dialog.hide()
  158. testo = "OPERATORE: <b>%s</b> -- MAGAZZINO/P.VENDITA: <b>%s</b> -- PUNTO CASSA: <b>%s</b>" %(Environment.params["usernameLoggedList"][1], strMagazzino, strPuntoCassa)
  159. self.info_label.set_markup(testo)
  160. # def on_no_stampa_toggled_toggled(self, button):
  161. def on_anagrafica_punti_cassa_activate_item(self, item):
  162. from AnagraficaPOS import AnagraficaPos
  163. anag = AnagraficaPos()
  164. showAnagrafica(self.getTopLevel(), anag, item, self)
  165. def on_anagrafica_tipi_carta_activate(self, item):
  166. from promogest.ui.AnagraficaCCardType import AnagraficaCCardType
  167. anag = AnagraficaCCardType()
  168. showAnagrafica(self.getTopLevel(), anag, item, self)
  169. def on_column_prezzo_edited(self, cell, path, value, treeview, editNext=True):
  170. """ Function to set the value prezzo edit in the cell"""
  171. model = treeview.get_model()
  172. value=value.replace(",",".")
  173. value = mN(value)
  174. model[path][5] = value
  175. if model[path][7] == '%':
  176. tipoSconto = "percentuale"
  177. else:
  178. tipoSconto = "valore"
  179. if model[path][6]== 0 or not model[path][5]:
  180. tipoSconto = None
  181. model[path][8] = model[path][5]
  182. else:
  183. if tipoSconto == "percentuale":
  184. prezzoscontato = mN(model[path][5]) - (mN(model[path][5]) * mN(model[path][6])) / 100
  185. else:
  186. prezzoscontato = mN(model[path][5]) -mN(model[path][6])
  187. if not prezzoscontato:
  188. prezzoscontato = "0.00"
  189. model[path][8] = prezzoscontato
  190. self.refreshTotal()
  191. self.on_cancel_button_clicked(self.getTopLevel)
  192. def on_column_sconto_edited(self, cell, path, value, treeview, editNext=True):
  193. model = treeview.get_model()
  194. model[path][6] = value
  195. prez = model[path][5]
  196. self.on_column_prezzo_edited(cell, path, prez, treeview)
  197. def on_column_listinoRiga_edited(self, cell, path, value, treeview, editNext=True):
  198. #rivedere assolutamente .....
  199. model = treeview.get_model()
  200. model[path][1] = value
  201. listin = {}
  202. for l in self.lsmodel:
  203. if l[1] == value:
  204. idlisti=l[0]
  205. listin = leggiListino(l[0],model[path][0])
  206. break
  207. prez = str(listin['prezzoDettaglio'])
  208. if listin.has_key('scontiDettaglio'):
  209. if len(listin["scontiDettaglio"]) > 0:
  210. model[path][6]= listin['scontiDettaglio'][0].valore or 0
  211. else:
  212. model[path][6] = 0
  213. self.on_column_prezzo_edited(cell, path, prez, treeview)
  214. def on_column_quantita_edited(self, cell, path, value, treeview, editNext=True):
  215. """ Set the value "quantita" edit in the cell """
  216. model = treeview.get_model()
  217. value=value.replace(",",".")
  218. value = mN(value)
  219. model[path][9] = value
  220. self.refreshTotal()
  221. self.on_cancel_button_clicked(self.getTopLevel)
  222. def on_column_descrizione_edited(self, cell, path, value, treeview, editNext=True):
  223. """ Set the value descrizione edit in the cell """
  224. model = treeview.get_model()
  225. model[path][4] = value
  226. self.on_cancel_button_clicked(self.getTopLevel)
  227. def on_column_tipo_edited(self, cell, path, value, treeview, editNext=True):
  228. """ Set the value tipo_sconto edit in the cell"""
  229. model = treeview.get_model()
  230. model[path][7] = value
  231. scont = model[path][6]
  232. self.on_column_sconto_edited(cell, path, scont, treeview)
  233. def on_vendita_dettaglio_window_key_press_event(self, widget, event):
  234. """ jolly key č F9, richiama ed inserisce l'articolo definito nel configure"""
  235. keyname = gdk_keyval_name(event.keyval)
  236. if keyname == 'F9':
  237. try:
  238. if hasattr(Environment.conf, "VenditaDettaglio"):
  239. if hasattr(Environment.conf.VenditaDettaglio,"jolly"):
  240. codice = Environment.conf.VenditaDettaglio.jolly
  241. else:
  242. articoloId = setconf("VenditaDettaglio", "jolly")
  243. codice = None
  244. if articoloId:
  245. codice = Articolo().getRecord(id=articoloId).codice
  246. else:
  247. articoloId = setconf("VenditaDettaglio", "jolly")
  248. codice = None
  249. if articoloId:
  250. codice = Articolo().getRecord(id=articoloId).codice
  251. if not codice:
  252. messageInfo(msg="ARTICOLO JOLLY NON SELEZIONATO")
  253. self.search_item(codice=codice, fnove=True)
  254. except:
  255. Environment.pg2log.info("ARTICOLO JOLLY NON SETTATO NEL CONFIGURE NELLA SEZIONE [VenditaDettaglio]")
  256. def fnovewidget(self,codice=None, destroy=None):
  257. if destroy:
  258. prezzo1 = self.prezzo_f9_entry.get_text()
  259. quantita1 = self.quantita_f9_entry.get_text()
  260. self.articolo_generico_dialogo.hide()
  261. self.search_item(codice=self.codi,fnove=True,valorigenerici=(quantita1,prezzo1) )
  262. else:
  263. self.codi = codice
  264. self.prezzo_f9_entry.set_text("")
  265. self.quantita_f9_entry.set_text("1")
  266. self.dialog_genrico_vbox.show_all()
  267. self.articolo_generico_dialogo.show_all()
  268. def on_generico_ok_button_clicked(self, button):
  269. self.fnovewidget(destroy=True)
  270. def on_annulla_generico_button_clicked(self, button):
  271. self.articolo_generico_dialogo.hide()
  272. def on_minus_button_clicked(self, button):
  273. valore = int(abs(float(self.prezzo_f9_entry.get_text())))
  274. self.prezzo_f9_entry.set_text(str(valore-1))
  275. def on_plus_button_clicked(self, button):
  276. valore = int(abs(float(self.prezzo_f9_entry.get_text())))
  277. self.prezzo_f9_entry.set_text(str(valore+1))
  278. def on_minus2_button_clicked(self, button):
  279. valore = int(abs(float(self.quantita_f9_entry.get_text())))
  280. self.quantita_f9_entry.set_text(str(valore-1))
  281. def on_plus2_button_clicked(self, button):
  282. valore = int(abs(float(self.quantita_f9_entry.get_text())))
  283. self.quantita_f9_entry.set_text(str(valore+1))
  284. def search_item(self, codiceABarre=None, codice=None,
  285. valorigenerici=[], descrizione=None,
  286. fnove=False):
  287. # Ricerca articolo per barcode
  288. if codiceABarre:
  289. arts = Articolo().select(codiceABarre = codiceABarre,
  290. offset = None,
  291. batchSize = None)
  292. elif codice:
  293. arts = Articolo().select(codice = codice,
  294. offset = None,
  295. batchSize = None)
  296. elif descrizione:
  297. arts = Articolo().select(denominazione = descrizione,
  298. offset = None,
  299. batchSize = None)
  300. if len(arts) == 1:
  301. idArticolo = arts[0].id
  302. codice = arts[0].codice or ''
  303. codiceABarre = arts[0].codice_a_barre or ''
  304. descrizione = arts[0].descrizione_etichetta or arts[0].denominazione or ''
  305. # Ricerca listino_articolo
  306. listino = leggiListino(self.id_listino, idArticolo)
  307. if fnove and not valorigenerici:
  308. self.fnovewidget(codice=codice)
  309. elif fnove and valorigenerici:
  310. quantita = valorigenerici[0] or 1
  311. prezzo = mN(valorigenerici[1]) or 0
  312. else:
  313. prezzo = mN(listino["prezzoDettaglio"])
  314. quantita = 1
  315. listinoRiga = (self.id_listino,listino['denominazione'])
  316. prezzoScontato = prezzo
  317. valoreSconto = 0
  318. tipoSconto = None
  319. if listino.has_key('scontiDettaglio'):
  320. if len(listino["scontiDettaglio"]) > 0:
  321. valoreSconto = listino['scontiDettaglio'][0].valore or 0
  322. if valoreSconto == 0:
  323. tipoSconto = None
  324. prezzoScontato = prezzo
  325. else:
  326. tipoSconto = listino['scontiDettaglio'][0].tipo_sconto
  327. if tipoSconto == "percentuale":
  328. prezzoScontato = mN(mN(prezzo) - (mN(prezzo) * mN(valoreSconto)) / 100)
  329. else:
  330. prezzoScontato = mN(mN(prezzo) -mN(valoreSconto))
  331. self.codice_a_barre_entry.set_text(codiceABarre)
  332. self.codice_entry.set_text(codice)
  333. self.activate_item(idArticolo, listinoRiga, codiceABarre,codice,
  334. descrizione, prezzo, valoreSconto,tipoSconto,
  335. prezzoScontato, quantita)
  336. #self.confirm_button.grab_focus()
  337. #if not fnove:
  338. self.on_confirm_button_clicked(self.getTopLevel())
  339. self.refreshTotal()
  340. else:
  341. self.ricercaArticolo()
  342. def on_search_button_clicked(self, button):
  343. self.ricercaArticolo()
  344. def on_codice_a_barre_entry_activate(self, text_entry):
  345. if self.codice_a_barre_entry.get_text() != '':
  346. self.search_item(codiceABarre = prepareFilterString(self.codice_a_barre_entry.get_text()))
  347. return True
  348. def on_codice_entry_activate(self,text_entry):
  349. if self.codice_entry.get_text() != '':
  350. self.search_item(codice = prepareFilterString(self.codice_entry.get_text()))
  351. return True
  352. def on_descrizione_entry_activate(self,text_entry):
  353. if self.descrizione_entry.get_text() != '':
  354. self.search_item(descrizione = prepareFilterString(self.descrizione_entry.get_text()))
  355. return True
  356. def setDao(self, dao):
  357. if dao is None:
  358. # Crea un nuovo Dao vuoto
  359. self.dao = ListinoArticolo()
  360. else:
  361. # Ricrea il Dao con una connessione al DBMS SQL
  362. self.dao = ListinoArticolo().select(idListino=dao.id_listino,
  363. idArticolo=dao.id_articolo,
  364. orderBy=ListinoArticolo.id_articolo)[0]
  365. self._refresh()
  366. def empty_current_row(self):
  367. self._currentRow['idArticolo'] = None
  368. self._currentRow['listinoRiga'] = (None,None)
  369. self._currentRow['codiceABarre'] = None
  370. self._currentRow['codice'] = None
  371. self._currentRow['descrizione'] = None
  372. self._currentRow['prezzo'] = 0
  373. self._currentRow['valoreSconto'] = 0
  374. self._currentRow['tipoSconto'] = None
  375. self._currentRow['prezzoScontato'] = 0
  376. self._currentRow['quantita'] = 0
  377. self.codice_a_barre_entry.set_text('')
  378. self.codice_entry.set_text('')
  379. self.descrizione_entry.set_text('')
  380. self.descrizione_label.set_text('')
  381. self.prezzo_entry.set_text('')
  382. self.sconto_entry.set_text('')
  383. self.prezzo_scontato_entry.set_text('')
  384. self.quantita_entry.set_text('')
  385. self.listini_combobox.clear()
  386. self.id_listino = self.ricercaListino()
  387. self.giacenza_label.set_text('-')
  388. def activate_item(self, idArticolo,listinoRiga,codiceABarre,codice,denominazione,
  389. prezzo,valoreSconto,tipoSconto,prezzoScontato,quantita):
  390. self._loading = True
  391. self.lsmodel.clear()
  392. listiniList= listinoCandidateSel(idArticolo=idArticolo,
  393. idMagazzino=self.id_magazzino ,
  394. idCliente=None)
  395. if listiniList:
  396. for l in listiniList:
  397. self.lsmodel.append([l.id,l.denominazione])
  398. if self.id_listino is not None:
  399. findComboboxRowFromId(self.listini_combobox, self.id_listino)
  400. else:
  401. self.listini_combobox.set_active(1)
  402. try:
  403. self.id_listino = findIdFromCombobox(self.listini_combobox)
  404. if prezzo == 0:
  405. listino = leggiListino(self.id_listino, idArticolo)
  406. prezzo = mN(listino["prezzoDettaglio"])
  407. prezzoScontato = prezzo
  408. valoreSconto = 0
  409. except:
  410. pass
  411. self._loading = False
  412. if tipoSconto == "percentuale":
  413. tipoSconto = "%"
  414. elif tipoSconto == "valore":
  415. tipoSconto = "€"
  416. else:
  417. tipoSconto = ""
  418. self.rhesus_button.set_sensitive(True)
  419. #self.annulling_button.set_sensitive(True)
  420. self._currentRow = {'idArticolo' : idArticolo,
  421. 'listinoRiga' : listinoRiga,
  422. 'codiceABarre' : codiceABarre,
  423. 'codice' : codice,
  424. 'descrizione' : denominazione,
  425. 'prezzo' : prezzo,
  426. 'valoreSconto' : valoreSconto,
  427. 'tipoSconto' : tipoSconto,
  428. 'prezzoScontato':prezzoScontato,
  429. 'quantita' : quantita}
  430. def on_scontrino_treeview_selection_changed(self, treeSelection):
  431. (model, iterator) = treeSelection.get_selected()
  432. if iterator is not None:
  433. self.delete_button.set_sensitive(True)
  434. #self.confirm_button.set_sensitive(True)
  435. self.rhesus_button.set_sensitive(True)
  436. #self.annulling_button.set_sensitive(True)
  437. self.search_button.set_sensitive(False)
  438. self.codice_a_barre_entry.set_sensitive(False)
  439. self.codice_entry.set_sensitive(False)
  440. self.descrizione_entry.set_sensitive(False)
  441. # Vado in editing
  442. self._state = 'editing'
  443. treeview = self.scontrino_treeview
  444. model = treeview.get_model()
  445. self.currentIteratorRow = iterator
  446. listinoRiga = model.get_value(self.currentIteratorRow, 1)
  447. idArticolo = model.get_value(self.currentIteratorRow, 0)
  448. self._quantita = model.get_value(self.currentIteratorRow, 9)
  449. self.lsmodel.clear()
  450. listiniList = listinoCandidateSel(idArticolo=idArticolo,
  451. idMagazzino=self.id_magazzino)
  452. listinoPref = Listino().select(idListino=self.id_listino)[0]
  453. self.lsmodel.append([listinoPref.id,listinoPref.denominazione])
  454. if listiniList:
  455. for l in listiniList:
  456. if l.denominazione != listinoPref.denominazione:
  457. self.lsmodel.append([l.id,l.denominazione])
  458. self.descrizione_label.set_markup('<b><span foreground="black" size="12000">'\
  459. +model.get_value(self.currentIteratorRow, 2)\
  460. + " - " \
  461. + model.get_value(self.currentIteratorRow, 3)\
  462. +" - " \
  463. +model.get_value(self.currentIteratorRow, 4)\
  464. +'</span></b>')
  465. self.refreshTotal()
  466. def on_confirm_button_clicked(self, button):
  467. # controllo che il prezzo non sia nullo
  468. if self._currentRow['prezzo'] == 0:
  469. messageWarning(msg="<b>ATTENZIONE:\n</b>Inserire un prezzo all'articolo",
  470. transient= self.getTopLevel())
  471. #self.prezzo_entry.grab_focus()
  472. self._state == 'editing'
  473. #return
  474. treeview = self.scontrino_treeview
  475. model = treeview.get_model()
  476. if self._state == 'search':
  477. model.append((self._currentRow['idArticolo'],
  478. self._currentRow['listinoRiga'][1],
  479. self._currentRow['codiceABarre'],
  480. self._currentRow['codice'],
  481. self._currentRow['descrizione'],
  482. str(mN(self._currentRow['prezzo'])),
  483. str(mN(self._currentRow['valoreSconto'])),
  484. self._currentRow['tipoSconto'],
  485. str(mN(self._currentRow['prezzoScontato'])),
  486. str(Decimal(self._currentRow['quantita'])),
  487. self.rowBackGround,
  488. self.rowBoldFont))
  489. elif self._state == 'editing':
  490. model.set_value(self.currentIteratorRow, 0, self._currentRow['idArticolo'])
  491. model.set_value(self.currentIteratorRow, 1, self._currentRow['listinoRiga'][1])
  492. model.set_value(self.currentIteratorRow, 2, self._currentRow['codiceABarre'])
  493. model.set_value(self.currentIteratorRow, 3, self._currentRow['codice'])
  494. model.set_value(self.currentIteratorRow, 4, self._currentRow['descrizione'])
  495. model.set_value(self.currentIteratorRow, 5, str(mN(self._currentRow['prezzo'])))
  496. model.set_value(self.currentIteratorRow, 6, str(mN(self._currentRow['valoreSconto'])))
  497. model.set_value(self.currentIteratorRow, 7, self._currentRow['tipoSconto'])
  498. model.set_value(self.currentIteratorRow, 8, str(mN(self._currentRow['prezzoScontato'])))
  499. model.set_value(self.currentIteratorRow, 9, str(Decimal(self._currentRow['quantita'])))
  500. self.marginevalue_label.set_text('')
  501. self.ultimocostovalue_label.set_text('')
  502. self.empty_current_row()
  503. self.scontrino_treeview.scroll_to_cell(str(len(model)-1))
  504. self.righe_label.set_markup('<b>[ '+str(len(model)) +' ] Righe scontrino</b>')
  505. # Disabilito cancella e conferma e abilito ricerca barcode
  506. self.delete_button.set_sensitive(False)
  507. #self.confirm_button.set_sensitive(False)
  508. self.rhesus_button.set_sensitive(False)
  509. #self.annulling_button.set_sensitive(False)
  510. self.codice_a_barre_entry.set_sensitive(True)
  511. self.codice_entry.set_sensitive(True)
  512. self.descrizione_entry.set_sensitive(True)
  513. self.search_button.set_sensitive(True)
  514. # Abilito pulsante totale e annulla
  515. notEmpty = (len(model) > 0)
  516. self.total_button.set_sensitive(notEmpty)
  517. self.subtotal_button.set_sensitive(notEmpty)
  518. self.empty_button.set_sensitive(notEmpty)
  519. self.setPagamento(enabled = notEmpty)
  520. self.sconto_hbox.set_sensitive(notEmpty)
  521. # Calcolo totali
  522. self.refreshTotal()
  523. treeview.get_selection().unselect_all()
  524. # vado in search
  525. self._state = 'search'
  526. self.codice_a_barre_entry.grab_focus()
  527. def on_cancel_button_clicked(self, button):
  528. self.empty_current_row()
  529. # Disabilito cancella e conferma e abilito ricerca barcode
  530. self.delete_button.set_sensitive(False)
  531. self.rhesus_button.set_sensitive(False)
  532. self.codice_a_barre_entry.set_sensitive(True)
  533. self.codice_entry.set_sensitive(True)
  534. self.descrizione_entry.set_sensitive(True)
  535. self.search_button.set_sensitive(True)
  536. treeview = self.scontrino_treeview
  537. model = treeview.get_model()
  538. # Abilito pulsante totale e annulla
  539. notEmpty = (len(model) > 0)
  540. self.total_button.set_sensitive(notEmpty)
  541. self.subtotal_button.set_sensitive(notEmpty)
  542. self.empty_button.set_sensitive(notEmpty)
  543. self.setPagamento(enabled = notEmpty)
  544. self.sconto_hbox.set_sensitive(notEmpty)
  545. treeview.get_selection().unselect_all()
  546. # vado in search
  547. self._state = 'search'
  548. self.codice_a_barre_entry.grab_focus()
  549. def on_rhesus_button_clicked(self, button):
  550. selection = self.scontrino_treeview.get_selection()
  551. (model, iter) = selection.get_selected()
  552. quantita = model.get_value(iter, 9)
  553. model[iter][9]= Decimal(quantita)* -1
  554. self.refreshTotal()
  555. self.on_cancel_button_clicked(self.getTopLevel)
  556. def on_delete_button_clicked(self, button):
  557. treeview = self.scontrino_treeview
  558. model = treeview.get_model()
  559. model.remove(self.currentIteratorRow)
  560. # Se era l'ultima riga disabilito text box e pulsanti per totali
  561. notEmpty = (len(model) > 0)
  562. self.total_button.set_sensitive(notEmpty)
  563. self.subtotal_button.set_sensitive(notEmpty)
  564. self.empty_button.set_sensitive(notEmpty)
  565. self.setPagamento(enabled = notEmpty)
  566. self.sconto_hbox.set_sensitive(notEmpty)
  567. # Disabilito cancella e conferma e abilito ricerca barcode
  568. self.delete_button.set_sensitive(False)
  569. self.rhesus_button.set_sensitive(False)
  570. self.codice_a_barre_entry.set_sensitive(True)
  571. self.codice_entry.set_sensitive(True)
  572. self.descrizione_entry.set_sensitive(True)
  573. self.search_button.set_sensitive(True)
  574. self.empty_current_row()
  575. # Calcolo totali
  576. self.refreshTotal()
  577. # vado in search
  578. self._state = 'search'
  579. self.codice_a_barre_entry.grab_focus()
  580. def refreshTotal(self):
  581. """ Here we can calculate subTotals and Totals of the sales
  582. """
  583. total = 0
  584. totale_scontato = "0.00"
  585. totale_sconto = "0.00"
  586. model = self.scontrino_treeview.get_model()
  587. for row in model:
  588. prezzo = mN(row[5]) or 0
  589. valoreSconto = mN(row[6]) or 0
  590. prezzoScontato = mN(row[8]) or 0
  591. quantita = Decimal(row[9])
  592. if valoreSconto == 0: #sconto
  593. # print "PREZZO E QUANTITA", prezzo, quantita
  594. total = total + (prezzo * quantita)
  595. else:
  596. total = total + (prezzoScontato * quantita)
  597. if not total:
  598. total = "0.00"
  599. totale_scontato = "0.00"
  600. totale_sconto = "0.00"
  601. self.sconto = Decimal(totale_sconto or 0)
  602. else:
  603. self.sconto = self.sconto_totale_entry.get_text()
  604. if self.tipo_sconto_euro.get_active():
  605. self.tipo_sconto_scontrino = "valore"
  606. totale_sconto = Decimal(self.sconto or 0)
  607. totale_scontato = total-totale_sconto
  608. else:
  609. self.tipo_sconto_scontrino = "percentuale"
  610. if not self.sconto:
  611. totale_scontato = total
  612. else:
  613. totale_sconto = total*(Decimal(self.sconto)/100)
  614. totale_scontato = total-totale_sconto
  615. self.label_totale.set_markup('<b><span foreground="black" size="40000">' + italianizza(mN(totale_scontato),curr="€ ") +'</span></b>')
  616. self.label_sconto.set_markup('<b><span foreground="#338000" size="24000">' + italianizza(mN(totale_sconto),curr="€ ") +'</span></b>')
  617. self.label_subtotale.set_markup('<b><span foreground="#338000" size="26000">' + italianizza(mN(total),curr="€ ") +'</span></b>')
  618. # self.label_totale.set_markup('<b><span foreground="black" size="40000">' + str(mN(totale_scontato)) +'</span></b>')
  619. # self.label_sconto.set_markup('<b><span foreground="#338000" size="24000">' + str(mN(totale_sconto)) +'</span></b>')
  620. # self.label_subtotale.set_markup('<b><span foreground="#338000" size="26000">' + str(mN(total)) +'</span></b>')
  621. return (totale_scontato,total,totale_sconto, self.sconto)
  622. def on_empty_button_clicked(self, button):
  623. self.scontrino_treeview.get_model().clear()
  624. self.empty_current_row()
  625. self.label_totale.set_markup('<b><span foreground="black" size="40000">0,00</span></b>')
  626. self.label_resto.set_markup('<b><span foreground="black" size="24000">0,00</span></b>')
  627. self.label_subtotale.set_markup('<b><span foreground="black" size="24000">0,00</span></b>')
  628. self.label_sconto.set_markup('<b><span foreground="black" size="26000">0,00</span></b>')
  629. self.empty_button.set_sensitive(False)
  630. self.total_button.set_sensitive(False)
  631. self.subtotal_button.set_sensitive(False)
  632. self.setPagamento(enabled = False)
  633. self.sconto_totale_entry.set_text("")
  634. self.sconto_hbox.set_sensitive(False)
  635. self.codice_a_barre_entry.grab_focus()
  636. def on_total_button_clicked(self, button):
  637. """ Funzione di salvataggio dello scontrino"""
  638. self.refreshTotal()
  639. dao = TestataScontrino()
  640. dao.data_inserimento = datetime.now()
  641. dao.totale_scontrino = mN(self.label_totale.get_text())
  642. dao.totale_sconto = mN(self.sconto_totale_entry.get_text())
  643. dao.totale_subtotale = mN(self.label_subtotale.get_text())
  644. dao.tipo_sconto_scontrino = self.tipo_sconto_scontrino
  645. dao.id_magazzino = int(self.idMagazzino)
  646. if self.idPuntoCassa:
  647. dao.id_pos = int(self.idPuntoCassa)
  648. dao.id_ccardtype = findIdFromCombobox(self.card_type_combobox)
  649. dao.id_user = Environment.params["usernameLoggedList"][0]
  650. #print "TOTALI",totale_scontrino, totale_sconto, totale_subtotale
  651. if dao.totale_scontrino < 0:
  652. msg = 'Attenzione!\n\nIl totale non puo\' essere negativo !'
  653. messageInfo(msg=msg)
  654. return
  655. # Creo dao testata_scontrino
  656. scontiSuTotale = []
  657. #res = self.sconti_testata_widget.getSconti()
  658. if dao.totale_sconto:
  659. daoSconto = ScontoTestataScontrino()
  660. daoSconto.valore = dao.totale_sconto
  661. daoSconto.tipo_sconto = dao.tipo_sconto_scontrino
  662. scontiSuTotale.append(daoSconto)
  663. dao.scontiSuTotale = scontiSuTotale
  664. #dao.totale_scontrino = totale_scontrino
  665. totale_contanti = 0
  666. totale_assegni = 0
  667. totale_carta_di_credito = 0
  668. if self.contanti_entry.get_text() != '':
  669. totale_contanti = mN(self.contanti_entry.get_text())
  670. resto = totale_contanti - dao.totale_scontrino
  671. self.label_resto.set_markup('<b><span foreground="black" size="24000">' + italianizza(resto) +'</span></b>')
  672. if self.non_contanti_entry.get_text() != '':
  673. if self.assegni_radio_button.get_active():
  674. totale_assegni = mN(self.non_contanti_entry.get_text())
  675. else:
  676. totale_carta_di_credito = mN(self.non_contanti_entry.get_text())
  677. dao.totale_contanti = totale_contanti
  678. dao.totale_assegni = totale_assegni
  679. dao.totale_carta_credito = totale_carta_di_credito
  680. # Creo righe
  681. righe = []
  682. model = self.scontrino_treeview.get_model()
  683. for row in model:
  684. idArticolo = row[0]
  685. descrizione = row[4]
  686. prezzo = mN(row[5])
  687. valoreSconto = mN(row[6])
  688. tipoSconto = row[7]
  689. prezzoScontato = mN(row[8])
  690. quantita = Decimal(row[9])
  691. # Nuova riga
  692. daoRiga = RigaScontrino()
  693. daoRiga.id_testata_scontrino = dao.id
  694. daoRiga.id_articolo = idArticolo
  695. daoRiga.descrizione = descrizione
  696. daoRiga.prezzo = prezzo
  697. daoRiga.prezzo_scontato = prezzoScontato
  698. daoRiga.quantita = quantita
  699. listarighesconto = []
  700. if valoreSconto > 0:
  701. daoScontoRigaScontrino = ScontoRigaScontrino()
  702. daoScontoRigaScontrino.valore = valoreSconto
  703. if tipoSconto == self._simboloPercentuale:
  704. daoScontoRigaScontrino.tipo_sconto = 'percentuale'
  705. else:
  706. daoScontoRigaScontrino.tipo_sconto = 'valore'
  707. listarighesconto.append(daoScontoRigaScontrino)
  708. daoRiga.sconti=listarighesconto
  709. righe.append(daoRiga)
  710. # Aggiungo righe e salvo dao testata scontrino
  711. dao.righe = righe
  712. dao.persist()
  713. if self.id_cliente_customcombobox.getId():
  714. a = TestataScontrinoCliente()
  715. a.id_cliente = self.id_cliente_customcombobox.getId()
  716. a.id_testata_scontrino = dao.id
  717. a.persist()
  718. # Creo il file e lo stampo
  719. if DRIVER and not self.no_print_toggled.get_active():
  720. print "SIAMO QUI PRONTI A MANDARE LO SCONTRINO IN CASSA"
  721. filescontrino = self.createFileToPos(dao)
  722. print "TORNATI", filescontrino
  723. self.codice_a_barre_entry.grab_focus()
  724. self.last_scontr_label.set_text("Tot. scontrino precedente: "+str(dao.totale_scontrino))
  725. # Svuoto transazione e mi rimetto in stato di ricerca
  726. self.search_button.set_sensitive(True)
  727. self.codice_a_barre_entry.set_sensitive(True)
  728. self.codice_entry.set_sensitive(True)
  729. self.descrizione_entry.set_sensitive(True)
  730. #self.confirm_button.set_sensitive(False)
  731. self.rhesus_button.set_sensitive(False)
  732. #self.annulling_button.set_sensitive(False)
  733. self.delete_button.set_sensitive(False)
  734. self.on_empty_button_clicked(self.empty_button)
  735. self.righe_label.set_markup('<b> [ 0 ] Righe scontrino</b>')
  736. self.codice_a_barre_entry.grab_focus()
  737. self._state = 'search'
  738. self.id_cliente_customcombobox.set_active(0)
  739. self.codice_a_barre_entry.grab_focus()
  740. # def on_chiusura_fiscale_activate(self, widget):
  741. # if DRIVER=="D":
  742. # GestioneChiusuraFiscale(self).chiusuraDialog(widget, self.id_magazzino)
  743. def ricercaArticolo(self):
  744. def on_ricerca_articolo_hide(anagWindow, anag):
  745. if anag.dao is None:
  746. anagWindow.destroy()
  747. return
  748. valoreSconto = 0
  749. tipoSconto = 'percentuale'
  750. anagWindow.destroy()
  751. idArticolo = anag.dao.id
  752. codiceABarre = anag.dao.codice_a_barre or ''
  753. codice = anag.dao.codice or ''
  754. descrizione = anag.dao.descrizione_etichetta or anag.dao.denominazione or ''
  755. # Ricerca listino_articolo
  756. listino = leggiListino(self.id_listino, idArticolo)
  757. #prezzo = listino["prezzoDettaglio"]
  758. listinoRiga = (self.id_listino, listino['denominazione'])
  759. prezzo = mN(listino["prezzoDettaglio"])
  760. prezzoScontato = prezzo
  761. tipoSconto = None
  762. if listino.has_key('scontiDettaglio'):
  763. if len(listino["scontiDettaglio"]) > 0:
  764. valoreSconto = listino['scontiDettaglio'][0].valore or 0
  765. if valoreSconto == 0:
  766. tipoSconto = None
  767. prezzoScontato = prezzo
  768. else:
  769. tipoSconto = listino['scontiDettaglio'][0].tipo_sconto
  770. if tipoSconto == "percentuale":
  771. prezzoScontato = mN(mN(prezzo) - (mN(prezzo) * mN(valoreSconto)) / 100)
  772. else:
  773. prezzoScontato = mN(mN(prezzo) -mN(valoreSconto))
  774. quantita = 1
  775. self.activate_item(idArticolo,
  776. listinoRiga,
  777. codiceABarre,
  778. codice or '',
  779. descrizione,
  780. prezzo,
  781. valoreSconto,
  782. tipoSconto,
  783. prezzoScontato,
  784. quantita)
  785. self.prezzo_entry.grab_focus()
  786. #try:
  787. #if Environment.conf.VenditaDettaglio.direct_confirm == "yes":
  788. self.on_confirm_button_clicked(self.getTopLevel())
  789. self.refreshTotal()
  790. #except:
  791. #pass
  792. from promogest.ui.RicercaComplessaArticoli import RicercaComplessaArticoli
  793. codiceABarre = self.codice_a_barre_entry.get_text()
  794. codice = self.codice_entry.get_text()
  795. descrizione = self.descrizione_entry.get_text()
  796. anag = RicercaComplessaArticoli(codiceABarre = codiceABarre,
  797. codice = codice,
  798. denominazione=descrizione)
  799. anag.setTreeViewSelectionType(GTK_SELECTIONMODE_SINGLE)
  800. anagWindow = anag.getTopLevel()
  801. anagWindow.connect("hide",
  802. on_ricerca_articolo_hide, anag)
  803. anagWindow.set_transient_for(self.getTopLevel())
  804. anagWindow.show_all()
  805. def on_new_button_clicked(self, button):
  806. """ open the anagraficaArticolo Semplice to add a new article
  807. """
  808. return
  809. from promogest.ui.AnagraficaArticoliSemplice import AnagraficaArticoliSemplice
  810. anag = AnagraficaArticoliSemplice()
  811. anagWindow = anag.getTopLevel()
  812. showAnagraficaRichiamata(self.getTopLevel(), anagWindow, button)
  813. def ricercaListino(self):
  814. """ check if there is a priceList like setted on configure file
  815. """
  816. if hasattr(Environment.conf, "VenditaDettaglio"):
  817. if hasattr(Environment.conf.VenditaDettaglio,"listino"):
  818. pricelist = Listino().select(denominazione = Environment.conf.VenditaDettaglio.listino,
  819. offset = None,
  820. batchSize = None)
  821. else:
  822. pricelist = Listino().select(id=setconf("VenditaDettaglio", "listino_vendita"))
  823. else:
  824. pricelist = Listino().select(id=setconf("VenditaDettaglio", "listino_vendita"))
  825. if pricelist:
  826. id_listino = pricelist[0].id
  827. else:
  828. id_listino = None
  829. return id_listino
  830. def on_total_button_grab_focus(self, button):
  831. totale_scontrino = mN(self.label_totale.get_text())
  832. if self.contanti_entry.get_text() != '':
  833. totale_pagamento = mN(self.contanti_entry.get_text())
  834. elif self.non_contanti_entry.get_text() != '':
  835. totale_pagamento = mN(self.non_contanti_entry.get_text())
  836. else:
  837. totale_pagamento = 0
  838. resto = totale_pagamento - totale_scontrino
  839. self.label_resto.set_markup('<b><span size="xx-large">'+ italianizza(resto) +'</span></b>')
  840. if self.total_button.is_focus():
  841. self.on_total_button_clicked(button)
  842. def on_contanti_radio_button_clicked(self, button):
  843. #predisposizione per il pagamento con contanti
  844. if self.total_button.get_property('sensitive'):
  845. self.contanti_entry.set_sensitive(True)
  846. self.contanti_entry.grab_focus()
  847. self.non_contanti_entry.set_text('')
  848. self.card_type_combobox.set_sensitive(False)
  849. self.non_contanti_entry.set_sensitive(False)
  850. else:
  851. self.contanti_entry.set_sensitive(False)
  852. self.card_type_combobox.set_sensitive(False)
  853. self.non_contanti_entry.set_sensitive(False)
  854. self.refreshTotal()
  855. def on_non_contanti_clicked(self):
  856. #predisposizione per il pagamento non in contanti
  857. if self.total_button.get_property('sensitive'):
  858. self.non_contanti_entry.set_sensitive(True)
  859. self.card_type_combobox.set_sensitive(True)
  860. self.non_contanti_entry.grab_focus()
  861. self.non_contanti_entry.set_text(str(self.refreshTotal()[0]))
  862. self.contanti_entry.set_text('')
  863. self.contanti_entry.set_sensitive(False)
  864. else:
  865. self.contanti_entry.set_sensitive(False)
  866. self.non_contanti_entry.set_sensitive(False)
  867. self.card_type_combobox.set_sensitive(False)
  868. self.refreshTotal()
  869. def on_assegni_radio_button_clicked(self, button):
  870. #predisposizione per il pagamento con assegni
  871. self.on_non_contanti_clicked()
  872. def on_carta_di_credito_radio_button_clicked(self, button):
  873. #predisposizione per il pagamento con carta di credito
  874. self.on_non_contanti_clicked()
  875. def setPagamento(self, enabled = False):
  876. self.contanti_radio_button.set_active(True)
  877. self.contanti_entry.set_text('')
  878. self.non_contanti_entry.set_text('')
  879. self.non_contanti_entry.set_sensitive(False)
  880. self.contanti_entry.set_sensitive(enabled)
  881. def on_vendita_dettaglio_window_close(self, widget, event=None):
  882. if self.shop:
  883. if YesNoDialog('Confermi la chiusura?', self.getTopLevel()):
  884. self.hide()
  885. Environment.pg2log.info("CHIUDO IL MODULO DI GESTIONE NEGOZIO APERTO CON SHOP")
  886. gtk.main_quit()
  887. else:
  888. return
  889. else:
  890. self.destroy()
  891. return None
  892. def createFileToPos(self, dao):
  893. if DRIVER == "E":
  894. print "DRIVER OLIVETTI"
  895. filescontrino = ElaExecute().create_export_file(daoScontrino=dao)
  896. elif DRIVER =="D":
  897. print "DRIVER DITRON"
  898. filescontrino = Ditron().create_export_file(daoScontrino=dao)
  899. Ditron().sendToPrint(filescontrino)
  900. return True
  901. else:
  902. print " WHAT ELSE?"
  903. def on_chiusura_fiscale_activate(self, widget):
  904. # if DRIVER=="D":
  905. anag = GestioneChiusuraFiscale(self) #.chiusuraDialog(widget, self.id_magazzino)
  906. #anag.set_transient_for(self)
  907. anagWindow = anag.getTopLevel()
  908. #anagWindow.connect("destroy", on_anagrafica_destroyed, [window, button,mainClass])
  909. #anagWindow.connect("hide", on_anagrafica_destroyed, [window, button,mainClass])
  910. anagWindow.set_transient_for(self.getTopLevel())
  911. anagWindow.show_all()
  912. def on_stampa_del_giornale_breve_activate(self, widget):
  913. if DRIVER =="D":
  914. Ditron().stampa_del_giornale_breve()
  915. def on_stampa_del_periodico_cassa_activate(self, widget):
  916. if DRIVER =="D":
  917. Ditron().stampa_del_periodico_cassa()
  918. def on_stampa_del_periodico_reparti_activate(self, widget):
  919. if DRIVER =="D":
  920. Ditron().stampa_del_periodico_reparti()
  921. def on_stampa_del_periodico_articoli_activate(self, widget):
  922. if DRIVER =="D":
  923. Ditron().stampa_del_periodico_articoli()
  924. def on_stampa_della_affluenza_oraria_activate(self, widget):
  925. if DRIVER =="D":
  926. Ditron().stampa_della_affluenza_oraria()
  927. def on_apri_cassetto_button_clicked(self, button):
  928. if DRIVER =="E":
  929. try: # vecchio stile ...adattamento ai dati in setconf
  930. path = Environment.conf.VenditaDettaglio.export_path
  931. except: # prendo la cartella temp standard
  932. path = Environment.tempDir
  933. filename = path+\
  934. "apri_cassetto.txt"
  935. f = file(filename, 'w')
  936. f.write("912 ; 1\n")
  937. f.close()
  938. #g = file(filename, 'rb')
  939. #g.close()
  940. return ElaExecute().copyToInDir(filename)
  941. def creaScontrinoReso(self):
  942. treeview = self.scontrino_treeview
  943. model = treeview.get_model()
  944. if not(len(self.idRhesusSource) > 0):
  945. return
  946. ts = TestataScontrino().getRecord(id=self.idRhesusSource[0])
  947. for r in ts.righe:
  948. idArticolo = r.id_articolo
  949. codiceArticolo = r.codice_articolo or ''
  950. codiceABarre = r.codice_a_barre or ''
  951. descrizione = r.descrizione or ''
  952. prezzo = mN(r.prezzo or 0)
  953. quantita = -1 * mN(r.quantita or 0)
  954. tipoSconto = None
  955. sconto = mN(r.valore_sconto or 0)
  956. prezzoScontato = mN(r.prezzo_scontato or 0)
  957. if sconto != 0:
  958. if r.tipo_sconto == 'percentuale':
  959. tipoSconto = self._simboloPercentuale
  960. else:
  961. tipoSconto = self._simboloEuro
  962. listinoRiga = ""
  963. model.append((idArticolo,
  964. str(listinoRiga),
  965. str(codiceABarre),
  966. str(codiceArticolo),
  967. descrizione,
  968. str(prezzo),
  969. str(sconto),
  970. str(tipoSconto),
  971. str(prezzoScontato),
  972. str(quantita),
  973. self.rowBackGround,
  974. self.rowBoldFont))
  975. notEmpty = (len(model) > 0)
  976. self.total_button.set_sensitive(notEmpty)
  977. self.empty_button.set_sensitive(notEmpty)
  978. self.setPagamento(enabled = notEmpty)
  979. self.search_button.set_sensitive(True)
  980. # Calcolo totali
  981. self.refreshTotal()
  982. # vado in search
  983. self.empty_current_row()
  984. self._state = 'search'
  985. self.codice_a_barre_entry.grab_focus()
  986. def on_scontrino_treeview_button_press_event(self, treeview, event):
  987. if event.button == 3:
  988. x = int(event.x)
  989. y = int(event.y)
  990. time = event.time
  991. pthinfo = treeview.get_path_at_pos(x, y)
  992. if pthinfo is not None:
  993. path, col, cellx, celly = pthinfo
  994. treeview.grab_focus()
  995. treeview.set_cursor(path, col, 0)
  996. self.file_menu.popup(None, None, None, event.button, time)
  997. return 1
  998. def createPopupMenu(self):
  999. self.file_menu = gtk.Menu() # Don't need to show menus
  1000. # Create the menu items
  1001. open_item = gtk.MenuItem("Conferma")
  1002. #save_item = gtk.MenuItem("Cancella")
  1003. quit_item = gtk.MenuItem("Annulla")
  1004. # Add them to the menu
  1005. self.file_menu.append(open_item)
  1006. self.file_menu.append(quit_item)
  1007. open_item.connect_object

Large files files are truncated, but you can click here to view the full file