|
|
@ -1,7 +1,7 @@ |
|
|
|
/** @odoo-module */ |
|
|
|
|
|
|
|
import { patch } from "@web/core/utils/patch"; |
|
|
|
import { Orderline } from "@point_of_sale/app/store/models"; |
|
|
|
import { Orderline, Order } from "@point_of_sale/app/store/models"; |
|
|
|
|
|
|
|
patch(Orderline.prototype, { |
|
|
|
export_as_JSON(){ |
|
|
@ -17,10 +17,12 @@ patch(Orderline.prototype, { |
|
|
|
init_from_JSON(json){ |
|
|
|
super.init_from_JSON(...arguments); |
|
|
|
// Set the product_uom_id from the JSON data
|
|
|
|
if(this.pos.units_by_id[json.product_uom_id]){ |
|
|
|
this.product_uom_id = { |
|
|
|
0 : this.pos.units_by_id[json.product_uom_id].id, |
|
|
|
1 : this.pos.units_by_id[json.product_uom_id].name, |
|
|
|
}; |
|
|
|
} |
|
|
|
}, |
|
|
|
// Add a custom set_uom method
|
|
|
|
set_uom(uom_id){ |
|
|
@ -39,7 +41,7 @@ patch(Orderline.prototype, { |
|
|
|
return this.pos.units_by_id[unit_id]; |
|
|
|
} |
|
|
|
return this.product.get_unit(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
onSelectionChangedUom(ev) { |
|
|
|
var splitTargetValue = ev.target.value.split(',') |
|
|
|
var price = splitTargetValue[0] |
|
|
@ -75,3 +77,10 @@ patch(Orderline.prototype, { |
|
|
|
}; |
|
|
|
}, |
|
|
|
}); |
|
|
|
patch(Order.prototype, { |
|
|
|
export_for_printing() { |
|
|
|
var result = super.export_for_printing(...arguments); |
|
|
|
result['orderlines'] = result['orderlines'].map(({ onSelectionChangedUom, ...rest }) => rest); |
|
|
|
return result; |
|
|
|
}, |
|
|
|
}); |