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.

35 lines
1.1 KiB

  1. # Copyright 2018 ACSONE SA/NV
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import api, fields, models
  4. from odoo.tools.translate import _
  5. class AccountAnalyticAccount(models.Model):
  6. _name = 'account.analytic.account'
  7. _inherit = 'account.analytic.account'
  8. sale_order_count = fields.Integer(compute="_compute_sale_order_count")
  9. @api.depends('recurring_invoice_line_ids')
  10. def _compute_sale_order_count(self):
  11. for rec in self:
  12. rec.sale_order_count = len(
  13. rec.recurring_invoice_line_ids.mapped(
  14. 'sale_order_line_id.order_id'
  15. )
  16. )
  17. @api.multi
  18. def action_view_sales_orders(self):
  19. self.ensure_one()
  20. orders = self.recurring_invoice_line_ids.mapped(
  21. 'sale_order_line_id.order_id'
  22. )
  23. return {
  24. "name": _("Sales Orders"),
  25. "view_mode": "tree,form",
  26. "res_model": "sale.order",
  27. "type": "ir.actions.act_window",
  28. "domain": [("id", "in", orders.ids)],
  29. }