diff --git a/.drone.yml b/.drone.yml index 67aa49b..82ae06b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -32,15 +32,15 @@ services: matrix: include: - - IMAGE: python:2.7 - TOXENV: py27 - DATABASE: sqlite - - IMAGE: python:2.7 - TOXENV: py27 - DATABASE: postgresql - IMAGE: python:3.6 TOXENV: py36 DATABASE: sqlite - IMAGE: python:3.6 TOXENV: py36 DATABASE: postgresql + - IMAGE: python:3.7 + TOXENV: py37 + DATABASE: sqlite + - IMAGE: python:3.7 + TOXENV: py37 + DATABASE: postgresql \ No newline at end of file diff --git a/INSTALL b/INSTALL index b01e1e4..91d1620 100644 --- a/INSTALL +++ b/INSTALL @@ -4,7 +4,6 @@ Installing datalife_stock_lot_cost_price Prerequisites ------------- - * Python 2.7 or later (http://www.python.org/) * trytond (http://www.tryton.org/) Installation diff --git a/setup.py b/setup.py index 232f8d1..a033a68 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # The COPYRIGHT file at the top level of this repository contains # the full copyright notices and license terms. @@ -6,10 +6,7 @@ from setuptools import setup, find_packages import re import os import io -try: - from configparser import ConfigParser -except ImportError: - from ConfigParser import ConfigParser +from configparser import ConfigParser MODULE2PREFIX = {} @@ -19,6 +16,7 @@ def read(fname): os.path.join(os.path.dirname(__file__), fname), 'r', encoding='utf-8').read() + def get_require_version(name): if minor_version % 2: require = '%s >= %s.%s.dev0, < %s.%s' @@ -28,6 +26,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')) @@ -45,9 +44,12 @@ requires = [] for dep in info.get('depends', []): if not re.match(r'(ir|res)(\W|$)', dep): prefix = MODULE2PREFIX.get(dep, 'trytond') + requires.append(get_require_version('%s_%s' % (prefix, dep))) + requires.append(get_require_version('trytond')) + tests_require = [get_require_version('proteus')] series = '%s.%s' % (major_version, minor_version) if minor_version % 2: @@ -99,15 +101,16 @@ 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', + 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Office/Business', ], license='GPL-3', + python_requires='>=3.4', install_requires=requires, dependency_links=dependency_links, zip_safe=False, @@ -118,8 +121,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_stock_lot_cost_price.rst', - ], ) diff --git a/stock.py b/stock.py index ab88f64..dd97307 100644 --- a/stock.py +++ b/stock.py @@ -8,9 +8,8 @@ from trytond.transaction import Transaction __all__ = ['Lot'] -class Lot: +class Lot(metaclass=PoolMeta): __name__ = 'stock.lot' - __metaclass__ = PoolMeta cost_price = fields.Function(fields.Numeric( 'Cost Price', digits=price_digits), 'get_cost_price') diff --git a/tests/scenario_stock_lot_cost_price.rst b/tests/scenario_stock_lot_cost_price.rst index ba79b59..04ce2b6 100644 --- a/tests/scenario_stock_lot_cost_price.rst +++ b/tests/scenario_stock_lot_cost_price.rst @@ -54,6 +54,16 @@ Create parties:: >>> customer = Party(name='Customer') >>> customer.save() +Create account category:: + + >>> ProductCategory = Model.get('product.category') + >>> account_category = ProductCategory(name="Account Category") + >>> account_category.accounting = True + >>> account_category.account_expense = expense + >>> account_category.account_revenue = revenue + >>> account_category.supplier_taxes.append(tax) + >>> account_category.save() + Create product:: >>> ProductUom = Model.get('product.uom') @@ -68,9 +78,7 @@ Create product:: >>> template.salable = True >>> template.list_price = Decimal('10') >>> template.cost_price_method = 'fixed' - >>> template.account_expense = expense - >>> template.account_revenue = revenue - >>> template.supplier_taxes.append(tax) + >>> template.account_category = account_category >>> product, = template.products >>> product.cost_price = Decimal('5') >>> template.save() diff --git a/tox.ini b/tox.ini index f8a2206..718b574 100644 --- a/tox.ini +++ b/tox.ini @@ -1,18 +1,15 @@ [tox] -envlist = {py27,py36}-{sqlite,postgresql,mysql},pypy-{sqlite,postgresql} +envlist = {py36,py37}-{sqlite,postgresql},pypy3-{sqlite,postgresql} [testenv] commands = {envpython} setup.py test deps = - {py27,py36}-postgresql: psycopg2 >= 2.5 - pypy-postgresql: psycopg2cffi >= 2.5 - mysql: MySQL-python - sqlite: sqlitebck + {py36,py37}-postgresql: psycopg2 >= 2.5 + pypy3-postgresql: psycopg2cffi >= 2.5 + {py36}-sqlite: sqlitebck setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} postgresql: TRYTOND_DATABASE_URI={env:POSTGRESQL_URI:postgresql://} - mysql: TRYTOND_DATABASE_URI={env:MYSQL_URI:mysql://} sqlite: DB_NAME={env:SQLITE_NAME::memory:} postgresql: DB_NAME={env:POSTGRESQL_NAME:test} - mysql: DB_NAME={env:MYSQL_NAME:test} -install_command = pip install --pre {opts} {packages} +install_command = pip install --pre --find-links https://trydevpi.tryton.org/ {opts} {packages} \ No newline at end of file diff --git a/tryton.cfg b/tryton.cfg index b253eb7..7f9cf0e 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=4.8.0 +version=5.0.0 depends: ir res