mirror of
https://gitlab.com/datalifeit/trytond-stock_product_category_location
synced 2023-12-14 04:33:11 +01:00
Migration to 5.0
This commit is contained in:
parent
5c5d28f2e9
commit
5638dfe3c6
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
|
|
@ -88,7 +88,7 @@ class ProductCategoryLocation(ModelSQL, ModelView):
|
||||||
cls.raise_user_error('unique_key')
|
cls.raise_user_error('unique_key')
|
||||||
values.setdefault(_uq, 1)
|
values.setdefault(_uq, 1)
|
||||||
|
|
||||||
others = cls.search([('id', 'not in', map(int, records))])
|
others = cls.search([('id', 'not in', list(map(int, records)))])
|
||||||
for other in others:
|
for other in others:
|
||||||
_uq = other._get_unique_key()
|
_uq = other._get_unique_key()
|
||||||
if values.get(_uq):
|
if values.get(_uq):
|
||||||
|
@ -97,9 +97,8 @@ class ProductCategoryLocation(ModelSQL, ModelView):
|
||||||
super(ProductCategoryLocation, cls).validate(records)
|
super(ProductCategoryLocation, cls).validate(records)
|
||||||
|
|
||||||
|
|
||||||
class Location:
|
class Location(metaclass=PoolMeta):
|
||||||
__name__ = 'stock.location'
|
__name__ = 'stock.location'
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
|
|
||||||
categories = fields.One2Many('stock.product.category.location', 'location', 'Categories',
|
categories = fields.One2Many('stock.product.category.location', 'location', 'Categories',
|
||||||
states={
|
states={
|
||||||
|
|
|
@ -6,9 +6,8 @@ from trytond.pool import PoolMeta, Pool
|
||||||
__all__ = ['Category']
|
__all__ = ['Category']
|
||||||
|
|
||||||
|
|
||||||
class Category:
|
class Category(metaclass=PoolMeta):
|
||||||
__name__ = 'product.category'
|
__name__ = 'product.category'
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
|
|
||||||
locations = fields.One2Many(
|
locations = fields.One2Many(
|
||||||
'stock.product.category.location', 'category', 'Default Locations')
|
'stock.product.category.location', 'category', 'Default Locations')
|
||||||
|
|
23
setup.py
23
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
|
||||||
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 = {
|
||||||
'stock_location_notebook': 'datalife'
|
'stock_location_notebook': 'datalife'
|
||||||
|
@ -22,6 +19,7 @@ def read(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'
|
||||||
|
@ -32,6 +30,7 @@ def get_require_version(name):
|
||||||
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'))
|
||||||
|
@ -64,12 +63,15 @@ 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')
|
||||||
|
|
||||||
req = get_require_version('%s_%s' % (prefix, dep))
|
req = get_require_version('%s_%s' % (prefix, dep))
|
||||||
if dep in dependency_links:
|
if dep in dependency_links:
|
||||||
req = '%s_%s @ %s' % (prefix, dep, dependency_links[dep])
|
req = '%s_%s @ %s' % (prefix, dep, dependency_links[dep])
|
||||||
requires.append(req)
|
requires.append(req)
|
||||||
|
|
||||||
requires.append(get_require_version('trytond'))
|
requires.append(get_require_version('trytond'))
|
||||||
|
|
||||||
|
|
||||||
tests_require = [get_require_version('proteus')]
|
tests_require = [get_require_version('proteus')]
|
||||||
|
|
||||||
if minor_version % 2:
|
if minor_version % 2:
|
||||||
|
@ -92,7 +94,7 @@ setup(name=name,
|
||||||
],
|
],
|
||||||
package_data={
|
package_data={
|
||||||
'trytond.modules.stock_product_category_location': (info.get('xml', [])
|
'trytond.modules.stock_product_category_location': (info.get('xml', [])
|
||||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.odt',
|
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.fodt',
|
||||||
'icons/*.svg', 'tests/*.rst']),
|
'icons/*.svg', 'tests/*.rst']),
|
||||||
},
|
},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
@ -117,15 +119,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.3',
|
|
||||||
'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.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,
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
entry_points="""
|
entry_points="""
|
||||||
|
@ -135,8 +138,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,
|
|
||||||
convert_2to3_doctests=[
|
|
||||||
'tests/scenario_stock_product_category_location.rst',
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
|
9
stock.py
9
stock.py
|
@ -5,8 +5,7 @@ from trytond.pool import PoolMeta
|
||||||
__all__ = ['ShipmentOut', 'ShipmentOutReturn', 'ShipmentIn']
|
__all__ = ['ShipmentOut', 'ShipmentOutReturn', 'ShipmentIn']
|
||||||
|
|
||||||
|
|
||||||
class ShipmentOut:
|
class ShipmentOut(metaclass=PoolMeta):
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
__name__ = 'stock.shipment.out'
|
__name__ = 'stock.shipment.out'
|
||||||
|
|
||||||
def _get_inventory_move(self, move):
|
def _get_inventory_move(self, move):
|
||||||
|
@ -25,8 +24,7 @@ class ShipmentOut:
|
||||||
return {'warehouse': self.warehouse}
|
return {'warehouse': self.warehouse}
|
||||||
|
|
||||||
|
|
||||||
class ShipmentOutReturn:
|
class ShipmentOutReturn(metaclass=PoolMeta):
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
__name__ = 'stock.shipment.out.return'
|
__name__ = 'stock.shipment.out.return'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -47,8 +45,7 @@ class ShipmentOutReturn:
|
||||||
return {'warehouse': incoming_move.shipment.warehouse}
|
return {'warehouse': incoming_move.shipment.warehouse}
|
||||||
|
|
||||||
|
|
||||||
class ShipmentIn:
|
class ShipmentIn(metaclass=PoolMeta):
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
__name__ = 'stock.shipment.in'
|
__name__ = 'stock.shipment.in'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
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 --find-links https://trydevpi.tryton.org/ {opts} {packages}
|
||||||
install_command = pip install --pre {opts} {packages}
|
|
|
@ -1,5 +1,5 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=4.8.0
|
version=5.0
|
||||||
depends:
|
depends:
|
||||||
ir
|
ir
|
||||||
res
|
res
|
||||||
|
|
Loading…
Reference in a new issue