Exemple #1
0
 def setup_slaves(self):
     from stoqlib.gui.slaves.productslave import ProductDetailsSlave
     self.details_slave = ProductDetailsSlave(self.store,
                                              self.model.sellable,
                                              self.db_form,
                                              self.visual_mode)
     self.add_extra_tab(_(u'Details'), self.details_slave)
Exemple #2
0
 def setup_slaves(self):
     from stoqlib.gui.slaves.productslave import ProductDetailsSlave
     details_slave = ProductDetailsSlave(self.store, self.model.sellable)
     details_slave.hide_stock_details()
     self.attach_slave('place_holder', details_slave)
Exemple #3
0
class ProductEditor(SellableEditor):
    model_name = _('Product')
    model_type = Product
    help_section = 'product'
    ui_form_name = u'product'

    product_widgets = ['manage_stock']

    _model_created = False

    def __init__(self, store, model=None, visual_mode=False):
        SellableEditor.__init__(self, store, model, visual_mode=visual_mode)
        # This can't be done in setup_slaves() as we need to access
        # self.main_dialog when setting up the quality test slave
        self._add_extra_tabs()

    def _add_extra_tabs(self):
        for tabname, tabslave in self.get_extra_tabs():
            self.add_extra_tab(tabname, tabslave)

    def get_taxes(self):
        query = (SellableTaxConstant.tax_type != int(TaxType.SERVICE))
        constants = self.store.find(SellableTaxConstant, query).order_by(
            SellableTaxConstant.description)
        return [(c.description, c) for c in constants]

    #
    # BaseEditor
    #

    def setup_slaves(self):
        from stoqlib.gui.slaves.productslave import ProductDetailsSlave
        self.details_slave = ProductDetailsSlave(self.store,
                                                 self.model.sellable,
                                                 self.db_form,
                                                 self.visual_mode)
        self.add_extra_tab(_(u'Details'), self.details_slave)

    def setup_proxies(self):
        super(ProductEditor, self).setup_proxies()
        self.product_proxy = self.add_proxy(self.model, self.product_widgets)

    def get_extra_tabs(self):
        from stoqlib.gui.slaves.productslave import (ProductTaxSlave,
                                                     ProductSupplierSlave)
        extra_tabs = []

        suppliers_slave = ProductSupplierSlave(self.store, self.model,
                                               self.visual_mode)
        extra_tabs.append((_(u'Suppliers'), suppliers_slave))

        tax_slave = ProductTaxSlave(self.store, self.model, self.visual_mode)
        extra_tabs.append((_(u'Taxes'), tax_slave))
        return extra_tabs

    def setup_widgets(self):
        self.cost.set_digits(sysparam(self.store).COST_PRECISION_DIGITS)
        self.consignment_yes_button.set_active(self.model.consignment)
        self.consignment_yes_button.set_sensitive(self._model_created)
        self.consignment_no_button.set_sensitive(self._model_created)
        self.manage_stock.set_sensitive(self._model_created)

        self.description.grab_focus()

    def create_model(self, store):
        self._model_created = True
        tax_constant = sysparam(store).DEFAULT_PRODUCT_TAX_CONSTANT
        sellable = Sellable(store=store)
        sellable.tax_constant = tax_constant
        sellable.unit = sysparam(self.store).SUGGESTED_UNIT
        model = Product(store=store, sellable=sellable)
        # FIXME: Instead of creating and then removing, we should only create
        # the Storable if the user chooses to do so, but due to the way the
        # editor is implemented, it is not that easy. Change this once we write
        # the new product editor.
        Storable(product=model, store=store)
        return model

    def on_confirm(self):
        # The user choose not to manage stock for this product, so we must
        # remove the storable.
        if not self.model.manage_stock and self.model.storable:
            self.store.remove(self.model.storable)

    #
    #   Callbacks
    #

    def on_consignment_yes_button__toggled(self, widget):
        self.model.consignment = widget.get_active()
        # For now, we won't support consigned products with batches
        self.details_slave.set_allow_batch(not widget.get_active())

    def on_manage_stock__toggled(self, widget):
        self.details_slave.set_has_storable(self.model.manage_stock)
Exemple #4
0
 def setup_slaves(self):
     from stoqlib.gui.slaves.productslave import ProductDetailsSlave
     details_slave = ProductDetailsSlave(self.store, self.model.sellable)
     details_slave.hide_stock_details()
     self.attach_slave('place_holder', details_slave)
Exemple #5
0
 def setup_slaves(self):
     from stoqlib.gui.slaves.productslave import ProductDetailsSlave
     self.details_slave = ProductDetailsSlave(self.store, self.model.sellable,
                                              self.db_form, self.visual_mode)
     self.add_extra_tab(_(u'Details'), self.details_slave)
Exemple #6
0
class ProductEditor(SellableEditor):
    model_name = _('Product')
    model_type = Product
    help_section = 'product'
    ui_form_name = u'product'

    product_widgets = ['manage_stock']

    _model_created = False

    def __init__(self, store, model=None, visual_mode=False):
        SellableEditor.__init__(self, store, model, visual_mode=visual_mode)
        # This can't be done in setup_slaves() as we need to access
        # self.main_dialog when setting up the quality test slave
        self._add_extra_tabs()

    def _add_extra_tabs(self):
        for tabname, tabslave in self.get_extra_tabs():
            self.add_extra_tab(tabname, tabslave)

    def get_taxes(self):
        query = (SellableTaxConstant.tax_type != int(TaxType.SERVICE))
        constants = self.store.find(
            SellableTaxConstant, query).order_by(SellableTaxConstant.description)
        return [(c.description, c) for c in constants]

    #
    # BaseEditor
    #

    def setup_slaves(self):
        from stoqlib.gui.slaves.productslave import ProductDetailsSlave
        self.details_slave = ProductDetailsSlave(self.store, self.model.sellable,
                                                 self.db_form, self.visual_mode)
        self.add_extra_tab(_(u'Details'), self.details_slave)

    def setup_proxies(self):
        super(ProductEditor, self).setup_proxies()
        self.product_proxy = self.add_proxy(self.model, self.product_widgets)

    def get_extra_tabs(self):
        from stoqlib.gui.slaves.productslave import (ProductTaxSlave,
                                                     ProductSupplierSlave)
        extra_tabs = []

        suppliers_slave = ProductSupplierSlave(self.store, self.model,
                                               self.visual_mode)
        extra_tabs.append((_(u'Suppliers'), suppliers_slave))

        tax_slave = ProductTaxSlave(self.store, self.model, self.visual_mode)
        extra_tabs.append((_(u'Taxes'), tax_slave))
        return extra_tabs

    def setup_widgets(self):
        self.cost.set_digits(sysparam.get_int('COST_PRECISION_DIGITS'))
        self.consignment_yes_button.set_active(self.model.consignment)
        self.consignment_yes_button.set_sensitive(self._model_created)
        self.consignment_no_button.set_sensitive(self._model_created)
        self.manage_stock.set_sensitive(self._model_created)

        self.description.grab_focus()

    def create_model(self, store):
        self._model_created = True
        sellable = Sellable(store=store)
        sellable.tax_constant_id = sysparam.get_object_id('DEFAULT_PRODUCT_TAX_CONSTANT')
        sellable.unit_id = sysparam.get_object_id('SUGGESTED_UNIT')
        model = Product(store=store, sellable=sellable)
        # FIXME: Instead of creating and then removing, we should only create
        # the Storable if the user chooses to do so, but due to the way the
        # editor is implemented, it is not that easy. Change this once we write
        # the new product editor.
        Storable(product=model, store=store)
        return model

    def on_confirm(self):
        # The user choose not to manage stock for this product, so we must
        # remove the storable.
        if not self.model.manage_stock and self.model.storable:
            self.store.remove(self.model.storable)

    #
    #   Callbacks
    #

    def on_consignment_yes_button__toggled(self, widget):
        self.model.consignment = widget.get_active()
        # For now, we won't support consigned products with batches
        self.details_slave.set_allow_batch(not widget.get_active())

    def on_manage_stock__toggled(self, widget):
        self.details_slave.set_has_storable(self.model.manage_stock)
Exemple #7
0
class ProductEditor(SellableEditor):
    model_name = _('Product')
    model_type = Product
    help_section = 'product'
    ui_form_name = u'product'

    _model_created = False

    def __init__(self, store, model=None, visual_mode=False):
        SellableEditor.__init__(self, store, model, visual_mode=visual_mode)
        # This can't be done in setup_slaves() as we need to access
        # self.main_dialog when setting up the quality test slave
        self._add_extra_tabs()

    def get_taxes(self):
        query = (SellableTaxConstant.tax_type != int(TaxType.SERVICE))
        constants = self.store.find(
            SellableTaxConstant, query).order_by(SellableTaxConstant.id)
        return [(c.description, c) for c in constants]

    #
    # BaseEditor
    #

    def setup_slaves(self):
        from stoqlib.gui.slaves.productslave import ProductDetailsSlave
        self.details_slave = ProductDetailsSlave(self.store, self.model.sellable,
                                                 self.db_form, self.visual_mode)
        self.add_extra_tab(_(u'Details'), self.details_slave)

    def _add_extra_tabs(self):
        for tabname, tabslave in self.get_extra_tabs():
            self.add_extra_tab(tabname, tabslave)

    def get_extra_tabs(self):
        from stoqlib.gui.slaves.productslave import (ProductTaxSlave,
                                                     ProductSupplierSlave)
        extra_tabs = []

        suppliers_slave = ProductSupplierSlave(self.store, self.model,
                                               self.visual_mode)
        extra_tabs.append((_(u'Suppliers'), suppliers_slave))

        tax_slave = ProductTaxSlave(self.store, self.model, self.visual_mode)
        extra_tabs.append((_(u'Taxes'), tax_slave))
        return extra_tabs

    def setup_widgets(self):
        self.cost.set_digits(sysparam(self.store).COST_PRECISION_DIGITS)
        self.consignment_yes_button.set_active(self.model.consignment)
        self.consignment_yes_button.set_sensitive(self._model_created)
        self.consignment_no_button.set_sensitive(self._model_created)
        self.description.grab_focus()

    def create_model(self, store):
        self._model_created = True
        tax_constant = sysparam(store).DEFAULT_PRODUCT_TAX_CONSTANT
        sellable = Sellable(store=store)
        sellable.tax_constant = tax_constant
        sellable.unit = sysparam(self.store).SUGGESTED_UNIT
        model = Product(store=store, sellable=sellable)
        Storable(product=model, store=store)
        return model

    def on_consignment_yes_button__toggled(self, widget):
        self.model.consignment = widget.get_active()
        # For now, we won't support consigned products with batches
        self.details_slave.set_allow_batch(not widget.get_active())
Exemple #8
0
class ProductEditor(SellableEditor):
    model_name = _('Product')
    model_type = Product
    help_section = 'product'
    ui_form_name = u'product'

    _model_created = False

    def __init__(self, store, model=None, visual_mode=False):
        SellableEditor.__init__(self, store, model, visual_mode=visual_mode)
        # This can't be done in setup_slaves() as we need to access
        # self.main_dialog when setting up the quality test slave
        self._add_extra_tabs()

    def get_taxes(self):
        query = (SellableTaxConstant.tax_type != int(TaxType.SERVICE))
        constants = self.store.find(SellableTaxConstant,
                                    query).order_by(SellableTaxConstant.id)
        return [(c.description, c) for c in constants]

    #
    # BaseEditor
    #

    def setup_slaves(self):
        from stoqlib.gui.slaves.productslave import ProductDetailsSlave
        self.details_slave = ProductDetailsSlave(self.store,
                                                 self.model.sellable,
                                                 self.db_form,
                                                 self.visual_mode)
        self.add_extra_tab(_(u'Details'), self.details_slave)

    def _add_extra_tabs(self):
        for tabname, tabslave in self.get_extra_tabs():
            self.add_extra_tab(tabname, tabslave)

    def get_extra_tabs(self):
        from stoqlib.gui.slaves.productslave import (ProductTaxSlave,
                                                     ProductSupplierSlave)
        extra_tabs = []

        suppliers_slave = ProductSupplierSlave(self.store, self.model,
                                               self.visual_mode)
        extra_tabs.append((_(u'Suppliers'), suppliers_slave))

        tax_slave = ProductTaxSlave(self.store, self.model, self.visual_mode)
        extra_tabs.append((_(u'Taxes'), tax_slave))
        return extra_tabs

    def setup_widgets(self):
        self.cost.set_digits(sysparam(self.store).COST_PRECISION_DIGITS)
        self.consignment_yes_button.set_active(self.model.consignment)
        self.consignment_yes_button.set_sensitive(self._model_created)
        self.consignment_no_button.set_sensitive(self._model_created)
        self.description.grab_focus()

    def create_model(self, store):
        self._model_created = True
        tax_constant = sysparam(store).DEFAULT_PRODUCT_TAX_CONSTANT
        sellable = Sellable(store=store)
        sellable.tax_constant = tax_constant
        sellable.unit = sysparam(self.store).SUGGESTED_UNIT
        model = Product(store=store, sellable=sellable)
        Storable(product=model, store=store)
        return model

    def on_consignment_yes_button__toggled(self, widget):
        self.model.consignment = widget.get_active()
        # For now, we won't support consigned products with batches
        self.details_slave.set_allow_batch(not widget.get_active())