diff --git a/README.md b/README.md
index e69de29..09f05aa 100644
--- a/README.md
+++ b/README.md
@@ -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.
diff --git a/__init__.py b/__init__.py
index 542096c..8a49cb1 100644
--- a/__init__.py
+++ b/__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')
diff --git a/invoice.py b/invoice.py
new file mode 100644
index 0000000..6539ba9
--- /dev/null
+++ b/invoice.py
@@ -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
+
diff --git a/invoice.xml b/invoice.xml
new file mode 100644
index 0000000..abf0d8b
--- /dev/null
+++ b/invoice.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+ account.invoice
+
+ invoice_form
+
+
+
diff --git a/locale/es.po b/locale/es.po
index 2ceeb14..0771462 100644
--- a/locale/es.po
+++ b/locale/es.po
@@ -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"
diff --git a/purchase.py b/purchase.py
index 31ae531..5454878 100644
--- a/purchase.py
+++ b/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'
diff --git a/tryton.cfg b/tryton.cfg
index aef0cdc..c18fc81 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -8,3 +8,4 @@ depends:
xml:
purchase.xml
sale.xml
+ invoice.xml
diff --git a/view/invoice_form.xml b/view/invoice_form.xml
new file mode 100644
index 0000000..4ef0621
--- /dev/null
+++ b/view/invoice_form.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+