Improvement on invoice lines and analytic accounts
This commit is contained in:
@@ -2,3 +2,4 @@
|
||||
|
||||
from . import sale
|
||||
from . import account_invoice
|
||||
from . import account_analytic_account
|
||||
|
||||
24
sale_usability_extension/account_analytic_account.py
Normal file
24
sale_usability_extension/account_analytic_account.py
Normal 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
|
||||
@@ -75,5 +75,25 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="account_analytic_account_sale_order_action" model="ir.actions.act_window">
|
||||
<field name="name">Quotations and Sales</field>
|
||||
<field name="res_model">sale.order</field>
|
||||
<field name="view_mode">tree,form,graph,calendar</field>
|
||||
<field name="context">{'search_default_project_id': active_id}</field>
|
||||
</record>
|
||||
|
||||
<record id="view_account_analytic_account_form" model="ir.ui.view">
|
||||
<field name="name">analytic.analytic.account.form</field>
|
||||
<field name="model">account.analytic.account</field>
|
||||
<field name="inherit_id" ref="analytic.view_account_analytic_account_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<div name="buttons" position="inside">
|
||||
<button class="oe_inline oe_stat_button" type="action" name="%(account_analytic_account_sale_order_action)d" icon="fa-strikethrough" attrs="{'invisible': [('type', '!=', 'contract')]}">
|
||||
<field string="Quote/Order" name="sale_order_count" widget="statinfo"/>
|
||||
</button>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user