-
-
Notifications
You must be signed in to change notification settings - Fork 631
[14.0][mig]pos_warning_exiting #664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ting from Point of sale Front office UI Co-authored-by: Iván Todorovich <ivan.todorovich@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. Thanks for porting this module !
This seems WIP. you added a new full file Chrome.js
that is not included in the loaded files.
Note : could you rename into chrome.js
BTW ?
yes, I have renamed the file. |
2b47360
to
b30282a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks Good To Me
b30282a
to
90822ae
Compare
@ivantodorovich can you please review this PR? |
pos_warning_exiting/__manifest__.py
Outdated
@@ -6,17 +6,13 @@ | |||
"name": "Point Of Sale - Warning on Exiting", | |||
"summary": "Add warning at exiting the PoS front office UI" | |||
" if there are pending draft orders", | |||
"version": "12.0.1.0.1", | |||
"version": "14.0.1.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version should be 14.0.1.0.0
odoo.define("pos_warning_exiting.Chrome", function (require) { | ||
"use strict"; | ||
|
||
const {_t} = require("web.core"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just use this.env._t
and avoid this requirement
Not blocking though
const reason = this.env._t( | ||
"You have some draft unpaid orders." + | ||
" You can exit temporarily the Point of Sale, but you" + | ||
" will loose that orders if you close the session: " + | ||
draft_orders_description.join(", ") | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking.
This won't ever be translated because you're including draft_orders_description
into the translatable string.
You need to do something like this:
const message = this.env._t(
"You have some draft unpaid orders. "
+ "You can exit temporarily the Point of Sale, but you "
+ "will loose that orders if you close the session: "
);
const reason = message + draft_orders_description.join(", ");
var self = this; | ||
const draft_orders_description = []; | ||
const order_jsons = this.env.pos.db.get_unpaid_orders(); | ||
|
||
if (order_jsons.length) { | ||
order_jsons.forEach(function (order_json) { | ||
if ( | ||
order_json.pos_session_id === self.env.pos.pos_session.id && | ||
order_json.lines.length | ||
) { | ||
var order_description = | ||
_t("Order #") + order_json.sequence_number; | ||
// Lazy depedency to pos_restaurant | ||
// to display table information | ||
if (order_json.table) { | ||
order_description += | ||
_t(" - Table: ") + order_json.table.name; | ||
} | ||
draft_orders_description.push(order_description); | ||
} | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking here but I would do something like this here
const unpaidOrders = this.env.pos.db.get_unpaid_orders();
const toLoseOrders = unpaidOrders.filter(
order => order.pos_session_id === this.env.pos.session_id.id && order.lines.length
);
if (toLoseOrders.length) {
const orderDescriptions = toLoseOrders.map(order => {
let description = this.env._t("Order #") + order.sequence_number;
// Lazy dependency to pos_restaurant to display table information
if (order.table) {
description += this.env._t(" - Table: ") + order.table.name;
}
return description;
})
// .. you know the rest
}
by using arrow functions you avoid having to define and use self
, and you achieve a more readable result IMO
90822ae
to
3a996a3
Compare
3a996a3
to
ee15733
Compare
ee15733
to
1f373cb
Compare
1f373cb
to
08d86c2
Compare
@ivantodorovich Thanks for the review suggestions are implemented you can re-review it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Thanks a lot for taking the time to do this
@HaraldPanten can u please review this pr? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functional review 👍
@brendapaniagua can u please review this pr? |
Thanks for the review suggestions are implemented you can re-review it |
/ocabot merge nobump |
This PR looks fantastic, let's merge it! |
Congratulations, your PR was merged at 98a3211. Thanks a lot for contributing to OCA. ❤️ |
No description provided.