Skip to content
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

[14.0][IMP] pos_disable_pricelist_selection: selectable pricelists #1110

Conversation

ilyasProgrammer
Copy link
Member

@ilyasProgrammer ilyasProgrammer commented Dec 15, 2023

No description provided.

@ilyasProgrammer ilyasProgrammer changed the title [IMP] pos_disable_pricelist_selection: selectable pricelists [14.0][IMP] pos_disable_pricelist_selection: selectable pricelists Dec 19, 2023
@ilyasProgrammer ilyasProgrammer force-pushed the 14.0-pos_disable_pricelist_selection-selectable-pricelist branch 4 times, most recently from 8da9e45 to c534b16 Compare December 20, 2023 10:58
Copy link

@aleuffre aleuffre left a comment

Choose a reason for hiding this comment

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

Code review. Please add some tests as well, especially for the pos_config part.

@@ -7,6 +7,7 @@
"license": "LGPL-3",
"category": "Purchase",
"website": "https://github.com/OCA/pos",
"maintainers": ["ilyasprogrammer"],
"depends": ["point_of_sale"],

Choose a reason for hiding this comment

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

chore: missing dependency on web_domain_field

Copy link
Member Author

Choose a reason for hiding this comment

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

web_domain_field is not required. Turns out compute domain thing works without web_domain_field. Just need to use Binary field.

Copy link

@aleuffre aleuffre Dec 20, 2023

Choose a reason for hiding this comment

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

Huh, that's good to know. Thanks!

def write(self, vals):
if vals.get("available_pricelist_ids"):
if self and not vals.get("selectable_pricelist_ids"):
selectable = set(self.selectable_pricelist_ids.ids)

Choose a reason for hiding this comment

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

issue: self could be a recordset containing multiple records.

else:
selectable = set(vals["selectable_pricelist_ids"][0][2])
# leave only ids from available_pricelist_ids
diff = list(

Choose a reason for hiding this comment

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

todo: this variable name is IMO misleading, since it's the intersection, and not the difference.

Comment on lines +37 to +42
if rec.hide_pricelist_button:
rec.pricelist_id_domain = [("id", "in", rec.allowed_pricelist_ids.ids)]
else:
rec.pricelist_id_domain = [
("id", "in", rec.selectable_pricelist_ids.ids)
]

Choose a reason for hiding this comment

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

chore: Documentation of the web_domain_field recommends using json.dumps to make sure any edge case is handled properly.

Choose a reason for hiding this comment

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

Couldn't find a way to cause an error, so considering this non-blocking.

Comment on lines 9 to 16
async onClick() {
// Replaced to use selectable_pricelists instead of pricelists
const selectionList = this.env.pos.selectable_pricelists.map(
(pricelist) => ({
id: pricelist.id,
label: pricelist.name,
isSelected: pricelist.id === this.currentOrder.pricelist.id,
item: pricelist,
})
);

const {confirmed, payload: selectedPricelist} = await this.showPopup(
"SelectionPopup",
{
title: this.env._t("Select the pricelist"),
list: selectionList,
}
);

if (confirmed) {
this.currentOrder.set_pricelist(selectedPricelist);
}
}
};

Choose a reason for hiding this comment

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

question (non-blocking): I don't know if this could be a better approach, but I wonder if, instead of overwriting the entire method, we could quietly replace this.env.pos.pricelists with this.env.pos.selectable_pricelists, then call super(), and finally put things back where they belong. My main concern is improving compatibility with other modules. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

agree

@ilyasProgrammer ilyasProgrammer force-pushed the 14.0-pos_disable_pricelist_selection-selectable-pricelist branch from ad792b3 to 1a7af56 Compare December 20, 2023 14:19
Copy link

@aleuffre aleuffre left a comment

Choose a reason for hiding this comment

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

Code review, LGTM

Copy link
Contributor

@francesco-ooops francesco-ooops left a comment

Choose a reason for hiding this comment

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

Functional is ok.

@legalsylvain what do you think?

@francesco-ooops
Copy link
Contributor

@pedrobaeza can this be merged based on existing reviews? thanks!

@pedrobaeza pedrobaeza added this to the 14.0 milestone Dec 28, 2023
@pedrobaeza
Copy link
Member

/ocabot merge major

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 14.0-ocabot-merge-pr-1110-by-pedrobaeza-bump-major, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 8e0b4dd into OCA:14.0 Dec 28, 2023
5 of 7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at c8271ee. 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.

5 participants