Improvement on invoice lines and analytic accounts

This commit is contained in:
Alexis de Lattre
2017-01-20 18:22:37 +01:00
parent baf7359cc7
commit 9761c7527b
5 changed files with 180 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
from openerp import models, fields, api
class AccountAnalyticAccount(models.Model):
_inherit = 'account.analytic.account'
sale_order_count = fields.Integer(
compute='compute_sale_order_count',
string='Number of Quotations/Orders', readonly=True)
sale_ids = fields.One2many(
'sale.order', 'project_id', string='Quotations/Orders')
@api.multi
def compute_sale_order_count(self):
for aaa in self:
try:
count = len(aaa.sale_ids)
except:
count = 0
aaa.sale_order_count = count