From 72e9034f9f3b0bedf679e16eb717fe37b91fb581 Mon Sep 17 00:00:00 2001 From: "Adrien Guilliams (adgu)" Date: Thu, 6 Apr 2023 14:06:59 +0000 Subject: [PATCH] [IMP] pos, l10n_fr_pos_cert: change price_manually_set behaviour The price_manually_set variable was used to largely, we fix it by adding a price_automatically_set variable. The price_manually_set is now used when changing the price through the numpad, whereas price_manually_set is used to indicate that the price is not the price set in the database. closes odoo/odoo#119362 X-original-commit: aa4f346d27aa28c23f8ee02fe73b892a1f5ef2dc Signed-off-by: Heinz Robin (rhe) --- .../static/src/xml/OrderReceipt.xml | 2 +- .../l10n_fr_pos_cert/static/src/xml/Orderline.xml | 2 +- .../src/js/Screens/TicketScreen/TicketScreen.js | 2 +- addons/point_of_sale/static/src/js/models.js | 13 +++++++++---- addons/pos_discount/static/src/js/DiscountButton.js | 2 +- addons/pos_loyalty/static/src/js/Loyalty.js | 2 +- .../SaleOrderManagementScreen.js | 2 +- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/addons/l10n_fr_pos_cert/static/src/xml/OrderReceipt.xml b/addons/l10n_fr_pos_cert/static/src/xml/OrderReceipt.xml index e2efd46a4e5..312c06d75a6 100644 --- a/addons/l10n_fr_pos_cert/static/src/xml/OrderReceipt.xml +++ b/addons/l10n_fr_pos_cert/static/src/xml/OrderReceipt.xml @@ -11,7 +11,7 @@ - +
Old unit price: diff --git a/addons/l10n_fr_pos_cert/static/src/xml/Orderline.xml b/addons/l10n_fr_pos_cert/static/src/xml/Orderline.xml index 431f5f878bb..36975221f5f 100644 --- a/addons/l10n_fr_pos_cert/static/src/xml/Orderline.xml +++ b/addons/l10n_fr_pos_cert/static/src/xml/Orderline.xml @@ -3,7 +3,7 @@ - +
  • Old unit price: diff --git a/addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js b/addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js index 5b34e2a8161..189750c07c1 100644 --- a/addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js +++ b/addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js @@ -542,7 +542,7 @@ export class TicketScreen extends IndependentToOrderScreen { return { quantity: -qty, price: orderline.price, - extras: { price_manually_set: true }, + extras: { price_automatically_set: true }, merge: false, refunded_orderline_id: orderline.id, tax_ids: orderline.tax_ids, diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 5e2b4adf5ad..61a6d9646fc 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1795,6 +1795,7 @@ export class Orderline extends PosModel { this.pos = options.pos; this.order = options.order; this.price_manually_set = options.price_manually_set || false; + this.price_automatically_set = options.price_automatically_set || false; if (options.json) { try { this.init_from_JSON(options.json); @@ -1832,6 +1833,7 @@ export class Orderline extends PosModel { this.set_product_lot(this.product); this.price = json.price_unit; this.price_manually_set = json.price_manually_set; + this.price_automatically_set = json.price_automatically_set; this.set_discount(json.discount); this.set_quantity(json.qty, "do not recompute unit price"); this.set_description(json.description); @@ -1868,6 +1870,7 @@ export class Orderline extends PosModel { orderline.price = this.price; orderline.selected = false; orderline.price_manually_set = this.price_manually_set; + orderline.price_automatically_set = this.price_automatically_set; orderline.customerNote = this.customerNote; return orderline; } @@ -2029,7 +2032,7 @@ export class Orderline extends PosModel { } // just like in sale.order changing the quantity will recompute the unit price - if (!keep_price && !this.price_manually_set) { + if (!keep_price && !(this.price_manually_set || this.price_automatically_set)) { this.set_unit_price( this.product.get_price( this.order.pricelist, @@ -2182,6 +2185,7 @@ export class Orderline extends PosModel { customer_note: this.get_customer_note(), refunded_orderline_id: this.refunded_orderline_id, price_manually_set: this.price_manually_set, + price_automatically_set: this.price_automatically_set, }; } //used to create a json of the ticket, to be sent to the printer @@ -2198,6 +2202,7 @@ export class Orderline extends PosModel { price_lst: this.get_lst_price(), fixed_lst_price: this.get_fixed_lst_price(), price_manually_set: this.price_manually_set, + price_automatically_set: this.price_automatically_set, display_discount_policy: this.display_discount_policy(), price_display_one: this.get_display_price_one(), price_display: this.get_display_price(), @@ -3111,7 +3116,7 @@ export class Order extends PosModel { if (lines[i].get_product() === tip_product) { lines[i].set_unit_price(tip); lines[i].set_lst_price(tip); - lines[i].price_manually_set = true; + lines[i].price_automatically_set = true; lines[i].order.tip_amount = tip; return; } @@ -3121,7 +3126,7 @@ export class Order extends PosModel { quantity: 1, price: tip, lst_price: tip, - extras: { price_manually_set: true }, + extras: { price_automatically_set: true }, }); } } @@ -3132,7 +3137,7 @@ export class Order extends PosModel { var self = this; this.pricelist = pricelist; - var lines_to_recompute = this.get_orderlines().filter((line) => !line.price_manually_set); + var lines_to_recompute = this.get_orderlines().filter((line) => !(line.price_manually_set || line.price_automatically_set)); lines_to_recompute.forEach((line) => { line.set_unit_price( line.product.get_price(self.pricelist, line.get_quantity(), line.get_price_extra()) diff --git a/addons/pos_discount/static/src/js/DiscountButton.js b/addons/pos_discount/static/src/js/DiscountButton.js index 691850e6e1a..4b3ce7e3be9 100644 --- a/addons/pos_discount/static/src/js/DiscountButton.js +++ b/addons/pos_discount/static/src/js/DiscountButton.js @@ -77,7 +77,7 @@ export class DiscountButton extends Component { ) : this.env._t("No tax")), extras: { - price_manually_set: true, + price_automatically_set: true, }, }); } diff --git a/addons/pos_loyalty/static/src/js/Loyalty.js b/addons/pos_loyalty/static/src/js/Loyalty.js index f7fff761b9b..2e14363e96d 100644 --- a/addons/pos_loyalty/static/src/js/Loyalty.js +++ b/addons/pos_loyalty/static/src/js/Loyalty.js @@ -459,7 +459,7 @@ patch(Order.prototype, "pos_loyalty.Order", { line.coupon_id = options.coupon_id; line.reward_identifier_code = options.reward_identifier_code; line.points_cost = options.points_cost; - line.price_manually_set = true; + line.price_automatically_set = true; } line.giftBarcode = options.giftBarcode; line.giftCardId = options.giftCardId; diff --git a/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderManagementScreen.js b/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderManagementScreen.js index f27f990e143..d95413aeedd 100644 --- a/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderManagementScreen.js +++ b/addons/pos_sale/static/src/js/OrderManagementScreen/SaleOrderManagementScreen.js @@ -284,7 +284,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(IndependentTo order: this.env.pos.get_order(), product: down_payment_product, price: down_payment, - price_manually_set: true, + price_automatically_set: true, sale_order_origin_id: clickedOrder, down_payment_details: tab, }