def finish(self): missing = get_missing_items(self.model, self.store) if missing: # We want to close the checkout, so the user will be back to the # list of items in the sale. self.close() run_dialog(MissingItemsDialog, self, self.model, missing) return False self.retval = True invoice_number = self.invoice_model.invoice_number # Workaround for bug 4218: If the invoice is was already used by # another store (another cashier), try using the next one # available, or show a warning if the number was manually set. while True: try: self.store.savepoint('before_set_invoice_number') self.model.invoice_number = invoice_number # We need to flush the database here, or a possible collision # of invoice_number will only be detected later on, when the # execution flow is not in the try-except anymore. self.store.flush() except IntegrityError: self.store.rollback_to_savepoint('before_set_invoice_number') if self._invoice_changed(): warning(_(u"The invoice number %s is already used. " "Confirm the sale again to chose another one.") % invoice_number) self.retval = False break else: invoice_number += 1 else: break self.close() group = self.model.group # FIXME: This is set too late on Sale.confirm(). If PaymentGroup don't # have a payer, we won't be able to print bills/booklets. group.payer = self.model.client and self.model.client.person # Commit before printing to avoid losing data if something breaks self.store.confirm(self.retval) ConfirmSaleWizardFinishEvent.emit(self.model) booklets = list(group.get_payments_by_method_name(u'store_credit')) bills = list(group.get_payments_by_method_name(u'bill')) if (booklets and yesno(_("Do you want to print the booklets for this sale?"), gtk.RESPONSE_YES, _("Print booklets"), _("Don't print"))): print_report(BookletReport, booklets) if (bills and BillReport.check_printable(bills) and yesno(_("Do you want to print the bills for this sale?"), gtk.RESPONSE_YES, _("Print bills"), _("Don't print"))): print_report(BillReport, bills)
def finish(self): missing = get_missing_items(self.model, self.store) if missing: # We want to close the checkout, so the user will be back to the # list of items in the sale. self.close() run_dialog(MissingItemsDialog, self, self.model, missing) return False self.retval = True invoice_number = self.invoice_model.invoice_number # Workaround for bug 4218: If the invoice is was already used by # another store (another cashier), try using the next one # available, or show a warning if the number was manually set. while True: try: self.store.savepoint('before_set_invoice_number') self.model.invoice_number = invoice_number # We need to flush the database here, or a possible collision # of invoice_number will only be detected later on, when the # execution flow is not in the try-except anymore. self.store.flush() except IntegrityError: self.store.rollback_to_savepoint('before_set_invoice_number') if self._invoice_changed(): warning( _(u"The invoice number %s is already used. " "Confirm the sale again to chose another one.") % invoice_number) self.retval = False break else: invoice_number += 1 else: break self.close() group = self.model.group # FIXME: This is set too late on Sale.confirm(). If PaymentGroup don't # have a payer, we won't be able to print bills/booklets. group.payer = self.model.client and self.model.client.person ConfirmSaleWizardFinishEvent.emit(self.model) booklets = list(group.get_payments_by_method_name(u'store_credit')) bills = list(group.get_payments_by_method_name(u'bill')) if (booklets and yesno( _("Do you want to print the booklets for this sale?"), gtk.RESPONSE_YES, _("Print booklets"), _("Don't print"))): print_report(BookletReport, booklets) if (bills and BillReport.check_printable(bills) and yesno( _("Do you want to print the bills for this sale?"), gtk.RESPONSE_YES, _("Print bills"), _("Don't print"))): print_report(BillReport, bills)
def finish(self): missing = get_missing_items(self.model, self.store) if missing: # We want to close the checkout, so the user will be back to the # list of items in the sale. self.close() run_dialog(MissingItemsDialog, self, self.model, missing) return False group = self.model.group # FIXME: This is set too late on Sale.confirm(). If PaymentGroup don't # have a payer, we won't be able to print bills/booklets. group.payer = self.model.client and self.model.client.person invoice_ok = InvoiceSetupEvent.emit() if invoice_ok is False: # If there is any problem with the invoice, the event will display an error # message and the dialog is kept open so the user can fix whatever is wrong. # If this is the second time the user is trying to confirm, an # error message is being displayed saying that the payment can't be # created twice, so we clear the payments created to avoid the message # TODO: Create the payments on the wizard finish event (here) self.payment_group.clear_unused() return self.retval = True self.close() retval = ConfirmSaleWizardFinishEvent.emit(self.model) if retval is not None: self.retval = retval if sysparam.get_bool('PRINT_SALE_DETAILS_ON_POS'): self.print_sale_details()
def finish(self): missing = get_missing_items(self.model, self.store) if missing: # We want to close the checkout, so the user will be back to the # list of items in the sale. self.close() run_dialog(MissingItemsDialog, self, self.model, missing) return False self.retval = True invoice_number = self.invoice_model.invoice_number # Workaround for bug 4218: If the invoice is was already used by # another store (another cashier), try using the next one # available, or show a warning if the number was manually set. while True: try: self.store.savepoint('before_set_invoice_number') self.model.invoice_number = invoice_number # We need to flush the database here, or a possible collision # of invoice_number will only be detected later on, when the # execution flow is not in the try-except anymore. self.store.flush() except IntegrityError: self.store.rollback_to_savepoint('before_set_invoice_number') if self._invoice_changed(): warning(_(u"The invoice number %s is already used. " "Confirm the sale again to chose another one.") % invoice_number) self.retval = False break else: invoice_number += 1 else: break self.close() group = self.model.group # FIXME: This is set too late on Sale.confirm(). If PaymentGroup don't # have a payer, we won't be able to print bills/booklets. group.payer = self.model.client and self.model.client.person ConfirmSaleWizardFinishEvent.emit(self.model) if sysparam.get_bool('PRINT_SALE_DETAILS_ON_POS'): self.print_sale_details()