Commit 1d62cd4b by François C.

uncommited stuff (should be only patches and methods for specific supercafoutch needs)

parent 38f3ee82
Pipeline #2908 failed with stage
in 1 minute 4 seconds
......@@ -427,6 +427,35 @@ class CagetteInventory(models.Model):
'inv_id': inv}
@staticmethod
def general_reset_stock(qty=0):
missed = []
done = []
api = OdooAPI()
# cond = [['active', '=', False], ['qty_available', '!=', 0]]
cond = [['active', '=', True], ['id', '>', 5100], ['id', '<=', 5400]]
fields = ['uom_id', 'name', 'qty_available']
res = api.search_read('product.product', cond, fields, 1500)
if len(res) > 0:
fields = {'company_id': 1, 'name': 'RAZ general reset',
'location_id': settings.STOCK_LOC_ID}
inv = api.create('stock.inventory', fields)
if not (inv is None):
for p in res:
try:
if p['qty_available'] != qty and p['qty_available'] < 0 and p['qty_available'] > -30:
fields = {'product_id': p['id'],
'inventory_id': inv,
'product_qty': qty,
'product_uom_id': p['uom_id'][0],
'location_id': settings.STOCK_LOC_ID}
li = api.create('stock.inventory.line', fields)
done.append({'product': p, 'id': li})
except Exception as e:
missed.append({'product': p, 'msg': str(e)})
api.execute('stock.inventory', 'action_done', [inv])
return {'missed': missed, 'done': done}
@staticmethod
def raz_archived_stock():
missed = []
done = []
......
......@@ -16,6 +16,7 @@ urlpatterns = [
url(r'^get_product_categories$', views.get_product_categories),
url(r'^create_inventory$', views.create_inventory),
url(r'^update_odoo_stock$', views.update_odoo_stock),
url(r'^general_reset_stock/?([0-9]*)$', views.general_reset_stock),
url(r'^raz_archived_stock$', views.raz_archived_stock),
url(r'^raz_negative_stock$', views.raz_negative_stock),
url(r'^raz_not_saleable$', views.raz_not_saleable),
......
......@@ -168,6 +168,17 @@ def update_odoo_stock(request):
res['msg'] = 'Forbidden'
return JsonResponse(res)
def general_reset_stock(request, qty):
res = {}
if True or CagetteUser.are_credentials_ok(request):
try:
res['action'] = CagetteInventory.general_reset_stock(qty)
except Exception as e:
res['msg'] = str(e)
else:
res['msg'] = 'Forbidden'
return JsonResponse(res)
def raz_archived_stock(request):
res = {}
if CagetteUser.are_credentials_ok(request):
......
......@@ -293,7 +293,7 @@ $(document).ready(function() {
let search_str = $('#search_member_input').val();
$.ajax({
url: '/members/search/' + search_str,
url: `/members/search/${search_str}?search_type=shift_template_data`,
dataType : 'json',
success: function(data) {
$('#partner_data_area').hide();
......
......@@ -1085,6 +1085,7 @@ function set_supplier_shortage(row, product, from_processed = false) {
product.old_qty = product.product_qty;
}
product.product_qty = 0;
product.package_qty = 0;
// Step 2: for consistency purposes, updated products need these fields to be set
} else {
if (!from_processed) {
......
......@@ -329,7 +329,7 @@ def save_error_report(request):
}
else:
# Read step 1 data from couch db document
order_id = f"order_{order['name'].split('PO')[1]}"
order_id = 'order_' + str(order['id'])
order_doc = c_db.getDocById(order_id)
try:
......
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