diff --git a/.drone.yml b/.drone.yml index e0bc2f7026..5da6083eb7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -25,12 +25,6 @@ services: matrix: include: - - IMAGE: python:2.7 - TOXENV: py27 - DATABASE: sqlite - - IMAGE: python:2.7 - TOXENV: py27 - DATABASE: postgresql - IMAGE: python:3.4 TOXENV: py34 DATABASE: sqlite diff --git a/CHANGELOG b/CHANGELOG index 05afdeb9ad..8b0971b829 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Remove support for Python 2.7 + Version 4.8.0 - 2018-04-23 * Bug fixes (see mercurial logs for details) @@ -5,4 +7,4 @@ Version 4.6.0 - 2017-10-30 * Bug fixes (see mercurial logs for details) Version 4.4.0 - 2017-05-01 -* Initial release \ No newline at end of file +* Initial release diff --git a/INSTALL b/INSTALL index 845b593580..f381606fbd 100644 --- a/INSTALL +++ b/INSTALL @@ -4,7 +4,7 @@ Installing trytond_sale_advance_payment Prerequisites ------------- - * Python 2.7 or later (http://www.python.org/) + * Python 3.4 or later (http://www.python.org/) * simpleeval (https://github.com/danthedeckie/simpleeval) * trytond (http://www.tryton.org/) * trytond_sale (http://www.tryton.org/) diff --git a/account.py b/account.py index a558227190..346ef9f0de 100644 --- a/account.py +++ b/account.py @@ -6,9 +6,8 @@ from trytond.pool import Pool, PoolMeta __all__ = ['Invoice', 'InvoiceLine'] -class Invoice: +class Invoice(metaclass=PoolMeta): __name__ = 'account.invoice' - __metaclass__ = PoolMeta def get_sales(self, name): pool = Pool() @@ -21,9 +20,8 @@ class Invoice: return list(sales) -class InvoiceLine: +class InvoiceLine(metaclass=PoolMeta): __name__ = 'account.invoice.line' - __metaclass__ = PoolMeta @classmethod def _get_origin(cls): diff --git a/sale.py b/sale.py index 7eba36c0a2..8b2b5a65ac 100644 --- a/sale.py +++ b/sale.py @@ -95,7 +95,7 @@ class AdvancePaymentTermLine(ModelView, ModelSQL, CompanyMultiValueMixin): try: if not isinstance(self.compute_amount(**names), Decimal): raise Exception('The formula does not return a Decimal') - except Exception, exception: + except Exception as exception: self.raise_user_error('invalid_formula', { 'formula': self.formula, 'exception': exception, @@ -280,9 +280,8 @@ class AdvancePaymentCondition(ModelSQL, ModelView): return advance_amount >= self.amount -class Sale: +class Sale(metaclass=PoolMeta): __name__ = 'sale.sale' - __metaclass__ = PoolMeta advance_payment_term = fields.Many2One('sale.advance_payment_term', 'Advance Payment Term', @@ -451,9 +450,8 @@ class Sale: return False -class SaleLine: +class SaleLine(metaclass=PoolMeta): __name__ = 'sale.line' - __metaclass__ = PoolMeta def get_move(self, shipment_type): move = super(SaleLine, self).get_move(shipment_type) @@ -477,8 +475,7 @@ class SaleLine: return lines -class HandleInvoiceException: - __metaclass__ = PoolMeta +class HandleInvoiceException(metaclass=PoolMeta): __name__ = 'sale.handle.invoice.exception' def default_ask(self, fields): diff --git a/setup.py b/setup.py index 401fb282ae..1735b33188 100644 --- a/setup.py +++ b/setup.py @@ -1,15 +1,12 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # 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 -import os import io -try: - from configparser import ConfigParser -except ImportError: - from ConfigParser import ConfigParser +import os +import re +from configparser import ConfigParser +from setuptools import setup def read(fname): @@ -27,6 +24,7 @@ def get_require_version(name): major_version, minor_version + 1) return require + config = ConfigParser() config.readfp(open('tryton.cfg')) info = dict(config.items('tryton')) @@ -104,7 +102,6 @@ setup(name=name, 'Natural Language :: Slovenian', 'Natural Language :: Spanish', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', @@ -114,6 +111,7 @@ setup(name=name, 'Topic :: Office/Business :: Financial :: Accounting', ], license='GPL-3', + python_requires='>=3.4', install_requires=requires, dependency_links=dependency_links, zip_safe=False, @@ -124,6 +122,4 @@ setup(name=name, test_suite='tests', test_loader='trytond.test_loader:Loader', tests_require=tests_require, - use_2to3=True, - convert_2to3_doctests=['tests/scenario_advance_payment.rst'], ) diff --git a/stock.py b/stock.py index 6ba9bb8736..aff4eb79cd 100644 --- a/stock.py +++ b/stock.py @@ -7,9 +7,8 @@ from trytond.pool import Pool, PoolMeta __all__ = ['ShipmentOut'] -class ShipmentOut: +class ShipmentOut(metaclass=PoolMeta): __name__ = 'stock.shipment.out' - __metaclass__ = PoolMeta @classmethod def __setup__(cls): diff --git a/tests/scenario_advance_payment.rst b/tests/scenario_advance_payment.rst index 598f8fd7e6..3dd7bcb198 100644 --- a/tests/scenario_advance_payment.rst +++ b/tests/scenario_advance_payment.rst @@ -108,7 +108,7 @@ Create an inventory:: >>> inventory_line.expected_quantity = 0.0 >>> inventory.click('confirm') >>> inventory.state - u'done' + 'done' Create advance payment term preventing the creation of shipment:: @@ -131,7 +131,7 @@ Create a normal sale:: >>> sale.click('confirm') >>> sale.click('process') >>> sale.state - u'processing' + 'processing' As usual an invoice and a shipment has been created:: @@ -160,7 +160,7 @@ Create a sale with advance payment:: >>> sale.click('confirm') >>> sale.click('process') >>> sale.state - u'processing' + 'processing' The advance payment invoice has been created:: @@ -186,7 +186,7 @@ Let's pay the advance payment invoice:: >>> sale.reload() >>> sale.state - u'processing' + 'processing' >>> len(sale.invoices) 1 >>> len(sale.shipments) @@ -233,7 +233,7 @@ Create a sale with advance payment:: >>> sale.click('confirm') >>> sale.click('process') >>> sale.state - u'processing' + 'processing' The shipment has been created:: @@ -258,14 +258,14 @@ Let's pay the advance payment invoice:: >>> pay.execute('choice') >>> sale.reload() >>> sale.state - u'processing' + 'processing' Packing the shipment is now allowed:: >>> shipment.click('pack') >>> shipment.reload() >>> shipment.state - u'packed' + 'packed' In case the product is to be supplied on sale --------------------------------------------- @@ -298,7 +298,7 @@ Sell 10 of those products:: >>> sale.click('confirm') >>> sale.click('process') >>> sale.state - u'processing' + 'processing' There is no purchase request created yet:: @@ -315,7 +315,7 @@ The advance payment invoice has been created, now pay it:: >>> pay.execute('choice') >>> sale.reload() >>> sale.state - u'processing' + 'processing' There is now a purchase request of the desired quantity:: @@ -342,7 +342,7 @@ Create a sale with this term:: >>> sale.click('confirm') >>> sale.click('process') >>> sale.state - u'processing' + 'processing' Let's cancel the advance invoice:: @@ -350,7 +350,7 @@ Let's cancel the advance invoice:: >>> inv.click('cancel') >>> sale.reload() >>> sale.invoice_state - u'exception' + 'exception' Handle the exception on the sale level, not recreating the invoice will create the final invoice with the remaining total:: @@ -381,12 +381,12 @@ it:: >>> sale.click('confirm') >>> sale.click('process') >>> sale.state - u'processing' + 'processing' >>> inv, = sale.advance_payment_invoices >>> inv.click('cancel') >>> sale.reload() >>> sale.invoice_state - u'exception' + 'exception' >>> handle_exception = Wizard('sale.handle.invoice.exception', [sale]) >>> handle_exception.execute('handle') diff --git a/tox.ini b/tox.ini index 2082ab4f4d..adbcbf8431 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,11 @@ [tox] -envlist = {py27,py34,py35,py36}-{sqlite,postgresql},pypy-{sqlite,postgresql} +envlist = {py34,py35,py36}-{sqlite,postgresql},pypy3-{sqlite,postgresql} [testenv] commands = {envpython} setup.py test deps = - {py27,py34,py35,py36}-postgresql: psycopg2 >= 2.5 - pypy-postgresql: psycopg2cffi >= 2.5 + {py34,py35,py36}-postgresql: psycopg2 >= 2.5 + pypy3-postgresql: psycopg2cffi >= 2.5 sqlite: sqlitebck setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://}