feat: dupliquer un job + enregistrer et créer un autre
Deploy via Portainer / deploy (push) Successful in 1s
Deploy via Portainer / deploy (push) Successful in 1s
This commit is contained in:
@@ -956,8 +956,19 @@ def new_job():
|
||||
handling_profiles = conn.execute('SELECT * FROM handling_profiles ORDER BY name').fetchall()
|
||||
material_profiles = conn.execute('SELECT * FROM material_profiles ORDER BY name').fetchall()
|
||||
pricing_profiles = conn.execute('SELECT * FROM pricing_profiles ORDER BY name').fetchall()
|
||||
projects = conn.execute('SELECT id,name FROM projects ORDER BY name').fetchall()
|
||||
settings = get_settings()
|
||||
|
||||
# Pré-remplissage depuis un job existant
|
||||
prefill = None
|
||||
clone_from = request.args.get('clone_from')
|
||||
if clone_from:
|
||||
prefill = conn.execute('SELECT * FROM jobs WHERE id=?', (clone_from,)).fetchone()
|
||||
if prefill:
|
||||
prefill = dict(prefill)
|
||||
prefill['hours'] = prefill['print_time_s'] // 3600
|
||||
prefill['minutes'] = (prefill['print_time_s'] % 3600) // 60
|
||||
|
||||
if request.method == 'POST':
|
||||
weight_g = float(request.form['weight_g'])
|
||||
hours = int(request.form.get('hours',0))
|
||||
@@ -1026,17 +1037,19 @@ def new_job():
|
||||
r['cotisations_amount'],r['vfl_amount'],r['tva_amount'],r['other_taxes_amount'],
|
||||
r['tax_amount'],r['final_price'],round(r['final_price'],2),
|
||||
request.form.get('notes','')))
|
||||
new_id = conn.execute('SELECT last_insert_rowid()').fetchone()[0]
|
||||
if material_id:
|
||||
conn.execute('UPDATE materials SET stock_g=MAX(0,stock_g-?) WHERE id=?', (weight_g, material_id))
|
||||
conn.commit(); conn.close()
|
||||
if request.form.get('action') == 'save_and_new':
|
||||
return redirect(url_for('new_job', clone_from=new_id))
|
||||
return redirect(url_for('jobs'))
|
||||
|
||||
projects = conn.execute('SELECT id,name FROM projects ORDER BY name').fetchall()
|
||||
conn.close()
|
||||
return render_template('new_job.html', clients=clients, materials=mats, settings=settings,
|
||||
machine_profiles=machine_profiles, handling_profiles=handling_profiles,
|
||||
material_profiles=material_profiles, pricing_profiles=pricing_profiles,
|
||||
projects=projects)
|
||||
projects=projects, prefill=prefill)
|
||||
|
||||
@app.route('/jobs/<int:id>')
|
||||
def job_detail(id):
|
||||
|
||||
Reference in New Issue
Block a user