|
|
@ -0,0 +1,35 @@ |
|
|
|
# Copyright 2018 ACSONE SA/NV |
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|
|
|
|
|
|
|
from odoo import api, fields, models |
|
|
|
from odoo.tools.translate import _ |
|
|
|
|
|
|
|
|
|
|
|
class AccountAnalyticAccount(models.Model): |
|
|
|
_name = 'account.analytic.account' |
|
|
|
_inherit = 'account.analytic.account' |
|
|
|
|
|
|
|
sale_order_count = fields.Integer(compute="_compute_sale_order_count") |
|
|
|
|
|
|
|
@api.depends('recurring_invoice_line_ids') |
|
|
|
def _compute_sale_order_count(self): |
|
|
|
for rec in self: |
|
|
|
rec.sale_order_count = len( |
|
|
|
rec.recurring_invoice_line_ids.mapped( |
|
|
|
'sale_order_line_id.order_id' |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
@api.multi |
|
|
|
def action_view_sales_orders(self): |
|
|
|
self.ensure_one() |
|
|
|
orders = self.recurring_invoice_line_ids.mapped( |
|
|
|
'sale_order_line_id.order_id' |
|
|
|
) |
|
|
|
return { |
|
|
|
"name": _("Sales Orders"), |
|
|
|
"view_mode": "tree,form", |
|
|
|
"res_model": "sale.order", |
|
|
|
"type": "ir.actions.act_window", |
|
|
|
"domain": [("id", "in", orders.ids)], |
|
|
|
} |