def finish(self): missing = get_missing_items(self.model, self.store) if missing: run_dialog(MissingItemsDialog, self, self.model, missing) return False 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. return # FIXME: If any issue happen at any point of the "send process", # trying to issue it again would make some products have their stock # decreased twice. Make sure we undo it first. # The issue itself was related to missing stock. Why get_missing_items # failed above? self.store.savepoint('before_send_transfer') try: self.model.send() except Exception as e: warning(_("An error happened when trying to confirm the transfer"), str(e)) self.store.rollback_to_savepoint('before_send_transfer') raise self.retval = self.model self.close() StockTransferWizardFinishEvent.emit(self.model) # Commit before printing to avoid losing data if something breaks self.store.confirm(self.retval) self._receipt_dialog(self.model)
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: run_dialog(MissingItemsDialog, self, self.model, missing) return False order = TransferOrder( open_date=self.model.open_date, receival_date=self.model.receival_date, source_branch=self.model.source_branch, destination_branch=self.model.destination_branch, source_responsible=self.model.source_responsible, destination_responsible=self.model.destination_responsible, store=self.store) for item in self.model.get_items(): transfer_item = order.add_sellable(item.sellable, quantity=item.quantity, batch=item.batch) transfer_item.send() # XXX Waiting for transfer order receiving wizard implementation order.receive() self.retval = self.model self.close() StockTransferWizardFinishEvent.emit(order) self._receipt_dialog(order)
def finish(self): missing = get_missing_items(self.model, self.store) if missing: run_dialog(MissingItemsDialog, self, self.model, missing) return False # If this wizard is for a purchase return, the items are automatically # added so the tax check escaped. So we do it now. if self.receiving_order is not None: missing_tax_info = [] for item in self.model.get_items(): sellable = item.sellable try: sellable.check_taxes_validity() except TaxError: missing_tax_info.append(sellable.description) if missing_tax_info: warning(_("There are some items with missing tax information"), ', '.join(missing_tax_info)) return False 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. return self.retval = self.model self.model.confirm() self.close() StockDecreaseWizardFinishEvent.emit(self.model) # Commit before printing to avoid losing data if something breaks self.store.confirm(self.retval) self._receipt_dialog()
def finish(self): missing = get_missing_items(self.model, self.store) if missing: run_dialog(MissingItemsDialog, self, self.model, missing) return False 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. return # FIXME: If any issue happen at any point of the "send process", # trying to issue it again would make some products have their stock # decreased twice. Make sure we undo it first. # The issue itself was related to missing stock. Why get_missing_items # failed above? self.store.savepoint('before_send_transfer') try: self.model.send() except Exception as e: warning(_("An error happened when trying to confirm the transfer"), str(e)) self.store.rollback_to_savepoint('before_send_transfer') raise self.retval = self.model self.close() StockTransferWizardFinishEvent.emit(self.model) # Commit before printing to avoid losing data if something breaks self.store.confirm(self.retval) self._receipt_dialog(self.model)
def finish(self): missing = get_missing_items(self.model, self.store) if missing: run_dialog(MissingItemsDialog, self, self.model, missing) return False order = TransferOrder( open_date=self.model.open_date, receival_date=self.model.receival_date, source_branch=self.model.source_branch, destination_branch=self.model.destination_branch, source_responsible=self.model.source_responsible, destination_responsible=self.model.destination_responsible, store=self.store) for item in self.model.get_items(): transfer_item = order.add_sellable(item.sellable, batch=None, quantity=item.quantity) transfer_item.send() # XXX Waiting for transfer order receiving wizard implementation order.receive() self.retval = self.model self.close() StockTransferWizardFinishEvent.emit(order) self._receipt_dialog(order)
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 # 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: run_dialog(MissingItemsDialog, self, self.model, missing) return False self.model.sync_stock() self.retval = self.model self.close() NewLoanWizardFinishEvent.emit(self.model) self._print_receipt(self.model)
def finish(self): missing = get_missing_items(self.model, self.store) if missing: run_dialog(MissingItemsDialog, self, self.model, missing) return False self.retval = self.model self.model.confirm() self.close() StockDecreaseWizardFinishEvent.emit(self.model) self._receipt_dialog()
def finish(self): missing = get_missing_items(self.model, self.store) if missing: run_dialog(MissingItemsDialog, self, self.model, missing) return False self.retval = self.model self.model.confirm() self.close() StockDecreaseWizardFinishEvent.emit(self.model) self._receipt_dialog()
def finish(self): missing = get_missing_items(self.model, self.store) if missing: run_dialog(MissingItemsDialog, self, self.model, missing) return False self.model.sync_stock() self.retval = self.model self.close() NewLoanWizardFinishEvent.emit(self.model) self._print_receipt(self.model)
def _confirm_order(self, order_view): if self.check_open_inventory(): return store = api.new_store() sale = store.fetch(order_view.sale) expire_date = sale.expire_date if (sale.status == Sale.STATUS_QUOTE and expire_date and expire_date.date() < date.today() and not yesno(_("This quote has expired. Confirm it anyway?"), Gtk.ResponseType.YES, _("Confirm quote"), _("Don't confirm"))): store.close() return missing = get_missing_items(sale, store) if missing: retval = run_dialog(MissingItemsDialog, self, sale, missing) if retval: self.refresh() store.close() return coupon = self._open_coupon(sale) if not coupon: store.close() return subtotal = coupon.add_sale_items(sale) try: if coupon.confirm(sale, store, subtotal=subtotal): workorders = WorkOrder.find_by_sale(store, sale) for order in workorders: # at this poing, orders could be either FINISHED or # DELIVERED (closed). If it is finished, we should close it # (mark delivered) ... if order.can_close(): order.close() else: # ... but if it didn't need closing, it should already # be delivered. assert order.is_finished() store.commit() self.refresh() else: coupon.cancel() except SellError as err: warning(str(err)) except ModelDataError as err: warning(str(err)) store.close()
def _confirm_order(self, order_view): if self.check_open_inventory(): return store = api.new_store() sale = store.fetch(order_view.sale) expire_date = sale.expire_date if (sale.status == Sale.STATUS_QUOTE and expire_date and expire_date.date() < date.today() and not yesno(_("This quote has expired. Confirm it anyway?"), gtk.RESPONSE_YES, _("Confirm quote"), _("Don't confirm"))): store.close() return missing = get_missing_items(sale, store) if missing: retval = run_dialog(MissingItemsDialog, self, sale, missing) if retval: self.refresh() store.close() return coupon = self._open_coupon(sale) if not coupon: store.close() return subtotal = self._add_sale_items(sale, coupon) try: if coupon.confirm(sale, store, subtotal=subtotal): workorders = WorkOrder.find_by_sale(store, sale) for order in workorders: # at this poing, orders could be either FINISHED or # DELIVERED (closed). If it is finished, we should close it # (mark delivered) ... if order.can_close(): order.close() else: # ... but if it didn't need closing, it should already # be delivered. assert order.is_finished() store.commit() self.refresh() else: coupon.cancel() except SellError as err: warning(str(err)) except ModelDataError as err: warning(str(err)) store.close()
def finish(self): missing = get_missing_items(self.model, self.store) if missing: run_dialog(MissingItemsDialog, self, self.model, missing) return False self.model.sync_stock() self.retval = self.model self.close() NewLoanWizardFinishEvent.emit(self.model) # Confirm before printing to avoid losing data if something breaks self.store.confirm(self.retval) self._print_receipt(self.model)
def finish(self): missing = get_missing_items(self.model, self.store) if missing: run_dialog(MissingItemsDialog, self, self.model, missing) return False self.model.sync_stock() self.retval = self.model self.close() # Confirm before printing to avoid losing data if something breaks self.store.confirm(self.retval) NewLoanWizardFinishEvent.emit(self.model) self._print_receipt(self.model)
def finish(self): missing = get_missing_items(self.model, self.store) if missing: run_dialog(MissingItemsDialog, self, self.model, missing) return False self.retval = self.model self.model.confirm() self.close() StockDecreaseWizardFinishEvent.emit(self.model) # Commit before printing to avoid losing data if something breaks self.store.confirm(self.retval) self._receipt_dialog()
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 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 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: run_dialog(MissingItemsDialog, self, self.model, missing) return False self.model.send() self.retval = self.model self.close() StockTransferWizardFinishEvent.emit(self.model) # Commit before printing to avoid losing data if something breaks self.store.confirm(self.retval) self._receipt_dialog(self.model)
def test_get_missing_items(self): sale = self.create_sale() stock_item = self.create_sale_item(sale=sale) missing_item = self.create_sale_item(sale=sale) stock_storable = self.create_storable(product=stock_item.sellable.product) missing_storable = self.create_storable(product=missing_item.sellable.product) self.create_product_stock_item(storable=stock_storable, quantity=1) self.create_product_stock_item(storable=missing_storable, quantity=0) missing = get_missing_items(sale, self.store) self.assertEquals(missing[0].storable, missing_storable)
def test_get_missing_items(self): sale = self.create_sale() stock_item = self.create_sale_item(sale=sale) missing_item = self.create_sale_item(sale=sale) stock_storable = self.create_storable( product=stock_item.sellable.product) missing_storable = self.create_storable( product=missing_item.sellable.product) self.create_product_stock_item(storable=stock_storable, quantity=1) self.create_product_stock_item(storable=missing_storable, quantity=0) missing = get_missing_items(sale, self.store) self.assertEquals(missing[0].storable, missing_storable)
def _confirm_order(self, order_view): if self.check_open_inventory(): return store = api.new_store() sale = store.fetch(order_view.sale) expire_date = sale.expire_date if (sale.status == Sale.STATUS_QUOTE and expire_date and expire_date.date() < date.today() and not yesno(_("This quote has expired. Confirm it anyway?"), gtk.RESPONSE_YES, _("Confirm quote"), _("Don't confirm"))): store.close() return missing = get_missing_items(sale, store) if missing: retval = run_dialog(MissingItemsDialog, self, sale, missing) if retval: self.refresh() store.close() return coupon = self._open_coupon() if not coupon: store.close() return subtotal = self._add_sale_items(sale, coupon) try: if coupon.confirm(sale, store, subtotal=subtotal): workorders = WorkOrder.find_by_sale(store, sale) for order in workorders: order.close() store.commit() self.refresh() else: coupon.cancel() except SellError as err: warning(str(err)) except ModelDataError as err: warning(str(err)) store.close()
def finish(self): missing = get_missing_items(self.model, self.store) if missing: run_dialog(MissingItemsDialog, self, self.model, missing) return False 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. return self.retval = self.model self.model.confirm() self.close() StockDecreaseWizardFinishEvent.emit(self.model) # Commit before printing to avoid losing data if something breaks self.store.confirm(self.retval) self._receipt_dialog()
def finish(self): missing = get_missing_items(self.model, self.store) if missing: run_dialog(MissingItemsDialog, self, self.model, missing) return False 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. return self.retval = self.model self.model.confirm() self.close() StockDecreaseWizardFinishEvent.emit(self.model) # Commit before printing to avoid losing data if something breaks self.store.confirm(self.retval) self._receipt_dialog()
def finish(self): missing = get_missing_items(self.model, self.store) if missing: run_dialog(MissingItemsDialog, self, self.model, missing) return False # If this wizard is for a purchase return, the items are automatically # added so the tax check escaped. So we do it now. if self.receiving_order is not None: missing_tax_info = [] for item in self.model.get_items(): sellable = item.sellable try: sellable.check_taxes_validity() except TaxError: missing_tax_info.append(sellable.description) if missing_tax_info: warning(_("There are some items with missing tax information"), ', '.join(missing_tax_info)) return False 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. return self.retval = self.model self.store.confirm(self.model) self.model.confirm() self.close() StockDecreaseWizardFinishEvent.emit(self.model) # Commit before printing to avoid losing data if something breaks self.store.confirm(self.retval) self._receipt_dialog()