|
|
@ -208,26 +208,7 @@ odoo.define('pos_order_mgmt.widgets', function (require) { |
|
|
|
} |
|
|
|
// Set order lines
|
|
|
|
var orderLines = order_data.line_ids || order_data.lines || []; |
|
|
|
_.each(orderLines, function (orderLine) { |
|
|
|
var line = orderLine; |
|
|
|
// In case of local data
|
|
|
|
if (line.length === 3) { |
|
|
|
line = line[2]; |
|
|
|
} |
|
|
|
var product = self.pos.db.get_product_by_id(line.product_id); |
|
|
|
// Check if product are available in pos
|
|
|
|
if (_.isUndefined(product)) { |
|
|
|
self.unknown_products.push(String(line.product_id)); |
|
|
|
} else { |
|
|
|
// Create a new order line
|
|
|
|
order.add_product(product, { |
|
|
|
price: line.price_unit, |
|
|
|
quantity: order_data.return ? line.qty * -1 : line.qty, |
|
|
|
discount: line.discount, |
|
|
|
merge: false, |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
self._prepare_orderlines_from_order_data(order, order_data, orderLines); |
|
|
|
if (order_data.return) { |
|
|
|
order.return = true; |
|
|
|
// A credit note should be emited if there was an invoice
|
|
|
@ -235,6 +216,7 @@ odoo.define('pos_order_mgmt.widgets', function (require) { |
|
|
|
// We'll refunded orders once they are synced
|
|
|
|
order.returned_order_id = order_data.id || order_data.name; |
|
|
|
order.origin_name = order_data.pos_reference || order.returned_order_id; |
|
|
|
order.trigger('change'); |
|
|
|
return order; |
|
|
|
} |
|
|
|
if (order_data.returned_order_id) { |
|
|
@ -250,7 +232,7 @@ odoo.define('pos_order_mgmt.widgets', function (require) { |
|
|
|
line = line[2]; |
|
|
|
} |
|
|
|
_.each(self.pos.cashregisters, function (cashregister) { |
|
|
|
if (cashregister.id === line.statement_id) { |
|
|
|
if (cashregister.journal.id === line.journal_id) { |
|
|
|
if (line.amount > 0) { |
|
|
|
// If it is not change
|
|
|
|
order.add_paymentline(cashregister); |
|
|
@ -261,6 +243,28 @@ odoo.define('pos_order_mgmt.widgets', function (require) { |
|
|
|
}); |
|
|
|
return order; |
|
|
|
}, |
|
|
|
_prepare_orderlines_from_order_data: function(order, order_data, orderLines) { |
|
|
|
var self = this; |
|
|
|
_.each(orderLines, function(line) { |
|
|
|
// In case of local data
|
|
|
|
if (line.length === 3) { |
|
|
|
line = line[2]; |
|
|
|
} |
|
|
|
var product = self.pos.db.get_product_by_id(line.product_id); |
|
|
|
// Check if product are available in pos
|
|
|
|
if (_.isUndefined(product)) { |
|
|
|
self.unknown_products.push(String(line.product_id)); |
|
|
|
} else { |
|
|
|
// Create a new order line
|
|
|
|
order.add_product(product, { |
|
|
|
price: line.price_unit, |
|
|
|
quantity: order_data.return ? line.qty * -1 : line.qty, |
|
|
|
discount: line.discount, |
|
|
|
merge: false, |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
load_order: function (order_id, action) { |
|
|
|
this.unknown_products = []; |
|
|
@ -270,7 +274,7 @@ odoo.define('pos_order_mgmt.widgets', function (require) { |
|
|
|
method: 'load_done_order_for_pos', |
|
|
|
args: [order_id], |
|
|
|
}).then(function (order_data) { |
|
|
|
self.gui.show_screen('orderlist'); |
|
|
|
self.gui.back(); |
|
|
|
var correct_order_print = true; |
|
|
|
if (action === 'return') { |
|
|
|
order_data.return = true; |
|
|
|