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.

74 lines
2.0 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 LasLabs Inc.
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo import http
  5. from odoo.http import request
  6. from odoo.addons.website_portal_sale.controllers.main import website_account
  7. class WebsiteAccount(website_account):
  8. @http.route()
  9. def account(self, **kw):
  10. response = super(WebsiteAccount, self).account(**kw)
  11. contracts = request.env['account.analytic.account']._search_contracts()
  12. response.qcontext.update({
  13. 'contract_count': len(contracts),
  14. })
  15. return response
  16. class WebsiteContract(http.Controller):
  17. @http.route(
  18. ['/my/contracts'],
  19. type='http',
  20. auth='user',
  21. website=True,
  22. )
  23. def portal_my_contracts(self):
  24. account_mod = request.env['account.analytic.account']
  25. values = {
  26. 'user': request.env.user,
  27. 'contracts': account_mod._search_contracts(),
  28. }
  29. return request.render(
  30. 'website_portal_contract.portal_my_contracts',
  31. values,
  32. )
  33. @http.route(
  34. ['/contract/<model("account.analytic.account"):contract>'],
  35. type='http',
  36. auth='user',
  37. website=True
  38. )
  39. def portal_contract(self, contract):
  40. action = request.env.ref(
  41. 'contract.action_account_analytic_overdue_all'
  42. )
  43. values = {
  44. 'user': request.env.user,
  45. 'contract': contract,
  46. 'action': action.id,
  47. }
  48. return request.render(
  49. 'website_portal_contract.website_contract',
  50. values,
  51. )
  52. @http.route(
  53. ["/contract/template/"
  54. "<model('account.analytic.contract.template'):contract>"],
  55. type='http',
  56. auth='user',
  57. website=True,
  58. )
  59. def template_view(self, contract, **kwargs):
  60. values = {'template': contract}
  61. return request.render(
  62. 'website_portal_contract.website_contract_template',
  63. values,
  64. )