[tryton-debian-vcs] tryton-modules-analytic-sale branch debian updated. debian/3.4.1-1-2-g158207b

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


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

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

    Merging upstream version 3.6.0.

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 fc03a20..c6c64fd 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: trytond_analytic_sale
-Version: 3.4.1
+Version: 3.6.0
 Summary: Tryton module to add analytic accounting on sale
 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_sale
         =====================
         
@@ -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 d08bd56..4b65954 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 .sale import *
@@ -8,5 +8,5 @@ from .sale import *
 def register():
     Pool.register(
         SaleLine,
-        Account,
+        AnalyticAccountEntry,
         module='analytic_sale', type_='model')
diff --git a/locale/bg_BG.po b/locale/bg_BG.po
index 6bbeda9..debcf6b 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:sale.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr ""
+
 msgctxt "field:sale.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Аналитични сметки"
+
+msgctxt "field:sale.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr ""
diff --git a/locale/ca_ES.po b/locale/ca_ES.po
index bb25bd3..2b0c41c 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:sale.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Falten alguns comptes analítics obligatoris a \"%(name)s\"."
+
 msgctxt "field:sale.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Comptes analítics"
+
+msgctxt "field:sale.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 518fc49..5a5a737 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:sale.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr ""
+
 msgctxt "field:sale.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr ""
+
+msgctxt "field:sale.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr ""
diff --git a/locale/de_DE.po b/locale/de_DE.po
index 55113f7..01c4ccf 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:sale.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Erforderliches Wurzelkonto für \"%(name)s\" fehlt"
+
 msgctxt "field:sale.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Kostenstellen"
+
+msgctxt "field:sale.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr "Kostenstellengröße"
diff --git a/locale/es_AR.po b/locale/es_AR.po
index 6c5db27..d6b0419 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:sale.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Falta una cuenta root obligatoria en «%(name)s»"
+
 msgctxt "field:sale.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Cuentas analíticas"
+
+msgctxt "field:sale.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 81105f9..0411492 100644
--- a/locale/es_CO.po
+++ b/locale/es_CO.po
@@ -2,6 +2,15 @@
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
+#, fuzzy
+msgctxt "error:sale.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Alguna cuenta raíz obligatoria falta en \"%(name)s\""
+
 msgctxt "field:sale.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Cuentas Analíticas"
+
+msgctxt "field:sale.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 81105f9..0454ccf 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:sale.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Faltan algunas cuentas raíz obligatorias en \"%(name)s\""
+
 msgctxt "field:sale.line,analytic_accounts:"
 msgid "Analytic Accounts"
-msgstr "Cuentas Analíticas"
+msgstr "Cuentas analíticas"
+
+msgctxt "field:sale.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 6c5db27..da7512f 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:sale.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Faltan algunas cuentas analíticas obligatorias en \"%(name)s\"."
+
 msgctxt "field:sale.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Cuentas analíticas"
+
+msgctxt "field:sale.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 6ad96cc..1a4e175 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:sale.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Certains comptes racines obligatoires manquent sur « %(name)s »"
+
 msgctxt "field:sale.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Comptes analytiques"
+
+msgctxt "field:sale.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 518fc49..5a5a737 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:sale.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr ""
+
 msgctxt "field:sale.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr ""
+
+msgctxt "field:sale.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr ""
diff --git a/locale/ru_RU.po b/locale/ru_RU.po
index 78cb58b..89344cc 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:sale.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr ""
+
 msgctxt "field:sale.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Счета аналитики"
+
+msgctxt "field:sale.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr ""
diff --git a/locale/sl_SI.po b/locale/sl_SI.po
index 5d070a2..e538913 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:sale.line:"
+msgid "Some mandatory root account are missing on \"%(name)s\""
+msgstr "Pri \"%(name)s\" manjkajo nekateri korenski konti."
+
 msgctxt "field:sale.line,analytic_accounts:"
 msgid "Analytic Accounts"
 msgstr "Analitični konti"
+
+msgctxt "field:sale.line,analytic_accounts_size:"
+msgid "Analytic Accounts Size"
+msgstr "Število analitičnih kontov"
diff --git a/sale.py b/sale.py
index 8bde6c4..1b67f09 100644
--- a/sale.py
+++ b/sale.py
@@ -1,224 +1,34 @@
-#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 fields
-from trytond.pyson import Eval
-from trytond.transaction import Transaction
+# 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
 
-__all__ = ['SaleLine', 'Account']
+from trytond.modules.analytic_account import AnalyticMixin
+
+__all__ = ['SaleLine', 'AnalyticAccountEntry']
 __metaclass__ = PoolMeta
 
 
-class SaleLine:
+class SaleLine(AnalyticMixin):
     __name__ = 'sale.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)
-        arch, fields, = super(SaleLine, cls)._view_look_dom_arch(tree, type,
-            field_children=field_children)
-        return arch, fields
-
-    @classmethod
-    def fields_get(cls, fields_names=None):
-        AnalyticAccount = Pool().get('analytic_account.account')
-
-        res = super(SaleLine, cls).fields_get(fields_names)
-
-        analytic_accounts_field = super(SaleLine, cls).fields_get(
-                ['analytic_accounts'])['analytic_accounts']
-
-        res.update(AnalyticAccount.analytic_accounts_fields_get(
-                analytic_accounts_field, fields_names,
-                states=cls.analytic_accounts.states,
-                required_states=Eval('type') == 'line'))
-        return res
-
-    @classmethod
-    def default_get(cls, fields, with_rec_name=True):
-        fields = [x for x in fields if not x.startswith('analytic_account_')]
-        return super(SaleLine, 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(SaleLine, 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(SaleLine, 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))
-        return super(SaleLine, cls).write(*args)
-
-    @classmethod
-    def delete(cls, lines):
-        Selection = Pool().get('analytic_account.account.selection')
-
-        selections = []
-        for line in lines:
-            if line.analytic_accounts:
-                selections.append(line.analytic_accounts)
-
-        super(SaleLine, cls).delete(lines)
-        Selection.delete(selections)
-
-    @classmethod
-    def copy(cls, lines, default=None):
-        Selection = Pool().get('analytic_account.account.selection')
-
-        new_lines = super(SaleLine, 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 get_invoice_line(self, invoice_type):
-        AccountSelection = Pool().get('analytic_account.account.selection')
+        pool = Pool()
+        AnalyticAccountEntry = pool.get('analytic.account.entry')
 
         invoice_lines = super(SaleLine, self).get_invoice_line(invoice_type)
-        if not invoice_lines:
-            return invoice_lines
-
-        selection = None
-        if self.analytic_accounts:
-            selection, = AccountSelection.copy([self.analytic_accounts])
         for invoice_line in invoice_lines:
-            invoice_line.analytic_accounts = selection
+            new_entries = AnalyticAccountEntry.copy(self.analytic_accounts,
+                default={
+                    'origin': None,
+                    })
+            invoice_line.analytic_accounts = new_entries
         return invoice_lines
 
 
-class Account:
-    __name__ = 'analytic_account.account'
-
-    @classmethod
-    def delete(cls, accounts):
-        SaleLine = Pool().get('sale.line')
-        super(Account, cls).delete(accounts)
-        # Restart the cache on the fields_view_get method of sale.line
-        SaleLine._fields_view_get_cache.clear()
-
-    @classmethod
-    def create(cls, vlist):
-        SaleLine = Pool().get('sale.line')
-        accounts = super(Account, cls).create(vlist)
-        # Restart the cache on the fields_view_get method of sale.line
-        SaleLine._fields_view_get_cache.clear()
-        return accounts
+class AnalyticAccountEntry:
+    __name__ = 'analytic.account.entry'
 
     @classmethod
-    def write(cls, accounts, values, *args):
-        SaleLine = Pool().get('sale.line')
-        super(Account, cls).write(accounts, values, *args)
-        # Restart the cache on the fields_view_get method of sale.line
-        SaleLine._fields_view_get_cache.clear()
+    def _get_origin(cls):
+        origins = super(AnalyticAccountEntry, cls)._get_origin()
+        return origins + ['sale.line']
diff --git a/setup.py b/setup.py
index b45d82a..8f0e2a8 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 sale',
@@ -63,7 +69,7 @@ setup(name=name,
         ],
     package_data={
         'trytond.modules.analytic_sale': (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 ce62a2a..7e53c85 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_sale import suite
 
diff --git a/tests/scenario_analytic_sale.rst b/tests/scenario_analytic_sale.rst
new file mode 100644
index 0000000..0e904c6
--- /dev/null
+++ b/tests/scenario_analytic_sale.rst
@@ -0,0 +1,190 @@
+======================
+Analytic Sale Scenario
+======================
+
+Imports::
+
+    >>> import datetime
+    >>> from dateutil.relativedelta import relativedelta
+    >>> from decimal import Decimal
+    >>> from operator import attrgetter
+    >>> from proteus import config, Model, Wizard, Report
+    >>> 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 analytic sale::
+
+    >>> Module = Model.get('ir.module.module')
+    >>> analytic_sale_module, = Module.find([('name', '=', 'analytic_sale')])
+    >>> analytic_sale_module.click('install')
+    >>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
+
+Create company::
+
+    >>> _ = create_company()
+    >>> company = get_company()
+
+Reload the context::
+
+    >>> User = Model.get('res.user')
+    >>> Group = Model.get('res.group')
+    >>> config._context = User.get_preferences(True, config.context)
+
+Create sale user::
+
+    >>> sale_user = User()
+    >>> sale_user.name = 'Sale'
+    >>> sale_user.login = 'sale'
+    >>> sale_user.main_company = company
+    >>> sale_group, = Group.find([('name', '=', 'Sales')])
+    >>> sale_user.groups.append(sale_group)
+    >>> sale_user.save()
+
+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 parties::
+
+    >>> Party = Model.get('party.party')
+    >>> customer = Party(name='Customer')
+    >>> customer.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 = 'goods'
+    >>> template.salable = True
+    >>> template.list_price = Decimal('10')
+    >>> template.cost_price = Decimal('5')
+    >>> template.cost_price_method = 'fixed'
+    >>> 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()
+
+Sale with analytic accounts::
+
+    >>> config.user = sale_user.id
+    >>> Sale = Model.get('sale.sale')
+    >>> SaleLine = Model.get('sale.line')
+    >>> sale = Sale()
+    >>> sale.party = customer
+    >>> sale.payment_term = payment_term
+    >>> sale.invoice_method = 'order'
+    >>> sale_line = sale.lines.new()
+    >>> entry, mandatory_entry = sale_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
+    >>> sale_line.product = product
+    >>> sale_line.quantity = 5
+    >>> sale.click('quote')
+    >>> sale.click('confirm')
+    >>> sale.click('process')
+
+Check analytic accounts on invoice::
+
+    >>> Invoice = Model.get('account.invoice')
+    >>> invoice = Invoice(sale.invoices[0].id)
+    >>> invoice_line, = invoice.lines
+    >>> entry, mandatory_entry = invoice_line.analytic_accounts
+    >>> entry.account == analytic_account
+    True
+    >>> mandatory_entry.account == mandatory_analytic_account
+    True
+
+Sale with an empty analytic account::
+
+    >>> config.user = sale_user.id
+    >>> Sale = Model.get('sale.sale')
+    >>> SaleLine = Model.get('sale.line')
+    >>> sale = Sale()
+    >>> sale.party = customer
+    >>> sale.payment_term = payment_term
+    >>> sale.invoice_method = 'order'
+    >>> sale_line = sale.lines.new()
+    >>> entry, mandatory_entry = sale_line.analytic_accounts
+    >>> mandatory_entry.account = mandatory_analytic_account
+    >>> sale_line.product = product
+    >>> sale_line.quantity = 5
+    >>> sale.click('quote')
+    >>> sale.click('confirm')
+    >>> sale.click('process')
+    >>> invoice, = sale.invoices
+
+Check invoice analytic accounts::
+
+    >>> invoice_line, = invoice.lines
+    >>> entry, mandatory_entry = invoice_line.analytic_accounts
+    >>> entry.account
+    >>> mandatory_entry.account == mandatory_analytic_account
+    True
+
+Return sales using the wizard::
+
+    >>> config.user = sale_user.id
+    >>> return_sale = Wizard('sale.return_sale', [sale])
+    >>> return_sale.execute('return_')
+    >>> returned_sale, = Sale.find([
+    ...     ('state', '=', 'draft'),
+    ...     ])
+    >>> sale_line, = returned_sale.lines
+    >>> entry, mandatory_entry = sale_line.analytic_accounts
+    >>> entry.account
+    >>> mandatory_entry.account == mandatory_analytic_account
+    True
diff --git a/tests/test_analytic_sale.py b/tests/test_analytic_sale.py
index 252a906..b2f4be4 100644
--- a/tests/test_analytic_sale.py
+++ b/tests/test_analytic_sale.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 AnalyticSaleTestCase(unittest.TestCase):
+class AnalyticSaleTestCase(ModuleTestCase):
     'Test AnalyticSale module'
-
-    def setUp(self):
-        trytond.tests.test_tryton.install_module('analytic_sale')
-
-    def test0005views(self):
-        'Test views'
-        test_view('analytic_sale')
-
-    def test0006depends(self):
-        'Test depends'
-        test_depends()
+    module = 'analytic_sale'
 
 
 def suite():
     suite = trytond.tests.test_tryton.suite()
     suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
         AnalyticSaleTestCase))
+    suite.addTests(doctest.DocFileSuite('scenario_analytic_sale.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 ae4e2b0..f94059a 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
 [tryton]
-version=3.4.1
+version=3.6.0
 depends:
     analytic_account
     analytic_invoice
diff --git a/trytond_analytic_sale.egg-info/PKG-INFO b/trytond_analytic_sale.egg-info/PKG-INFO
index e368537..0656bb9 100644
--- a/trytond_analytic_sale.egg-info/PKG-INFO
+++ b/trytond_analytic_sale.egg-info/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: trytond-analytic-sale
-Version: 3.4.1
+Version: 3.6.0
 Summary: Tryton module to add analytic accounting on sale
 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_sale
         =====================
         
@@ -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_sale.egg-info/SOURCES.txt b/trytond_analytic_sale.egg-info/SOURCES.txt
index 9b53888..8b9be19 100644
--- a/trytond_analytic_sale.egg-info/SOURCES.txt
+++ b/trytond_analytic_sale.egg-info/SOURCES.txt
@@ -24,6 +24,7 @@ tryton.cfg
 ./locale/ru_RU.po
 ./locale/sl_SI.po
 ./tests/__init__.py
+./tests/scenario_analytic_sale.rst
 ./tests/test_analytic_sale.py
 ./view/sale_line_form.xml
 locale/bg_BG.po
diff --git a/trytond_analytic_sale.egg-info/requires.txt b/trytond_analytic_sale.egg-info/requires.txt
index 82b5119..2994643 100644
--- a/trytond_analytic_sale.egg-info/requires.txt
+++ b/trytond_analytic_sale.egg-info/requires.txt
@@ -1,4 +1,4 @@
-trytond_analytic_account >= 3.4, < 3.5
-trytond_analytic_invoice >= 3.4, < 3.5
-trytond_sale >= 3.4, < 3.5
-trytond >= 3.4, < 3.5
\ No newline at end of file
+trytond_analytic_account >= 3.6, < 3.7
+trytond_analytic_invoice >= 3.6, < 3.7
+trytond_sale >= 3.6, < 3.7
+trytond >= 3.6, < 3.7
\ No newline at end of file
diff --git a/view/sale_line_form.xml b/view/sale_line_form.xml
index 4b4ef47..fa828e5 100644
--- a/view/sale_line_form.xml
+++ b/view/sale_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='amount']"
-        position="after">
-        <group col="4" colspan="4" name="analytic_accounts">
-            <field name="analytic_accounts"/>
-        </group>
+    <xpath expr="/form/notebook/page/field[@name='amount']" position="after">
+        <field name="analytic_accounts" colspan="4"/>
     </xpath>
 </data>
-- 
tryton-modules-analytic-sale



More information about the tryton-debian-vcs mailing list