[FIX] pos_sale: runbot error 27820

`Orderline.getDisplayData()` relies on the presence of the component's `env`.
However, since 7dd76be303b6769767ef0736ba738fc0063a4a28, an `Orderline` instance
can be created without `env`, which results to a traceback when rendering the
order widget. This commit makes sure the `env` is present in the Orderline
instance created from pos_sale module.

Closes runbot error: 27820

closes odoo/odoo#142167

Signed-off-by: Vlad Stroia (vlst) <vlst@odoo.com>
This commit is contained in:
Joseph Caburnay
2023-11-15 18:12:01 +00:00
parent d0e7c62465
commit b74ca03bcb
@@ -219,7 +219,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) {
sale_order_line_id: line,
customer_note: line.customer_note,
};
let new_line = new Orderline({ env: this.env }, line_values);
const new_line = new Orderline({ env: this.env }, line_values);
if (
new_line.get_product().tracking !== "none" &&
@@ -257,12 +257,11 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) {
if (product_unit && !product.get_unit().is_pos_groupable) {
//loop for value of quantity
for (let j = 0; j < new_line.quantity; j++) {
let splitted_line = new Orderline({}, line_values);
const splitted_line = new Orderline({ env: this.env }, line_values);
splitted_line.quantity = 1;
this.pos.get_order().add_orderline(splitted_line);
}
}
else {
} else {
this.pos.get_order().add_orderline(new_line);
}
}