PageRenderTime 29ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://promogest.googlecode.com/
Python | 515 lines | 481 code | 17 blank | 17 comment | 0 complexity | 148223491bed3edbea5a9484a3b119bd MD5 | raw file
Possible License(s): GPL-2.0
  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. # 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. import os, popen2
  17. from promogest.dao.DaoUtils import giacenzaSel
  18. from datetime import datetime, timedelta
  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.ui.Distinta import Distinta
  25. from promogest.modules.VenditaDettaglio.dao.TestataScontrinoCliente import TestataScontrinoCliente
  26. from promogest.ui.widgets.FilterWidget import FilterWidget
  27. from promogest.dao.Inventario import Inventario
  28. from promogest.dao.Magazzino import Magazzino
  29. from promogest.dao.Articolo import Articolo
  30. from promogest.dao.TestataDocumento import TestataDocumento
  31. from promogest.dao.RigaDocumento import RigaDocumento
  32. from promogest.dao.Listino import Listino
  33. from promogest.ui.utils import *
  34. from promogest.ui import utils
  35. from promogest.modules.VenditaDettaglio.ui.VenditaDettaglioUtils import fillComboboxPos
  36. from promogest.lib.HtmlHandler import createHtmlObj, renderTemplate, renderHTML
  37. class GestioneScontrini(GladeWidget):
  38. """ Classe per la gestione degli scontrini emessi """
  39. def __init__(self, idArticolo = None,
  40. daData = None,
  41. aData = None,
  42. righe = []):
  43. self._idArticolo = idArticolo
  44. self._daData = daData
  45. self._aData = aData
  46. self._righe = righe
  47. self._htmlTemplate = None
  48. self.dao = None
  49. self.daoTse = None
  50. GladeWidget.__init__(self, 'scontrini_emessi',
  51. fileName="VenditaDettaglio/gui/scontrini_emessi.glade", isModule=True)
  52. self._window = self.scontrini_emessi
  53. self.placeWindow(self._window)
  54. self.draw()
  55. def draw(self):
  56. self.filterss = FilterWidget(
  57. owner=self,
  58. filtersElement=GladeWidget(
  59. rootWidget='scontrini_filter_table',
  60. fileName="VenditaDettaglio/gui/_scontrini_emessi_elements.glade",
  61. isModule=True),
  62. #resultsElement="scontrino"
  63. )
  64. self.filters = self.filterss.filtersElement
  65. self.filterTopLevel = self.filterss.getTopLevel()
  66. filterElement = self.filterss.filter_frame
  67. filterElement.unparent()
  68. self.filter_viewport.add(filterElement)
  69. self.anagrafica_hpaned.set_position(350)
  70. resultElement = self.filterss.filter_list_vbox
  71. resultElement.unparent()
  72. self.anagrafica_results_viewport.add(resultElement)
  73. self.detail = createHtmlObj(self)
  74. self.detail_scrolled.add(self.detail)
  75. self.filterss.hbox1.destroy()
  76. self.filterss.filter_info_hbox.show()
  77. self.filterss.filter_info_label.set_text("")
  78. self.filters.id_articolo_filter_customcombobox.setId(self._idArticolo)
  79. if self._daData is None:
  80. self.filters.da_data_filter_entry.setNow()
  81. else:
  82. self.filters.da_data_filter_entry.set_text(self_daData)
  83. if self._aData is None:
  84. self.filters.a_data_filter_entry.setNow()
  85. else:
  86. self.filters.a_data_filter_entry.set_text(self_aData)
  87. fillComboboxMagazzini(self.filters.id_magazzino_filter_combobox)
  88. fillComboboxPos(self.filters.id_pos_filter_combobox)
  89. if hasattr(Environment.conf, "VenditaDettaglio"):
  90. if hasattr(Environment.conf.VenditaDettaglio, "magazzino"):
  91. findComboboxRowFromStr(self.filters.id_magazzino_filter_combobox, Environment.conf.VenditaDettaglio.magazzino,2)
  92. if hasattr(Environment.conf.VenditaDettaglio, "puntocassa"):
  93. findComboboxRowFromStr(self.filters.id_pos_filter_combobox, Environment.conf.VenditaDettaglio.puntocassa,2)
  94. else:
  95. if setconf("VenditaDettaglio", "magazzino_vendita"):
  96. findComboboxRowFromId(self.filters.id_magazzino_filter_combobox,setconf("VenditaDettaglio", "magazzino_vendita"))
  97. if setconf("VenditaDettaglio", "punto_cassa"):
  98. findComboboxRowFromId(self.filters.id_pos_filter_combobox, setconf("VenditaDettaglio", "punto_cassa"))
  99. self.refreshHtml()
  100. self.refresh()
  101. def _reOrderBy(self, column):
  102. if column.get_name() == "data_column":
  103. return self.filterss._changeOrderBy(column,(None,TestataScontrino.data_inserimento))
  104. if column.get_name() == "totale_column":
  105. return self.filterss._changeOrderBy(column,(None,TestataScontrino.totale_scontrino))
  106. if column.get_name() == "contanti_column":
  107. return self.filterss._changeOrderBy(column,(None,TestataScontrino.totale_contanti))
  108. if column.get_name() == "assegni_column":
  109. return self.filterss._changeOrderBy(column,(None,TestataScontrino.totale_assegni))
  110. if column.get_name() == "cdicredito_column":
  111. return self.filterss._changeOrderBy(column,(None,TestataScontrino.totale_carta_credito))
  112. def clear(self):
  113. # Annullamento filtro
  114. self.filters.id_articolo_filter_customcombobox.set_active(0)
  115. self.filters.id_cliente_search_customcombobox.set_active(0)
  116. if hasattr(Environment.conf, "VenditaDettaglio"):
  117. if hasattr(Environment.conf.VenditaDettaglio, "magazzino"):
  118. findComboboxRowFromStr(self.filters.id_magazzino_filter_combobox, Environment.conf.VenditaDettaglio.magazzino,2)
  119. if hasattr(Environment.conf.VenditaDettaglio, "puntocassa"):
  120. findComboboxRowFromStr(self.filters.id_pos_filter_combobox, Environment.conf.VenditaDettaglio.puntocassa,2)
  121. else:
  122. if setconf("VenditaDettaglio", "magazzino_vendita"):
  123. findComboboxRowFromId(self.filters.id_magazzino_filter_combobox,setconf("VenditaDettaglio", "magazzino_vendita"))
  124. if setconf("VenditaDettaglio", "punto_cassa"):
  125. findComboboxRowFromId(self.filters.id_pos_filter_combobox, setconf("VenditaDettaglio", "punto_cassa"))
  126. self.filters.da_data_filter_entry.setNow()
  127. self.filters.a_data_filter_entry.setNow()
  128. self.refresh()
  129. def refresh(self):
  130. # Aggiornamento TreeView
  131. idArticolo = self.filters.id_articolo_filter_customcombobox.getId()
  132. daData = stringToDate(self.filters.da_data_filter_entry.get_text())
  133. aData = stringToDateBumped(self.filters.a_data_filter_entry.get_text())
  134. idPuntoCassa = findIdFromCombobox(self.filters.id_pos_filter_combobox)
  135. idMagazzino = findIdFromCombobox(self.filters.id_magazzino_filter_combobox)
  136. idCliente = self.filters.id_cliente_search_customcombobox.getId()
  137. self.filterss.numRecords = TestataScontrino().count(idArticolo=idArticolo,
  138. daData=daData,
  139. aData=aData,
  140. idMagazzino = idMagazzino,
  141. idPuntoCassa = idPuntoCassa,
  142. idCliente = idCliente)
  143. self.filterss._refreshPageCount()
  144. scos = TestataScontrino().select( orderBy=self.filterss.orderBy,
  145. idArticolo=idArticolo,
  146. daData=daData,
  147. aData=aData,
  148. idMagazzino = idMagazzino,
  149. idPuntoCassa = idPuntoCassa,
  150. idCliente = idCliente,
  151. offset=self.filterss.offset,
  152. batchSize=self.filterss.batchSize)
  153. #self.filterss._treeViewModel.clear()
  154. self.rows_listore.clear()
  155. for s in scos:
  156. totale = mNLC(s.totale_scontrino,2) or 0
  157. contanti = mNLC(s.totale_contanti,2) or 0
  158. assegni = mNLC(s.totale_assegni,2) or 0
  159. carta = mNLC(s.totale_carta_credito,2) or 0
  160. self.rows_listore.append((s,
  161. dateTimeToString(s.data_inserimento).replace(" "," Ore: "),
  162. totale,
  163. contanti, assegni, carta,
  164. dateToString(s.data_movimento),
  165. str(s.numero_movimento or '')))
  166. scos_no_batchSize = TestataScontrino().select( orderBy=self.filterss.orderBy,
  167. idArticolo=idArticolo,
  168. idMagazzino = idMagazzino,
  169. idPuntoCassa = idPuntoCassa,
  170. daData=daData,
  171. aData=aData,
  172. idCliente=idCliente,
  173. offset=None,
  174. batchSize=None)
  175. self.scontrini = scos_no_batchSize
  176. self.calcolaTotale(scos_no_batchSize)
  177. def calcolasconto(self, dao):
  178. if dao.sconti[0].tipo_sconto=="valore":
  179. return dao.sconti[0].valore
  180. else:
  181. #print ((dao.totale_scontrino*100)/dao.sconti[0].valore), (dao.totale_scontrino)
  182. return (100 * dao.totale_scontrino) / (100 - dao.sconti[0].valore) -(dao.totale_scontrino)
  183. #totale_scontato = total-totale_sconto
  184. def calcolaTotale(self, scos_no_batchSize):
  185. tot=0
  186. totccr = 0
  187. totass = 0
  188. totnum = 0
  189. totcont = 0
  190. tot_sconti = 0
  191. for m in scos_no_batchSize:
  192. if m.sconti:
  193. tot_sconti += self.calcolasconto(m)
  194. tot += m.totale_scontrino
  195. totccr += m.totale_carta_credito
  196. totass += m.totale_assegni
  197. totcont += m.totale_contanti
  198. totnum += 1
  199. #self.filterss.label1.set_text("")
  200. stringa = """GENERALE:<b><span foreground="black" size="20000">%s</span></b> - NUM. SCONTRINI:<b><span foreground="black" size="18000">%s</span></b> TOT CARTA:<b>%s</b> - TOT ASSEGNI:<b>%s</b> - TOT CONT.:<b>%s</b> - TOT SCONTI:<b>%s</b> - """ %(mNLC(tot,2), totnum, mNLC(totccr,2), mNLC(totass,2), mNLC(totcont,2), mNLC(tot_sconti,2) )
  201. self.filterss.info_label.set_markup(str(stringa))
  202. def on_filter_treeview_cursor_changed(self, treeview):
  203. sel = self.filterss.resultsElement.get_selection()
  204. (model, iterator) = sel.get_selected()
  205. if iterator is None:
  206. print 'on_filter_treeview_cursor_changed(): FIXME: iterator is None!'
  207. return
  208. self.dao = model.get_value(iterator, 0)
  209. self.refreshHtml(self.dao)
  210. def on_filter_treeview_row_activated(self, treeview, path, column):
  211. # Not used here
  212. pass
  213. def on_filter_treeview_selection_changed(self, treeSelection):
  214. (model, iterator) = treeSelection.get_selected()
  215. if iterator:
  216. self.crea_fattura_button.set_sensitive(True)
  217. self.id_cliente_emessi_customcombobox.set_sensitive(True)
  218. self.operazione_combobox.set_sensitive(True)
  219. self.daoTse = model.get_value(iterator, 0)
  220. if model.get_value(iterator, 0).id_cliente_testata_scontrino:
  221. a = model.get_value(iterator, 0).id_cliente_testata_scontrino
  222. self.id_cliente_emessi_customcombobox.setId(a)
  223. else:
  224. self.id_cliente_emessi_customcombobox.set_active(0)
  225. self.operazione_combobox.set_active(0)
  226. #self.crea_fattura_button.set_sensitive(False)
  227. #self.id_cliente_emessi_customcombobox.set_sensitive(False)
  228. #self.operazione_combobox.set_sensitive(False)
  229. #self.daoTse = None
  230. else:
  231. self.id_cliente_emessi_customcombobox.set_active(0)
  232. self.crea_fattura_button.set_sensitive(False)
  233. self.id_cliente_emessi_customcombobox.set_sensitive(False)
  234. self.operazione_combobox.set_sensitive(False)
  235. self.daoTse = None
  236. def refreshHtml(self, dao=None):
  237. pageData = {}
  238. html = '<html></html>'
  239. if self.dao:
  240. pageData = {
  241. "file": "scontrino.html",
  242. "dao" :self.dao,
  243. }
  244. html = renderTemplate(pageData)
  245. renderHTML(self.detail,html)
  246. def on_scontrini_window_close(self, widget, event=None):
  247. self.destroy()
  248. return None
  249. def on_rhesus_button_clicked(self, widget):
  250. if self.dao is not None:
  251. self._righe.append(self.dao.id)
  252. self.on_scontrini_window_close(widget)
  253. def on_delete_button_clicked(self, button):
  254. if self.dao is not None:
  255. msg = """ ATTENZIONE!!!!
  256. Si sta per cancellare uno scontrino, L'operazione
  257. č irreversibile per cui dovete essere sicuri di
  258. quel che state facendo. VUOI CANCELLARLO?"""
  259. if YesNoDialog(msg=msg, transient=self.getTopLevel()):
  260. if self.dao.numero_movimento:
  261. messageInfo(msg= """Esiste giŕ un movimento abbinato di chiusura per scarico da cassa,
  262. l'operazione č comunque impossibile
  263. Rivolgersi all'assistenza""")
  264. else:
  265. Environment.pg2log.info("CANCELLO UNO SCONTRINO DAL PG2 ")
  266. self.dao.delete()
  267. self.refresh()
  268. else:
  269. return
  270. def on_affluenza_oraria_chart_clicked(self, button):
  271. if "Statistiche" in Environment.modulesList and \
  272. hasattr(Environment.conf,"Statistiche") and \
  273. hasattr(Environment.conf.Statistiche,"affluenza_oraria_giornaliera") and\
  274. Environment.conf.Statistiche.affluenza_oraria_giornaliera == "yes":
  275. from promogest.modules.Statistiche.ui.chart import chartViewer
  276. chartViewer(self._window, func="affluenzaOrariaGiornaliera",scontrini= self.scontrini)
  277. else:
  278. fenceDialog()
  279. def on_affluenza_mensile_chart_clicked(self, button):
  280. if "Statistiche" in Environment.modulesList and \
  281. hasattr(Environment.conf,"Statistiche") and \
  282. hasattr(Environment.conf.Statistiche,"affluenza_giornaliera_mensile") and\
  283. Environment.conf.Statistiche.affluenza_giornaliera_mensile == "yes":
  284. from promogest.modules.Statistiche.ui.chart import chartViewer
  285. chartViewer(self._window, func="affluenzaGiornalieraMensile", scontrini= self.scontrini)
  286. else:
  287. fenceDialog()
  288. def on_affluenza_annuale_chart_clicked(self, button):
  289. if "Statistiche" in Environment.modulesList and \
  290. hasattr(Environment.conf,"Statistiche") and \
  291. hasattr(Environment.conf.Statistiche,"affluenza_mensile_annuale") and\
  292. Environment.conf.Statistiche.affluenza_mensile_annuale == "yes":
  293. from promogest.modules.Statistiche.ui.chart import chartViewer
  294. chartViewer(self._window, func="affluenzaMensileAnnuale", scontrini= self.scontrini)
  295. else:
  296. fenceDialog()
  297. def on_esporta_affluenza_csv_clicked(self, button):
  298. print "esport to csv"
  299. def on_aggiorna_inve_activate(self, item):
  300. """ Questa funzione serve a ricalibrare le giacenze di inventario con
  301. gli articoli venduti al dettaglio """
  302. msg = """ ATTENZIONE!!!!
  303. QUESTA OPERAZIONE Č PERICOLOSSIMA!!!!
  304. č stata aggiunta per corprire una casistica specifica
  305. di "aggiornamento della tabella inventario
  306. rispetto al venduto al dettaglio vuoi farlo??"""
  307. if YesNoDialog(msg=msg, transient=self.getTopLevel()):
  308. if posso("IN"):
  309. idMagazzinosel = Magazzino().select(denominazione = Environment.conf.VenditaDettaglio.magazzino)
  310. if Environment.conf.VenditaDettaglio.jolly:
  311. idArticoloGenericoSel = Articolo().select(codiceEM = Environment.conf.VenditaDettaglio.jolly)
  312. if idArticoloGenericoSel:
  313. idArticoloGenerico = idArticoloGenericoSel[0].id
  314. else:
  315. idArticoloGenerico = None
  316. if idMagazzinosel:
  317. idMagazzino = idMagazzinosel[0].id
  318. else:
  319. print "ERRORE NELLA DEFINIZIONE DEL MAGAZZINO"
  320. return
  321. for scontrino in self.scontrini:
  322. for riga in scontrino.righe:
  323. daoInv = Inventario().select(idArticolo=riga.id_articolo, idMagazzino = idMagazzino)
  324. if daoInv and idArticoloGenerico!=riga.id_articolo:
  325. if daoInv[0].data_aggiornamento is None or scontrino.data_inserimento < daoInv[0].data_aggiornamento:
  326. quantitaprecedente = daoInv[0].quantita or 0
  327. quantitavenduta = riga.quantita
  328. nuovaquantita = quantitaprecedente+quantitavenduta
  329. print "OPERAZIONE DA EFFETTUARE", quantitaprecedente,quantitavenduta, nuovaquantita
  330. daoInv[0].quantita= nuovaquantita
  331. daoInv[0].persist()
  332. else:
  333. print "IL MODULO INVENTARIO NON e' ATTIVO "
  334. def on_distinta_button_clicked(self, button):
  335. gest = Distinta(righe = self.scontrini)
  336. gestWnd = gest.getTopLevel()
  337. showAnagraficaRichiamata(self.getTopLevel(), gestWnd, None, None)
  338. def ricercaListino(self):
  339. """ check if there is a priceList like setted on configure file
  340. """
  341. if hasattr(Environment.conf, "VenditaDettaglio"):
  342. if hasattr(Environment.conf.VenditaDettaglio,"listino"):
  343. pricelist = Listino().select(denominazione = Environment.conf.VenditaDettaglio.listino,
  344. offset = None,
  345. batchSize = None)
  346. else:
  347. pricelist = Listino().select(id=setconf("VenditaDettaglio", "listino_vendita"))
  348. else:
  349. pricelist = Listino().select(id=setconf("VenditaDettaglio", "listino_vendita"))
  350. if pricelist:
  351. id_listino = pricelist[0].id
  352. else:
  353. id_listino = None
  354. return id_listino
  355. def on_crea_fattura_button_clicked(self, button):
  356. """ RIGA DOCUMENTO:
  357. id, valore_unitario_netto, valore_unitario_lordo,
  358. quantita, moltiplicatore, applicazione_sconti,
  359. percentuale_iva, descrizione, id_articolo, id_magazzino,
  360. id_multiplo, id_listino, id_iva, id_riga_padre
  361. RIGA SCONTRINO:
  362. id, prezzo, prezzo_scontato, quantita,
  363. descrizione, id_testata_scontrino, id_articolo
  364. TODO: Vanno gestiti gli sconti
  365. """
  366. if not self.daoTse:
  367. messageInfo(msg="Nessuno scontrino selezionato")
  368. return
  369. if self.daoTse and not self.daoTse.id_cliente_testata_scontrino:
  370. if self.id_cliente_emessi_customcombobox.getId():
  371. a = TestataScontrinoCliente()
  372. a.id_cliente = self.id_cliente_emessi_customcombobox.getId()
  373. a.id_testata_scontrino = self.daoTse.id
  374. a.persist()
  375. else:
  376. messageInfo(msg="Scontrino selezionato, ma nessun cliente assegnato")
  377. return
  378. if not findStrFromCombobox(self.operazione_combobox,0):
  379. obligatoryField(self.getTopLevel(), self.operazione_combobox, msg="SELEZIONA IL TIPO DOCUMENTO")
  380. one_day = datetime.timedelta(days=1)
  381. proviamo = datetime.datetime(self.daoTse.data_inserimento.year,self.daoTse.data_inserimento.month,
  382. self.daoTse.data_inserimento.day)
  383. listascontrini = TestataScontrino().select(daData=proviamo, aData=proviamo+one_day, batchSize=None, orderBy="data_inserimento")
  384. a = [i for i,x in enumerate(listascontrini) if x == self.daoTse]
  385. if a:
  386. a = a[0]
  387. else:
  388. a=0
  389. posizione= a + 1
  390. note = "Rif. Scontrino" + " n. " + str(posizione) + " del " + dateToString(self.daoTse.data_inserimento)
  391. newDao = TestataDocumento()
  392. newDao.data_documento = stringToDate(self.daoTse.data_inserimento)
  393. newDao.operazione = findStrFromCombobox(self.operazione_combobox,0)
  394. newDao.id_cliente = self.id_cliente_emessi_customcombobox.getId()
  395. newDao.note_pie_pagina = note
  396. #newDao.applicazione_sconti = self.dao.applicazione_sconti
  397. #sconti = []
  398. #sco = self.dao.sconti or []
  399. scontiRigaDocumento=[]
  400. scontiSuTotale=[]
  401. righeDocumento=[]
  402. #for s in sco:
  403. #daoSconto = ScontoTestataDocumento()
  404. #daoSconto.valore = s.valore
  405. #daoSconto.tipo_sconto = s.tipo_sconto
  406. #scontiSuTotale.append(daoSconto)
  407. newDao.scontiSuTotale = scontiSuTotale
  408. #righe = []
  409. rig = self.daoTse.righe
  410. for r in rig:
  411. daoRiga = RigaDocumento()
  412. daoRiga.id_testata_documento = newDao.id
  413. daoRiga.id_articolo = r.id_articolo
  414. daoRiga.id_magazzino = self.daoTse.id_magazzino
  415. daoRiga.descrizione = r.descrizione
  416. # Copia il campo iva
  417. arto = leggiArticolo(r.id_articolo)
  418. daoRiga.id_iva = arto["idAliquotaIva"]
  419. #ricalcola prezzi
  420. daoRiga.id_listino = self.ricercaListino()
  421. imponibile = float(r.prezzo)/(1+float(arto["percentualeAliquotaIva"])/100)
  422. imponibile_scontato = float(r.prezzo_scontato)/(1+float(arto["percentualeAliquotaIva"])/100)
  423. daoRiga.valore_unitario_lordo = imponibile or 0
  424. daoRiga.valore_unitario_netto = imponibile_scontato
  425. daoRiga.percentuale_iva = arto["percentualeAliquotaIva"]
  426. #daoRiga.applicazione_sconti = r.applicazione_sconti
  427. daoRiga.quantita = r.quantita
  428. daoRiga.id_multiplo = None
  429. daoRiga.moltiplicatore = 1
  430. #sconti = []
  431. scontiRigaDocumento = []
  432. #sco = r.sconti
  433. #for s in sco:
  434. #daoSconto = ScontoRigaDocumento()
  435. #daoSconto.valore = s.valore
  436. #daoSconto.tipo_sconto = s.tipo_sconto
  437. #scontiRigaDocumento.append(daoSconto)
  438. daoRiga.scontiRigaDocumento = scontiRigaDocumento
  439. righeDocumento.append(daoRiga)
  440. newDao.righeDocumento = righeDocumento
  441. tipoid = findStrFromCombobox(self.operazione_combobox,0)
  442. #tipo = Operazione().getRecord(id=tipoid)
  443. #if not newDao.numero:
  444. valori = numeroRegistroGet(tipo=tipoid, date=self.daoTse.data_inserimento)
  445. newDao.numero = valori[0]
  446. newDao.registro_numerazione= valori[1]
  447. newDao.persist()
  448. res = TestataDocumento().getRecord(id=newDao.id)
  449. msg = "Documento creato da scontrino !\n\nIl nuovo documento e' il n. " + str(res.numero) + " del " + dateToString(res.data_documento) + " (" + newDao.operazione + ")\n" + "Lo vuoi modificare?"
  450. if YesNoDialog(msg=msg, transient=self.getTopLevel()):
  451. from promogest.ui.AnagraficaDocumenti import AnagraficaDocumenti
  452. anag = AnagraficaDocumenti()
  453. anagWindow = anag.getTopLevel()
  454. anagWindow.show_all()
  455. anag.editElement.setVisible(True)
  456. anag.editElement.setDao(newDao)
  457. anag.editElement.id_persona_giuridica_customcombobox.set_sensitive(True)
  458. anag.editElement.setFocus()
  459. self.destroy()