mirror of
https://gitlab.com/datalifeit/trytond-stock_label_printer
synced 2023-12-14 07:02:52 +01:00
Migration to 5.0
This commit is contained in:
parent
80b7acd0b3
commit
be8a8657be
24
.drone.yml
24
.drone.yml
|
@ -32,27 +32,15 @@ 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
|
||||
- IMAGE: python:3.4
|
||||
TOXENV: py34
|
||||
DATABASE: postgresql
|
||||
- IMAGE: python:3.5
|
||||
TOXENV: py35
|
||||
DATABASE: sqlite
|
||||
- IMAGE: python:3.5
|
||||
TOXENV: py35
|
||||
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
|
|
@ -7,9 +7,8 @@ from trytond.pyson import Eval
|
|||
__all__ = ['Printer']
|
||||
|
||||
|
||||
class Printer:
|
||||
class Printer(metaclass=PoolMeta):
|
||||
__name__ = 'label.printer'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
location = fields.Many2One('stock.location', 'Location',
|
||||
domain=[('type', 'in', ['storage', 'production'])],
|
||||
|
|
20
setup.py
20
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
|
|||
import re
|
||||
import os
|
||||
import io
|
||||
try:
|
||||
from configparser import ConfigParser
|
||||
except ImportError:
|
||||
from ConfigParser import ConfigParser
|
||||
from configparser import ConfigParser
|
||||
|
||||
MODULE2PREFIX = {
|
||||
'label_printer': 'datalife'
|
||||
|
@ -22,6 +19,7 @@ def read(fname):
|
|||
'r', encoding='utf-8').read()
|
||||
|
||||
|
||||
|
||||
def get_require_version(name):
|
||||
if minor_version % 2:
|
||||
require = '%s >= %s.%s.dev0, < %s.%s'
|
||||
|
@ -32,6 +30,7 @@ def get_require_version(name):
|
|||
return require
|
||||
|
||||
|
||||
|
||||
config = ConfigParser()
|
||||
config.readfp(open('tryton.cfg'))
|
||||
info = dict(config.items('tryton'))
|
||||
|
@ -49,9 +48,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:
|
||||
|
@ -86,7 +88,7 @@ setup(name=name,
|
|||
],
|
||||
package_data={
|
||||
'trytond.modules.stock_label_printer': (info.get('xml', [])
|
||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.odt',
|
||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.fodt',
|
||||
'icons/*.svg', 'tests/*.rst']),
|
||||
},
|
||||
classifiers=[
|
||||
|
@ -111,15 +113,16 @@ setup(name=name,
|
|||
'Natural Language :: Slovenian',
|
||||
'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 :: 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,
|
||||
|
@ -130,5 +133,4 @@ setup(name=name,
|
|||
test_suite='tests',
|
||||
test_loader='trytond.test_loader:Loader',
|
||||
tests_require=tests_require,
|
||||
use_2to3=True,
|
||||
)
|
||||
|
|
9
stock.py
9
stock.py
|
@ -10,9 +10,8 @@ from trytond.pyson import Eval, Not, Equal
|
|||
__all__ = ['Location']
|
||||
|
||||
|
||||
class Location:
|
||||
class Location(metaclass=PoolMeta):
|
||||
__name__ = 'stock.location'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
printers = fields.One2Many('label.printer', 'location', 'Printers',
|
||||
states={'invisible': ~Eval('type').in_(['storage', 'production'])},
|
||||
|
@ -62,12 +61,12 @@ class Location:
|
|||
dt = datetime(year=year, month=1, day=1) + relativedelta(minutes=minutes)
|
||||
if code[2:3].upper() == 'H':
|
||||
dt += relativedelta(minutes=-60)
|
||||
return map(int, res), dt
|
||||
return list(map(int, res)), dt
|
||||
|
||||
@classmethod
|
||||
def base35encode(cls, number, alphabet='0123456789ABCDEFGHIJKLMNPQRSTUVWXYZ'):
|
||||
"""Converts an integer to a base36 string"""
|
||||
if not isinstance(number, (int, long)):
|
||||
if not isinstance(number, int):
|
||||
raise TypeError('number must be an integer')
|
||||
|
||||
base35 = ''
|
||||
|
@ -96,6 +95,6 @@ class Location:
|
|||
'V': 30, 'W': 31, 'X': 32, 'Y': 33, 'Z': 34}
|
||||
value = 0
|
||||
new_number = number[::-1].upper()
|
||||
for x in xrange(0, len(new_number)):
|
||||
for x in range(0, len(new_number)):
|
||||
value += pow(35, x) * conv[new_number[x]]
|
||||
return value
|
||||
|
|
13
tox.ini
13
tox.ini
|
@ -1,18 +1,15 @@
|
|||
[tox]
|
||||
envlist = {py27,py34,py35,py36}-{sqlite,postgresql,mysql},pypy-{sqlite,postgresql}
|
||||
envlist = {py36,py37}-{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
|
||||
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 --process-dependency-links {opts} {packages}
|
||||
install_command = pip install --pre {opts} {packages}
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=4.8.0
|
||||
version=5.0.0
|
||||
depends:
|
||||
ir
|
||||
label_printer
|
||||
|
|
|
@ -23,9 +23,8 @@ class GetPackCode(ModelView):
|
|||
return str(datetime.datetime.now().year)
|
||||
|
||||
|
||||
class UnitLoadTrace:
|
||||
class UnitLoadTrace(metaclass=PoolMeta):
|
||||
__name__ = 'stock.unit_load.trace'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
get_pack_code = StateView('stock.unit_load.trace.get_pack_code',
|
||||
'stock_label_printer.unit_load_trace_get_pack_code_view_form',
|
||||
|
|
Loading…
Reference in a new issue