-
-
Notifications
You must be signed in to change notification settings - Fork 602
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
[16.0][ADD] pos_order_to_sale_order_sale_financial_risk: Sale Financial Risk in POS #1024
[16.0][ADD] pos_order_to_sale_order_sale_financial_risk: Sale Financial Risk in POS #1024
Conversation
feff0b6
to
c46c303
Compare
e463155
to
e8a43ca
Compare
6127e03
to
e514684
Compare
06b627c
to
ed68499
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.
Functional review ok
@@ -0,0 +1,23 @@ | |||
{ | |||
"name": "Sale Financial Risk Pos Compatibility", |
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.
name: "Sale Financial Risk in POS"
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.
Resolved
"name": "Sale Financial Risk Pos Compatibility", | ||
"version": "16.0.1.0.0", | ||
"category": "Sales/Point of Sale", | ||
"summary": "Sale Financial Risk Pos Compatibility", |
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.
Sale Financial Risk control for Sales Orders created from POS
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.
Resolved
user_dict = super(PosSession, self)._get_pos_ui_res_users(params) | ||
user_id = user_dict.get("id") | ||
if user_id and (user := self.env["res.users"].browse(user_id)).exists(): | ||
user_dict.update( | ||
has_role_risk_manager=user.has_group( | ||
"account_financial_risk.group_overpass_partner_risk_exception" | ||
) | ||
) | ||
return user_dict |
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.
user will exist because the id is from the current user
user_dict = super(PosSession, self)._get_pos_ui_res_users(params) | |
user_id = user_dict.get("id") | |
if user_id and (user := self.env["res.users"].browse(user_id)).exists(): | |
user_dict.update( | |
has_role_risk_manager=user.has_group( | |
"account_financial_risk.group_overpass_partner_risk_exception" | |
) | |
) | |
return user_dict | |
data = super()._get_pos_ui_res_users(params) | |
user = self.env["res.users"].browse(data["id"]) | |
data["has_role_risk_manager"] = user.has_group( | |
"account_financial_risk.group_overpass_partner_risk_exception", | |
) | |
return data |
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.
Resolved
|
||
import CreateOrderPopup from "point_of_sale.CreateOrderPopup"; | ||
import Registries from "point_of_sale.Registries"; | ||
import {_t} from "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 use this.env._t instead
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.
Resolved
], | ||
], | ||
}); | ||
console.log(this.env.pos); |
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.
to delete?
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.
Resolved
], | ||
], | ||
}); | ||
console.log(this.env.pos); |
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.
to delete?
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.
Resolved
ed68499
to
0e7ce01
Compare
642e150
to
bc18518
Compare
c66a0f0
to
95c1ae6
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.
rename sale_financial_risk_pos_compatibility to pos_sale_financial_risk
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.
changes are needed regarding the overriding of the createSaleOrder method
} else { | ||
return await super._actionCreateSaleOrder(order_state); | ||
} | ||
const {confirmed} = await this.showPopup("ConfirmRiskPopup", { |
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.
it seems to be necessary to show different popup depending on the settings
if (this.env.pos.user.has_role_risk_manager) {
const {confirmed} = await this.showPopup("ConfirmPopup", {
title: this.env._t("Partner risk exceeded"),
body: exception_msg,
});
if (confirmed) {
return await super._actionCreateSaleOrder(order_state);
}
} else {
await this.showPopup("ErrorPopup", {
title: this.env._t("Partner risk exceeded"),
body: exception_msg,
});
}
return await this.cancel();
creating a new popup is unnecessary
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.
Resolved
showButton: this.env.pos.user.has_role_risk_manager, | ||
}); | ||
if (confirmed) { | ||
this.extraContext = {context: {bypass_risk: true}}; |
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.
Instead of using this variable, I suggest setting this value as an order property;
order.set_bypass_risk(true);
and order model:
const PosSaleFinancialRiskOrder = (Order) =>
class PosSaleFinancialRiskOrder extends Order {
constructor() {
super(...arguments);
this.bypass_risk = false;
}
set_bypass_risk(bypass_risk) {
this.bypass_risk = bypass_risk
}
export_as_JSON() {
const result = super.export_as_JSON(...arguments);
result.bypass_risk = this.bypass_risk;
return result;
}
init_from_JSON(json) {
super.init_from_JSON(...arguments);
this.bypass_risk = json.bypass_risk;
}
}
Registries.Model.extend(Order, PosSaleFinancialRiskOrder);
export default PosSaleFinancialRiskOrder;
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.
so this values will available in order_data
of def create_order_from_pos(self, order_data, action)
method
and you can check:
if "bypass_risk" in order_data:
self = self.with_context(bypass_risk=bypass_risk)
return super(SaleOrder, self).create_order_from_pos(order_data, action)
please check this way
}) | ||
.finally(function () { | ||
framework.unblockUI(); | ||
}); |
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.
There is no need to override this method if you will be using the order
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.
please check comments
showButton: false, | ||
}; | ||
|
||
Registries.Component.add(ConfirmRiskPopup); |
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 need create new popup
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.
Resolved
bbbff55
to
8cf2faa
Compare
8cf2faa
to
b1bc5ca
Compare
@ivantodorovich, @ivs-cetmix, @GabbasovDinar, @DemchukM Could you please make code review again? |
Thanks a lot @geomer198 ! Looks great to me 👍🏻 Before merging, could you squash the 2 commits and reword the first one to account for the new module name? 🙏🏻 |
1f864b2
to
d66b2fb
Compare
@ivantodorovich Is all okay? |
Perfect, thanks!! /ocabot merge nobump |
This PR looks fantastic, let's merge it! |
@ivantodorovich your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-1024-by-ivantodorovich-bump-nobump. After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red. |
The merge command failed with some error. Could you rebase? I'll try with ocabot but it can fail depending on the PR permissions /ocabot rebase |
@ivantodorovich The rebase process failed, because command
|
d66b2fb
to
ea24bab
Compare
@ivantodorovich There is a problem with tests, tests that do not depend on this module are not run. |
It may be related to this warning: You probably have to choose a different and unique name for the test tours |
e9ef3cc
to
397df34
Compare
830b7a4
to
88e4a95
Compare
@ivantodorovich Is all good now? |
This PR has the |
Looks great! Thanks! /ocabot merge nobump |
On my way to merge this fine PR! |
Congratulations, your PR was merged at 1af25ee. Thanks a lot for contributing to OCA. ❤️ |
This module is a bridging module between sale_financial_risk and pos_order_to_sale_order. It implements control for the Sale Orders created from POS.
Same warning or blocking message will be displayed in POS as if an order was created from the backend.