You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
3.4 KiB

[ADD] bond and loan issues management [ADD] bond and loan issues management module skeleton [IMP] change increase menu sequence [IMP] add models, fields and views [IMP] add xml declaration in head of file [ADD] add easy_my_coop_loan_website - WIP [IMP] add access rights [IMP] this raise inconsistency so replace id by default_code. [IMP] change import openerp to odoo [IMP] add website loan module [FIX] put website display in loan [FIX] fix import [FIX] fix function [IMP] use correct name [IMP] make the loan and bond visible [IMP] add js, field and logic to set amount limit per subscription [IMP] remove dependency on recaptcha as user is logged to subscribe [IMP] add fields [IMP] save loan issue subscription still in WIP [IMP] remove alert pop up [IMP] add dependency to easy_my_coop_website [IMP] remove force send for sub request creation email notification [IMP] add mail templates [IMP] save subscription in the corresponding loan issue. add email notif [FIX] fix loan issue line view [FIX] add related field to loan issue. It is where the data stand [IMP] move term_view up [FIX] fix js error when false is returned [FIX] fix function when loan_issue_id in None [IMP] add actions and button [FIX] fix action [FIX] fix mail template [IMP] set noupdate=1 [IMP] change order [IMP] display loan issue lines on partner form [IMP] add loan view in partner form [IMP] add face value on loan issue and line add face value on loan issue and line. add as well the quantity and computation of the amount [FIX] missing id overriding values wasn't working [IMP] getting bond face value and setting it as step. [IMP] subscribed_amount computed field is the sum of the amount lines [IMP] allow a waiting payment to be cancelled [IMP] make field required [REFACT] move loan issue line code to dedicated file [IMP] add interest calculation and model [ADD] bond and loan issues management module skeleton [IMP] add models, fields and views [IMP] allow creation by hand [IMP] adding partner related field [IMP] put code in separate function [FIX] pass it to get method [IMP] routes consistent form [FIX] fix eof [FIX] GET is working for ajax call [IMP] website page for loan issue subscription
5 years ago
  1. from odoo import http
  2. from odoo.http import request
  3. from odoo.tools.translate import _
  4. class WebsiteLoanIssueSubscription(http.Controller):
  5. @http.route(['/subscription/get_loan_issue'],
  6. type='json',
  7. auth="user",
  8. methods=['POST'], website=True)
  9. def get_loan_issue(self, loan_issue_id, **kw):
  10. loan_issue_obj = request.env['loan.issue']
  11. if loan_issue_id:
  12. loan_issue = loan_issue_obj.sudo().browse(int(loan_issue_id))
  13. return {
  14. loan_issue.id: {
  15. 'max_amount': loan_issue.maximum_amount_per_sub,
  16. 'face_value': loan_issue.face_value,
  17. }
  18. }
  19. else:
  20. return False
  21. @http.route(['/subscription/loan_issue_form'],
  22. type='http', auth="user", website=True)
  23. def display_loan_issue_subscription_page(self, **kwargs):
  24. values = {}
  25. partner = request.env.user.partner_id
  26. is_company = partner.is_company
  27. values = self.fill_values(values, is_company)
  28. values.update(kwargs=kwargs.items())
  29. return request.render(
  30. "easy_my_coop_loan_website.loanissuesubscription",
  31. values)
  32. def get_loan_issues(self, is_company):
  33. loan_obj = request.env['loan.issue']
  34. loan_issues = loan_obj.sudo().get_web_issues(is_company)
  35. return loan_issues
  36. def fill_values(self, values, is_company):
  37. company = request.website.company_id
  38. loan_issues = self.get_loan_issues(is_company)
  39. values['loan_issues'] = loan_issues
  40. values['company'] = company
  41. if not values.get('loan_issue_id'):
  42. for loan_issue in loan_issues:
  43. if loan_issue.default_issue is True:
  44. values['loan_issue_id'] = loan_issue.id
  45. break
  46. if not values.get('loan_issue_id', False) and loan_issues:
  47. values['loan_issue_id'] = loan_issues[0].id
  48. return values
  49. def validation(self, loan_issue, kwargs):
  50. sub_amount = kwargs.get('subscription_amount')
  51. redirect = "easy_my_coop_loan_website.loanissuesubscription"
  52. values = {}
  53. if not loan_issue:
  54. values["error_msg"] = _("The selected loan issue is not found")
  55. return request.render(redirect, values)
  56. if sub_amount:
  57. values["error_msg"] = _("The amount shoud be of monetary type")
  58. return request.render(redirect, values)
  59. return True
  60. @http.route(['/subscription/subscribe_loan_issue'],
  61. type='http',
  62. auth="user", website=True)
  63. def loan_issue_subscription(self, **kwargs):
  64. loan_obj = request.env['loan.issue']
  65. loan_obj_line = request.env['loan.issue.line']
  66. loan_issue = loan_obj.sudo().browse(kwargs.get('loan_issue_id'))
  67. partner = request.env.user.partner_id
  68. if self.validation(loan_issue, kwargs):
  69. values = {
  70. 'loan_issue_id': loan_issue.id,
  71. 'partner_id': partner.id,
  72. 'amount': kwargs['subscription_amount'],
  73. 'state': 'subscribed'
  74. }
  75. loan_obj_line.sudo().create(values)
  76. return request.render("easy_my_coop_website.cooperator_thanks", values)