Skip to content

[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

Merged
merged 7 commits into from
Jun 23, 2021

Conversation

hkapatel-initos
Copy link
Contributor

No description provided.

Copy link
Contributor

@legalsylvain legalsylvain left a 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 ?

@hkapatel-initos hkapatel-initos changed the title [14.0][mig]pos_warning_exiting [wip][14.0][mig]pos_warning_exiting Jun 3, 2021
@hkapatel-initos
Copy link
Contributor Author

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.

@hkapatel-initos hkapatel-initos force-pushed the 14.0-mig-pos_warning_exiting branch 3 times, most recently from 2b47360 to b30282a Compare June 4, 2021 07:18
Copy link
Contributor

@dsolanki-initos dsolanki-initos left a 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

@hkapatel-initos hkapatel-initos force-pushed the 14.0-mig-pos_warning_exiting branch from b30282a to 90822ae Compare June 10, 2021 04:52
@hkapatel-initos hkapatel-initos changed the title [wip][14.0][mig]pos_warning_exiting [14.0][mig]pos_warning_exiting Jun 10, 2021
@hkapatel-initos
Copy link
Contributor Author

@ivantodorovich can you please review this PR?

@@ -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",
Copy link
Contributor

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");
Copy link
Contributor

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

Comment on lines 39 to 43
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(", ")
);
Copy link
Contributor

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(", ");

Comment on lines 15 to 36
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);
}
});
}
Copy link
Contributor

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

@hkapatel-initos hkapatel-initos force-pushed the 14.0-mig-pos_warning_exiting branch from 90822ae to 3a996a3 Compare June 14, 2021 07:13
@hkapatel-initos hkapatel-initos force-pushed the 14.0-mig-pos_warning_exiting branch from 3a996a3 to ee15733 Compare June 14, 2021 07:34
@hkapatel-initos hkapatel-initos mentioned this pull request Jun 14, 2021
16 tasks
@hkapatel-initos hkapatel-initos force-pushed the 14.0-mig-pos_warning_exiting branch from ee15733 to 1f373cb Compare June 16, 2021 04:35
@hkapatel-initos hkapatel-initos force-pushed the 14.0-mig-pos_warning_exiting branch from 1f373cb to 08d86c2 Compare June 16, 2021 04:46
@hkapatel-initos
Copy link
Contributor Author

@ivantodorovich Thanks for the review suggestions are implemented you can re-review it

Copy link
Contributor

@ivantodorovich ivantodorovich left a 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

@hkapatel-initos
Copy link
Contributor Author

@HaraldPanten can u please review this pr?

Copy link

@HaraldPanten HaraldPanten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional review 👍

@hkapatel-initos
Copy link
Contributor Author

@brendapaniagua can u please review this pr?

@hkapatel-initos
Copy link
Contributor Author

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 ?

Thanks for the review suggestions are implemented you can re-review it

@ivantodorovich
Copy link
Contributor

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 14.0-ocabot-merge-pr-664-by-ivantodorovich-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit d120638 into OCA:14.0 Jun 23, 2021
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 98a3211. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants