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

[IMP] account_financial_risk: Send email when risk confirmed #393

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from

Conversation

SirAionTech
Copy link

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).

@OCA-git-bot
Copy link
Contributor

Hi @carlosdauden,
some modules you are maintaining are being modified, check this out!

@SirAionTech SirAionTech marked this pull request as ready for review August 1, 2024 08:00
@SirAionTech SirAionTech force-pushed the 16.0-imp-account_financial_risk-risk_template branch from 2a7c330 to f94b108 Compare August 1, 2024 10:38
@SirAionTech SirAionTech marked this pull request as draft August 1, 2024 10:40
@SirAionTech SirAionTech force-pushed the 16.0-imp-account_financial_risk-risk_template branch from f94b108 to cf45b8d Compare August 1, 2024 10:42
@SirAionTech SirAionTech marked this pull request as ready for review August 1, 2024 10:43
@SirAionTech SirAionTech force-pushed the 16.0-imp-account_financial_risk-risk_template branch from cf45b8d to 2376dad Compare September 27, 2024 16:00
Copy link
Contributor

@carlosdauden carlosdauden left a 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()
Copy link
Contributor

@carlosdauden carlosdauden Dec 2, 2024

Choose a reason for hiding this comment

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

Suggested change
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

Comment on lines 35 to 36
def _post_account_move_confirm_risk(self, origin_record):
template = origin_record.company_id.account_move_confirm_risk_template_id
Copy link
Contributor

@carlosdauden carlosdauden Dec 2, 2024

Choose a reason for hiding this comment

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

Suggested change
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)

Copy link
Author

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.

Comment on lines +42 to +53
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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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

@SirAionTech SirAionTech force-pushed the 16.0-imp-account_financial_risk-risk_template branch from 2376dad to 449b2bd Compare December 2, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants