PageRenderTime 30ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://promogest.googlecode.com/
Python | 1345 lines | 1103 code | 82 blank | 160 comment | 44 complexity | 41a2ed0ea2d0151db362da2afe03148b 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 by Promotux
  3. # di Francesco Meloni snc - http://www.promotux.it/
  4. # Author: Francesco Meloni <francesco@promotux.it>
  5. # Author: Francesco Marella <francesco.marella@gmail.com>
  6. # This file is part of Promogest.
  7. # Promogest is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 2 of the License, or
  10. # (at your option) any later version.
  11. # Promogest is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. # You should have received a copy of the GNU General Public License
  16. # along with Promogest. If not, see <http://www.gnu.org/licenses/>.
  17. from promogest.ui.utils import *
  18. from promogest.ui.gtk_compat import *
  19. import os, popen2
  20. import gtkhtml2
  21. from promogest.dao.DaoUtils import giacenzaSel
  22. from datetime import datetime, timedelta
  23. from promogest import Environment
  24. from promogest.ui.GladeWidget import GladeWidget
  25. from promogest.dao.TestataMovimento import TestataMovimento
  26. from promogest.dao.RigaMovimento import RigaMovimento
  27. from promogest.dao.ScontoRigaMovimento import ScontoRigaMovimento
  28. from promogest.modules.VenditaDettaglio.dao.TestataScontrino import TestataScontrino
  29. from promogest.modules.VenditaDettaglio.dao.RigaScontrino import RigaScontrino
  30. from promogest.modules.VenditaDettaglio.dao.ScontoRigaScontrino import ScontoRigaScontrino
  31. from promogest.modules.VenditaDettaglio.dao.ChiusuraFiscale import ChiusuraFiscale
  32. from promogest.dao.Articolo import Articolo
  33. from promogest.dao.CodiceABarreArticolo import CodiceABarreArticolo
  34. from promogest.dao.AliquotaIva import AliquotaIva
  35. from promogest.dao.Magazzino import Magazzino
  36. from promogest.dao.Listino import Listino
  37. from promogest.dao.ListinoArticolo import ListinoArticolo
  38. from promogest.ui.widgets.FilterWidget import FilterWidget
  39. from GestioneScontrini import GestioneScontrini
  40. from GestioneChiusuraFiscale import GestioneChiusuraFiscale
  41. class AnagraficaVenditaDettaglio(GladeWidget):
  42. """ Frame per la gestione delle vendite a dettaglio """
  43. def __init__(self):
  44. GladeWidget.__init__(self, 'vendita_dettaglio_window',
  45. fileName='promogest/modules/VenditaDettaglio/gui/vendita_dettaglio_window.glade',
  46. isModule=True)
  47. self.placeWindow(self.getTopLevel())
  48. self._currentRow = {}
  49. self._simboloPercentuale = '%'
  50. self._simboloEuro = '€'
  51. textStatusBar = " ***** PromoGest2 - Vendita Dettaglio - by PromoTUX Informatica - 800 034561 - www.promogest.me - info@PromoTUX.it ***** "
  52. context_id = self.vendita_dettaglio_statusbar.get_context_id("vendita_dettaglio_window")
  53. self.vendita_dettaglio_statusbar.push(context_id,textStatusBar)
  54. azienda = Azienda().getRecord(id=Environment.params["schema"])
  55. self.logo_articolo.set_from_file(azienda.percorso_immagine)
  56. self.createPopupMenu()
  57. #nascondo i dati riga e le info aggiuntive
  58. self.dati_riga_frame.destroy()
  59. self.draw()
  60. def draw(self):
  61. accelGroup = gtk.AccelGroup()
  62. self.getTopLevel().add_accel_group(accelGroup)
  63. self.contanti_radio_button.add_accelerator('clicked', accelGroup, GDK_KEY_F1 , 0, GTK_ACCEL_VISIBLE)
  64. self.assegni_radio_button.add_accelerator('clicked', accelGroup, GDK_KEY_F2, 0, GTK_ACCEL_VISIBLE)
  65. self.carta_di_credito_radio_button.add_accelerator('clicked', accelGroup, GDK_KEY_F3, 0, GTK_ACCEL_VISIBLE)
  66. self.total_button.add_accelerator('grab_focus', accelGroup, GDK_KEY_F5, 0, GTK_ACCEL_VISIBLE)
  67. self.total_button.set_focus_on_click(False)
  68. # Costruisco treeview scontrino
  69. self.modelRiga = gtk.ListStore(int,str, str, str, str, str, str, str, str, str)
  70. treeview = self.scontrino_treeview
  71. rendererSx = gtk.CellRendererText()
  72. rendererDx = gtk.CellRendererText()
  73. rendererDx.set_property('xalign', 1)
  74. self.lsmodel = gtk.ListStore(int, str)
  75. cellcombo1= gtk.CellRendererCombo()
  76. cellcombo1.set_property("editable", True)
  77. cellcombo1.set_property("visible", True)
  78. cellcombo1.set_property("text-column", 1)
  79. cellcombo1.set_property("editable", True)
  80. cellcombo1.set_property("has-entry", False)
  81. cellcombo1.set_property("model", self.lsmodel)
  82. cellcombo1.connect('edited', self.on_column_listinoRiga_edited, treeview, True)
  83. column = gtk.TreeViewColumn('List.', cellcombo1, text=1)
  84. column.set_sizing(GTK_COLUMN_GROWN_ONLY)
  85. column.set_clickable(True)
  86. column.set_resizable(True)
  87. column.set_expand(False)
  88. column.set_min_width(20)
  89. treeview.append_column(column)
  90. column = gtk.TreeViewColumn('Codice a barre', rendererSx, text=2)
  91. column.set_sizing(GTK_COLUMN_GROWN_ONLY)
  92. column.set_clickable(False)
  93. column.set_resizable(True)
  94. column.set_expand(False)
  95. column.set_min_width(90)
  96. treeview.append_column(column)
  97. column = gtk.TreeViewColumn('Codice', rendererSx, text=3)
  98. column.set_sizing(GTK_COLUMN_GROWN_ONLY)
  99. column.set_clickable(False)
  100. column.set_resizable(True)
  101. column.set_expand(False)
  102. column.set_min_width(70)
  103. treeview.append_column(column)
  104. cellrendererDescrizione = gtk.CellRendererText()
  105. cellrendererDescrizione.set_property("editable", True)
  106. cellrendererDescrizione.set_property("visible", True)
  107. cellrendererDescrizione.connect('edited', self.on_column_descrizione_edited, treeview, True)
  108. column = gtk.TreeViewColumn('Descrizione', cellrendererDescrizione, text=4)
  109. column.set_sizing(GTK_COLUMN_GROWN_ONLY)
  110. column.set_clickable(True)
  111. rendererSx.connect('edited', self.on_column_descrizione_edited, treeview, True)
  112. column.set_resizable(True)
  113. column.set_expand(True)
  114. column.set_min_width(50)
  115. treeview.append_column(column)
  116. cellspin = gtk.CellRendererSpin()
  117. cellspin.set_property("editable", True)
  118. cellspin.set_property("visible", True)
  119. adjustment = gtk.Adjustment(1, 1, 1000,0.500,2)
  120. cellspin.set_property("adjustment", adjustment)
  121. cellspin.set_property("digits",3)
  122. cellspin.set_property("climb-rate",3)
  123. #cellspin.set_property("foreground", "orange")
  124. cellspin.connect('edited', self.on_column_prezzo_edited, treeview, True)
  125. column = gtk.TreeViewColumn('Prezzo', cellspin, text=5,foreground=4, background=2)
  126. column.set_sizing(GTK_COLUMN_GROWN_ONLY)
  127. #column.set_clickable(False)
  128. column.set_resizable(True)
  129. column.set_expand(False)
  130. column.set_min_width(80)
  131. treeview.append_column(column)
  132. cellspinsconto = gtk.CellRendererSpin()
  133. cellspinsconto.set_property("editable", True)
  134. cellspinsconto.set_property("visible", True)
  135. adjustment = gtk.Adjustment(1, 1, 1000,1,2)
  136. cellspinsconto.set_property("adjustment", adjustment)
  137. #cellspin.set_property("digits",3)
  138. #cellspin.set_property("climb-rate",3)
  139. cellspinsconto.connect('edited', self.on_column_sconto_edited, treeview, True)
  140. column = gtk.TreeViewColumn('Sconto', cellspinsconto, text=6)
  141. column.set_sizing(GTK_COLUMN_GROWN_ONLY)
  142. column.set_clickable(True)
  143. column.set_resizable(True)
  144. column.set_expand(False)
  145. column.set_min_width(50)
  146. treeview.append_column(column)
  147. lsmodel = gtk.ListStore(str)
  148. lsmodel.append(["%"])
  149. lsmodel.append(["€"])
  150. cellcombo= gtk.CellRendererCombo()
  151. cellcombo.set_property("editable", True)
  152. cellcombo.set_property("visible", True)
  153. cellcombo.set_property("text-column", 0)
  154. cellcombo.set_property("editable", True)
  155. cellcombo.set_property("has-entry", False)
  156. cellcombo.set_property("model", lsmodel)
  157. cellcombo.connect('edited', self.on_column_tipo_edited, treeview, True)
  158. column = gtk.TreeViewColumn('Tipo', cellcombo, text=7)
  159. column.set_sizing(GTK_COLUMN_GROWN_ONLY)
  160. column.set_clickable(True)
  161. column.set_resizable(True)
  162. column.set_expand(False)
  163. column.set_min_width(20)
  164. treeview.append_column(column)
  165. column = gtk.TreeViewColumn('Pr.Scont', rendererDx, text=8)
  166. column.set_sizing(GTK_COLUMN_GROWN_ONLY)
  167. column.set_clickable(False)
  168. column.set_resizable(True)
  169. column.set_expand(False)
  170. column.set_min_width(50)
  171. treeview.append_column(column)
  172. cellspin = gtk.CellRendererSpin()
  173. cellspin.set_property("editable", True)
  174. cellspin.set_property("visible", True)
  175. adjustment = gtk.Adjustment(1, 1, 1000,1,2)
  176. cellspin.set_property("adjustment", adjustment)
  177. cellspin.set_property("digits",2)
  178. cellspin.set_property("climb-rate",3)
  179. cellspin.connect('edited', self.on_column_quantita_edited, treeview, True)
  180. column = gtk.TreeViewColumn('Quantitŕ', cellspin, text=9)
  181. column.set_sizing(GTK_COLUMN_GROWN_ONLY)
  182. #column.set_clickable(False)
  183. column.set_resizable(True)
  184. column.set_expand(False)
  185. column.set_min_width(50)
  186. treeview.append_column(column)
  187. treeview.set_model(self.modelRiga)
  188. # Disabilito bottoni e text entry
  189. #self.confirm_button.set_sensitive(False)
  190. self.delete_button.set_sensitive(False)
  191. self.rhesus_button.set_sensitive(False)
  192. #self.annulling_button.set_sensitive(False)
  193. self.total_button.set_sensitive(False)
  194. self.empty_button.set_sensitive(False)
  195. self.setPagamento(enabled = False)
  196. self.codice_a_barre_entry.grab_focus()
  197. self._loading = False
  198. # Segnali
  199. treeViewSelection = self.scontrino_treeview.get_selection()
  200. self.scontrino_treeview.set_property('rules-hint',True)
  201. treeViewSelection.connect('changed', self.on_scontrino_treeview_selection_changed)
  202. # Ricerca listino
  203. self.id_listino = self.ricercaListino()
  204. # Ricerca magazzino
  205. magalist = Magazzino().select(denominazione = Environment.conf.VenditaDettaglio.magazzino,
  206. offset = None,
  207. batchSize = None)
  208. if len(magalist) > 0:
  209. self.id_magazzino = magalist[0].id
  210. else:
  211. self.id_magazzino = None
  212. # Vado in stato di ricerca
  213. self._state = 'search'
  214. self.empty_current_row()
  215. def on_column_prezzo_edited(self, cell, path, value, treeview, editNext=True):
  216. """ Function to set the value prezzo edit in the cell"""
  217. model = treeview.get_model()
  218. value=value.replace(",",".")
  219. value = mN(value)
  220. model[path][5] = value
  221. if model[path][7] == '%':
  222. tipoSconto = "percentuale"
  223. else:
  224. tipoSconto = "valore"
  225. if model[path][6]== 0 or not model[path][5]:
  226. tipoSconto = None
  227. model[path][8] = model[path][5]
  228. else:
  229. if tipoSconto == "percentuale":
  230. prezzoscontato = mN(model[path][5]) - (mN(model[path][5]) * mN(model[path][6])) / 100
  231. else:
  232. prezzoscontato = mN(model[path][5]) -mN(model[path][6])
  233. if not prezzoscontato:
  234. prezzoscontato = "0.00"
  235. model[path][8] = prezzoscontato
  236. self.refreshTotal()
  237. self.on_cancel_button_clicked(self.getTopLevel)
  238. def on_column_sconto_edited(self, cell, path, value, treeview, editNext=True):
  239. model = treeview.get_model()
  240. model[path][6] = value
  241. prez = model[path][5]
  242. self.on_column_prezzo_edited(cell, path, prez, treeview)
  243. def on_column_listinoRiga_edited(self, cell, path, value, treeview, editNext=True):
  244. #rivedere assolutamente .....
  245. model = treeview.get_model()
  246. model[path][1] = value
  247. listin = {}
  248. for l in self.lsmodel:
  249. if l[1] == value:
  250. idlisti=l[0]
  251. listin = leggiListino(l[0],model[path][0] )
  252. break
  253. prez = str(listin['prezzoDettaglio'])
  254. if listin.has_key('scontiDettaglio'):
  255. if len(listin["scontiDettaglio"]) > 0:
  256. model[path][6]= listin['scontiDettaglio'][0].valore or 0
  257. else:
  258. model[path][6] = 0
  259. self.on_column_prezzo_edited(cell, path, prez, treeview)
  260. def on_column_quantita_edited(self, cell, path, value, treeview, editNext=True):
  261. """ Function ti set the value quantita edit in the cell """
  262. model = treeview.get_model()
  263. value=value.replace(",",".")
  264. value = mN(value)
  265. model[path][9] = value
  266. self.refreshTotal()
  267. self.on_cancel_button_clicked(self.getTopLevel)
  268. def on_column_descrizione_edited(self, cell, path, value, treeview, editNext=True):
  269. """ Function ti set the value quantita edit in the cell """
  270. model = treeview.get_model()
  271. model[path][4] = value
  272. self.on_cancel_button_clicked(self.getTopLevel)
  273. def on_column_tipo_edited(self, cell, path, value, treeview, editNext=True):
  274. """ Function ti set the value quantita edit in the cell"""
  275. model = treeview.get_model()
  276. model[path][7] = value
  277. scont = model[path][6]
  278. self.on_column_sconto_edited(cell, path, scont, treeview)
  279. def on_vendita_dettaglio_window_key_press_event(self,widget, event):
  280. """ jolly key č F9, richiama ed inserisce l'articolo definito nel configure"""
  281. keyname = gdk_keyval_name(event.keyval)
  282. if keyname == 'F9':
  283. try:
  284. codice = Environment.conf.VenditaDettaglio.jolly
  285. self.search_item(codice=codice, fnove=True)
  286. except:
  287. print "ARTICOLO JOLLY NON SETTATO NEL CONFIGURE NELLA SEZIONE [VenditaDettaglio]"
  288. def fnovewidget(self):
  289. dialog = gtk.MessageDialog(self.getTopLevel(),
  290. GTK_DIALOG_MODAL,
  291. | GTK_DIALOG_DESTROY_WITH_PARENT,
  292. GTK_DIALOG_MESSAGE_INFO , GTK_BUTTONS_OK)
  293. dialog.set_markup("""<b>ARTICOLO GENERICO</b>: Inserire Quantitŕ e Prezzo""")
  294. hbox = gtk.HBox()
  295. entry = self.createSignedDecimalEntryField(None,None,10,0)
  296. entry.set_text("1.00")
  297. entry1 = self.createSignedMoneyEntryField(None,None,10,0)
  298. labelMoney = gtk.Label()
  299. labelMoney.set_markup("<b> Quantitŕ</b>")
  300. labelMoney1 = gtk.Label()
  301. labelMoney1.set_markup("<b> Prezzo </b>")
  302. hbox.pack_start(labelMoney, False, False, 0)
  303. hbox.pack_start(entry, False, False, 0)
  304. hbox1 = gtk.HBox()
  305. hbox1.pack_start(labelMoney1, False, False, 0)
  306. hbox1.pack_start(entry1, False, False, 0)
  307. dialog.vbox.pack_start(hbox1, False, False, 0)
  308. dialog.vbox.pack_start(hbox, False, False, 0)
  309. dialog.show_all()
  310. response = dialog.run()
  311. dialog.destroy()
  312. quantita = entry.get_text().strip()
  313. prezzo = mN(entry1.get_text())
  314. return ( quantita,prezzo )
  315. def search_item(self, codiceABarre=None, codice=None, descrizione=None, fnove=False):
  316. # Ricerca articolo per barcode
  317. if codiceABarre is not None:
  318. arts = Articolo().select( codiceABarre = codiceABarre,
  319. offset = None,
  320. batchSize = None)
  321. elif codice is not None:
  322. arts = Articolo().select( codice = codice,
  323. offset = None,
  324. batchSize = None)
  325. elif descrizione is not None:
  326. arts = Articolo().select( denominazione = descrizione,
  327. offset = None,
  328. batchSize = None)
  329. if len(arts) == 1:
  330. idArticolo = arts[0].id
  331. codice = arts[0].codice or ''
  332. codiceABarre = arts[0].codice_a_barre or ''
  333. descrizione = arts[0].descrizione_etichetta or arts[0].denominazione or ''
  334. # Ricerca listino_articolo
  335. listino = leggiListino(self.id_listino, idArticolo)
  336. if fnove:
  337. valorigenerici = self.fnovewidget()
  338. quantita = valorigenerici[0] or 1
  339. prezzo = mN(valorigenerici[1]) or 0
  340. else:
  341. prezzo = mN(listino["prezzoDettaglio"])
  342. quantita = 1
  343. listinoRiga = (self.id_listino,listino['denominazione'])
  344. prezzoScontato = prezzo
  345. valoreSconto = 0
  346. tipoSconto = None
  347. if listino.has_key('scontiDettaglio'):
  348. if len(listino["scontiDettaglio"]) > 0:
  349. valoreSconto = listino['scontiDettaglio'][0].valore or 0
  350. if valoreSconto == 0:
  351. tipoSconto = None
  352. prezzoScontato = prezzo
  353. else:
  354. tipoSconto = listino['scontiDettaglio'][0].tipo_sconto
  355. if tipoSconto == "percentuale":
  356. prezzoScontato = mN(mN(prezzo) - (mN(prezzo) * mN(valoreSconto)) / 100)
  357. else:
  358. prezzoScontato = mN(mN(prezzo) -mN(valoreSconto))
  359. self.codice_a_barre_entry.set_text(codiceABarre)
  360. self.codice_entry.set_text(codice)
  361. self.activate_item(idArticolo, listinoRiga, codiceABarre,codice,
  362. descrizione, prezzo, valoreSconto,tipoSconto,
  363. prezzoScontato, quantita)
  364. #self.confirm_button.grab_focus()
  365. #if not fnove:
  366. self.on_confirm_button_clicked(self.getTopLevel())
  367. self.refreshTotal()
  368. else:
  369. self.ricercaArticolo()
  370. def on_search_button_clicked(self, button):
  371. self.ricercaArticolo()
  372. def on_codice_a_barre_entry_activate(self, text_entry):
  373. if self.codice_a_barre_entry.get_text() != '':
  374. self.search_item(codiceABarre = prepareFilterString(self.codice_a_barre_entry.get_text()))
  375. return True
  376. def on_codice_entry_activate(self,text_entry):
  377. if self.codice_entry.get_text() != '':
  378. self.search_item(codice = prepareFilterString(self.codice_entry.get_text()))
  379. return True
  380. def on_descrizione_entry_activate(self,text_entry):
  381. if self.descrizione_entry.get_text() != '':
  382. self.search_item(descrizione = prepareFilterString(self.descrizione_entry.get_text()))
  383. return True
  384. def setDao(self, dao):
  385. if dao is None:
  386. # Crea un nuovo Dao vuoto
  387. self.dao = ListinoArticolo()
  388. else:
  389. # Ricrea il Dao con una connessione al DBMS SQL
  390. self.dao = ListinoArticolo().select(idListino=dao.id_listino,
  391. idArticolo=dao.id_articolo,
  392. orderBy=ListinoArticolo.id_articolo)[0]
  393. self._refresh()
  394. def empty_current_row(self):
  395. self._currentRow['idArticolo'] = None
  396. self._currentRow['listinoRiga'] = (None,None)
  397. self._currentRow['codiceABarre'] = None
  398. self._currentRow['codice'] = None
  399. self._currentRow['descrizione'] = None
  400. self._currentRow['prezzo'] = 0
  401. self._currentRow['valoreSconto'] = 0
  402. self._currentRow['tipoSconto'] = None
  403. self._currentRow['prezzoScontato'] = 0
  404. self._currentRow['quantita'] = 0
  405. self.codice_a_barre_entry.set_text('')
  406. self.codice_entry.set_text('')
  407. self.descrizione_entry.set_text('')
  408. self.descrizione_label.set_text('')
  409. self.prezzo_entry.set_text('')
  410. self.sconto_entry.set_text('')
  411. self.prezzo_scontato_entry.set_text('')
  412. self.quantita_entry.set_text('')
  413. self.listini_combobox.clear()
  414. self.id_listino = self.ricercaListino()
  415. self.giacenza_label.set_text('-')
  416. def activate_item(self, idArticolo,listinoRiga,codiceABarre,codice,denominazione,
  417. prezzo,valoreSconto,tipoSconto,prezzoScontato,quantita):
  418. self._loading = True
  419. self.lsmodel.clear()
  420. #fillComboboxListiniFiltrati(self.listini_combobox,
  421. #idArticolo=idArticolo,
  422. #idMagazzino=None,
  423. #idCliente=None,
  424. #filter=False)
  425. listiniList= listinoCandidateSel(idArticolo=idArticolo,
  426. idMagazzino=self.id_magazzino ,
  427. idCliente=None)
  428. if listiniList:
  429. for l in listiniList:
  430. self.lsmodel.append([l.id,l.denominazione])
  431. if self.id_listino is not None:
  432. findComboboxRowFromId(self.listini_combobox, self.id_listino)
  433. else:
  434. self.listini_combobox.set_active(1)
  435. try:
  436. self.id_listino = findIdFromCombobox(self.listini_combobox)
  437. if prezzo == 0:
  438. listino = leggiListino(self.id_listino, idArticolo)
  439. prezzo = mN(listino["prezzoDettaglio"])
  440. prezzoScontato = prezzo
  441. valoreSconto = 0
  442. except:
  443. pass
  444. self._loading = False
  445. if tipoSconto == "percentuale":
  446. tipoSconto = "%"
  447. elif tipoSconto == "valore":
  448. tipoSconto = "€"
  449. else:
  450. tipoSconto = ""
  451. self.rhesus_button.set_sensitive(True)
  452. #self.annulling_button.set_sensitive(True)
  453. self._currentRow = {'idArticolo' : idArticolo,
  454. 'listinoRiga' : listinoRiga,
  455. 'codiceABarre' : codiceABarre,
  456. 'codice' : codice,
  457. 'descrizione' : denominazione,
  458. 'prezzo' : prezzo,
  459. 'valoreSconto' : valoreSconto,
  460. 'tipoSconto' : tipoSconto,
  461. 'prezzoScontato':prezzoScontato,
  462. 'quantita' : quantita}
  463. def on_scontrino_treeview_selection_changed(self, treeSelection):
  464. (model, iterator) = treeSelection.get_selected()
  465. if iterator is not None:
  466. self.delete_button.set_sensitive(True)
  467. #self.confirm_button.set_sensitive(True)
  468. self.rhesus_button.set_sensitive(True)
  469. #self.annulling_button.set_sensitive(True)
  470. self.search_button.set_sensitive(False)
  471. self.codice_a_barre_entry.set_sensitive(False)
  472. self.codice_entry.set_sensitive(False)
  473. self.descrizione_entry.set_sensitive(False)
  474. # Vado in editing
  475. self._state = 'editing'
  476. treeview = self.scontrino_treeview
  477. model = treeview.get_model()
  478. self.currentIteratorRow = iterator
  479. listinoRiga = model.get_value(self.currentIteratorRow, 1)
  480. idArticolo = model.get_value(self.currentIteratorRow, 0)
  481. self._quantita = model.get_value(self.currentIteratorRow, 9)
  482. self.lsmodel.clear()
  483. listiniList = listinoCandidateSel(idArticolo=idArticolo,
  484. idMagazzino=self.id_magazzino)
  485. listinoPref = Listino().select(idListino=self.id_listino)[0]
  486. self.lsmodel.append([listinoPref.id,listinoPref.denominazione])
  487. if listiniList:
  488. for l in listiniList:
  489. if l.denominazione != listinoPref.denominazione:
  490. self.lsmodel.append([l.id,l.denominazione])
  491. self.descrizione_label.set_markup('<b><span foreground="black" size="12000">'\
  492. +model.get_value(self.currentIteratorRow, 2)\
  493. + " - " \
  494. + model.get_value(self.currentIteratorRow, 3)\
  495. +" - " \
  496. +model.get_value(self.currentIteratorRow, 4)\
  497. +'</span></b>')
  498. self.refreshTotal()
  499. def on_confirm_button_clicked(self, button):
  500. # controllo che il prezzo non sia nullo
  501. if self._currentRow['prezzo'] == 0:
  502. dialog = gtk.MessageDialog(self.getTopLevel(),
  503. GTK_DIALOG_MODAL
  504. | GTK_DIALOG_DESTROY_WITH_PARENT,
  505. GTK_DIALOG_MESSAGE_WARNING, GTK_BUTTONS_OK)
  506. dialog.set_markup("<b>ATTENZIONE:\n</b>Inserire un prezzo all'articolo")
  507. response = dialog.run()
  508. dialog.destroy()
  509. #self.prezzo_entry.grab_focus()
  510. self._state == 'editing'
  511. #return
  512. treeview = self.scontrino_treeview
  513. model = treeview.get_model()
  514. if self._state == 'search':
  515. model.append((self._currentRow['idArticolo'],
  516. self._currentRow['listinoRiga'][1],
  517. self._currentRow['codiceABarre'],
  518. self._currentRow['codice'],
  519. self._currentRow['descrizione'],
  520. mN(self._currentRow['prezzo']),
  521. mN(self._currentRow['valoreSconto']),
  522. self._currentRow['tipoSconto'],
  523. mN(self._currentRow['prezzoScontato']),
  524. Decimal(self._currentRow['quantita'])))
  525. elif self._state == 'editing':
  526. model.set_value(self.currentIteratorRow, 0, self._currentRow['idArticolo'])
  527. model.set_value(self.currentIteratorRow, 1, self._currentRow['listinoRiga'][1])
  528. model.set_value(self.currentIteratorRow, 2, self._currentRow['codiceABarre'])
  529. model.set_value(self.currentIteratorRow, 3, self._currentRow['codice'])
  530. model.set_value(self.currentIteratorRow, 4, self._currentRow['descrizione'])
  531. model.set_value(self.currentIteratorRow, 5, mN(self._currentRow['prezzo']))
  532. model.set_value(self.currentIteratorRow, 6, mN(self._currentRow['valoreSconto']))
  533. model.set_value(self.currentIteratorRow, 7, self._currentRow['tipoSconto'])
  534. model.set_value(self.currentIteratorRow, 8, mN(self._currentRow['prezzoScontato']))
  535. model.set_value(self.currentIteratorRow, 9, Decimal(self._currentRow['quantita']))
  536. self.marginevalue_label.set_text('')
  537. self.ultimocostovalue_label.set_text('')
  538. self.empty_current_row()
  539. self.scontrino_treeview.scroll_to_cell(str(len(model)-1))
  540. self.righe_label.set_markup('<b>[ '+str(len(model)) +' ] Righe scontrino</b>')
  541. # Disabilito cancella e conferma e abilito ricerca barcode
  542. self.delete_button.set_sensitive(False)
  543. #self.confirm_button.set_sensitive(False)
  544. self.rhesus_button.set_sensitive(False)
  545. #self.annulling_button.set_sensitive(False)
  546. self.codice_a_barre_entry.set_sensitive(True)
  547. self.codice_entry.set_sensitive(True)
  548. self.descrizione_entry.set_sensitive(True)
  549. self.search_button.set_sensitive(True)
  550. # Abilito pulsante totale e annulla
  551. notEmpty = (len(model) > 0)
  552. self.total_button.set_sensitive(notEmpty)
  553. self.empty_button.set_sensitive(notEmpty)
  554. self.setPagamento(enabled = notEmpty)
  555. # Calcolo totali
  556. self.refreshTotal()
  557. treeview.get_selection().unselect_all()
  558. # vado in search
  559. self._state = 'search'
  560. self.codice_a_barre_entry.grab_focus()
  561. def on_cancel_button_clicked(self, button):
  562. self.empty_current_row()
  563. # Disabilito cancella e conferma e abilito ricerca barcode
  564. self.delete_button.set_sensitive(False)
  565. #self.confirm_button.set_sensitive(False)
  566. self.rhesus_button.set_sensitive(False)
  567. #self.annulling_button.set_sensitive(False)
  568. self.codice_a_barre_entry.set_sensitive(True)
  569. self.codice_entry.set_sensitive(True)
  570. self.descrizione_entry.set_sensitive(True)
  571. self.search_button.set_sensitive(True)
  572. treeview = self.scontrino_treeview
  573. model = treeview.get_model()
  574. # Abilito pulsante totale e annulla
  575. notEmpty = (len(model) > 0)
  576. self.total_button.set_sensitive(notEmpty)
  577. self.empty_button.set_sensitive(notEmpty)
  578. self.setPagamento(enabled = notEmpty)
  579. treeview.get_selection().unselect_all()
  580. # vado in search
  581. self._state = 'search'
  582. self.codice_a_barre_entry.grab_focus()
  583. def on_rhesus_button_clicked(self, button):
  584. selection = self.scontrino_treeview.get_selection()
  585. (model, iter) = selection.get_selected()
  586. quantita = model.get_value(iter, 9)
  587. model[iter][9]= Decimal(quantita)* -1
  588. self.refreshTotal()
  589. self.on_cancel_button_clicked(self.getTopLevel)
  590. def on_delete_button_clicked(self, button):
  591. treeview = self.scontrino_treeview
  592. model = treeview.get_model()
  593. model.remove(self.currentIteratorRow)
  594. # Se era l'ultima riga disabilito text box e pulsanti per totali
  595. notEmpty = (len(model) > 0)
  596. self.total_button.set_sensitive(notEmpty)
  597. self.empty_button.set_sensitive(notEmpty)
  598. self.setPagamento(enabled = notEmpty)
  599. # Disabilito cancella e conferma e abilito ricerca barcode
  600. self.delete_button.set_sensitive(False)
  601. #self.confirm_button.set_sensitive(False)
  602. self.rhesus_button.set_sensitive(False)
  603. #self.annulling_button.set_sensitive(False)
  604. self.codice_a_barre_entry.set_sensitive(True)
  605. self.codice_entry.set_sensitive(True)
  606. self.descrizione_entry.set_sensitive(True)
  607. self.search_button.set_sensitive(True)
  608. self.empty_current_row()
  609. # Calcolo totali
  610. self.refreshTotal()
  611. # vado in search
  612. self._state = 'search'
  613. self.codice_a_barre_entry.grab_focus()
  614. def refreshTotal(self):
  615. total = 0
  616. model = self.scontrino_treeview.get_model()
  617. for row in model:
  618. prezzo = mN(row[5]) or 0
  619. valoreSconto = mN(row[6]) or 0
  620. prezzoScontato = mN(row[8]) or 0
  621. quantita = Decimal(row[9])
  622. if valoreSconto == 0: #sconto
  623. total = total + (prezzo * quantita)
  624. else:
  625. total = total + (prezzoScontato * quantita)
  626. if not total:
  627. total = "0.00"
  628. self.label_totale.set_markup('<b><span foreground="black" size="38000">' + str(mN(total)) +'</span></b>')
  629. return total
  630. def on_empty_button_clicked(self, button):
  631. self.scontrino_treeview.get_model().clear()
  632. self.empty_current_row()
  633. self.label_totale.set_markup('<b><span foreground="black" size="38000">0.00</span></b>')
  634. self.label_resto.set_markup('<b><span foreground="black" size="24000">0.00</span></b>')
  635. self.empty_button.set_sensitive(False)
  636. self.total_button.set_sensitive(False)
  637. self.setPagamento(enabled = False)
  638. self.codice_a_barre_entry.grab_focus()
  639. def on_total_button_clicked(self, button):
  640. totale_scontrino = mN(self.refreshTotal())
  641. if totale_scontrino < 0:
  642. msg = 'Attenzione!\n\nIl totale non puo\' essere negativo !'
  643. messageError(msg=msg, transient=self.getTopLevel())
  644. return
  645. # Creo dao testata_scontrino
  646. dao = TestataScontrino()
  647. dao.totale_scontrino = totale_scontrino
  648. totale_contanti = 0
  649. totale_assegni = 0
  650. totale_carta_di_credito = 0
  651. if self.contanti_entry.get_text() != '':
  652. totale_contanti = mN(self.contanti_entry.get_text())
  653. resto = totale_contanti - dao.totale_scontrino
  654. self.label_resto.set_markup('<b><span foreground="black" size="24000">' + str(resto) +'</span></b>')
  655. if self.non_contanti_entry.get_text() != '':
  656. if self.assegni_radio_button.get_active():
  657. totale_assegni = mN(self.non_contanti_entry.get_text())
  658. else:
  659. totale_carta_di_credito = mN(self.non_contanti_entry.get_text())
  660. dao.totale_contanti = totale_contanti
  661. dao.totale_assegni = totale_assegni
  662. dao.totale_carta_credito = totale_carta_di_credito
  663. # Creo righe
  664. righe = []
  665. model = self.scontrino_treeview.get_model()
  666. for row in model:
  667. idArticolo = row[0]
  668. descrizione = row[4]
  669. prezzo = mN(row[5])
  670. valoreSconto = mN(row[6])
  671. tipoSconto = row[7]
  672. prezzoScontato = mN(row[8])
  673. quantita = Decimal(row[9])
  674. # Nuova riga
  675. daoRiga = RigaScontrino()
  676. daoRiga.id_testata_scontrino = dao.id
  677. daoRiga.id_articolo = idArticolo
  678. daoRiga.descrizione = descrizione
  679. daoRiga.prezzo = prezzo
  680. daoRiga.prezzo_scontato = prezzoScontato
  681. daoRiga.quantita = quantita
  682. listarighesconto = []
  683. if valoreSconto > 0:
  684. daoScontoRigaScontrino = ScontoRigaScontrino()
  685. daoScontoRigaScontrino.valore = valoreSconto
  686. if tipoSconto == self._simboloPercentuale:
  687. daoScontoRigaScontrino.tipo_sconto = 'percentuale'
  688. else:
  689. daoScontoRigaScontrino.tipo_sconto = 'valore'
  690. listarighesconto.append(daoScontoRigaScontrino)
  691. daoRiga.sconti=listarighesconto
  692. righe.append(daoRiga)
  693. # Aggiungo righe e salvo dao
  694. dao.righe = righe
  695. dao.persist()
  696. # Rileggo dao
  697. dao.update()
  698. # Creo il file
  699. filescontrino = self.create_export_file(dao)
  700. # Mando comando alle casse
  701. if hasattr(Environment.conf, "VenditaDettaglio"):
  702. if not(hasattr(Environment.conf.VenditaDettaglio,'disabilita_stampa') and \
  703. Environment.conf.VenditaDettaglio.disabilita_stampa == 'yes'):
  704. program_launch = Environment.conf.VenditaDettaglio.driver_command
  705. program_params = (' ' + filescontrino + ' ' +
  706. Environment.conf.VenditaDettaglio.serial_device)
  707. if os.name == 'nt':
  708. exportingProcessPid = os.spawnl(os.P_NOWAIT, program_launch, program_params)
  709. id, ret_value = os.waitpid(exportingProcessPid, 0)
  710. ret_value = ret_value >> 8
  711. else:
  712. command = program_launch + program_params
  713. process = popen2.Popen3(command, True)
  714. message = process.childerr.readlines()
  715. ret_value = process.wait()
  716. else:
  717. ret_value = 0
  718. # Elimino il file
  719. os.remove(filescontrino)
  720. if ret_value != 0:
  721. string_message = ''
  722. for s in message:
  723. string_message = string_message + s + "\n"
  724. # Mostro messaggio di errore
  725. messageError(msg=string_message, transient=self.getTopLevel())
  726. # Elimino lo scontrino
  727. dao.delete()
  728. # Svuoto transazione e mi rimetto in stato di ricerca
  729. self.search_button.set_sensitive(True)
  730. self.codice_a_barre_entry.set_sensitive(True)
  731. self.codice_entry.set_sensitive(True)
  732. self.descrizione_entry.set_sensitive(True)
  733. #self.confirm_button.set_sensitive(False)
  734. self.rhesus_button.set_sensitive(False)
  735. #self.annulling_button.set_sensitive(False)
  736. self.delete_button.set_sensitive(False)
  737. self.on_empty_button_clicked(self.empty_button)
  738. self.righe_label.set_markup('<b> [ 0 ] Righe scontrino</b>')
  739. self._state = 'search'
  740. #def on_chiusura_fiscale_activate(self, widget):
  741. # Chiedo conferma
  742. #GestioneChiusuraFiscale(self).chiusuraDialog(widget, self.id_magazzino)
  743. def create_export_file(self, daoScontrino):
  744. # Genero nome file
  745. filename = Environment.conf.VenditaDettaglio.export_path + str(daoScontrino.id) + datetime.today().strftime('%d_%m_%Y_%H_%M_%S')
  746. f = file(filename,'w')
  747. # nel file scontrino i resi vengono vengono messi alla fine (limitazione cassa) DITRON
  748. righe = []
  749. for riga in daoScontrino.righe:
  750. if riga.quantita < 0:
  751. righe.append(riga)
  752. else:
  753. righe.insert(0, riga)
  754. for riga in righe:
  755. quantita = abs(riga.quantita)
  756. if quantita != 1:
  757. # quantita' non unitaria
  758. stringa = '000000000000000000%09d00\r\n' % (quantita * 1000)
  759. f.write(stringa)
  760. if riga.quantita < 0:
  761. # riga reso
  762. stringa = '020000000000000000%09d00\r\n' % (0)
  763. f.write(stringa)
  764. reparto = getattr(Environment.conf.VenditaDettaglio,'reparto_default',1)
  765. art = leggiArticolo(riga.id_articolo)
  766. repartoIva = 'reparto_' + art["denominazioneBreveAliquotaIva"].lower()
  767. if hasattr(Environment.conf.VenditaDettaglio, repartoIva):
  768. reparto = getattr(Environment.conf.VenditaDettaglio,repartoIva,reparto)
  769. reparto = str(reparto).zfill(2)
  770. if not(riga.quantita < 0):
  771. stringa = '01%-16s%09.2f%2s\r\n' % (riga.descrizione[:16], riga.prezzo, reparto)
  772. f.write(stringa)
  773. if riga.sconti:
  774. for sconto in riga.sconti:
  775. if sconto.valore != 0:
  776. if sconto.tipo_sconto == 'percentuale':
  777. stringa = '07%-16s%09.2f00\r\n' % ('sconto', sconto.valore)
  778. else:
  779. stringa = '06%-16s%09.2f00\r\n' % ('sconto', sconto.valore * quantita)
  780. f.write(stringa)
  781. else:
  782. # per i resi, nello scontrino, si scrive direttamente il prezzo scontato (limitazione cassa)
  783. stringa = '01%-16s%09.2f%2s\r\n' % (riga.descrizione[:16], riga.prezzo_scontato, reparto)
  784. f.write(stringa)
  785. if daoScontrino.totale_contanti is None or daoScontrino.totale_contanti == 0:
  786. totale_contanti = daoScontrino.totale_scontrino
  787. else:
  788. totale_contanti = daoScontrino.totale_contanti
  789. if daoScontrino.totale_assegni is not None and daoScontrino.totale_assegni != 0:
  790. stringa = '20 %09d00\r\n' % (daoScontrino.totale_assegni * 100)
  791. f.write(stringa)
  792. if daoScontrino.totale_carta_credito is not None and daoScontrino.totale_carta_credito != 0:
  793. stringa = '30 %09d00\r\n' % (daoScontrino.totale_carta_credito * 100)
  794. f.write(stringa)
  795. #stringa = '10 %09.2f00\r\n' % (totale_contanti)
  796. #f.write(stringa)
  797. #stringa='70 00000000000..\r\n'
  798. #f.write(stringa)
  799. stringa = '10 %09.2f00\r\n' % (totale_contanti)
  800. f.write(stringa)
  801. #stringa='71 Francesco Meloni ..\r\n'
  802. #f.write(stringa)
  803. #stringa='71 CIAO A TUTTI ..\r\n'
  804. #f.write(stringa)
  805. #stringa='71ARRIVEDERCI ALLA PROSSIMA ..\r\n'
  806. #f.write(stringa)
  807. #stringa='72 00000000000..\r\n'
  808. #f.write(stringa)
  809. f.close()
  810. return filename
  811. def on_stampa_del_giornale_breve_activate(self, widget):
  812. filename = Environment.conf.VenditaDettaglio.export_path + 'stampa_del_giornale_breve_' + datetime.date.today().strftime('%d_%m_%Y_%H_%M_%S')
  813. f = file(filename,'w')
  814. stringa = '52 00000000002..\r\n'
  815. f.write(stringa)
  816. f.close()
  817. self.sendToPrint(filename)
  818. def on_stampa_del_periodico_cassa_activate(self, widget):
  819. filename = Environment.conf.VenditaDettaglio.export_path + 'stampa_del_periodico_cassa_' + datetime.date.today().strftime('%d_%m_%Y_%H_%M_%S')
  820. f = file(filename,'w')
  821. stringa = '52 00000000004..\r\n'
  822. f.write(stringa)
  823. f.close()
  824. self.sendToPrint(filename)
  825. def on_stampa_del_periodico_reparti_activate(self, widget):
  826. filename = Environment.conf.VenditaDettaglio.export_path + 'stampa_del_periodico_reparti_' + datetime.date.today().strftime('%d_%m_%Y_%H_%M_%S')
  827. f = file(filename,'w')
  828. stringa = '52 00000000006..\r\n'
  829. f.write(stringa)
  830. f.close()
  831. self.sendToPrint(filename)
  832. def on_stampa_del_periodico_articoli_activate(self, widget):
  833. filename = Environment.conf.VenditaDettaglio.export_path + 'stampa_del_periodico_articoli_' + datetime.date.today().strftime('%d_%m_%Y_%H_%M_%S')
  834. f = file(filename,'w')
  835. stringa = '52 00000000008..\r\n'
  836. f.write(stringa)
  837. f.close()
  838. self.sendToPrint(filename)
  839. def on_stampa_della_affluenza_oraria_activate(self, widget):
  840. filename = Environment.conf.VenditaDettaglio.export_path + 'stampa_della_affluenza_oraria_' + datetime.date.today().strftime('%d_%m_%Y_%H_%M_%S')
  841. f = file(filename,'w')
  842. stringa = '52 00000000009..\r\n'
  843. f.write(stringa)
  844. f.close()
  845. self.sendToPrint(filename)
  846. def sendToPrint(self, filesToSend):
  847. # Mando comando alle casse
  848. program_launch = Environment.conf.VenditaDettaglio.driver_command
  849. program_params = (' ' + filesToSend + ' ' +
  850. Environment.conf.VenditaDettaglio.serial_device)
  851. if os.name == 'nt':
  852. exportingProcessPid = os.spawnl(os.P_NOWAIT, program_launch, program_params)
  853. id, ret_value = os.waitpid(exportingProcessPid, 0)
  854. ret_value = ret_value >> 8
  855. else:
  856. command = program_launch + program_params
  857. process = popen2.Popen3(command, True)
  858. message = process.childerr.readlines()
  859. ret_value = process.wait()
  860. # Elimino il file
  861. os.remove(filesToSend)
  862. if ret_value != 0:
  863. string_message = ''
  864. for s in message:
  865. string_message = string_message + s + "\n"
  866. # Mostro messaggio di errore
  867. messageError(msg=string_message, transient=self.getTopLevel())
  868. def ricercaArticolo(self):
  869. def on_ricerca_articolo_hide(anagWindow, anag):
  870. if anag.dao is None:
  871. anagWindow.destroy()
  872. return
  873. valoreSconto = 0
  874. tipoSconto = 'percentuale'
  875. anagWindow.destroy()
  876. idArticolo = anag.dao.id
  877. codiceABarre = anag.dao.codice_a_barre or ''
  878. codice = anag.dao.codice or ''
  879. descrizione = anag.dao.descrizione_etichetta or anag.dao.denominazione or ''
  880. # Ricerca listino_articolo
  881. listino = leggiListino(self.id_listino, idArticolo)
  882. #prezzo = listino["prezzoDettaglio"]
  883. listinoRiga = (self.id_listino, listino['denominazione'])
  884. prezzo = mN(listino["prezzoDettaglio"])
  885. prezzoScontato = prezzo
  886. tipoSconto = None
  887. if listino.has_key('scontiDettaglio'):
  888. if len(listino["scontiDettaglio"]) > 0:
  889. valoreSconto = listino['scontiDettaglio'][0].valore or 0
  890. if valoreSconto == 0:
  891. tipoSconto = None
  892. prezzoScontato = prezzo
  893. else:
  894. tipoSconto = listino['scontiDettaglio'][0].tipo_sconto
  895. if tipoSconto == "percentuale":
  896. prezzoScontato = mN(mN(prezzo) - (mN(prezzo) * mN(valoreSconto)) / 100)
  897. else:
  898. prezzoScontato = mN(mN(prezzo) -mN(valoreSconto))
  899. quantita = 1
  900. self.activate_item(idArticolo,
  901. listinoRiga,
  902. codiceABarre,
  903. codice or '',
  904. descrizione,
  905. prezzo,
  906. valoreSconto,
  907. tipoSconto,
  908. prezzoScontato,
  909. quantita)
  910. self.prezzo_entry.grab_focus()
  911. try:
  912. if Environment.conf.VenditaDettaglio.direct_confirm == "yes":
  913. self.on_confirm_button_clicked(self.getTopLevel())
  914. self.refreshTotal()
  915. except:
  916. pass
  917. from promogest.ui.RicercaComplessaArticoli import RicercaComplessaArticoli
  918. codiceABarre = self.codice_a_barre_entry.get_text()
  919. codice = self.codice_entry.get_text()
  920. descrizione = self.descrizione_entry.get_text()
  921. anag = RicercaComplessaArticoli(codiceABarre = codiceABarre,
  922. codice = codice,
  923. denominazione=descrizione)
  924. anag.setTreeViewSelectionType(GTK_SELECTIONMODE_SINGLE)
  925. anagWindow = anag.getTopLevel()
  926. anagWindow.connect("hide",
  927. on_ricerca_articolo_hide, anag)
  928. anagWindow.set_transient_for(self.getTopLevel())
  929. anagWindow.show_all()
  930. def on_new_button_clicked(self, button):
  931. """
  932. open the anagraficaArticolo Semplice to add a new article
  933. """
  934. from promogest.ui.AnagraficaArticoliSemplice import AnagraficaArticoliSemplice
  935. anag = AnagraficaArticoliSemplice()
  936. anagWindow = anag.getTopLevel()
  937. showAnagraficaRichiamata(self.getTopLevel(), anagWindow, button)
  938. def ricercaListino(self):
  939. """
  940. check if there is a priceList like setted on configure file
  941. """
  942. pricelist = Listino().select(denominazione = Environment.conf.VenditaDettaglio.listino,
  943. offset = None,
  944. batchSize = None)
  945. if pricelist and len(pricelist) > 0:
  946. id_listino = pricelist[0].id
  947. else:
  948. id_listino = None
  949. return id_listino
  950. def on_total_button_grab_focus(self, button):
  951. totale_scontrino = mN(self.label_totale.get_text())
  952. if self.contanti_entry.get_text() != '':
  953. totale_pagamento = mN(self.contanti_entry.get_text())
  954. elif self.non_contanti_entry.get_text() != '':
  955. totale_pagamento = mN(self.non_contanti_entry.get_text())
  956. else:
  957. totale_pagamento = 0
  958. resto = totale_pagamento - totale_scontrino
  959. self.label_resto.set_markup('<b><span size="xx-large">'+ str(resto) +'</span></b>')
  960. if self.total_button.is_focus():
  961. self.on_total_button_clicked(button)
  962. def on_contanti_radio_button_clicked(self, button):
  963. #predisposizione per il pagamento con contanti
  964. if self.total_button.get_property('sensitive'):
  965. self.contanti_entry.set_sensitive(True)
  966. self.contanti_entry.grab_focus()
  967. self.non_contanti_entry.set_text('')
  968. self.non_contanti_entry.set_sensitive(False)
  969. else:
  970. self.contanti_entry.set_sensitive(False)
  971. self.non_contanti_entry.set_sensitive(False)
  972. def on_non_contanti_clicked(self):
  973. #predisposizione per il pagamento non in contanti
  974. if self.total_button.get_property('sensitive'):
  975. self.non_contanti_entry.set_sensitive(True)
  976. self.non_contanti_entry.grab_focus()
  977. self.non_contanti_entry.set_text(str(self.refreshTotal()))
  978. self.contanti_entry.set_text('')
  979. self.contanti_entry.set_sensitive(False)
  980. else:
  981. self.contanti_entry.set_sensitive(False)
  982. self.non_contanti_entry.set_sensitive(False)
  983. def on_assegni_radio_button_clicked(self, button):
  984. #predisposizione per il pagamento con assegni
  985. self.on_non_contanti_clicked()
  986. def on_carta_di_credito_radio_button_clicked(self, button):
  987. #predisposizione per il pagamento con carta di credito
  988. self.on_non_contanti_clicked()
  989. def setPagamento(self, enabled = False):
  990. self.contanti_radio_button.set_active(True)
  991. self.contanti_entry.set_text('')
  992. self.non_contanti_entry.set_text('')
  993. self.non_contanti_entry.set_sensitive(False)
  994. self.contanti_entry.set_sensitive(enabled)
  995. def on_vendita_dettaglio_window_close(self, widget, event=None):
  996. self.destroy()
  997. return None
  998. def on_list_button_clicked(self, widget):
  999. self.idRhesusSource = []
  1000. gest = GestioneScontrini(daData=None, aData=None, righe=self.idRhesusSource)
  1001. gestWnd = gest.getTopLevel()
  1002. showAnagraficaRichiamata(self.getTopLevel(), gestWnd, None, self.creaScontrinoR

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