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.

36 lines
1.1 KiB

4 years ago
4 years ago
  1. # Copyright 2018 Rémy Taymans <remytaymans@gmail.com>
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo.http import request
  4. from odoo.addons.portal.controllers.portal import CustomerPortal
  5. class PortalPosOrderAmount(CustomerPortal):
  6. def _prepare_portal_layout_values(self):
  7. values = super(
  8. PortalPosOrderAmount, self
  9. )._prepare_portal_layout_values()
  10. user = request.env.user
  11. owned_posorder = (
  12. request.env["pos.order"]
  13. .sudo()
  14. .search(
  15. [
  16. (
  17. "partner_id",
  18. "=",
  19. user.partner_id.commercial_partner_id.id,
  20. ),
  21. ("state", "!=", "cancel"),
  22. ]
  23. )
  24. )
  25. values["posorder_amount"] = sum(
  26. po.amount_total for po in owned_posorder
  27. )
  28. values["company_currency"] = (
  29. request.env["res.company"]._company_default_get().currency_id
  30. )
  31. return values