def recover_deleted_product(parent_product: Product, shop: Shop, deleted_product: Product, combination: Combination, combination_hash: str) -> Product: deleted_product.name = get_variation_product_name(parent_product, combination) deleted_product.tax_class = parent_product.tax_class deleted_product.sales_unit = parent_product.sales_unit deleted_product.shipping_mode = parent_product.shipping_mode deleted_product.type = parent_product.type deleted_product.manufacturer = parent_product.manufacturer deleted_product.height = parent_product.height deleted_product.depth = parent_product.depth deleted_product.net_weight = parent_product.net_weight deleted_product.gross_weight = parent_product.gross_weight deleted_product.deleted = False deleted_product.save() deleted_product.link_to_parent(parent_product, combination_hash=combination_hash) return deleted_product
def create_variation_product(parent_product: Product, shop: Shop, sku: str, combination: Combination, combination_hash: str) -> Product: variation_child = Product( name=get_variation_product_name(parent_product, combination), tax_class=parent_product.tax_class, sales_unit=parent_product.sales_unit, sku=sku, shipping_mode=parent_product.shipping_mode, type=parent_product.type, manufacturer=parent_product.manufacturer, height=parent_product.height, depth=parent_product.depth, net_weight=parent_product.net_weight, gross_weight=parent_product.gross_weight, ) variation_child.full_clean() variation_child.save() variation_child.link_to_parent(parent_product, combination_hash=combination_hash) return variation_child