Commit 1d83c96f by François C.

Fix wrong PO name displayed in Orders helper after PO has been created

parent e29e6648
Pipeline #2478 passed with stage
in 1 minute 29 seconds
......@@ -238,6 +238,8 @@ class Order(models.Model):
@staticmethod
def create(supplier_id, date_planned, order_lines):
res = {}
try:
order_data = {
"partner_id": int(supplier_id),
"partner_ref": False,
......@@ -294,13 +296,18 @@ class Order(models.Model):
api = OdooAPI()
id_po = api.create('purchase.order', order_data)
res_confirm = api.execute('purchase.order', 'button_confirm', [id_po])
res_for_name = api.search_read('purchase.order', [['id', '=', int(id_po)]], ['display_name'])
res = {
'id_po': id_po,
'display_name': res_for_name[0]['display_name'],
'confirm_po': True,
'supplier_id': supplier_id,
'date_planned': date_planned
}
except Exception as e:
res = {'error': str(e)}
coop_logger.error("Error while creating PO : %s (order_data = %s order_lines = %s)", str(e), str(order_data), str(order_lines))
return res
......
......@@ -1344,7 +1344,7 @@ function create_orders() {
let new_order_template = $("#templates #new_order_item_template");
new_order_template.find(".new_order_supplier_name").text(supplier_name);
new_order_template.find(".new_order_po").text(`PO${new_order.id_po}`);
new_order_template.find(".new_order_po").text(`${new_order.display_name}`);
new_order_template.find(".new_order_date_planned").text(`Date de livraison prévue: ${date_planned}`);
new_order_template.find(".download_order_file_button").attr('id', `download_attachment_${new_order.id_po}`);
......
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