diff --git a/.drone.yml b/.drone.yml index 9d7c769d8c..c4fd423e94 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,9 +1,9 @@ -image: python2.7 +image: python:all env: - POSTGRESQL_URI=postgresql://postgres@127.0.0.1:5432/ - MYSQL_URI=mysql://root@127.0.0.1:3306/ script: - pip install tox - - tox -e "py27-{sqlite,postgresql}" + - tox -e "{py27,py33,py34,py35}-{sqlite,postgresql}" --skip-missing-interpreters services: - postgres diff --git a/CHANGELOG b/CHANGELOG index b25366964e..f085a6733f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add Python3 support * Change payment term percentage into ratio Version 3.8.0 - 2015-11-02 diff --git a/account.py b/account.py index 954fe53deb..995e03c9d6 100644 --- a/account.py +++ b/account.py @@ -10,7 +10,6 @@ from trytond.transaction import Transaction __all__ = ['Configuration', 'ConfigurationTaxRounding', 'FiscalYear', 'Period', 'Move', 'Reconciliation'] -__metaclass__ = PoolMeta tax_roundings = [ ('document', 'Per Document'), @@ -19,6 +18,7 @@ tax_roundings = [ class Configuration: + __metaclass__ = PoolMeta __name__ = 'account.configuration' tax_rounding = fields.Function(fields.Selection(tax_roundings, 'Tax Rounding'), 'on_change_with_tax_rounding') @@ -68,6 +68,7 @@ class ConfigurationTaxRounding(ModelSQL, ModelView, MatchMixin): class FiscalYear: + __metaclass__ = PoolMeta __name__ = 'account.fiscalyear' out_invoice_sequence = fields.Many2One('ir.sequence.strict', 'Customer Invoice Sequence', required=True, @@ -182,6 +183,7 @@ class FiscalYear: class Period: + __metaclass__ = PoolMeta __name__ = 'account.period' out_invoice_sequence = fields.Many2One('ir.sequence.strict', 'Customer Invoice Sequence', @@ -303,6 +305,7 @@ class Period: class Move: + __metaclass__ = PoolMeta __name__ = 'account.move' @classmethod @@ -311,6 +314,7 @@ class Move: class Reconciliation: + __metaclass__ = PoolMeta __name__ = 'account.move.reconciliation' @classmethod diff --git a/invoice.odt b/invoice.odt index 308bf8853c..f24dce3c02 100644 Binary files a/invoice.odt and b/invoice.odt differ diff --git a/party.py b/party.py index 769f51406a..c9dba11a9b 100644 --- a/party.py +++ b/party.py @@ -4,10 +4,10 @@ from trytond.model import ModelView, ModelSQL, fields from trytond.pool import Pool, PoolMeta __all__ = ['Address', 'Party'] -__metaclass__ = PoolMeta class Address: + __metaclass__ = PoolMeta __name__ = 'party.address' invoice = fields.Boolean('Invoice') diff --git a/setup.py b/setup.py index 9b445f97d2..6d122b830b 100644 --- a/setup.py +++ b/setup.py @@ -5,11 +5,17 @@ from setuptools import setup import re import os -import ConfigParser +import io +try: + from configparser import ConfigParser +except ImportError: + from ConfigParser import ConfigParser def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() + return io.open( + os.path.join(os.path.dirname(__file__), fname), + 'r', encoding='utf-8').read() def get_require_version(name): @@ -21,7 +27,7 @@ def get_require_version(name): major_version, minor_version + 1) return require -config = ConfigParser.ConfigParser() +config = ConfigParser() config.readfp(open('tryton.cfg')) info = dict(config.items('tryton')) for key in ('depends', 'extras_depend', 'xml'): @@ -95,6 +101,9 @@ setup(name=name, 'Natural Language :: Spanish', 'Operating System :: OS Independent', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Office/Business', @@ -111,4 +120,10 @@ setup(name=name, test_suite='tests', test_loader='trytond.test_loader:Loader', tests_require=tests_require, + use_2to3=True, + convert_2to3_doctests=[ + 'tests/scenario_invoice.rst', + 'tests/scenario_invoice_alternate_currency.rst', + 'tests/scenario_invoice_supplier.rst', + ], ) diff --git a/tests/scenario_invoice.rst b/tests/scenario_invoice.rst index 0f905192e3..5aef8c90a9 100644 --- a/tests/scenario_invoice.rst +++ b/tests/scenario_invoice.rst @@ -12,7 +12,7 @@ Imports:: ... get_company >>> from trytond.modules.account.tests.tools import create_fiscalyear, \ ... create_chart, get_accounts, create_tax, set_tax_code - >>> from.trytond.modules.account_invoice.tests.tools import \ + >>> from trytond.modules.account_invoice.tests.tools import \ ... set_fiscalyear_invoice_sequences >>> today = datetime.date.today() diff --git a/tests/scenario_invoice_alternate_currency.rst b/tests/scenario_invoice_alternate_currency.rst index 62fc0ce819..b0b7e6c4bf 100644 --- a/tests/scenario_invoice_alternate_currency.rst +++ b/tests/scenario_invoice_alternate_currency.rst @@ -14,7 +14,7 @@ Imports:: ... get_company >>> from trytond.modules.account.tests.tools import create_fiscalyear, \ ... create_chart, get_accounts, create_tax, set_tax_code - >>> from.trytond.modules.account_invoice.tests.tools import \ + >>> from trytond.modules.account_invoice.tests.tools import \ ... set_fiscalyear_invoice_sequences >>> today = datetime.date.today() diff --git a/tests/scenario_invoice_supplier.rst b/tests/scenario_invoice_supplier.rst index cb1e565215..0c53eae0df 100644 --- a/tests/scenario_invoice_supplier.rst +++ b/tests/scenario_invoice_supplier.rst @@ -12,7 +12,7 @@ Imports:: ... get_company >>> from trytond.modules.account.tests.tools import create_fiscalyear, \ ... create_chart, get_accounts, create_tax, set_tax_code - >>> from.trytond.modules.account_invoice.tests.tools import \ + >>> from trytond.modules.account_invoice.tests.tools import \ ... set_fiscalyear_invoice_sequences >>> today = datetime.date.today() diff --git a/tests/test_account_invoice.py b/tests/test_account_invoice.py index 9cc8661804..e478039eed 100644 --- a/tests/test_account_invoice.py +++ b/tests/test_account_invoice.py @@ -7,6 +7,7 @@ from decimal import Decimal import trytond.tests.test_tryton from trytond.tests.test_tryton import ModuleTestCase, with_transaction from trytond.tests.test_tryton import doctest_setup, doctest_teardown +from trytond.tests.test_tryton import doctest_checker from trytond.pool import Pool from trytond.modules.currency.tests import create_currency @@ -87,9 +88,9 @@ class AccountInvoiceTestCase(ModuleTestCase): date=datetime.date(2011, 10, 1)) self.assertEqual(terms, [ (datetime.date(2011, 10, 31), Decimal('396.84')), - (datetime.date(2011, 11, 01), Decimal('396.84')), - (datetime.date(2011, 12, 01), Decimal('396.84')), - (datetime.date(2012, 01, 14), Decimal('396.83')), + (datetime.date(2011, 11, 1), Decimal('396.84')), + (datetime.date(2011, 12, 1), Decimal('396.84')), + (datetime.date(2012, 1, 14), Decimal('396.83')), ]) @@ -99,12 +100,15 @@ def suite(): AccountInvoiceTestCase)) suite.addTests(doctest.DocFileSuite('scenario_invoice.rst', setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8', + checker=doctest_checker, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) suite.addTests(doctest.DocFileSuite('scenario_invoice_supplier.rst', setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8', + checker=doctest_checker, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) suite.addTests(doctest.DocFileSuite( 'scenario_invoice_alternate_currency.rst', setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8', + checker=doctest_checker, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) return suite diff --git a/tox.ini b/tox.ini index e9d2876444..e2a064851d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,10 @@ [tox] -envlist = py27-{sqlite,postgresql,mysql},pypy-{sqlite,postgresql} +envlist = {py27,py33,py34,py35}-{sqlite,postgresql,mysql},pypy-{sqlite,postgresql} [testenv] commands = {envpython} setup.py test deps = - py27-postgresql: psycopg2 >= 2.0 + {py27,py33,py34,py35}-postgresql: psycopg2 >= 2.0 pypy-postgresql: psycopg2cffi >= 2.5 mysql: MySQL-python setenv =