diff --git a/pos_tare/static/src/js/Screens/ProductScreen/ProductScreen.js b/pos_tare/static/src/js/Screens/ProductScreen/ProductScreen.js index e0503bae34..ebd84dcb05 100644 --- a/pos_tare/static/src/js/Screens/ProductScreen/ProductScreen.js +++ b/pos_tare/static/src/js/Screens/ProductScreen/ProductScreen.js @@ -22,112 +22,19 @@ odoo.define("pos_tare.screens", function (require) { } async _getAddProductOptions(product) { - let price_extra = 0.0; - let draftPackLotLines, weight, description, packLotLinesToEdit, tare; // eslint-disable-line + return super._getAddProductOptions(product).then( + payload => { + if (!payload) return + if (!payload.quantity) return payload - if ( - this.env.pos.config.product_configurator && - _.some( - product.attribute_line_ids, - (id) => id in this.env.pos.attributes_by_ptal_id - ) - ) { - const attributes = _.map( - product.attribute_line_ids, - (id) => this.env.pos.attributes_by_ptal_id[id] - ).filter((attr) => attr !== undefined); - const {confirmed, payload} = await this.showPopup( - "ProductConfiguratorPopup", - { - product: product, - attributes: attributes, + const {weight, tare} = payload.quantity + return { + ...payload, + quantity: weight, + tare: tare, } - ); - - if (confirmed) { - description = payload.selected_attributes.join(", "); - price_extra += payload.price_extra; - } else { - return; - } - } - - // Gather lot information if required. - if ( - ["serial", "lot"].includes(product.tracking) && - (this.env.pos.picking_type.use_create_lots || - this.env.pos.picking_type.use_existing_lots) - ) { - const isAllowOnlyOneLot = product.isAllowOnlyOneLot(); - if (isAllowOnlyOneLot) { - packLotLinesToEdit = []; - } else { - const orderline = this.currentOrder - .get_orderlines() - .filter((line) => !line.get_discount()) - .find((line) => line.product.id === product.id); - if (orderline) { - packLotLinesToEdit = orderline.getPackLotLinesToEdit(); - } else { - packLotLinesToEdit = []; - } - } - const {confirmed, payload} = await this.showPopup("EditListPopup", { - title: this.env._t("Lot/Serial Number(s) Required"), - isSingleItem: isAllowOnlyOneLot, - array: packLotLinesToEdit, - }); - if (confirmed) { - // Segregate the old and new packlot lines - const modifiedPackLotLines = Object.fromEntries( - payload.newArray - .filter((item) => item.id) - .map((item) => [item.id, item.text]) - ); - const newPackLotLines = payload.newArray - .filter((item) => !item.id) - .map((item) => ({lot_name: item.text})); - - draftPackLotLines = {modifiedPackLotLines, newPackLotLines}; - } else { - // We don't proceed on adding product. - return; } - } - - // Take the weight if necessary. - if (product.to_weight && this.env.pos.config.iface_electronic_scale) { - // Show the ScaleScreen to weigh the product. - if (this.isScaleAvailable) { - const {confirmed, payload} = await this.showTempScreen( - "ScaleScreen", - { - product, - } - ); - if (confirmed) { - // ///////////////////////////// - // Overload Section - // We add the tare to the payload - // ///////////////////////////// - weight = payload.weight; - tare = payload.tare; - } else { - // Do not add the product; - return; - } - } else { - await this._onScaleNotAvailable(); - } - } - - return { - draftPackLotLines, - quantity: weight, - description, - price_extra, - tare: tare, - }; + ) } _setValue(val) { @@ -139,9 +46,9 @@ odoo.define("pos_tare.screens", function (require) { title: this.env._t("Feature Disabled"), body: this.env._t( "You can not set the tare." + - " To be able to set the tare manually" + - " you have to change the tare input method" + - " in the POS configuration" + " To be able to set the tare manually" + + " you have to change the tare input method" + + " in the POS configuration" ), }); } else { diff --git a/pos_tare/static/src/js/Screens/ScaleScreen/ScaleScreen.js b/pos_tare/static/src/js/Screens/ScaleScreen/ScaleScreen.js index 0823000499..e7fdbfeb2e 100644 --- a/pos_tare/static/src/js/Screens/ScaleScreen/ScaleScreen.js +++ b/pos_tare/static/src/js/Screens/ScaleScreen/ScaleScreen.js @@ -38,8 +38,10 @@ odoo.define("pos_tare.ScaleScreen", function (require) { this.props.resolve({ confirmed: true, payload: { - weight: this.state.weight, - tare: this.state.tare, + weight: { + weight: this.state.weight, + tare: this.state.tare ? parseFloat(this.state.tare): 0, + }, }, }); this.trigger("close-temp-screen");