Improvement on invoice lines and analytic accounts
This commit is contained in:
@@ -70,6 +70,28 @@ class AccountInvoice(models.Model):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
class AccountInvoiceLine(models.Model):
|
||||||
|
_inherit = 'account.invoice.line'
|
||||||
|
|
||||||
|
# In the 'account' module, we have related stored field for:
|
||||||
|
# company_id, partner_id
|
||||||
|
currency_id = fields.Many2one(
|
||||||
|
related='invoice_id.currency_id', readonly=True, store=True)
|
||||||
|
invoice_type = fields.Selection(
|
||||||
|
related='invoice_id.type', store=True, readonly=True)
|
||||||
|
date_invoice = fields.Date(
|
||||||
|
related='invoice_id.date_invoice', store=True, readonly=True)
|
||||||
|
commercial_partner_id = fields.Many2one(
|
||||||
|
related='invoice_id.partner_id.commercial_partner_id',
|
||||||
|
store=True, readonly=True)
|
||||||
|
state = fields.Selection(
|
||||||
|
related='invoice_id.state', store=True, readonly=True,
|
||||||
|
string='Invoice State')
|
||||||
|
invoice_number = fields.Char(
|
||||||
|
related='invoice_id.move_id.name', store=True, readonly=True,
|
||||||
|
string='Invoice Number')
|
||||||
|
|
||||||
|
|
||||||
class AccountFiscalYear(models.Model):
|
class AccountFiscalYear(models.Model):
|
||||||
_inherit = 'account.fiscalyear'
|
_inherit = 'account.fiscalyear'
|
||||||
|
|
||||||
@@ -110,6 +132,10 @@ class AccountAccount(models.Model):
|
|||||||
class AccountAnalyticAccount(models.Model):
|
class AccountAnalyticAccount(models.Model):
|
||||||
_inherit = 'account.analytic.account'
|
_inherit = 'account.analytic.account'
|
||||||
|
|
||||||
|
invoice_line_ids = fields.One2many(
|
||||||
|
'account.invoice.line', 'account_analytic_id', 'Invoice Lines',
|
||||||
|
readonly=True)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def name_get(self):
|
def name_get(self):
|
||||||
if self._context.get('analytic_account_show_code_only'):
|
if self._context.get('analytic_account_show_code_only'):
|
||||||
|
|||||||
@@ -65,6 +65,102 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!-- Having a menu entry on invoice lines is often very usefull for odoo user:
|
||||||
|
they can search in their lines, etc...
|
||||||
|
So I enhance the generic views and add actions, but I don't add menu entries here ;
|
||||||
|
the creation of the corresponding menu entry should be done in the customer-specifc
|
||||||
|
module -->
|
||||||
|
<record id="view_invoice_line_tree" model="ir.ui.view">
|
||||||
|
<field name="name">account_usability.invoice_line_tree</field>
|
||||||
|
<field name="model">account.invoice.line</field>
|
||||||
|
<field name="inherit_id" ref="account.view_invoice_line_tree"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="name" position="before">
|
||||||
|
<field name="partner_id" invisible="not context.get('show_invoice_fields')"/>
|
||||||
|
<field name="date_invoice" invisible="not context.get('show_invoice_fields')"/>
|
||||||
|
<field name="invoice_number" invisible="not context.get('show_invoice_fields')"/>
|
||||||
|
</field>
|
||||||
|
<field name="price_subtotal" position="after">
|
||||||
|
<field name="currency_id"/>
|
||||||
|
<field name="state" invisible="not context.get('show_invoice_fields')"/>
|
||||||
|
<field name="invoice_type" invisible="1"/>
|
||||||
|
</field>
|
||||||
|
<xpath expr="/tree" position="attributes">
|
||||||
|
<attribute name="edit">0</attribute>
|
||||||
|
<attribute name="create">0</attribute>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="account_invoice_line_search" model="ir.ui.view">
|
||||||
|
<field name="name">account_usability.invoice_line_search</field>
|
||||||
|
<field name="model">account.invoice.line</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search string="Search Invoice Lines">
|
||||||
|
<field name="partner_id"/>
|
||||||
|
<field name="product_id"/>
|
||||||
|
<field name="account_id"/>
|
||||||
|
<field name="invoice_number"/>
|
||||||
|
<field name="name"/>
|
||||||
|
<filter name="out_invoice" string="Customer Invoices"
|
||||||
|
domain="[('invoice_type', '=', 'out_invoice')]"/>
|
||||||
|
<filter name="out_refund" string="Customer Refunds"
|
||||||
|
domain="[('invoice_type', '=', 'out_refund')]"/>
|
||||||
|
<filter name="in_invoice" string="Supplier Invoices"
|
||||||
|
domain="[('invoice_type', '=', 'in_invoice')]"/>
|
||||||
|
<filter name="in_refund" string="Supplier Refunds"
|
||||||
|
domain="[('invoice_type', '=', 'in_refund')]"/>
|
||||||
|
<separator/>
|
||||||
|
<filter name="draft" string="Draft" domain="[('state', '=', 'draft')]"/>
|
||||||
|
<filter name="unpaid" string="Not Paid" domain="[('state', '=', 'open')]"/>
|
||||||
|
<filter name="paid" string="Paid" domain="[('state', '=', 'paid')]"/>
|
||||||
|
|
||||||
|
<group string="Group By" name="groupby">
|
||||||
|
<filter name="partner_groupby" string="Partner"
|
||||||
|
context="{'group_by': 'partner_id'}"/>
|
||||||
|
<filter name="date_groupby" string="Invoice Date"
|
||||||
|
context="{'group_by': 'date_invoice'}"/>
|
||||||
|
<filter name="product_groupby" string="Product"
|
||||||
|
context="{'group_by': 'product_id'}"/>
|
||||||
|
<filter name="account_groupby" string="Account"
|
||||||
|
context="{'group_by': 'account_id'}"/>
|
||||||
|
</group>
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="out_invoice_line_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Customer Invoice Lines</field>
|
||||||
|
<field name="res_model">account.invoice.line</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
<field name="domain">[('invoice_type', '=', 'out_invoice')]</field>
|
||||||
|
<field name="context">{'show_invoice_fields': True}</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="out_refund_line_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Customer Refund Lines</field>
|
||||||
|
<field name="res_model">account.invoice.line</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
<field name="domain">[('invoice_type', '=', 'out_refund')]</field>
|
||||||
|
<field name="context">{'show_invoice_fields': True}</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="in_invoice_line_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Supplier Invoice Lines</field>
|
||||||
|
<field name="res_model">account.invoice.line</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
<field name="domain">[('invoice_type', '=', 'in_invoice')]</field>
|
||||||
|
<field name="context">{'show_invoice_fields': True}</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="in_refund_line_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Supplier Refund Lines</field>
|
||||||
|
<field name="res_model">account.invoice.line</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
<field name="domain">[('invoice_type', '=', 'in_refund')]</field>
|
||||||
|
<field name="context">{'show_invoice_fields': True}</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<!-- model account.move.line / Journal Items -->
|
<!-- model account.move.line / Journal Items -->
|
||||||
<record id="account.action_account_moves_all_a" model="ir.actions.act_window">
|
<record id="account.action_account_moves_all_a" model="ir.actions.act_window">
|
||||||
<field name="limit">200</field>
|
<field name="limit">200</field>
|
||||||
@@ -249,5 +345,18 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</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">
|
||||||
|
<notebook position="inside">
|
||||||
|
<page name="invoice_lines" string="Related Invoice Lines">
|
||||||
|
<field name="invoice_line_ids" nolabel="1" context="{'show_invoice_fields': 1}"/>
|
||||||
|
</page>
|
||||||
|
</notebook>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|||||||
@@ -2,3 +2,4 @@
|
|||||||
|
|
||||||
from . import sale
|
from . import sale
|
||||||
from . import account_invoice
|
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>
|
</field>
|
||||||
</record>
|
</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>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|||||||
Reference in New Issue
Block a user