예제 #1
0
파일: salewizard.py 프로젝트: Farrapo/stoq
    def setup_slaves(self):
        marker('Setting up slaves')
        BaseMethodSelectionStep.setup_slaves(self)
        marker('Finished parent')

        self.pm_slave.set_client(self.model.client,
                                 total_amount=self.wizard.get_total_to_pay())

        marker('Setting discount')
        self.discount_slave = SaleDiscountSlave(self.store, self.model,
                                                self.model_type)

        if sysparam.get_bool('USE_TRADE_AS_DISCOUNT'):
            self.subtotal_expander.set_expanded(True)
            self.discount_slave.discount_value_ck.set_active(True)
            self.discount_slave.update_sale_discount()
        marker('Finshed setting up discount')

        self.discount_slave.connect('discount-changed',
                                    self.on_discount_slave_changed)
        slave_holder = 'discount_surcharge_slave'
        if self.get_slave(slave_holder):
            self.detach_slave(slave_holder)
        self.attach_slave(slave_holder, self.discount_slave)
        marker('Finished setting up slaves')
예제 #2
0
 def _fill_transporter_combo(self):
     marker('Filling transporters')
     transporters = Transporter.get_active_transporters(self.store)
     items = api.for_person_combo(transporters)
     self.transporter.prefill(items)
     self.transporter.set_sensitive(len(items))
     marker('Filled transporters')
예제 #3
0
    def _get_columns(self):
        marker('_get_columns')
        self._price_columns = {}
        columns = [Column("code", title=_(u"Code"), data_type=str,
                          width=100),
                   Column("barcode", title=_(u"Barcode"), data_type=str,
                          width=100, visible=False),
                   Column("category_description", title=_(u"Category"),
                          data_type=str, width=100),
                   Column("description", title=_(u"Description"),
                          data_type=str, width=200),
                   Column("cost", title=_(u"Cost"),
                          data_type=currency, width=90),
                   Column("price", title=_(u"Default Price"),
                          data_type=currency, width=90)
                   ]

        self._price_columns[None] = columns[-1]
        for cat in self.categories:
            columns.append(Column('price_%s' % (cat.id, ),
                                  title=cat.get_description(), data_type=currency,
                                  width=90, visible=True))
            self._price_columns[cat.id] = columns[-1]
        self._columns = columns
        marker('Done _get_columns')
        return columns
예제 #4
0
    def _get_columns(self):
        marker('_get_columns')
        self._price_columns = {}
        columns = [Column("code", title=_(u"Code"), data_type=str,
                          width=100),
                   Column("barcode", title=_(u"Barcode"), data_type=str,
                          width=100, visible=False),
                   Column("category_description", title=_(u"Category"),
                          data_type=str, width=100),
                   Column("description", title=_(u"Description"),
                          data_type=str, width=200),
                   Column("cost", title=_(u"Cost"),
                          data_type=currency, width=90),
                   Column("price", title=_(u"Default Price"),
                          data_type=currency, width=90)
                   ]

        self._price_columns[None] = columns[-1]
        for cat in self.categories:
            columns.append(Column('price_%s' % (cat.id, ),
                                  title=cat.get_description(), data_type=currency,
                                  width=90, visible=True))
            self._price_columns[cat.id] = columns[-1]
        self._columns = columns
        marker('Done _get_columns')
        return columns
예제 #5
0
    def post_init(self):
        BaseMethodSelectionStep.post_init(self)

        marker('Entering post_init')
        if self.wizard.need_create_payment():
            self.wizard.payment_group.clear_unused()
        self.register_validate_function(self._refresh_next)
        self._update_next_step(self.get_selected_method())
        # If there's no salesperson, keep the focus there as it should be
        # selected first to have a nice flow
        if (hasattr(self, 'cash_change_slave')
                and self.model.salesperson is not None):
            self.cash_change_slave.received_value.grab_focus()

        self.force_validation()
        self.data_table.set_focus_chain([
            self.salesperson,
            self.invoice_number_holder,
            self.client_gadget.box,
            self.transporter,
            self.create_transporter,
            self.cfop,
            self.create_cfop,
        ])
        marker('Leaving post_init')
예제 #6
0
    def setup_slaves(self):
        marker('Setting up slaves')
        BaseMethodSelectionStep.setup_slaves(self)
        marker('Finished parent')

        self.pm_slave.set_client(self.model.client,
                                 total_amount=self.wizard.get_total_to_pay())

        marker('Setting discount')
        self.discount_slave = SaleDiscountSlave(self.store, self.model,
                                                self.model_type)

        if sysparam.get_bool('USE_TRADE_AS_DISCOUNT'):
            self.subtotal_expander.set_expanded(True)
            self.discount_slave.discount_value_ck.set_active(True)
            self.discount_slave.update_sale_discount()
        marker('Finshed setting up discount')

        self.discount_slave.connect('discount-changed',
                                    self.on_discount_slave_changed)
        slave_holder = 'discount_surcharge_slave'
        if self.get_slave(slave_holder):
            self.detach_slave(slave_holder)
        self.attach_slave(slave_holder, self.discount_slave)
        marker('Finished setting up slaves')
예제 #7
0
파일: salewizard.py 프로젝트: romaia/stoq
 def _fill_transporter_combo(self):
     marker('Filling transporters')
     transporters = Transporter.get_active_transporters(self.store)
     items = api.for_person_combo(transporters)
     self.transporter.prefill(items)
     self.transporter.set_sensitive(len(items))
     marker('Filled transporters')
예제 #8
0
파일: salewizard.py 프로젝트: Farrapo/stoq
 def _setup_clients_widget(self):
     marker('Filling clients')
     self.client_gadget = ClientSearchEntryGadget(
         entry=self.client,
         store=self.store,
         model=self.model,
         parent=self.wizard)
     marker('Filled clients')
예제 #9
0
 def on_apply__clicked(self, button):
     markup = self.markup.read()
     cat = self.category.read()
     marker('Updating prices')
     for i in self.slave.listcontainer.list:
         i.set_markup(cat, markup)
         self.slave.listcontainer.list.refresh(i)
     marker('Done updating prices')
예제 #10
0
 def on_apply__clicked(self, button):
     markup = self.markup.read()
     cat = self.category.read()
     marker('Updating prices')
     for i in self.slave.listcontainer.list:
         i.set_markup(cat, markup)
         self.slave.listcontainer.list.refresh(i)
     marker('Done updating prices')
예제 #11
0
파일: salewizard.py 프로젝트: esosaja/stoq
 def _setup_clients_widget(self):
     marker('Filling clients')
     self.client_gadget = ClientSearchEntryGadget(
         entry=self.client,
         store=self.store,
         model=self.model,
         parent=self.wizard)
     marker('Filled clients')
예제 #12
0
 def _setup_clients_widget(self):
     marker('Filling clients')
     self.client_gadget = ClientEntryGadget(
         entry=self.client,
         store=self.store,
         initial_value=self.model.client,
         parent=self.wizard,
         run_editor=self._run_client_editor)
     marker('Filled clients')
예제 #13
0
    def next_step(self):
        self.store.savepoint('before_salesperson_step')

        marker('running SalesPersonStep')
        self._update_sale_items()
        step = SalesPersonStep(self.wizard, self.store, self.model,
                               self.wizard.payment_group)
        marker('finished creating SalesPersonStep')
        return step
예제 #14
0
 def setup_proxies(self):
     marker('Setting up proxies')
     self.setup_widgets()
     self.proxy = self.add_proxy(self.model, self.proxy_widgets)
     if self.model.client:
         self.client_gadget.set_editable(False)
     if sysparam.get_bool('ASK_SALES_CFOP'):
         self.add_proxy(self.model, SalesPersonStep.cfop_widgets)
     marker('Finished setting up proxies')
예제 #15
0
 def _setup_clients_widget(self):
     marker('Filling clients')
     self.client_gadget = ClientEntryGadget(
         entry=self.client,
         store=self.store,
         initial_value=self.model.client,
         parent=self.wizard,
         run_editor=self._run_client_editor)
     marker('Filled clients')
예제 #16
0
 def setup_proxies(self):
     marker('Setting up proxies')
     self.setup_widgets()
     self.proxy = self.add_proxy(self.model, self.proxy_widgets)
     if self.model.client:
         self.client_gadget.set_editable(False)
     if sysparam.get_bool('ASK_SALES_CFOP'):
         self.add_proxy(self.model, SalesPersonStep.cfop_widgets)
     marker('Finished setting up proxies')
예제 #17
0
파일: salewizard.py 프로젝트: romaia/stoq
 def update_discount_and_surcharge(self):
     marker("update_discount_and_surcharge")
     # Here we need avoid to reset sale data defined when creating the
     # Sale in the POS application, i.e, we should not reset the
     # discount and surcharge if they are already set (this is the
     # case when CONFIRM_SALES_ON_TILL parameter is enabled).
     if not sysparam(self.store).CONFIRM_SALES_ON_TILL:
         self.model.discount_value = currency(0)
         self.model.surcharge_value = currency(0)
예제 #18
0
 def update_discount_and_surcharge(self):
     marker("update_discount_and_surcharge")
     # Here we need avoid to reset sale data defined when creating the
     # Sale in the POS application, i.e, we should not reset the
     # discount and surcharge if they are already set (this is the
     # case when CONFIRM_SALES_ON_TILL parameter is enabled).
     if not sysparam(self.store).CONFIRM_SALES_ON_TILL:
         self.model.discount_value = currency(0)
         self.model.surcharge_value = currency(0)
예제 #19
0
파일: salewizard.py 프로젝트: Farrapo/stoq
    def next_step(self):
        self.store.savepoint('before_salesperson_step')

        marker('running SalesPersonStep')
        self._update_sale_items()
        step = SalesPersonStep(self.wizard, self.store, self.model,
                               self.wizard.payment_group,
                               self.wizard.invoice_model)
        marker('finished creating SalesPersonStep')
        return step
예제 #20
0
    def _fill_clients_combo(self):
        marker('Filling clients')
        # FIXME: This should not be using a normal ProxyComboEntry,
        #        we need a specialized widget that does the searching
        #        on demand.

        clients = Client.get_active_clients(self.store)
        self.client.prefill(api.for_person_combo(clients))
        self.client.set_sensitive(len(self.client.get_model()))
        marker('Filled clients')
예제 #21
0
파일: salewizard.py 프로젝트: romaia/stoq
    def _fill_clients_combo(self):
        marker('Filling clients')
        # FIXME: This should not be using a normal ProxyComboEntry,
        #        we need a specialized widget that does the searching
        #        on demand.

        clients = Client.get_active_clients(self.store)
        self.client.prefill(api.for_person_combo(clients))
        self.client.set_sensitive(len(self.client.get_model()))
        marker('Filled clients')
예제 #22
0
    def __init__(self, wizard, store, model, payment_group, invoice_model):
        self.invoice_model = invoice_model

        self.payment_group = payment_group

        BaseMethodSelectionStep.__init__(self)
        marker("WizardEditorStep.__init__")
        WizardEditorStep.__init__(self, store, wizard, model)

        self._update_totals()
        self.update_discount_and_surcharge()
예제 #23
0
    def __init__(self, wizard, store, model, payment_group, previous=None):
        self.pm_slave = None
        self.payment_group = payment_group

        BaseMethodSelectionStep.__init__(self)
        marker("WizardEditorStep.__init__")
        WizardEditorStep.__init__(self, store, wizard, model,
                                  previous=previous)

        self._update_totals()
        self.update_discount_and_surcharge()
예제 #24
0
파일: salewizard.py 프로젝트: esosaja/stoq
    def setup_slaves(self):
        marker('SelectPaymentMethodSlave')
        self.pm_slave = SelectPaymentMethodSlave(store=self.store,
                                                 payment_type=Payment.TYPE_IN)
        self.attach_slave('select_method_holder', self.pm_slave)

        marker('CashChangeSlave')
        self.cash_change_slave = CashChangeSlave(self.store, self.model, self.wizard)
        self.attach_slave('cash_change_holder', self.cash_change_slave)
        self.cash_change_slave.received_value.connect(
            'activate', lambda entry: self.wizard.go_to_next())
예제 #25
0
    def __init__(self, wizard, store, model, payment_group, previous=None):
        self.pm_slave = None
        self.payment_group = payment_group

        BaseMethodSelectionStep.__init__(self)
        marker("WizardEditorStep.__init__")
        WizardEditorStep.__init__(self, store, wizard, model,
                                  previous=previous)

        self._update_totals()
        self.update_discount_and_surcharge()
예제 #26
0
파일: salewizard.py 프로젝트: Farrapo/stoq
    def setup_slaves(self):
        marker('SelectPaymentMethodSlave')
        self.pm_slave = SelectPaymentMethodSlave(store=self.store,
                                                 payment_type=Payment.TYPE_IN)
        self.attach_slave('select_method_holder', self.pm_slave)

        marker('CashChangeSlave')
        self.cash_change_slave = CashChangeSlave(self.store, self.model, self.wizard)
        self.attach_slave('cash_change_holder', self.cash_change_slave)
        self.cash_change_slave.received_value.connect(
            'activate', lambda entry: self.wizard.go_to_next())
예제 #27
0
파일: salewizard.py 프로젝트: Farrapo/stoq
 def update_discount_and_surcharge(self):
     marker("update_discount_and_surcharge")
     # Here we need avoid to reset sale data defined when creating the
     # Sale in the POS application, i.e, we should not reset the
     # discount and surcharge if they are already set (this is the
     # case when one of the parameters, CONFIRM_SALES_ON_TILL or
     # USE_TRADE_AS_DISCOUNT is enabled).
     if (not sysparam.get_bool('CONFIRM_SALES_ON_TILL') and
             not sysparam.get_bool('USE_TRADE_AS_DISCOUNT')):
         self.model.discount_value = currency(0)
         self.model.surcharge_value = currency(0)
예제 #28
0
 def update_discount_and_surcharge(self):
     marker("update_discount_and_surcharge")
     # Here we need avoid to reset sale data defined when creating the
     # Sale in the POS application, i.e, we should not reset the
     # discount and surcharge if they are already set (this is the
     # case when one of the parameters, CONFIRM_SALES_ON_TILL or
     # USE_TRADE_AS_DISCOUNT is enabled).
     if (not sysparam.get_bool('CONFIRM_SALES_ON_TILL')
             and not sysparam.get_bool('USE_TRADE_AS_DISCOUNT')):
         self.model.discount_value = currency(0)
         self.model.surcharge_value = currency(0)
예제 #29
0
 def setup_proxies(self):
     marker('Setting up proxies')
     self.setup_widgets()
     self.proxy = self.add_proxy(self.model, SalesPersonStep.proxy_widgets)
     self.invoice_proxy = self.add_proxy(self.invoice_model,
                                         self.invoice_widgets)
     if self.model.client:
         self.client.set_sensitive(False)
         self.create_client.set_sensitive(False)
     if sysparam(self.store).ASK_SALES_CFOP:
         self.add_proxy(self.model, SalesPersonStep.cfop_widgets)
     marker('Finished setting up proxies')
예제 #30
0
파일: salewizard.py 프로젝트: romaia/stoq
    def __init__(self, wizard, store, model, payment_group,
                 invoice_model):
        self.invoice_model = invoice_model

        self.payment_group = payment_group

        BaseMethodSelectionStep.__init__(self)
        marker("WizardEditorStep.__init__")
        WizardEditorStep.__init__(self, store, wizard, model)

        self._update_totals()
        self.update_discount_and_surcharge()
예제 #31
0
    def post_init(self):
        BaseMethodSelectionStep.post_init(self)

        marker('Entering post_init')
        if self.wizard.need_create_payment():
            self.wizard.payment_group.clear_unused()
        self.register_validate_function(self._refresh_next)
        self._update_next_step(self.get_selected_method())
        if hasattr(self, 'cash_change_slave'):
            self.cash_change_slave.received_value.grab_focus()

        self.force_validation()
        marker('Leaving post_init')
예제 #32
0
    def get_columns(self):
        marker('_get_columns')
        columns = []
        text_columns = []
        for field in self._fields:
            col = field.get_column(self.search_spec)
            columns.append(col)
            if field.data_type is str and isinstance(col, SearchColumn):
                text_columns.append(col.search_attribute)

        self.text_field_columns = text_columns
        marker('Done _get_columns')
        return columns
예제 #33
0
    def get_columns(self):
        marker('_get_columns')
        columns = []
        text_columns = []
        for field in self._fields:
            col = field.get_column(self.search_spec)
            columns.append(col)
            if field.data_type is str and isinstance(col, SearchColumn):
                text_columns.append(col.search_attribute)

        self.text_field_columns = text_columns
        marker('Done _get_columns')
        return columns
예제 #34
0
파일: salewizard.py 프로젝트: romaia/stoq
 def setup_proxies(self):
     marker('Setting up proxies')
     self.setup_widgets()
     self.proxy = self.add_proxy(self.model,
                                 SalesPersonStep.proxy_widgets)
     self.invoice_proxy = self.add_proxy(self.invoice_model,
                                         self.invoice_widgets)
     if self.model.client:
         self.client.set_sensitive(False)
         self.create_client.set_sensitive(False)
     if sysparam(self.store).ASK_SALES_CFOP:
         self.add_proxy(self.model, SalesPersonStep.cfop_widgets)
     marker('Finished setting up proxies')
예제 #35
0
    def __init__(self, store, model, subtotal, total_paid=0):
        """Creates a new SaleWizard that confirms a sale.
        To avoid excessive querying of the database we pass
        some data already queried/calculated before hand.

        :param store: a store
        :param model: a |sale|
        :param subtotal: subtotal of the sale
        :param total_paid: totaly value already paid
        """
        marker('ConfirmSaleWizard')
        self._check_payment_group(model, store)
        self._subtotal = subtotal
        self._total_paid = total_paid
        self.model = model

        # invoice_model is a Settable so avoid bug 4218, where more
        # than one checkout may try to use the same invoice number.
        self.invoice_model = Settable(invoice_number=None,
                                      original_invoice=None)
        marker('running SalesPersonStep')
        first_step = self.first_step(self, store, model, self.payment_group,
                                     self.invoice_model)
        marker('finished creating SalesPersonStep')
        BaseWizard.__init__(self, store, first_step, model)

        if not sysparam(self.store).CONFIRM_SALES_ON_TILL:
            # This was added to allow us to work even if an error
            # happened while adding a payment, where we already order
            # but cannot confirm and are thrown back to the main
            # POS interface
            if self.model.can_order():
                self.model.order()

        marker('leaving ConfirmSaleWizard.__init__')
예제 #36
0
    def confirm(self, dialog):
        marker('Saving data')

        objs = self.get_changed_objects()
        total = len(objs)
        for i, obj in enumerate(objs):
            for field in self._fields:
                field.save_value(obj)
                yield i, total
            # Flush soon, so that any errors triggered by database constraints
            # pop up.
            self._store.flush()

        marker('Done saving data')
예제 #37
0
파일: salewizard.py 프로젝트: romaia/stoq
    def _fill_cost_center_combo(self):
        marker('Filling cost centers')
        cost_centers = CostCenter.get_active(self.store)

        # we keep this value because each call to is_empty() is a new sql query
        # to the database
        cost_centers_exists = not cost_centers.is_empty()

        if cost_centers_exists:
            self.cost_center.prefill(api.for_combo(cost_centers, attr='name',
                                                   empty=_('No cost center.')))
        self.cost_center.set_visible(cost_centers_exists)
        self.cost_center_lbl.set_visible(cost_centers_exists)
        marker('Filled cost centers')
예제 #38
0
    def confirm(self, dialog):
        marker('Saving data')

        objs = self.get_changed_objects()
        total = len(objs)
        for i, obj in enumerate(objs):
            for field in self._fields:
                field.save_value(obj)
                yield i, total
            # Flush soon, so that any errors triggered by database constraints
            # pop up.
            self._store.flush()

        marker('Done saving data')
예제 #39
0
    def post_init(self):
        BaseMethodSelectionStep.post_init(self)

        marker('Entering post_init')
        self.toogle_client_details()
        if self.wizard.need_create_payment():
            self.wizard.payment_group.clear_unused()
        self.register_validate_function(self._refresh_next)
        self._update_next_step(self.get_selected_method())
        if hasattr(self, 'cash_change_slave'):
            self.cash_change_slave.received_value.grab_focus()

        self.force_validation()
        marker('Leaving post_init')
예제 #40
0
파일: salewizard.py 프로젝트: esosaja/stoq
    def _fill_cost_center_combo(self):
        marker('Filling cost centers')
        cost_centers = CostCenter.get_active(self.store)

        # we keep this value because each call to is_empty() is a new sql query
        # to the database
        cost_centers_exists = not cost_centers.is_empty()

        if cost_centers_exists:
            self.cost_center.prefill(api.for_combo(cost_centers, attr='name',
                                                   empty=_('No cost center.')))
        self.cost_center.set_visible(cost_centers_exists)
        self.cost_center_lbl.set_visible(cost_centers_exists)
        marker('Filled cost centers')
예제 #41
0
파일: salewizard.py 프로젝트: Farrapo/stoq
    def post_init(self):
        BaseMethodSelectionStep.post_init(self)

        marker('Entering post_init')
        if self.wizard.need_create_payment():
            self.wizard.payment_group.clear_unused()
        self.register_validate_function(self._refresh_next)
        self._update_next_step(self.get_selected_method())
        # If there's no salesperson, keep the focus there as it should be
        # selected first to have a nice flow
        if (hasattr(self, 'cash_change_slave') and
                self.model.salesperson is not None):
            self.cash_change_slave.received_value.grab_focus()

        self.force_validation()
        marker('Leaving post_init')
예제 #42
0
파일: salewizard.py 프로젝트: pkaislan/stoq
    def setup_slaves(self):
        marker('Setting up slaves')
        BaseMethodSelectionStep.setup_slaves(self)
        marker('Finished parent')

        self.pm_slave.set_client(self.model.client,
                                 total_amount=self.wizard.get_total_to_pay())

        marker('Setting discount')
        self.discount_slave = SaleDiscountSlave(self.store, self.model,
                                                self.model_type)
        marker('Finshed setting up discount')

        self.discount_slave.connect('discount-changed',
                                    self.on_discount_slave_changed)
        slave_holder = 'discount_surcharge_slave'
        if self.get_slave(slave_holder):
            self.detach_slave(slave_holder)
        self.attach_slave(slave_holder, self.discount_slave)
        marker('Finished setting up slaves')
예제 #43
0
    def on_confirm(self):
        marker('Saving prices')
        # FIXME: Improve this part. This is just a quick workaround to
        # release the bugfix asap
        self.main_dialog.ok_button.set_sensitive(False)
        self.main_dialog.cancel_button.set_sensitive(False)
        d = ProgressDialog(_('Updating items'), pulse=False)
        d.set_transient_for(self.main_dialog)
        d.start(wait=0)
        d.cancel.hide()

        total = len(self.slave.listcontainer.list)
        for i, s in enumerate(self.slave.listcontainer.list):
            s.save_changes()
            d.progressbar.set_text('%s/%s' % (i + 1, total))
            d.progressbar.set_fraction((i + 1) / float(total))
            while gtk.events_pending():
                gtk.main_iteration(False)

        d.stop()
        marker('Done saving prices')
        self.slave.listcontainer.list.clear()
예제 #44
0
    def setup_slaves(self):
        marker('Setting up slaves')
        BaseMethodSelectionStep.setup_slaves(self)
        marker('Finished parent')

        self.pm_slave.method_set_sensitive(u'store_credit',
                                           bool(self.model.client))
        self.pm_slave.method_set_sensitive(u'bill', bool(self.model.client))
        self.pm_slave.method_set_sensitive(u'credit', bool(self.model.client))

        marker('Setting discount')
        self.discount_slave = SaleDiscountSlave(self.store, self.model,
                                                self.model_type)
        marker('Finshed setting up discount')

        self.discount_slave.connect('discount-changed',
                                    self.on_discount_slave_changed)
        slave_holder = 'discount_surcharge_slave'
        if self.get_slave(slave_holder):
            self.detach_slave(slave_holder)
        self.attach_slave(slave_holder, self.discount_slave)
        marker('Finished setting up slaves')
예제 #45
0
파일: salewizard.py 프로젝트: romaia/stoq
    def setup_slaves(self):
        marker('Setting up slaves')
        BaseMethodSelectionStep.setup_slaves(self)
        marker('Finished parent')

        self.pm_slave.method_set_sensitive(u'store_credit',
                                           bool(self.model.client))
        self.pm_slave.method_set_sensitive(u'bill',
                                           bool(self.model.client))

        marker('Setting discount')
        self.discount_slave = SaleDiscountSlave(self.store, self.model,
                                                self.model_type)
        marker('Finshed setting up discount')

        self.discount_slave.connect('discount-changed',
                                    self.on_discount_slave_changed)
        slave_holder = 'discount_surcharge_slave'
        if self.get_slave(slave_holder):
            self.detach_slave(slave_holder)
        self.attach_slave(slave_holder, self.discount_slave)
        marker('Finished setting up slaves')
예제 #46
0
    def on_confirm(self):
        marker('Saving prices')
        # FIXME: Improve this part. This is just a quick workaround to
        # release the bugfix asap
        self.main_dialog.ok_button.set_sensitive(False)
        self.main_dialog.cancel_button.set_sensitive(False)
        d = ProgressDialog(_('Updating items'), pulse=False)
        d.set_transient_for(self.main_dialog)
        d.start(wait=0)
        d.cancel.hide()

        total = len(self.slave.listcontainer.list)
        for i, s in enumerate(self.slave.listcontainer.list):
            s.save_changes()
            d.progressbar.set_text('%s/%s' % (i + 1, total))
            d.progressbar.set_fraction((i + 1) / float(total))
            while gtk.events_pending():
                gtk.main_iteration(False)

        d.stop()
        marker('Done saving prices')
        self.slave.listcontainer.list.clear()
예제 #47
0
    def __init__(self, store, model, subtotal, total_paid=0,
                 current_document=None):
        """Creates a new SaleWizard that confirms a sale.
        To avoid excessive querying of the database we pass
        some data already queried/calculated before hand.

        :param store: a store
        :param model: a |sale|
        :param subtotal: subtotal of the sale
        :param total_paid: totaly value already paid
        :param current_document: the current document of the identified client,
          if any
        """
        marker('ConfirmSaleWizard')
        self._check_payment_group(model, store)
        self._subtotal = subtotal
        self._total_paid = total_paid
        self._current_document = current_document
        self.model = model

        # invoice_model is a Settable so avoid bug 4218, where more
        # than one checkout may try to use the same invoice number.
        self.invoice_model = Settable(invoice_number=None,
                                      original_invoice=None)

        adjusted_batches = model.check_and_adjust_batches()
        if not adjusted_batches:
            first_step = ConfirmSaleBatchStep(store, self, model, None)
        else:
            marker('running SalesPersonStep')
            first_step = SalesPersonStep(self, store, model, self.payment_group,
                                         self.invoice_model)
            marker('finished creating SalesPersonStep')

        BaseWizard.__init__(self, store, first_step, model)

        if not sysparam.get_bool('CONFIRM_SALES_ON_TILL'):
            # This was added to allow us to work even if an error
            # happened while adding a payment, where we already order
            # but cannot confirm and are thrown back to the main
            # POS interface
            if self.model.can_order():
                self.model.order()

        marker('leaving ConfirmSaleWizard.__init__')
예제 #48
0
    def __init__(self,
                 store,
                 model,
                 subtotal,
                 total_paid=0,
                 current_document=None):
        """Creates a new SaleWizard that confirms a sale.
        To avoid excessive querying of the database we pass
        some data already queried/calculated before hand.

        :param store: a store
        :param model: a |sale|
        :param subtotal: subtotal of the sale
        :param total_paid: totaly value already paid
        :param current_document: the current document of the identified client,
          if any
        """
        marker('ConfirmSaleWizard')
        self._check_payment_group(model, store)
        self._subtotal = subtotal
        self._total_paid = total_paid
        self._current_document = current_document
        self.model = model

        adjusted_batches = model.check_and_adjust_batches()
        if not adjusted_batches:
            first_step = ConfirmSaleBatchStep(store, self, model, None)
        else:
            marker('running SalesPersonStep')
            first_step = SalesPersonStep(self, store, model,
                                         self.payment_group)
            marker('finished creating SalesPersonStep')

        BaseWizard.__init__(self, store, first_step, model)

        if not sysparam.get_bool('CONFIRM_SALES_ON_TILL'):
            # This was added to allow us to work even if an error
            # happened while adding a payment, where we already order
            # but cannot confirm and are thrown back to the main
            # POS interface
            if self.model.can_order():
                self.model.order()

        marker('leaving ConfirmSaleWizard.__init__')
예제 #49
0
    def _setup_widgets(self):
        self.category.prefill(api.for_combo(self.categories))

        prices = self.store.find(ClientCategoryPrice).order_by(ClientCategoryPrice.id)
        category_prices = {}
        for p in prices:
            c = category_prices.setdefault(p.sellable_id, {})
            c[p.category_id] = p.price

        marker('SellableView')
        sellables = self.store.find(SellableView).order_by(Sellable.code)

        marker('add_items')
        for s in sellables:
            for category_id, price in category_prices.get(s.id, {}).items():
                s.set_price(category_id, price)
            self.slave.listcontainer.list.append(s)
        marker('Done add_items')
예제 #50
0
    def _setup_widgets(self):
        self.category.prefill(api.for_combo(self.categories))

        prices = self.store.find(ClientCategoryPrice)
        category_prices = {}
        for p in prices:
            c = category_prices.setdefault(p.sellable_id, {})
            c[p.category_id] = p.price

        marker('SellableView')
        sellables = self.store.find(SellableView).order_by(Sellable.code)

        marker('add_items')
        for s in sellables:
            for category_id, price in category_prices.get(s.id, {}).items():
                s.set_price(category_id, price)
            self.slave.listcontainer.list.append(s)
        marker('Done add_items')
예제 #51
0
    def setup_widgets(self):
        marker('Setting up widgets')
        # Only quotes have expire date.
        self.expire_date.hide()
        self.expire_label.hide()

        # Hide client category widgets
        self.client_category_lbl.hide()
        self.client_category.hide()

        # if the NF-e plugin is active, the client is mandantory in this
        # wizard (in this situation, we have only quote sales).
        if self.model.status == Sale.STATUS_QUOTE:
            manager = get_plugin_manager()
            mandatory_client = manager.is_active('nfe')
            self.client.set_property('mandatory', mandatory_client)

        marker('Filling sales persons')
        salespersons = SalesPerson.get_active_salespersons(self.store)
        self.salesperson.prefill(salespersons)
        marker('Finished filling sales persons')

        marker('Read parameter')
        change_salesperson = sysparam.get_int('ACCEPT_CHANGE_SALESPERSON')
        if change_salesperson == ChangeSalespersonPolicy.ALLOW:
            self.salesperson.grab_focus()
        elif change_salesperson == ChangeSalespersonPolicy.DISALLOW:
            self.salesperson.set_sensitive(False)
        elif change_salesperson == ChangeSalespersonPolicy.FORCE_CHOOSE:
            self.model.salesperson = None
            self.salesperson.grab_focus()
        else:
            raise AssertionError
        marker('Finished reading parameter')
        self._setup_clients_widget()
        self._fill_transporter_combo()
        self._fill_cost_center_combo()

        if sysparam.get_bool('ASK_SALES_CFOP'):
            self._fill_cfop_combo()
        else:
            self.cfop_lbl.hide()
            self.cfop.hide()
            self.create_cfop.hide()

        marker('Finished setting up widgets')
예제 #52
0
 def _fill_cfop_combo(self):
     marker('Filling CFOPs')
     cfops = CfopData.get_for_sale(self.store)
     self.cfop.prefill(api.for_combo(cfops))
     marker('Filled CFOPs')
예제 #53
0
파일: salewizard.py 프로젝트: romaia/stoq
    def setup_widgets(self):
        marker('Setting up widgets')
        # Only quotes have expire date.
        self.expire_date.hide()
        self.expire_label.hide()

        # Hide operation nature widgets
        self.operation_nature.hide()
        self.nature_lbl.hide()

        # Hide client category widgets
        self.client_category_lbl.hide()
        self.client_category.hide()

        # if the NF-e plugin is active, the client is mandantory in this
        # wizard (in this situation, we have only quote sales).
        if self.model.status == Sale.STATUS_QUOTE:
            manager = get_plugin_manager()
            mandatory_client = manager.is_active('nfe')
            self.client.set_property('mandatory', mandatory_client)

        marker('Filling sales persons')
        salespersons = self.store.find(SalesPerson)
        self.salesperson.prefill(api.for_person_combo(salespersons))
        marker('Finished filling sales persons')

        marker('Read parameter')
        if not sysparam(self.store).ACCEPT_CHANGE_SALESPERSON:
            self.salesperson.set_sensitive(False)
        else:
            self.salesperson.grab_focus()
        marker('Finished reading parameter')
        self._fill_clients_combo()
        self._fill_transporter_combo()
        self._fill_cost_center_combo()

        if sysparam(self.store).ASK_SALES_CFOP:
            self._fill_cfop_combo()
        else:
            self.cfop_lbl.hide()
            self.cfop.hide()
            self.create_cfop.hide()

        # the maximum number allowed for an invoice is 999999999.
        self.invoice_number.set_adjustment(
            gtk.Adjustment(lower=1, upper=999999999, step_incr=1))

        if not self.model.invoice_number:
            new_invoice_number = Sale.get_last_invoice_number(self.store) + 1
            self.invoice_model.invoice_number = new_invoice_number
        else:
            new_invoice_number = self.model.invoice_number
            self.invoice_model.invoice_number = new_invoice_number
            self.invoice_number.set_sensitive(False)

        self.invoice_model.original_invoice = new_invoice_number
        marker('Finished setting up widgets')
예제 #54
0
 def _fill_cfop_combo(self):
     marker('Filling CFOPs')
     cfops = self.store.find(CfopData)
     self.cfop.prefill(api.for_combo(cfops))
     marker('Filled CFOPs')
예제 #55
0
파일: salewizard.py 프로젝트: romaia/stoq
 def _fill_cfop_combo(self):
     marker('Filling CFOPs')
     cfops = self.store.find(CfopData)
     self.cfop.prefill(api.for_combo(cfops))
     marker('Filled CFOPs')
예제 #56
0
파일: pos.py 프로젝트: pkaislan/stoq
 def on_barcode__activate(self, entry):
     marker("enter pressed")
     self._checkout_or_add_item()
예제 #57
0
파일: salewizard.py 프로젝트: Farrapo/stoq
 def _fill_cfop_combo(self):
     marker('Filling CFOPs')
     cfops = CfopData.get_for_sale(self.store)
     self.cfop.prefill(api.for_combo(cfops))
     marker('Filled CFOPs')
예제 #58
0
파일: salewizard.py 프로젝트: esosaja/stoq
    def setup_widgets(self):
        marker('Setting up widgets')
        # Only quotes have expire date.
        self.expire_date.hide()
        self.expire_label.hide()

        # Hide client category widgets
        self.client_category_lbl.hide()
        self.client_category.hide()

        # if the NF-e plugin is active, the client is mandantory in this
        # wizard (in this situation, we have only quote sales).
        if self.model.status == Sale.STATUS_QUOTE:
            manager = get_plugin_manager()
            mandatory_client = manager.is_active('nfe')
            self.client.set_property('mandatory', mandatory_client)

        marker('Filling sales persons')
        salespersons = self.store.find(SalesPerson)
        self.salesperson.prefill(api.for_person_combo(salespersons))
        marker('Finished filling sales persons')

        marker('Read parameter')
        change_salesperson = sysparam.get_int('ACCEPT_CHANGE_SALESPERSON')
        if change_salesperson == ChangeSalespersonPolicy.ALLOW:
            self.salesperson.grab_focus()
        elif change_salesperson == ChangeSalespersonPolicy.DISALLOW:
            self.salesperson.set_sensitive(False)
        elif change_salesperson == ChangeSalespersonPolicy.FORCE_CHOOSE:
            self.model.salesperson = None
            self.salesperson.grab_focus()
        else:
            raise AssertionError
        marker('Finished reading parameter')
        self._setup_clients_widget()
        self._fill_transporter_combo()
        self._fill_cost_center_combo()

        if sysparam.get_bool('ASK_SALES_CFOP'):
            self._fill_cfop_combo()
        else:
            self.cfop_lbl.hide()
            self.cfop.hide()
            self.create_cfop.hide()

        # the maximum number allowed for an invoice is 999999999.
        self.invoice_number.set_adjustment(
            gtk.Adjustment(lower=1, upper=999999999, step_incr=1))

        if not self.model.invoice_number:
            new_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.invoice_model.invoice_number = new_invoice_number
        else:
            new_invoice_number = self.model.invoice_number
            self.invoice_model.invoice_number = new_invoice_number
            self.invoice_number.set_sensitive(False)

        self.invoice_model.original_invoice = new_invoice_number
        marker('Finished setting up widgets')
예제 #59
0
 def _apply(self):
     marker('Updating values')
     for i in self._results:
         self._editor.apply_operation(i)
         self._results.refresh(i)
     marker('Done updating values')
예제 #60
0
 def _apply(self):
     marker('Updating values')
     for i in self._results:
         self._editor.apply_operation(i)
         self._results.refresh(i)
     marker('Done updating values')