Migration to 5.0
This commit is contained in:
parent
e8fcce40a6
commit
58f042064d
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
|
16
cost.py
16
cost.py
|
@ -17,19 +17,16 @@ class CostMixin(object):
|
|||
('ul_quantity', 'ULs quantity')])
|
||||
|
||||
|
||||
class CostType(CostMixin):
|
||||
class CostType(CostMixin, metaclass=PoolMeta):
|
||||
__name__ = 'sale.cost.type'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
class CostTemplate(CostMixin):
|
||||
class CostTemplate(CostMixin, metaclass=PoolMeta):
|
||||
__name__ = 'sale.cost.template'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
class CostSale(CostMixin):
|
||||
class CostSale(CostMixin, metaclass=PoolMeta):
|
||||
__name__ = 'sale.cost'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
document_ul_quantity = fields.Function(
|
||||
fields.Float('ULs', digits=(16, 0)),
|
||||
|
@ -48,7 +45,7 @@ class CostSale(CostMixin):
|
|||
values = {r.id: 0 for r in records}
|
||||
sales = {i: 0 for i in list(set([
|
||||
r.document for r in records if r.document]))}
|
||||
for sale, _ in sales.iteritems():
|
||||
for sale, _ in sales.items():
|
||||
lines = [l for l in sale.lines if not l.cost and l.type == 'line']
|
||||
sales[sale] = sum(l.ul_quantity or 0 for l in lines)
|
||||
|
||||
|
@ -63,7 +60,7 @@ class CostSale(CostMixin):
|
|||
values = {r.id: 0 for r in records}
|
||||
sales = {i: 0 for i in list(set([
|
||||
r.document for r in records if r.document]))}
|
||||
for sale, _ in sales.iteritems():
|
||||
for sale, _ in sales.items():
|
||||
lines = [l for l in sale.lines if not l.cost and l.type == 'line']
|
||||
sales[sale] = sum(l.cases_quantity or 0 for l in lines)
|
||||
|
||||
|
@ -92,9 +89,8 @@ class CostSale(CostMixin):
|
|||
[self])[self.id]
|
||||
|
||||
|
||||
class CostLineSale:
|
||||
class CostLineSale(metaclass=PoolMeta):
|
||||
__name__ = 'sale.cost.line'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
document_ul_quantity = fields.Function(
|
||||
fields.Float('ULs', digits=(16, 0)),
|
||||
|
|
6
sale.py
6
sale.py
|
@ -9,9 +9,8 @@ from trytond.modules.product import price_digits
|
|||
__all__ = ['Sale', 'SaleLine']
|
||||
|
||||
|
||||
class Sale:
|
||||
class Sale(metaclass=PoolMeta):
|
||||
__name__ = 'sale.sale'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
ul_quantity = fields.Function(
|
||||
fields.Float('ULs', digits=(16, 0)),
|
||||
|
@ -23,9 +22,8 @@ class Sale:
|
|||
return sum(l.ul_quantity or 0 for l in self.lines)
|
||||
|
||||
|
||||
class SaleLine:
|
||||
class SaleLine(metaclass=PoolMeta):
|
||||
__name__ = 'sale.line'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
ul_quantity = fields.Float('ULs', digits=(16, 0),
|
||||
states={'readonly': Eval('sale_state') != 'draft'},
|
||||
|
|
|
@ -9,9 +9,8 @@ from sql.conditionals import Coalesce
|
|||
__all__ = ['Product']
|
||||
|
||||
|
||||
class Product:
|
||||
class Product(metaclass=PoolMeta):
|
||||
__name__ = 'sale.reporting.product'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
cases_quantity = fields.Float('Cases',
|
||||
digits=(16, Eval('cases_digits', 2)),
|
||||
|
|
24
setup.py
24
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 = {
|
||||
'stock_unit_load': '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'))
|
||||
|
@ -63,13 +62,16 @@ 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'),
|
||||
'datalife_sale_cost'
|
||||
]
|
||||
|
@ -109,7 +111,7 @@ setup(name=name,
|
|||
],
|
||||
package_data={
|
||||
'trytond.modules.sale_unit_load': (info.get('xml', [])
|
||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.odt',
|
||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.fodt',
|
||||
'icons/*.svg', 'tests/*.rst']),
|
||||
},
|
||||
classifiers=[
|
||||
|
@ -134,15 +136,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,
|
||||
zip_safe=False,
|
||||
entry_points="""
|
||||
|
@ -153,9 +156,4 @@ setup(name=name,
|
|||
test_loader='trytond.test_loader:Loader',
|
||||
tests_require=tests_require,
|
||||
dependency_links=tests_dependency_links,
|
||||
use_2to3=True,
|
||||
convert_2to3_doctests=[
|
||||
'tests/scenario_sale.rst',
|
||||
'tests/scenario_sale_cost.rst',
|
||||
],
|
||||
)
|
||||
|
|
|
@ -161,7 +161,7 @@ Create an Inventory::
|
|||
>>> inventory_line.expected_quantity = 0.0
|
||||
>>> inventory.click('confirm')
|
||||
>>> inventory.state
|
||||
u'done'
|
||||
'done'
|
||||
|
||||
Sale 5 products::
|
||||
|
||||
|
|
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 {opts} {packages}
|
||||
install_command = pip install --pre --find-links https://trydevpi.tryton.org/ {opts} {packages}
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=4.8.0
|
||||
version=5.0
|
||||
depends:
|
||||
ir
|
||||
res
|
||||
|
|
|
@ -6,9 +6,8 @@ from trytond.pool import PoolMeta
|
|||
__all__ = ['UnitLoad']
|
||||
|
||||
|
||||
class UnitLoad:
|
||||
class UnitLoad(metaclass=PoolMeta):
|
||||
__name__ = 'stock.unit_load'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
customer = fields.Function(fields.Many2One('party.party', 'Customer'),
|
||||
'get_customer')
|
||||
|
|
Loading…
Reference in New Issue