[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) <rhe@odoo.com>
This commit is contained in:
Adrien Guilliams (adgu)
2023-04-27 02:44:40 +02:00
parent 244b8502d2
commit 72e9034f9f
7 changed files with 15 additions and 10 deletions
@@ -11,7 +11,7 @@
<t t-name="OrderLinesReceipt" t-inherit="point_of_sale.OrderLinesReceipt" t-inherit-mode="extension" owl="1">
<xpath expr="//t[@t-foreach='receipt.orderlines']" position="inside">
<t t-if="receipt.l10n_fr_hash !== false and line.price !== line.fixed_lst_price">
<t t-if="receipt.l10n_fr_hash !== false and line.price_manually_set">
<div class="pos-receipt-right-padding">
Old unit price:
<span class="oldPrice">
@@ -3,7 +3,7 @@
<t t-name="Orderline" t-inherit="point_of_sale.Orderline" t-inherit-mode="extension" owl="1">
<xpath expr="//ul[hasclass('info-list')]" position="inside">
<t t-if="env.pos.is_french_country() !== false and props.line.price !== props.line.get_fixed_lst_price()">
<t t-if="env.pos.is_french_country() !== false and props.line.price_manually_set">
<li class="info">
Old unit price:
<span class="oldPrice">
@@ -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,
+9 -4
View File
@@ -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())
@@ -77,7 +77,7 @@ export class DiscountButton extends Component {
)
: this.env._t("No tax")),
extras: {
price_manually_set: true,
price_automatically_set: true,
},
});
}
+1 -1
View File
@@ -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;
@@ -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,
}