-
-
Notifications
You must be signed in to change notification settings - Fork 615
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
[14.0][IMP] pos_disable_pricelist_selection: selectable pricelists #1110
Conversation
8da9e45
to
c534b16
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.
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"], |
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.
chore: missing dependency on web_domain_field
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.
web_domain_field is not required. Turns out compute domain thing works without web_domain_field. Just need to use Binary field.
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.
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) |
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.
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( |
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.
todo: this variable name is IMO misleading, since it's the intersection, and not the difference.
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) | ||
] |
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.
chore: Documentation of the web_domain_field
recommends using json.dumps
to make sure any edge case is handled properly.
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.
Couldn't find a way to cause an error, so considering this non-blocking.
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); | ||
} | ||
} | ||
}; |
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.
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?
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.
agree
ad792b3
to
1a7af56
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.
Code review, LGTM
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 is ok.
@legalsylvain what do you think?
@pedrobaeza can this be merged based on existing reviews? thanks! |
/ocabot merge major |
This PR looks fantastic, let's merge it! |
Congratulations, your PR was merged at c8271ee. Thanks a lot for contributing to OCA. ❤️ |
No description provided.