Migration to 5.0
This commit is contained in:
parent
3251bca2c5
commit
5be420f606
12
.drone.yml
12
.drone.yml
|
@ -32,15 +32,15 @@ services:
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- IMAGE: python:2.7
|
|
||||||
TOXENV: py27
|
|
||||||
DATABASE: sqlite
|
|
||||||
- IMAGE: python:2.7
|
|
||||||
TOXENV: py27
|
|
||||||
DATABASE: postgresql
|
|
||||||
- IMAGE: python:3.6
|
- IMAGE: python:3.6
|
||||||
TOXENV: py36
|
TOXENV: py36
|
||||||
DATABASE: sqlite
|
DATABASE: sqlite
|
||||||
- IMAGE: python:3.6
|
- IMAGE: python:3.6
|
||||||
TOXENV: py36
|
TOXENV: py36
|
||||||
DATABASE: postgresql
|
DATABASE: postgresql
|
||||||
|
- IMAGE: python:3.7
|
||||||
|
TOXENV: py37
|
||||||
|
DATABASE: sqlite
|
||||||
|
- IMAGE: python:3.7
|
||||||
|
TOXENV: py37
|
||||||
|
DATABASE: postgresql
|
1
INSTALL
1
INSTALL
|
@ -4,7 +4,6 @@ Installing datalife_ir_sequence_period
|
||||||
Prerequisites
|
Prerequisites
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
* Python 2.7 or later (http://www.python.org/)
|
|
||||||
* trytond (http://www.tryton.org/)
|
* trytond (http://www.tryton.org/)
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
|
|
12
ir.py
12
ir.py
|
@ -1,6 +1,6 @@
|
||||||
# The COPYRIGHT file at the top level of this repository contains the full
|
# The COPYRIGHT file at the top level of this repository contains the full
|
||||||
# copyright notices and license terms.
|
# copyright notices and license terms.
|
||||||
from itertools import izip
|
|
||||||
from trytond.model import ModelSQL, ModelView, MatchMixin, fields
|
from trytond.model import ModelSQL, ModelView, MatchMixin, fields
|
||||||
from trytond.pool import PoolMeta, Pool
|
from trytond.pool import PoolMeta, Pool
|
||||||
from trytond.pyson import Eval, And, Bool
|
from trytond.pyson import Eval, And, Bool
|
||||||
|
@ -13,9 +13,8 @@ __all__ = ['Sequence', 'SequencePeriod', 'SequenceStrict']
|
||||||
sql_sequence = backend.get('Database').has_sequence()
|
sql_sequence = backend.get('Database').has_sequence()
|
||||||
|
|
||||||
|
|
||||||
class Sequence:
|
class Sequence(metaclass=PoolMeta):
|
||||||
__name__ = 'ir.sequence'
|
__name__ = 'ir.sequence'
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
|
|
||||||
periods = fields.One2Many('ir.sequence.period', 'sequence', 'Periods',
|
periods = fields.One2Many('ir.sequence.period', 'sequence', 'Periods',
|
||||||
states={'invisible': Eval('type') != 'incremental'},
|
states={'invisible': Eval('type') != 'incremental'},
|
||||||
|
@ -44,7 +43,7 @@ class Sequence:
|
||||||
def get_id(cls, domain, _lock=False):
|
def get_id(cls, domain, _lock=False):
|
||||||
if isinstance(domain, cls):
|
if isinstance(domain, cls):
|
||||||
domain = domain.id
|
domain = domain.id
|
||||||
if isinstance(domain, (int, long)):
|
if isinstance(domain, int):
|
||||||
domain = [('id', '=', domain)]
|
domain = [('id', '=', domain)]
|
||||||
|
|
||||||
with Transaction().set_context(user=False, _check_access=False):
|
with Transaction().set_context(user=False, _check_access=False):
|
||||||
|
@ -115,7 +114,7 @@ class SequencePeriod(ModelSQL, ModelView, MatchMixin):
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, vlist):
|
def create(cls, vlist):
|
||||||
periods = super(SequencePeriod, cls).create(vlist)
|
periods = super(SequencePeriod, cls).create(vlist)
|
||||||
for period, values in izip(periods, vlist):
|
for period, values in zip(periods, vlist):
|
||||||
if sql_sequence and not cls._strict:
|
if sql_sequence and not cls._strict:
|
||||||
period.update_sql_sequence(values.get('number_next',
|
period.update_sql_sequence(values.get('number_next',
|
||||||
cls.default_number_next()))
|
cls.default_number_next()))
|
||||||
|
@ -226,9 +225,8 @@ class SequencePeriod(ModelSQL, ModelView, MatchMixin):
|
||||||
return self.start_date <= date <= self.end_date
|
return self.start_date <= date <= self.end_date
|
||||||
|
|
||||||
|
|
||||||
class SequenceStrict:
|
class SequenceStrict(metaclass=PoolMeta):
|
||||||
__name__ = 'ir.sequence.strict'
|
__name__ = 'ir.sequence.strict'
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
|
|
||||||
# needed due to both models share form view
|
# needed due to both models share form view
|
||||||
periods = fields.Function(
|
periods = fields.Function(
|
||||||
|
|
|
@ -7,9 +7,8 @@ from trytond.transaction import Transaction
|
||||||
__all__ = ['Purchase']
|
__all__ = ['Purchase']
|
||||||
|
|
||||||
|
|
||||||
class Purchase:
|
class Purchase(metaclass=PoolMeta):
|
||||||
__name__ = 'purchase.purchase'
|
__name__ = 'purchase.purchase'
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
|
|
3
sale.py
3
sale.py
|
@ -7,9 +7,8 @@ from trytond.transaction import Transaction
|
||||||
__all__ = ['Sale']
|
__all__ = ['Sale']
|
||||||
|
|
||||||
|
|
||||||
class Sale:
|
class Sale(metaclass=PoolMeta):
|
||||||
__name__ = 'sale.sale'
|
__name__ = 'sale.sale'
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
|
|
15
setup.py
15
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 COPYRIGHT file at the top level of this repository contains
|
||||||
# the full copyright notices and license terms.
|
# the full copyright notices and license terms.
|
||||||
|
|
||||||
|
@ -6,10 +6,7 @@ from setuptools import setup, find_packages
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import io
|
import io
|
||||||
try:
|
from configparser import ConfigParser
|
||||||
from configparser import ConfigParser
|
|
||||||
except ImportError:
|
|
||||||
from ConfigParser import ConfigParser
|
|
||||||
|
|
||||||
MODULE2PREFIX = {}
|
MODULE2PREFIX = {}
|
||||||
|
|
||||||
|
@ -19,6 +16,7 @@ def read(fname):
|
||||||
os.path.join(os.path.dirname(__file__), fname),
|
os.path.join(os.path.dirname(__file__), fname),
|
||||||
'r', encoding='utf-8').read()
|
'r', encoding='utf-8').read()
|
||||||
|
|
||||||
|
|
||||||
def get_require_version(name):
|
def get_require_version(name):
|
||||||
if minor_version % 2:
|
if minor_version % 2:
|
||||||
require = '%s >= %s.%s.dev0, < %s.%s'
|
require = '%s >= %s.%s.dev0, < %s.%s'
|
||||||
|
@ -28,6 +26,7 @@ def get_require_version(name):
|
||||||
major_version, minor_version + 1)
|
major_version, minor_version + 1)
|
||||||
return require
|
return require
|
||||||
|
|
||||||
|
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
config.readfp(open('tryton.cfg'))
|
config.readfp(open('tryton.cfg'))
|
||||||
info = dict(config.items('tryton'))
|
info = dict(config.items('tryton'))
|
||||||
|
@ -45,7 +44,9 @@ requires = []
|
||||||
for dep in info.get('depends', []):
|
for dep in info.get('depends', []):
|
||||||
if not re.match(r'(ir|res)(\W|$)', dep):
|
if not re.match(r'(ir|res)(\W|$)', dep):
|
||||||
prefix = MODULE2PREFIX.get(dep, 'trytond')
|
prefix = MODULE2PREFIX.get(dep, 'trytond')
|
||||||
|
|
||||||
requires.append(get_require_version('%s_%s' % (prefix, dep)))
|
requires.append(get_require_version('%s_%s' % (prefix, dep)))
|
||||||
|
|
||||||
requires.append(get_require_version('trytond'))
|
requires.append(get_require_version('trytond'))
|
||||||
|
|
||||||
tests_require = []
|
tests_require = []
|
||||||
|
@ -99,15 +100,16 @@ setup(name=name,
|
||||||
'Natural Language :: Slovenian',
|
'Natural Language :: Slovenian',
|
||||||
'Natural Language :: Spanish',
|
'Natural Language :: Spanish',
|
||||||
'Operating System :: OS Independent',
|
'Operating System :: OS Independent',
|
||||||
'Programming Language :: Python :: 2.7',
|
|
||||||
'Programming Language :: Python :: 3.4',
|
'Programming Language :: Python :: 3.4',
|
||||||
'Programming Language :: Python :: 3.5',
|
'Programming Language :: Python :: 3.5',
|
||||||
'Programming Language :: Python :: 3.6',
|
'Programming Language :: Python :: 3.6',
|
||||||
|
'Programming Language :: Python :: 3.7',
|
||||||
'Programming Language :: Python :: Implementation :: CPython',
|
'Programming Language :: Python :: Implementation :: CPython',
|
||||||
'Programming Language :: Python :: Implementation :: PyPy',
|
'Programming Language :: Python :: Implementation :: PyPy',
|
||||||
'Topic :: Office/Business',
|
'Topic :: Office/Business',
|
||||||
],
|
],
|
||||||
license='GPL-3',
|
license='GPL-3',
|
||||||
|
python_requires='>=3.4',
|
||||||
install_requires=requires,
|
install_requires=requires,
|
||||||
dependency_links=dependency_links,
|
dependency_links=dependency_links,
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
|
@ -118,5 +120,4 @@ setup(name=name,
|
||||||
test_suite='tests',
|
test_suite='tests',
|
||||||
test_loader='trytond.test_loader:Loader',
|
test_loader='trytond.test_loader:Loader',
|
||||||
tests_require=tests_require,
|
tests_require=tests_require,
|
||||||
use_2to3=True,
|
|
||||||
)
|
)
|
||||||
|
|
15
stock.py
15
stock.py
|
@ -21,26 +21,21 @@ class ShipmentMixin(object):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
class ShipmentOut(ShipmentMixin):
|
class ShipmentOut(ShipmentMixin, metaclass=PoolMeta):
|
||||||
__name__ = 'stock.shipment.out'
|
__name__ = 'stock.shipment.out'
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
|
|
||||||
|
|
||||||
class ShipmentOutReturn(ShipmentMixin):
|
class ShipmentOutReturn(ShipmentMixin, metaclass=PoolMeta):
|
||||||
__name__ = 'stock.shipment.out.return'
|
__name__ = 'stock.shipment.out.return'
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
|
|
||||||
|
|
||||||
class ShipmentIn(ShipmentMixin):
|
class ShipmentIn(ShipmentMixin, metaclass=PoolMeta):
|
||||||
__name__ = 'stock.shipment.in'
|
__name__ = 'stock.shipment.in'
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
|
|
||||||
|
|
||||||
class ShipmentInReturn(ShipmentMixin):
|
class ShipmentInReturn(ShipmentMixin, metaclass=PoolMeta):
|
||||||
__name__ = 'stock.shipment.in.return'
|
__name__ = 'stock.shipment.in.return'
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
|
|
||||||
|
|
||||||
class ShipmentInternal(ShipmentMixin):
|
class ShipmentInternal(ShipmentMixin, metaclass=PoolMeta):
|
||||||
__name__ = 'stock.shipment.internal'
|
__name__ = 'stock.shipment.internal'
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
|
|
13
tox.ini
13
tox.ini
|
@ -1,18 +1,15 @@
|
||||||
[tox]
|
[tox]
|
||||||
envlist = {py27,py36}-{sqlite,postgresql,mysql},pypy-{sqlite,postgresql}
|
envlist = {py36,py37}-{sqlite,postgresql},pypy3-{sqlite,postgresql}
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
commands = {envpython} setup.py test
|
commands = {envpython} setup.py test
|
||||||
deps =
|
deps =
|
||||||
{py27,py36}-postgresql: psycopg2 >= 2.5
|
{py36,py37}-postgresql: psycopg2 >= 2.5
|
||||||
pypy-postgresql: psycopg2cffi >= 2.5
|
pypy3-postgresql: psycopg2cffi >= 2.5
|
||||||
mysql: MySQL-python
|
{py36}-sqlite: sqlitebck
|
||||||
sqlite: sqlitebck
|
|
||||||
setenv =
|
setenv =
|
||||||
sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://}
|
sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://}
|
||||||
postgresql: TRYTOND_DATABASE_URI={env:POSTGRESQL_URI:postgresql://}
|
postgresql: TRYTOND_DATABASE_URI={env:POSTGRESQL_URI:postgresql://}
|
||||||
mysql: TRYTOND_DATABASE_URI={env:MYSQL_URI:mysql://}
|
|
||||||
sqlite: DB_NAME={env:SQLITE_NAME::memory:}
|
sqlite: DB_NAME={env:SQLITE_NAME::memory:}
|
||||||
postgresql: DB_NAME={env:POSTGRESQL_NAME:test}
|
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 --process-dependency-links {opts} {packages}
|
|
|
@ -1,5 +1,5 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=4.8.0
|
version=5.0.0
|
||||||
depends:
|
depends:
|
||||||
ir
|
ir
|
||||||
res
|
res
|
||||||
|
|
Loading…
Reference in New Issue