def post_init(self): # self.wizard.model will return something if it is coming back from self.slave = ProductEditor(self.store, wizard=self.wizard, product_type=self.wizard.product_type) self.slave.get_toplevel().reparent(self.place_holder) self.wizard.model = self.slave.model self.slave.register_validate_function(self.wizard.refresh_next) self.slave.force_validation()
def test_show(self): product = self.create_product(storable=True) image = self.create_image() image.image = _image image.sellable = product.sellable editor = ProductEditor(self.store, product) editor.code.update("12345") self.check_editor(editor, 'editor-product-show')
def test_create_without_category(self): # Removing data from SellableCategory, so we can test the validation of # category_combo update when there is no category. self.store.execute(Update({Sellable.category_id: None}, table=Sellable)) self.clean_domain([CommissionSource, SellableCategory]) editor = ProductEditor(self.store) editor.code.update("12345") self.assertNotSensitive(editor, ['category_combo']) self.check_editor(editor, 'editor-product-create-no-category')
def test_cost_precision_digits(self): # Set a number of digts greated than 2 sysparam.set_int(self.store, 'COST_PRECISION_DIGITS', 5) product = self.create_product(storable=True) product.sellable.cost = Decimal('1.23456') editor = ProductEditor(self.store, product) editor.code.update("12345") # We expect the editor to show the correct value self.check_editor(editor, 'editor-product-cost-precision-digits')
class ProductEditorStep(BaseWizardStep): gladefile = 'HolderTemplate' # # BaseWizardStep # def post_init(self): # self.wizard.model will return something if it is coming back from self.slave = ProductEditor(self.store, wizard=self.wizard, product_type=self.wizard.product_type) self.slave.get_toplevel().reparent(self.place_holder) self.wizard.model = self.slave.model self.slave.register_validate_function(self.wizard.refresh_next) self.slave.force_validation() def previous_step(self): # Avoid creating duplicated products when going back self.store.rollback(close=False) return super(ProductEditorStep, self).previous_step() def has_next_step(self): return False
def test_create_with_template(self): attribute_group = self.create_attribute_group() grid_attribute = self.create_grid_attribute(attribute_group=attribute_group, description=u'attr 1') grid_attribute2 = self.create_grid_attribute(attribute_group=attribute_group, description=u'attr 2') grid_product = self.create_product(storable=True, is_grid=True) self.create_product_attribute(product=grid_product, attribute=grid_attribute) self.create_product_attribute(product=grid_product, attribute=grid_attribute2) editor = ProductEditor(self.store, product_type=Product.TYPE_GRID, template=grid_product) # Be sure that its not the same product self.assertNotEqual(grid_product, editor.model) # But they have the same list of |grid_attribute| grid_product_attributes = set(attr.attribute for attr in grid_product.attributes) model_attributes = set(attr.attribute for attr in editor.model.attributes) self.assertEqual(grid_product_attributes, model_attributes) # and they are not empty self.assertNotEqual(len(model_attributes), 0)
def test_create_grid_product(self): grid_product = self.create_product(is_grid=True) editor = ProductEditor(self.store, grid_product) self.assertEqual(grid_product.product_type, Product.TYPE_GRID) self.check_editor(editor, 'editor-product-create-grid-product')
def test_create(self): editor = ProductEditor(self.store) editor.code.update("12345") self.check_editor(editor, 'editor-product-create')
def test_visual_mode(self): product = self.create_product(storable=True) editor = ProductEditor(self.store, product, visual_mode=True) editor.code.update("12412") self.assertNotSensitive(editor, ['add_category', 'sale_price_button']) self.check_editor(editor, 'editor-product-visual-mode')
def test_product_editor(self): product = self.create_product(stock=10) editor = ProductEditor(store=self.store, model=product) self.check_editor(editor, u'editor-product-optical-plugin')