def __init__(self, store, model=None, edit_mode=False): title = self._get_title(model) self.sync_mode = api.sysparam.get_bool('SYNCHRONIZED_MODE') self.current_branch = api.get_current_branch(store) if self.sync_mode and not model: self.temporary_identifier = PurchaseOrder.get_temporary_identifier( store) model = model or self._create_model(store) # Should we show all products or only the ones associated with the # selected supplier? self.all_products = False # If we receive the order right after the purchase. self.receiving_model = None purchase_edit = [ PurchaseOrder.ORDER_CONFIRMED, PurchaseOrder.ORDER_PENDING ] if not model.status in purchase_edit: raise ValueError('Invalid order status. It should ' 'be ORDER_PENDING or ORDER_CONFIRMED') first_step = StartPurchaseStep(self, store, model) BaseWizard.__init__(self, store, first_step, model, title=title, edit_mode=edit_mode)
def next_step(self): self.wizard.all_products = self.all_products.get_active() if self.wizard.is_for_another_branch(): info(_('The identifier for this purchase will be defined when it ' 'is synchronized to the detination branch')) self.model.identifier = PurchaseOrder.get_temporary_identifier(self.store) return PurchaseItemStep(self.wizard, self, self.store, self.model)
def create_purchase_order(self, responsible, create_payments=False, station_name=u'StoqLinkServer'): payment_group = self._create_payment_group() identifier = PurchaseOrder.get_temporary_identifier(self.store) notes = _(u"Invoice number: %s") % self.invoice_number station = set_current_branch_station(self.store, station_name, confirm=False) self._create_and_confirm_purchase_order(identifier, payment_group, notes, station, responsible) if create_payments: self._create_payments(station) self.create_receiving_order(station) self.store.commit() return self.purchase_order
def __init__(self, store, model=None, edit_mode=False): title = self._get_title(model) self.sync_mode = api.sysparam.get_bool('SYNCHRONIZED_MODE') self.current_branch = api.get_current_branch(store) if self.sync_mode and not model: self.temporary_identifier = PurchaseOrder.get_temporary_identifier(store) model = model or self._create_model(store) # Should we show all products or only the ones associated with the # selected supplier? self.all_products = False # If we receive the order right after the purchase. self.receiving_model = None purchase_edit = [PurchaseOrder.ORDER_CONFIRMED, PurchaseOrder.ORDER_PENDING] if not model.status in purchase_edit: raise ValueError('Invalid order status. It should ' 'be ORDER_PENDING or ORDER_CONFIRMED') first_step = StartPurchaseStep(self, store, model) BaseWizard.__init__(self, store, first_step, model, title=title, edit_mode=edit_mode)