コード例 #1
0
ファイル: producteditor.py プロジェクト: esosaja/stoq
    def get_extra_tabs(self):
        from stoqlib.gui.slaves.productslave import (ProductTaxSlave,
                                                     ProductSupplierSlave,
                                                     ProductGridSlave)
        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))

        if self.model.product_type == Product.TYPE_GRID:
            # If there is a wizard, it means we are creating a new product.
            # Store the selected attributes in the database
            if self._wizard:
                for attribute in self._wizard.attr_list:
                    ProductAttribute(store=self.store,
                                     product_id=self.model.id,
                                     attribute_id=attribute.id)

            attribute_option_slave = ProductGridSlave(self.store, self.model,
                                                      self.visual_mode)
            extra_tabs.append((_(u'Grid'), attribute_option_slave))
            attribute_option_slave.grid_tab_alignment.connect(
                'focus', self._on_grid_tab_alignment__focus)

        return extra_tabs
コード例 #2
0
ファイル: producteditor.py プロジェクト: Felipebros/stoq
    def create_model(self, store):
        self._model_created = True
        sellable = Sellable(store=store)
        model = Product(store=store, sellable=sellable)
        no_storable = [Product.TYPE_WITHOUT_STOCK, Product.TYPE_PACKAGE]
        if not self._product_type in no_storable:
            storable = Storable(product=model, store=store)

        if self._product_type == Product.TYPE_BATCH:
            storable.is_batch = True
        elif self._product_type == Product.TYPE_WITHOUT_STOCK:
            model.manage_stock = False
        elif self._product_type == Product.TYPE_CONSIGNED:
            model.consignment = True
        elif self._product_type == Product.TYPE_GRID:
            model.is_grid = True
            # Configurable products should not manage stock
            model.manage_stock = False
        elif self._product_type == Product.TYPE_PACKAGE:
            model.is_package = True
            # Package products should not manage stock
            model.manage_stock = False

        if self._template is not None:
            sellable.tax_constant = self._template.sellable.tax_constant
            sellable.unit = self._template.sellable.unit
            sellable.category = self._template.sellable.category
            sellable.base_price = self._template.sellable.base_price
            sellable.cost = self._template.sellable.cost
            sellable.default_sale_cfop = self._template.sellable.default_sale_cfop

            model.manufacturer = self._template.manufacturer
            model.brand = self._template.brand
            model.model = self._template.model
            model.family = self._template.family
            model.ncm = self._template.ncm
            model.set_icms_template(self._template._icms_template)
            model.set_ipi_template(self._template._ipi_template)
            model.set_pis_template(self._template._pis_template)
            model.set_cofins_template(self._template._cofins_template)

            for product_attr in self._template.attributes:
                ProductAttribute(store=self.store,
                                 product_id=model.id,
                                 attribute_id=product_attr.attribute.id)
            for supplier_info in self._template.suppliers:
                ProductSupplierInfo(store=self.store,
                                    product=model,
                                    supplier=supplier_info.supplier)
        else:
            sellable.tax_constant = sysparam.get_object(
                self.store, 'DEFAULT_PRODUCT_TAX_CONSTANT')
            sellable.unit_id = sysparam.get_object_id('SUGGESTED_UNIT')

        return model