Migration to 5.0

This commit is contained in:
Javier Uribe 2019-02-28 13:56:35 +01:00
parent 0cef839535
commit cbe53e6f57
6 changed files with 35 additions and 45 deletions

View file

@ -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

View file

@ -88,7 +88,7 @@ class ProductLimit(ModelSQL, ModelView):
products = Product.browse(product_ids)
with Transaction().set_context(context):
products = Product.get_quantity(products, 'forecast_quantity')
p_forecast = {k: value for k, value in products.iteritems()
p_forecast = {k: value for k, value in products.items()
if value}
ret = []
@ -111,9 +111,8 @@ class ProductLimit(ModelSQL, ModelView):
return ret
class ShipmentOut:
class ShipmentOut(metaclass=PoolMeta):
__name__ = 'stock.shipment.out'
__metaclass__ = PoolMeta
@classmethod
def __setup__(cls):
@ -166,9 +165,8 @@ class ShipmentOut:
cache.add((move.product, move.quantity))
class ShipmentOutReturn:
class ShipmentOutReturn(metaclass=PoolMeta):
__name__ = 'stock.shipment.out.return'
__metaclass__ = PoolMeta
def product_limits_by_location(self):
ProductLimit = Pool().get('stock.location.product_limit')
@ -176,9 +174,8 @@ class ShipmentOutReturn:
self.customer_location.id)
class Location:
class Location(metaclass=PoolMeta):
__name__ = 'stock.location'
__metaclass__ = PoolMeta
limits = fields.One2Many('stock.location.product_limit', 'location',
'Limits')
@ -195,7 +192,7 @@ class Location:
product_id = Transaction().context.get('product')
res = dict([(l.id, 0) for l in locations])
if not product_id or not isinstance(product_id, (int, long)):
if not product_id or not isinstance(product_id, int):
return res
default_uom = Product(product_id).default_uom
@ -254,7 +251,7 @@ class ProductLimitNote(Report):
)
values = {(data['start_date'] + relativedelta(days=-1), None): stock}
for key, qty in qties.iteritems():
for key, qty in qties.items():
_origin = key[3] or key[4]
if _origin:
model, id = _origin.split(',')
@ -275,12 +272,12 @@ class ProductLimitNote(Report):
cumulate_moves[k[0]] += v
cumulate += v
report_context['cumulate'] = sorted([(k, v) for k, v in
cumulate_moves.iteritems()], key=lambda x: x[0])
cumulate_moves.items()], key=lambda x: x[0])
return report_context
@classmethod
def _get_sorted_moves(cls, moves):
new_moves = [(k, v) for k, v in moves.iteritems()]
new_moves = [(k, v) for k, v in moves.items()]
new_moves = sorted(new_moves, key=lambda x: x[0][0])
return new_moves
@ -334,9 +331,8 @@ class PrintProductLimitNote(Wizard):
return action, data
class DeliveryNote:
class DeliveryNote(metaclass=PoolMeta):
__name__ = 'stock.shipment.out.delivery_note'
__metaclass__ = PoolMeta
@classmethod
def get_context(cls, records, data):
@ -354,9 +350,8 @@ class DeliveryNote:
return report_context
class RestockingList:
class RestockingList(metaclass=PoolMeta):
__name__ = 'stock.shipment.out.return.restocking_list'
__metaclass__ = PoolMeta
@classmethod
def get_context(cls, records, data):
@ -374,9 +369,8 @@ class RestockingList:
return report_context
class Configuration:
class Configuration(metaclass=PoolMeta):
__name__ = 'stock.configuration'
__metaclass__ = PoolMeta
show_limit = fields.Boolean('Show product limits', help=(
'If checked a summary of product limits is shown in shipment reports.')

View file

@ -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 = {
'company_logo': 'trytonspain'
@ -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'))
@ -64,12 +63,15 @@ requires = []
for dep in info.get('depends', []):
if not re.match(r'(ir|res)(\W|$)', dep):
prefix = MODULE2PREFIX.get(dep, 'trytond')
req = get_require_version('%s_%s' % (prefix, dep))
if dep in dependency_links:
req = '%s_%s @ %s' % (prefix, dep, dependency_links[dep])
requires.append(req)
requires.append(get_require_version('trytond'))
tests_require = [get_require_version('proteus')]
dependency_links = list(dependency_links.values())
@ -118,15 +120,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,
@ -137,8 +140,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_shipment_out.rst',
],
)

View file

@ -136,9 +136,9 @@ Testing the reports::
>>> delivery_note = Report('stock.shipment.out.delivery_note')
>>> ext, _, _, name = delivery_note.execute([shipment_out], {})
>>> ext
u'odt'
'odt'
>>> name
u'Delivery Note'
'Delivery Note'
>>> conf = Model.get('stock.configuration')(1)
>>> conf.show_limit = False
>>> conf.save()

13
tox.ini
View file

@ -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 {opts} {packages}

View file

@ -1,5 +1,5 @@
[tryton]
version=4.8.0
version=5.0.0
depends:
company_logo
ir