Commit 70860307 by Yvon Kerdoncuff

entirely rework inventaire par produits app

parent abe34fb6
Pipeline #4183 failed with stage
...@@ -397,12 +397,11 @@ class CagetteProducts(models.Model): ...@@ -397,12 +397,11 @@ class CagetteProducts(models.Model):
return api.search_read('product.product', cond, fields) return api.search_read('product.product', cond, fields)
@staticmethod @staticmethod
def get_active_products_from_name(name): def get_all_active_products():
api = OdooAPI() api = OdooAPI()
cond = [['active', '=', True], cond = [['active', '=', True]]
['name', 'ilike', name]] fields = ['id', 'uom_id', 'name', 'qty_available', 'barcode']
fields = ['id', 'uom_id', 'name', 'qty_available', 'barcode', 'active', 'shelf_id', 'product_tmpl_id'] return api.search_read('product.product', cond, fields, limit=False)
return api.search_read('product.product', cond, fields)
@staticmethod @staticmethod
def get_vrac_products_from_cats(cats, withCandidate=False, fields=[]): def get_vrac_products_from_cats(cats, withCandidate=False, fields=[]):
......
.main, .barcode_or_name_search_area {
margin-top: 20px;
}
#barcode_or_name_selector {
border: 1px solid #555;
border-radius:15px;
}
.stock_edit_input { .stock_edit_input {
max-width: 100px; max-width: 100px;
}
.dataTables_filter {
display: block !important; /* S'assure qu'elle est bien affichée */
} }
\ No newline at end of file
...@@ -7,7 +7,7 @@ urlpatterns = [ ...@@ -7,7 +7,7 @@ urlpatterns = [
url(r'^simple_list$', views.get_simple_list), url(r'^simple_list$', views.get_simple_list),
url(r'^get_product_for_order_helper$', views.get_product_for_order_helper), url(r'^get_product_for_order_helper$', views.get_product_for_order_helper),
url(r'^get_product_data$', views.get_product_data), url(r'^get_product_data$', views.get_product_data),
url(r'^get_products_data_by_barcode_or_name$', views.get_products_data_by_barcode_or_name), url(r'^get_all_active_products$', views.get_all_active_products),
url(r'^get_products_stdprices$', views.get_products_stdprices), url(r'^get_products_stdprices$', views.get_products_stdprices),
url(r'^update_product_stock$', views.update_product_stock), url(r'^update_product_stock$', views.update_product_stock),
url(r'^update_product_purchase_ok$', views.update_product_purchase_ok), url(r'^update_product_purchase_ok$', views.update_product_purchase_ok),
......
...@@ -55,19 +55,8 @@ def get_product_for_order_helper(request): ...@@ -55,19 +55,8 @@ def get_product_for_order_helper(request):
else: else:
return JsonResponse(res, safe=False) return JsonResponse(res, safe=False)
def get_products_data_by_barcode_or_name(request): def get_all_active_products(request):
input = request.GET['input'] products = CagetteProducts.get_all_active_products()
# check if it is probably a barcode input
if input.isdigit() and len(input) > 6:
products = CagetteProduct.get_product_from_barcode(input)
# or a text input
else:
products = CagetteProducts.get_active_products_from_name(input)
#commented because too slow
#for product in products:
# add_shelf_sortorder(product)
if not products: if not products:
return JsonResponse({"product": products}, status=404) return JsonResponse({"product": products}, status=404)
else: else:
......
...@@ -18,11 +18,6 @@ ...@@ -18,11 +18,6 @@
<h1>Inventaire par produits</h1> <h1>Inventaire par produits</h1>
</div> </div>
<div class="barcode_or_name_search_area txtcenter">
<input type="text" id="barcode_or_name_selector" name="barcode_or_name_selector" placeholder="Nom ou codebarre">
<button type="button" class="btn--primary" id="button_barcode_or_name_selector" name="button">Recherche</button>
</div>
<div class="main"> <div class="main">
<table id="products_table" class="display" cellspacing="0" ></table> <table id="products_table" class="display" cellspacing="0" ></table>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment