-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
[IMP] account_financial_risk: Send email when risk confirmed #393
base: 16.0
Are you sure you want to change the base?
[IMP] account_financial_risk: Send email when risk confirmed #393
Conversation
Hi @carlosdauden, |
2a7c330
to
f94b108
Compare
f94b108
to
cf45b8d
Compare
cf45b8d
to
2376dad
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.
Try this to simplify the extension with other modules as #394
template = origin_record.company_id.account_move_confirm_risk_template_id | ||
if template: | ||
template.send_mail(origin_record.id) | ||
|
||
def button_continue(self): | ||
self.ensure_one() |
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.
self.ensure_one() | |
self.ensure_one() | |
res = getattr( | |
self.origin_reference.with_context(bypass_risk=True), self.continue_method | |
)() | |
self._post_confirm_risk() | |
return res |
def _post_account_move_confirm_risk(self, origin_record): | ||
template = origin_record.company_id.account_move_confirm_risk_template_id |
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.
def _post_account_move_confirm_risk(self, origin_record): | |
template = origin_record.company_id.account_move_confirm_risk_template_id | |
def _post_confirm_risk(self): | |
origin_record = self.origin_reference | |
model_preffix = origin_record._name.replace('.', '_') | |
template = getattr(origin_record.company_id, f"{model_preffix}_confirm_risk_template_id", False) |
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 your suggestions!
Sure this would simplify code for other modules, but I think it would become too hard to understand what's happening as it sometimes happens when reflection is used.
I created this hook to explicitly do things for account.move
records, (that's why its name is _post_*account_move*_confirm_risk
); I've added documentation and modified its signature to make it more clear, let me know if that's ok for you.
origin_record = self.origin_reference | ||
continue_result = getattr( | ||
origin_record.with_context(bypass_risk=True), self.continue_method | ||
)() | ||
if origin_record._name == "account.move": | ||
self._post_account_move_confirm_risk(origin_record) | ||
return continue_result |
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.
origin_record = self.origin_reference | |
continue_result = getattr( | |
origin_record.with_context(bypass_risk=True), self.continue_method | |
)() | |
if origin_record._name == "account.move": | |
self._post_account_move_confirm_risk(origin_record) | |
return continue_result |
2376dad
to
449b2bd
Compare
Allow to send a configurable email template when risk for an invoice is explicitly exceeded in the wizard.
Also track the credit limit date because it is just as important as the amount (that is already tracked).