[tryton-debian-vcs] tryton-modules-analytic-invoice branch upstream updated. upstream/3.4.1-1-g1f23d8b

Mathias Behrle tryton-debian-vcs at alioth.debian.org
Thu Apr 23 16:02:37 UTC 2015


The following commit has been merged in the upstream branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/tryton-modules-analytic-invoice.git;a=commitdiff;h=upstream/3.4.1-1-g1f23d8b

commit 1f23d8b246142250752ad1118b6b352efc783b4a
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Thu Apr 23 16:59:53 2015 +0200

    Adding upstream version 3.6.0.
    
    Signed-off-by: Mathias Behrle <mathiasb at m9s.biz>

diff --git a/CHANGELOG b/CHANGELOG
index ce6497a..87af13c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,7 @@
-Version 3.4.1 - 2015-03-01
+Version 3.6.0 - 2015-04-20
 * Bug fixes (see mercurial logs for details)
+* Add support for PyPy
+* Use One2Many for analytic accounts
 
 Version 3.4.0 - 2014-10-20
 * Bug fixes (see mercurial logs for details)
diff --git a/PKG-INFO b/PKG-INFO
index 928419b..6aa760c 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: trytond_analytic_invoice
-Version: 3.4.1
+Version: 3.6.0
 Summary: Tryton module to add analytic accounting on invoice
 Home-page: http://www.tryton.org/
 Author: Tryton
 Author-email: issue_tracker at tryton.org
 License: GPL-3
-Download-URL: http://downloads.tryton.org/3.4/
+Download-URL: http://downloads.tryton.org/3.6/
 Description: trytond_analytic_invoice
         ========================
         
@@ -63,5 +63,7 @@ Classifier: Natural Language :: Slovenian
 Classifier: Natural Language :: Spanish
 Classifier: Operating System :: OS Independent
 Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
 Classifier: Topic :: Office/Business
 Classifier: Topic :: Office/Business :: Financial :: Accounting
diff --git a/__init__.py b/__init__.py
index f71cffd..9487c80 100644
--- a/__init__.py
+++ b/__init__.py
@@ -1,5 +1,5 @@
-#This file is part of Tryton.  The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# 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
 from .invoice import *
@@ -8,5 +8,5 @@ from .invoice import *
 def register():
     Pool.register(
         InvoiceLine,
-        Account,
+        AnalyticAccountEntry,
         module='analytic_invoice', type_='model')
diff --git a/invoice.py b/invoice.py
index 1f73a0f..bef3db7 100644
--- a/invoice.py
+++ b/invoice.py
@@ -1,243 +1,63 @@
-#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.model import ModelView, ModelSQL, fields
-from trytond.pyson import Eval
-from trytond.transaction import Transaction
-from trytond.pool import Pool, PoolMeta
+# 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 PoolMeta, Pool
 
-__all__ = ['InvoiceLine', 'Account']
+from trytond.modules.analytic_account import AnalyticMixin
+
+__all__ = ['InvoiceLine', 'AnalyticAccountEntry']
 __metaclass__ = PoolMeta
 
 
-class InvoiceLine:
+class InvoiceLine(AnalyticMixin):
     __name__ = 'account.invoice.line'
-    analytic_accounts = fields.Many2One('analytic_account.account.selection',
-        'Analytic Accounts',
-        states={
-            'invisible': Eval('type') != 'line',
-            },
-        depends=['type'])
-
-    @classmethod
-    def _view_look_dom_arch(cls, tree, type, field_children=None):
-        AnalyticAccount = Pool().get('analytic_account.account')
-        AnalyticAccount.convert_view(tree)
-        return super(InvoiceLine, cls)._view_look_dom_arch(tree, type,
-            field_children=field_children)
-
-    @classmethod
-    def fields_get(cls, fields_names=None):
-        AnalyticAccount = Pool().get('analytic_account.account')
-
-        fields = super(InvoiceLine, cls).fields_get(fields_names)
-
-        analytic_accounts_field = super(InvoiceLine, cls).fields_get(
-                ['analytic_accounts'])['analytic_accounts']
-
-        fields.update(AnalyticAccount.analytic_accounts_fields_get(
-                analytic_accounts_field, fields_names,
-                states=cls.analytic_accounts.states,
-                required_states=Eval('type') == 'line'))
-        return fields
-
-    @classmethod
-    def default_get(cls, fields, with_rec_name=True):
-        fields = [x for x in fields if not x.startswith('analytic_account_')]
-        return super(InvoiceLine, cls).default_get(fields,
-            with_rec_name=with_rec_name)
-
-    @classmethod
-    def read(cls, ids, fields_names=None):
-        if fields_names:
-            fields_names2 = [x for x in fields_names
-                    if not x.startswith('analytic_account_')]
-        else:
-            fields_names2 = fields_names
-
-        res = super(InvoiceLine, cls).read(ids, fields_names=fields_names2)
-
-        if not fields_names:
-            fields_names = cls._fields.keys()
-
-        root_ids = []
-        for field in fields_names:
-            if field.startswith('analytic_account_') and '.' not in field:
-                root_ids.append(int(field[len('analytic_account_'):]))
-        if root_ids:
-            id2record = {}
-            for record in res:
-                id2record[record['id']] = record
-            lines = cls.browse(ids)
-            for line in lines:
-                for root_id in root_ids:
-                    id2record[line.id]['analytic_account_'
-                        + str(root_id)] = None
-                if line.type != 'line':
-                    continue
-                if not line.analytic_accounts:
-                    continue
-                for account in line.analytic_accounts.accounts:
-                    if account.root.id in root_ids:
-                        id2record[line.id]['analytic_account_'
-                            + str(account.root.id)] = account.id
-                        for field in fields_names:
-                            if field.startswith('analytic_account_'
-                                    + str(account.root.id) + '.'):
-                                ham, field2 = field.split('.', 1)
-                                id2record[line.id][field] = account[field2]
-        return res
-
-    @classmethod
-    def create(cls, vlist):
-        Selection = Pool().get('analytic_account.account.selection')
-        vlist = [x.copy() for x in vlist]
-        for vals in vlist:
-            selection_vals = {}
-            for field in vals.keys():
-                if field.startswith('analytic_account_'):
-                    if vals[field]:
-                        selection_vals.setdefault('accounts', [])
-                        selection_vals['accounts'].append(('add',
-                                [vals[field]]))
-                    del vals[field]
-            if vals.get('analytic_accounts'):
-                Selection.write([Selection(vals['analytic_accounts'])],
-                    selection_vals)
-            elif vals.get('type', 'line') == 'line':
-                selection, = Selection.create([selection_vals])
-                vals['analytic_accounts'] = selection.id
-        return super(InvoiceLine, cls).create(vlist)
-
-    @classmethod
-    def write(cls, *args):
-        Selection = Pool().get('analytic_account.account.selection')
-        actions = iter(args)
-        args = []
-        for lines, values in zip(actions, actions):
-            values = values.copy()
-            selection_vals = {}
-            for field, value in values.items():
-                if field.startswith('analytic_account_'):
-                    root_id = int(field[len('analytic_account_'):])
-                    selection_vals[root_id] = value
-                    del values[field]
-            if selection_vals:
-                for line in lines:
-                    if line.type != 'line':
-                        continue
-                    accounts = []
-                    if not line.analytic_accounts:
-                        # Create missing selection
-                        selection, = Selection.create([{}])
-                        cls.write([line], {
-                                'analytic_accounts': selection.id,
-                                })
-                    for account in line.analytic_accounts.accounts:
-                        if account.root.id in selection_vals:
-                            value = selection_vals[account.root.id]
-                            if value:
-                                accounts.append(value)
-                        else:
-                            accounts.append(account.id)
-                    for account_id in selection_vals.values():
-                        if account_id \
-                                and account_id not in accounts:
-                            accounts.append(account_id)
-                    to_remove = list(
-                        set((a.id for a in line.analytic_accounts.accounts))
-                        - set(accounts))
-                    Selection.write([line.analytic_accounts], {
-                            'accounts': [
-                                ('remove', to_remove),
-                                ('add', accounts),
-                                ],
-                            })
-            args.extend((lines, values))
-        super(InvoiceLine, cls).write(*args)
-
-    @classmethod
-    def delete(cls, lines):
-        Selection = Pool().get('analytic_account.account.selection')
-
-        selection_ids = []
-        for line in lines:
-            if line.analytic_accounts:
-                selection_ids.append(line.analytic_accounts.id)
-
-        super(InvoiceLine, cls).delete(lines)
-        Selection.delete(Selection.browse(selection_ids))
-
-    @classmethod
-    def copy(cls, lines, default=None):
-        Selection = Pool().get('analytic_account.account.selection')
-
-        new_lines = super(InvoiceLine, cls).copy(lines, default=default)
-
-        for line in new_lines:
-            if line.analytic_accounts:
-                selection, = Selection.copy([line.analytic_accounts])
-                cls.write([line], {
-                        'analytic_accounts': selection.id,
-                        })
-        return new_lines
 
     def _credit(self):
-        Selection = Pool().get('analytic_account.account.selection')
+        pool = Pool()
+        AnalyticAccountEntry = pool.get('analytic.account.entry')
 
         result = super(InvoiceLine, self)._credit()
-
         if self.analytic_accounts:
-            selection, = Selection.copy([self.analytic_accounts])
-            result['analytic_accounts'] = selection.id
+            new_entries = AnalyticAccountEntry.copy(self.analytic_accounts,
+                default={
+                    'origin': None,
+                    })
+            result['analytic_accounts'] = [('add',
+                    [e.id for e in new_entries])]
+
         return result
 
+    def get_analytic_entry(self, entry, value):
+        analytic_entry = {}
+        analytic_entry['name'] = self.description
+        analytic_entry['debit'] = value['debit']
+        analytic_entry['credit'] = value['credit']
+        analytic_entry['account'] = entry.account.id
+        analytic_entry['journal'] = self.invoice.journal.id
+        analytic_entry['date'] = (self.invoice.accounting_date or
+            self.invoice.invoice_date)
+        analytic_entry['reference'] = self.invoice.reference
+        analytic_entry['party'] = self.invoice.party.id
+        return analytic_entry
+
     def get_move_line(self):
         values = super(InvoiceLine, self).get_move_line()
-        if self.analytic_accounts and self.analytic_accounts.accounts:
+        if self.analytic_accounts:
             for value in values:
                 value['analytic_lines'] = []
                 to_create = []
-                for account in self.analytic_accounts.accounts:
-                    vals = {}
-                    vals['name'] = self.description
-                    vals['debit'] = value['debit']
-                    vals['credit'] = value['credit']
-                    vals['account'] = account.id
-                    vals['journal'] = self.invoice.journal.id
-                    vals['date'] = (self.invoice.accounting_date
-                        or self.invoice.invoice_date)
-                    vals['reference'] = self.invoice.reference
-                    vals['party'] = self.invoice.party.id
-                    to_create.append(vals)
+                for entry in self.analytic_accounts:
+                    if not entry.account:
+                        continue
+                    to_create.append(self.get_analytic_entry(entry, value))
                 if to_create:
                     value['analytic_lines'] = [('create', to_create)]
         return values
 
 
-class Account(ModelSQL, ModelView):
-    __name__ = 'analytic_account.account'
-
-    @classmethod
-    def delete(cls, accounts):
-        InvoiceLine = Pool().get('account.invoice.line')
-        super(Account, cls).delete(accounts)
-        # Restart the cache on the fields_view_get method of
-        # account.invoice.line
-        InvoiceLine._fields_view_get_cache.clear()
-
-    @classmethod
-    def create(cls, vlist):
-        InvoiceLine = Pool().get('account.invoice.line')
-        accounts = super(Account, cls).create(vlist)
-        # Restart the cache on the fields_view_get method of
-        # account.invoice.line
-        InvoiceLine._fields_view_get_cache.clear()
-        return accounts
+class AnalyticAccountEntry:
+    __name__ = 'analytic.account.entry'
 
     @classmethod
-    def write(cls, accounts, values, *args):
-        InvoiceLine = Pool().get('account.invoice.line')
-        super(Account, cls).write(accounts, values, *args)
-        # Restart the cache on the fields_view_get method of
-        # account.invoice.line
-        InvoiceLine._fields_view_get_cache.clear()
+    def _get_origin(cls):
+        origins = super(AnalyticAccountEntry, cls)._get_origin()
+        return origins + ['account.invoice.line']
diff --git a/locale/bg_BG.po b/locale/bg_BG.po
index 5716284..712e989 100644
--- a/locale/bg_BG.po
+++ b/locale/bg_BG.po
@@ -2,6 +2,14 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
+msgctxt "error:account.invoice.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr ""
+
 msgctxt "field:account.invoice.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Аналитични сметки"
+
+msgctxt "field:account.invoice.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr ""
diff --git a/locale/ca_ES.po b/locale/ca_ES.po
index 6943cd3..2b7232d 100644
--- a/locale/ca_ES.po
+++ b/locale/ca_ES.po
@@ -2,6 +2,14 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
+msgctxt "error:account.invoice.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Falten alguns comptes analítics obligatoris a \"%(name)s\"."
+
 msgctxt "field:account.invoice.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Comptes analítics"
+
+msgctxt "field:account.invoice.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr "Mida dels comptes analítics"
diff --git a/locale/cs_CZ.po b/locale/cs_CZ.po
index 1d3bd89..aeb0025 100644
--- a/locale/cs_CZ.po
+++ b/locale/cs_CZ.po
@@ -2,6 +2,14 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
+msgctxt "error:account.invoice.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr ""
+
 msgctxt "field:account.invoice.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr ""
+
+msgctxt "field:account.invoice.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr ""
diff --git a/locale/de_DE.po b/locale/de_DE.po
index 7ac1f90..0b636e0 100644
--- a/locale/de_DE.po
+++ b/locale/de_DE.po
@@ -2,6 +2,14 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
+msgctxt "error:account.invoice.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Erforderliches Wurzelkonto für \"%(name)s\" fehlt"
+
 msgctxt "field:account.invoice.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Kostenstellen"
+
+msgctxt "field:account.invoice.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr "Kostenstellengröße"
diff --git a/locale/es_AR.po b/locale/es_AR.po
index 825e4f5..9485215 100644
--- a/locale/es_AR.po
+++ b/locale/es_AR.po
@@ -2,6 +2,14 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
+msgctxt "error:account.invoice.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Falta una cuenta root obligatoria en «%(name)s»"
+
 msgctxt "field:account.invoice.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Cuentas analíticas"
+
+msgctxt "field:account.invoice.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr "Tamaño de cuentas analíticas"
diff --git a/locale/es_CO.po b/locale/es_CO.po
index c2fb3e2..005f715 100644
--- a/locale/es_CO.po
+++ b/locale/es_CO.po
@@ -2,6 +2,14 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
+msgctxt "error:account.invoice.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Alguna cuenta raíz obligatoria falta en \"%(name)s\""
+
 msgctxt "field:account.invoice.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Cuentas Analíticas"
+
+msgctxt "field:account.invoice.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr "Tamaño de Centro de Costos"
diff --git a/locale/es_EC.po b/locale/es_EC.po
index c2fb3e2..217c1fc 100644
--- a/locale/es_EC.po
+++ b/locale/es_EC.po
@@ -2,6 +2,14 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
+msgctxt "error:account.invoice.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Faltan algunas cuentas raíz obligatorias en \"%(name)s\""
+
 msgctxt "field:account.invoice.line,analytic_accounts:"
 msgid "Analytic Accounts"
-msgstr "Cuentas Analíticas"
+msgstr "Cuentas analíticas"
+
+msgctxt "field:account.invoice.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr "Tamaño de cuentas analíticas"
diff --git a/locale/es_ES.po b/locale/es_ES.po
index 825e4f5..7b6e63a 100644
--- a/locale/es_ES.po
+++ b/locale/es_ES.po
@@ -2,6 +2,14 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
+msgctxt "error:account.invoice.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Faltan algunas cuentas analíticas obligatorias en \"%(name)s\"."
+
 msgctxt "field:account.invoice.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Cuentas analíticas"
+
+msgctxt "field:account.invoice.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr "Tamaño de cuentas analíticas"
diff --git a/locale/fr_FR.po b/locale/fr_FR.po
index d24b295..4877fcd 100644
--- a/locale/fr_FR.po
+++ b/locale/fr_FR.po
@@ -2,6 +2,14 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
+msgctxt "error:account.invoice.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Certains comptes racines obligatoires sont manquants sur « %(name)s »"
+
 msgctxt "field:account.invoice.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Comptes analytiques"
+
+msgctxt "field:account.invoice.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr "Taille des comptes analytiques"
diff --git a/locale/nl_NL.po b/locale/nl_NL.po
index 1d3bd89..aeb0025 100644
--- a/locale/nl_NL.po
+++ b/locale/nl_NL.po
@@ -2,6 +2,14 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
+msgctxt "error:account.invoice.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr ""
+
 msgctxt "field:account.invoice.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr ""
+
+msgctxt "field:account.invoice.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr ""
diff --git a/locale/ru_RU.po b/locale/ru_RU.po
index 054e2aa..c81d9d4 100644
--- a/locale/ru_RU.po
+++ b/locale/ru_RU.po
@@ -2,6 +2,14 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
+msgctxt "error:account.invoice.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr ""
+
 msgctxt "field:account.invoice.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Счета аналитики"
+
+msgctxt "field:account.invoice.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr ""
diff --git a/locale/sl_SI.po b/locale/sl_SI.po
index e17f67e..4e61b0f 100644
--- a/locale/sl_SI.po
+++ b/locale/sl_SI.po
@@ -2,6 +2,14 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
+msgctxt "error:account.invoice.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Pri \"%(name)s\" manjkajo nekateri korenski konti."
+
 msgctxt "field:account.invoice.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Analitični konti"
+
+msgctxt "field:account.invoice.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr "Število analitičnih kontov"
diff --git a/setup.py b/setup.py
index e034f3f..7b55524 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
-#This file is part of Tryton.  The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# 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 setuptools import setup
 import re
@@ -47,6 +47,12 @@ for dep in info.get('depends', []):
         requires.append(get_require_version('trytond_%s' % dep))
 requires.append(get_require_version('trytond'))
 
+tests_require = [get_require_version('proteus')]
+dependency_links = []
+if minor_version % 2:
+    # Add development index for testing with proteus
+    dependency_links.append('https://trydevpi.tryton.org/')
+
 setup(name=name,
     version=version,
     description='Tryton module to add analytic accounting on invoice',
@@ -63,7 +69,7 @@ setup(name=name,
         ],
     package_data={
         'trytond.modules.analytic_invoice': (info.get('xml', [])
-            + ['tryton.cfg', 'view/*.xml', 'locale/*.po']),
+            + ['tryton.cfg', 'view/*.xml', 'locale/*.po', 'tests/*.rst']),
         },
     classifiers=[
         'Development Status :: 5 - Production/Stable',
@@ -84,11 +90,14 @@ setup(name=name,
         'Natural Language :: Spanish',
         'Operating System :: OS Independent',
         'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: Implementation :: CPython',
+        'Programming Language :: Python :: Implementation :: PyPy',
         'Topic :: Office/Business',
         'Topic :: Office/Business :: Financial :: Accounting',
         ],
     license='GPL-3',
     install_requires=requires,
+    dependency_links=dependency_links,
     zip_safe=False,
     entry_points="""
     [trytond.modules]
@@ -96,4 +105,5 @@ setup(name=name,
     """,
     test_suite='tests',
     test_loader='trytond.test_loader:Loader',
+    tests_require=tests_require,
     )
diff --git a/tests/__init__.py b/tests/__init__.py
index 52b39ea..c7ab712 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,5 +1,5 @@
-#This file is part of Tryton.  The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# 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 .test_analytic_invoice import suite
 
diff --git a/tests/scenario_analytic_invoice.rst b/tests/scenario_analytic_invoice.rst
new file mode 100644
index 0000000..d1c33fd
--- /dev/null
+++ b/tests/scenario_analytic_invoice.rst
@@ -0,0 +1,166 @@
+=========================
+Analytic Invoice Scenario
+=========================
+
+Imports::
+    >>> import datetime
+    >>> from dateutil.relativedelta import relativedelta
+    >>> from decimal import Decimal
+    >>> from operator import attrgetter
+    >>> from proteus import config, Model, Wizard
+    >>> from trytond.modules.company.tests.tools import create_company, \
+    ...     get_company
+    >>> from trytond.modules.account.tests.tools import create_fiscalyear, \
+    ...     create_chart, get_accounts
+    >>> from.trytond.modules.account_invoice.tests.tools import \
+    ...     set_fiscalyear_invoice_sequences, create_payment_term
+    >>> today = datetime.date.today()
+
+Create database::
+
+    >>> config = config.set_trytond()
+    >>> config.pool.test = True
+
+Install account_invoice::
+
+    >>> Module = Model.get('ir.module.module')
+    >>> analytic_invoice_module, = Module.find(
+    ...     [('name', '=', 'analytic_invoice')])
+    >>> analytic_invoice_module.click('install')
+    >>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
+
+Create company::
+
+    >>> _ = create_company()
+    >>> company = get_company()
+
+Create fiscal year::
+
+    >>> fiscalyear = set_fiscalyear_invoice_sequences(
+    ...     create_fiscalyear(company))
+    >>> fiscalyear.click('create_period')
+
+Create chart of accounts::
+
+    >>> _ = create_chart(company)
+    >>> accounts = get_accounts(company)
+    >>> revenue = accounts['revenue']
+    >>> expense = accounts['expense']
+
+Create analytic accounts::
+
+    >>> AnalyticAccount = Model.get('analytic_account.account')
+    >>> root = AnalyticAccount(type='root', name='Root')
+    >>> root.save()
+    >>> analytic_account = AnalyticAccount(root=root, parent=root,
+    ...     name='Analytic')
+    >>> analytic_account.save()
+    >>> mandatory_root = AnalyticAccount(type='root', name='Root',
+    ...     mandatory=True)
+    >>> mandatory_root.save()
+    >>> mandatory_analytic_account = AnalyticAccount(root=mandatory_root,
+    ...     parent=mandatory_root, name='Mandatory Analytic')
+    >>> mandatory_analytic_account.save()
+
+Create party::
+
+    >>> Party = Model.get('party.party')
+    >>> party = Party(name='Party')
+    >>> party.save()
+
+Create product::
+
+    >>> ProductUom = Model.get('product.uom')
+    >>> unit, = ProductUom.find([('name', '=', 'Unit')])
+    >>> ProductTemplate = Model.get('product.template')
+    >>> Product = Model.get('product.product')
+    >>> product = Product()
+    >>> template = ProductTemplate()
+    >>> template.name = 'product'
+    >>> template.default_uom = unit
+    >>> template.type = 'service'
+    >>> template.list_price = Decimal('40')
+    >>> template.cost_price = Decimal('25')
+    >>> template.account_expense = expense
+    >>> template.account_revenue = revenue
+    >>> template.save()
+    >>> product.template = template
+    >>> product.save()
+
+Create payment term::
+
+    >>> payment_term = create_payment_term()
+    >>> payment_term.save()
+
+Create invoice with analytic accounts::
+
+    >>> Invoice = Model.get('account.invoice')
+    >>> invoice = Invoice()
+    >>> invoice.party = party
+    >>> invoice.payment_term = payment_term
+    >>> line = invoice.lines.new()
+    >>> entry, mandatory_entry = line.analytic_accounts
+    >>> entry.root == root
+    True
+    >>> bool(entry.required)
+    False
+    >>> entry.account = analytic_account
+    >>> mandatory_entry.root == mandatory_root
+    True
+    >>> bool(mandatory_entry.required)
+    True
+    >>> mandatory_entry.account = mandatory_analytic_account
+    >>> line.product = product
+    >>> line.quantity = 5
+    >>> invoice.click('post')
+    >>> invoice.state
+    u'posted'
+    >>> analytic_account.reload()
+    >>> analytic_account.credit
+    Decimal('200.00')
+    >>> analytic_account.debit
+    Decimal('0.00')
+    >>> mandatory_analytic_account.reload()
+    >>> mandatory_analytic_account.credit
+    Decimal('200.00')
+    >>> mandatory_analytic_account.debit
+    Decimal('0.00')
+
+
+Create invoice with an empty analytic account::
+
+    >>> invoice = Invoice()
+    >>> invoice.party = party
+    >>> invoice.payment_term = payment_term
+    >>> line = invoice.lines.new()
+    >>> entry, mandatory_entry = line.analytic_accounts
+    >>> mandatory_entry.account = mandatory_analytic_account
+    >>> line.product = product
+    >>> line.quantity = 1
+    >>> invoice.click('post')
+    >>> invoice.state
+    u'posted'
+    >>> analytic_account.reload()
+    >>> analytic_account.credit
+    Decimal('200.00')
+    >>> analytic_account.debit
+    Decimal('0.00')
+    >>> mandatory_analytic_account.reload()
+    >>> mandatory_analytic_account.credit
+    Decimal('240.00')
+    >>> mandatory_analytic_account.debit
+    Decimal('0.00')
+
+Credit invoice with refund::
+
+    >>> credit = Wizard('account.invoice.credit', [invoice])
+    >>> credit.form.with_refund = True
+    >>> credit.execute('credit')
+    >>> invoice.reload()
+    >>> invoice.state
+    u'paid'
+    >>> mandatory_analytic_account.reload()
+    >>> mandatory_analytic_account.credit
+    Decimal('240.00')
+    >>> mandatory_analytic_account.debit
+    Decimal('40.00')
diff --git a/tests/test_analytic_invoice.py b/tests/test_analytic_invoice.py
index 08b998d..74b5c94 100644
--- a/tests/test_analytic_invoice.py
+++ b/tests/test_analytic_invoice.py
@@ -1,27 +1,22 @@
-#This file is part of Tryton.  The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton.  The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
 import unittest
+import doctest
 import trytond.tests.test_tryton
-from trytond.tests.test_tryton import test_view, test_depends
+from trytond.tests.test_tryton import ModuleTestCase
+from trytond.tests.test_tryton import doctest_setup, doctest_teardown
 
 
-class AnalyticInvoiceTestCase(unittest.TestCase):
+class AnalyticInvoiceTestCase(ModuleTestCase):
     'Test AnalyticInvoice module'
-
-    def setUp(self):
-        trytond.tests.test_tryton.install_module('analytic_invoice')
-
-    def test0005views(self):
-        'Test views'
-        test_view('analytic_invoice')
-
-    def test0006depends(self):
-        'Test depends'
-        test_depends()
+    module = 'analytic_invoice'
 
 
 def suite():
     suite = trytond.tests.test_tryton.suite()
     suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
         AnalyticInvoiceTestCase))
+    suite.addTests(doctest.DocFileSuite('scenario_analytic_invoice.rst',
+            setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8',
+            optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
     return suite
diff --git a/tryton.cfg b/tryton.cfg
index d49ff4d..cd3fbb5 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
 [tryton]
-version=3.4.1
+version=3.6.0
 depends:
     account_invoice
     analytic_account
diff --git a/trytond_analytic_invoice.egg-info/PKG-INFO b/trytond_analytic_invoice.egg-info/PKG-INFO
index bbda857..591f046 100644
--- a/trytond_analytic_invoice.egg-info/PKG-INFO
+++ b/trytond_analytic_invoice.egg-info/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: trytond-analytic-invoice
-Version: 3.4.1
+Version: 3.6.0
 Summary: Tryton module to add analytic accounting on invoice
 Home-page: http://www.tryton.org/
 Author: Tryton
 Author-email: issue_tracker at tryton.org
 License: GPL-3
-Download-URL: http://downloads.tryton.org/3.4/
+Download-URL: http://downloads.tryton.org/3.6/
 Description: trytond_analytic_invoice
         ========================
         
@@ -63,5 +63,7 @@ Classifier: Natural Language :: Slovenian
 Classifier: Natural Language :: Spanish
 Classifier: Operating System :: OS Independent
 Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
 Classifier: Topic :: Office/Business
 Classifier: Topic :: Office/Business :: Financial :: Accounting
diff --git a/trytond_analytic_invoice.egg-info/SOURCES.txt b/trytond_analytic_invoice.egg-info/SOURCES.txt
index 68d3ca8..7ebd6ed 100644
--- a/trytond_analytic_invoice.egg-info/SOURCES.txt
+++ b/trytond_analytic_invoice.egg-info/SOURCES.txt
@@ -24,6 +24,7 @@ tryton.cfg
 ./locale/ru_RU.po
 ./locale/sl_SI.po
 ./tests/__init__.py
+./tests/scenario_analytic_invoice.rst
 ./tests/test_analytic_invoice.py
 ./view/invoice_line_form.xml
 locale/bg_BG.po
diff --git a/trytond_analytic_invoice.egg-info/requires.txt b/trytond_analytic_invoice.egg-info/requires.txt
index b5971d1..c1d538f 100644
--- a/trytond_analytic_invoice.egg-info/requires.txt
+++ b/trytond_analytic_invoice.egg-info/requires.txt
@@ -1,3 +1,3 @@
-trytond_account_invoice >= 3.4, < 3.5
-trytond_analytic_account >= 3.4, < 3.5
-trytond >= 3.4, < 3.5
\ No newline at end of file
+trytond_account_invoice >= 3.6, < 3.7
+trytond_analytic_account >= 3.6, < 3.7
+trytond >= 3.6, < 3.7
\ No newline at end of file
diff --git a/view/invoice_line_form.xml b/view/invoice_line_form.xml
index b0fa414..affdb3c 100644
--- a/view/invoice_line_form.xml
+++ b/view/invoice_line_form.xml
@@ -2,11 +2,7 @@
 <!-- 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/notebook/page/field[@name='taxes']"
-        position="before">
-        <group col="4" colspan="4" name="analytic_accounts">
-            <field name="analytic_accounts"/>
-        </group>
+    <xpath expr="/form/notebook/page/field[@name='taxes']" position="before">
+        <field name="analytic_accounts" colspan="4"/>
     </xpath>
 </data>
-- 
tryton-modules-analytic-invoice



More information about the tryton-debian-vcs mailing list