add operation analytic to invoice
This commit is contained in:
parent
5c38127f37
commit
f8d3c1b03d
@ -0,0 +1,8 @@
|
||||
######################
|
||||
Analytic Operations Module
|
||||
######################
|
||||
|
||||
|
||||
The *Analytic Operations Module* adds the concept of analytic account general
|
||||
in invoice, purchase, sale. This allows added the account analytic to the lines of
|
||||
operation more fast.
|
10
__init__.py
10
__init__.py
@ -2,7 +2,7 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.pool import Pool
|
||||
from . import purchase, sale
|
||||
from . import invoice, purchase, sale
|
||||
|
||||
__all__ = ['register']
|
||||
|
||||
@ -13,8 +13,10 @@ def register():
|
||||
purchase.PurchaseLine,
|
||||
sale.Sale,
|
||||
sale.SaleLine,
|
||||
module='analytic_operation', type_='model')
|
||||
invoice.Invoice,
|
||||
invoice.InvoiceLine,
|
||||
module='analytic_operations', type_='model')
|
||||
Pool.register(
|
||||
module='analytic_operation', type_='wizard')
|
||||
module='analytic_operations', type_='wizard')
|
||||
Pool.register(
|
||||
module='analytic_operation', type_='report')
|
||||
module='analytic_operations', type_='report')
|
||||
|
39
invoice.py
Normal file
39
invoice.py
Normal file
@ -0,0 +1,39 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.pyson import Eval
|
||||
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
class Invoice(metaclass=PoolMeta):
|
||||
'Account Invoice'
|
||||
__name__ = 'account.invoice'
|
||||
|
||||
_states = {
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}
|
||||
|
||||
|
||||
account_analytic = fields.Many2One('analytic_account.account', 'Analytic Account', required=True,
|
||||
domain=[('type', '=', 'normal')],
|
||||
states=_states)
|
||||
|
||||
|
||||
class InvoiceLine(metaclass=PoolMeta):
|
||||
'Invoice Line'
|
||||
__name__ = 'account.invoice.line'
|
||||
|
||||
@fields.depends('product', 'unit', '_parent_invoice.type', 'analytic_accounts',
|
||||
'_parent_invoice.party', 'party', 'invoice', 'invoice_type',
|
||||
'_parent_invoice.account_analytic', '_parent_invoice.invoice_date',
|
||||
'_parent_invoice.accounting_date','company', methods=['_get_tax_rule_pattern'])
|
||||
def on_change_product(self):
|
||||
super(InvoiceLine, self).on_change_product()
|
||||
self.analytic_accounts = tuple()
|
||||
try:
|
||||
self.analytic_accounts += ({'root': self.invoice.account_analytic.root,
|
||||
'account': self.invoice.account_analytic},)
|
||||
except:
|
||||
pass
|
||||
|
11
invoice.xml
Normal file
11
invoice.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--This file file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="invoice_view_form">
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="inherit" ref="account_invoice.invoice_view_form"/>
|
||||
<field name="name">invoice_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
@ -2,6 +2,10 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:account.invoice,account_analytic:"
|
||||
msgid "Analytic Account"
|
||||
msgstr "Cuenta Analítica"
|
||||
|
||||
msgctxt "field:purchase.purchase,account_analytic:"
|
||||
msgid "Analytic Account"
|
||||
msgstr "Cuenta Analítica"
|
||||
|
12
purchase.py
12
purchase.py
@ -10,11 +10,13 @@ class Purchase(metaclass=PoolMeta):
|
||||
'Purchase Analytic Operation'
|
||||
__name__ = 'purchase.purchase'
|
||||
|
||||
account_analytic = fields.Many2One('analytic_account.account',
|
||||
'Analytic Account', required=True,
|
||||
domain=[
|
||||
('type', '=', 'normal'),
|
||||
])
|
||||
_states = {
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}
|
||||
|
||||
account_analytic = fields.Many2One('analytic_account.account', 'Analytic Account', required=True,
|
||||
domain=[('type', '=', 'normal')],
|
||||
states=_states)
|
||||
class PurchaseLine(metaclass=PoolMeta):
|
||||
'Purchase Line Analytic Operation'
|
||||
__name__ = 'purchase.line'
|
||||
|
@ -8,3 +8,4 @@ depends:
|
||||
xml:
|
||||
purchase.xml
|
||||
sale.xml
|
||||
invoice.xml
|
||||
|
10
view/invoice_form.xml
Normal file
10
view/invoice_form.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath
|
||||
expr="/form/field[@name='reference']" position="after">
|
||||
<label name="account_analytic"/>
|
||||
<field name="account_analytic" xexpand="1"/>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in New Issue
Block a user