Update to 4.7

This commit is contained in:
C?dric Krier 2018-02-14 16:37:34 +01:00
parent 2327f11120
commit 17fccd3545
10 changed files with 111 additions and 30 deletions

49
.drone.yml Normal file
View file

@ -0,0 +1,49 @@
clone:
hg:
image: plugins/hg
pipeline:
tox:
image: ${IMAGE}
environment:
- CFLAGS=-O0
- DB_CACHE=/cache
- TOX_TESTENV_PASSENV=CFLAGS DB_CACHE
- POSTGRESQL_URI=postgresql://postgres@postgresql:5432/
commands:
- pip install tox
- tox -e "${TOXENV}-${DATABASE}"
services:
postgresql:
image: postgres
when:
matrix:
DATABASE: postgresql
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

View file

@ -1,14 +1,14 @@
# 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 trytond.pool import Pool from trytond.pool import Pool
from .sale import * from . import sale
def register(): def register():
Pool.register( Pool.register(
Sale, sale.Sale,
RecomputePriceStart, sale.RecomputePriceStart,
module='sale_recompute_price', type_='model') module='sale_recompute_price', type_='model')
Pool.register( Pool.register(
RecomputePrice, sale.RecomputePrice,
module='sale_recompute_price', type_='wizard') module='sale_recompute_price', type_='wizard')

View file

@ -35,8 +35,8 @@ class Sale:
new_unit_price = (line.unit_price * factor).quantize( new_unit_price = (line.unit_price * factor).quantize(
Decimal(str(10 ** -digits))) Decimal(str(10 ** -digits)))
values = { values = {
'unit_price': new_unit_price 'unit_price': new_unit_price,
} }
# Compatibility with sale_discount module # Compatibility with sale_discount module
if hasattr(line, 'gross_unit_price'): if hasattr(line, 'gross_unit_price'):
digits = line.__class__.gross_unit_price.digits[1] digits = line.__class__.gross_unit_price.digits[1]

View file

@ -4,7 +4,11 @@
from setuptools import setup from setuptools import setup
import re import re
import os import os
import ConfigParser import io
try:
from configparser import ConfigParser
except ImportError:
from ConfigParser import ConfigParser
MODULE = 'sale_recompute_price' MODULE = 'sale_recompute_price'
PREFIX = 'nantic' PREFIX = 'nantic'
@ -12,7 +16,9 @@ MODULE2PREFIX = {}
def read(fname): def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read() return io.open(
os.path.join(os.path.dirname(__file__), fname),
'r', encoding='utf-8').read()
def get_require_version(name): def get_require_version(name):
@ -24,7 +30,7 @@ def get_require_version(name):
major_version, minor_version + 1) major_version, minor_version + 1)
return require return require
config = ConfigParser.ConfigParser() config = ConfigParser()
config.readfp(open('tryton.cfg')) config.readfp(open('tryton.cfg'))
info = dict(config.items('tryton')) info = dict(config.items('tryton'))
for key in ('depends', 'extras_depend', 'xml'): for key in ('depends', 'extras_depend', 'xml'):
@ -38,14 +44,16 @@ minor_version = int(minor_version)
requires = [] requires = []
for dep in info.get('depends', []): for dep in info.get('depends', []):
if not re.match(r'(ir|res|webdav)(\W|$)', dep): if not re.match(r'(ir|res)(\W|$)', dep):
prefix = MODULE2PREFIX.get(dep, 'trytond') prefix = MODULE2PREFIX.get(dep, 'trytond')
requires.append('%s_%s >= %s.%s, < %s.%s' % requires.append(get_require_version('%s_%s' % (prefix, dep)))
(prefix, dep, major_version, minor_version,
major_version, minor_version + 1))
requires.append(get_require_version('trytond')) requires.append(get_require_version('trytond'))
tests_require = [get_require_version('proteus')] tests_require = [get_require_version('proteus')]
dependency_links = []
if minor_version % 2:
# Add development index for testing with proteus
dependency_links.append('https://trydevpi.tryton.org/')
setup(name='%s_%s' % (PREFIX, MODULE), setup(name='%s_%s' % (PREFIX, MODULE),
version=version, version=version,
@ -62,7 +70,7 @@ setup(name='%s_%s' % (PREFIX, MODULE),
], ],
package_data={ package_data={
'trytond.modules.%s' % MODULE: (info.get('xml', []) 'trytond.modules.%s' % MODULE: (info.get('xml', [])
+ ['tryton.cfg', 'locale/*.po', 'tests/*.rst']), + ['tryton.cfg', 'view/*.xml', 'locale/*.po', 'tests/*.rst']),
}, },
classifiers=[ classifiers=[
'Development Status :: 5 - Production/Stable', 'Development Status :: 5 - Production/Stable',
@ -82,12 +90,17 @@ setup(name='%s_%s' % (PREFIX, MODULE),
'Natural Language :: Russian', 'Natural Language :: Russian',
'Natural Language :: Spanish', 'Natural Language :: Spanish',
'Operating System :: OS Independent', 'Operating System :: OS Independent',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Office/Business', 'Topic :: Office/Business',
], ],
license='GPL-3', license='GPL-3',
install_requires=requires, install_requires=requires,
dependency_links=dependency_links,
zip_safe=False, zip_safe=False,
entry_points=""" entry_points="""
[trytond.modules] [trytond.modules]
@ -96,4 +109,8 @@ setup(name='%s_%s' % (PREFIX, MODULE),
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_sale_recompute_price.rst',
],
) )

View file

@ -1,3 +1,8 @@
# 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 .test_sale_recompute_price import suite try:
from trytond.modules.sale_recompute_price.tests.test_sale_recompute_price import suite
except ImportError:
from .test_sale_recompute_price import suite
__all__ = ['suite']

View file

@ -8,6 +8,7 @@ Imports::
>>> from decimal import Decimal >>> from decimal import Decimal
>>> from operator import attrgetter >>> from operator import attrgetter
>>> from proteus import config, Model, Wizard, Report >>> from proteus import config, Model, Wizard, Report
>>> from trytond.tests.tools import activate_modules
>>> from trytond.modules.company.tests.tools import create_company, \ >>> from trytond.modules.company.tests.tools import create_company, \
... get_company ... get_company
>>> from trytond.modules.account.tests.tools import create_fiscalyear, \ >>> from trytond.modules.account.tests.tools import create_fiscalyear, \
@ -17,17 +18,9 @@ Imports::
>>> today = datetime.date.today() >>> today = datetime.date.today()
Create database::
>>> config = config.set_trytond()
>>> config.pool.test = True
Install sale:: Install sale::
>>> Module = Model.get('ir.module') >>> config = activate_modules('sale_recompute_price')
>>> module, = Module.find([('name', '=', 'sale_recompute_price')])
>>> module.click('install')
>>> Wizard('ir.module.install_upgrade').execute('upgrade')
Create company:: Create company::

View file

@ -4,8 +4,7 @@ import unittest
import doctest import doctest
import trytond.tests.test_tryton import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase from trytond.tests.test_tryton import ModuleTestCase
from trytond.tests.test_tryton import (doctest_setup, doctest_teardown, from trytond.tests.test_tryton import doctest_teardown, doctest_checker
doctest_checker)
class TestSaleRecomputePriceCase(ModuleTestCase): class TestSaleRecomputePriceCase(ModuleTestCase):
@ -18,7 +17,7 @@ def suite():
suite.addTests(unittest.TestLoader().loadTestsFromTestCase( suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
TestSaleRecomputePriceCase)) TestSaleRecomputePriceCase))
suite.addTests(doctest.DocFileSuite('scenario_sale_recompute_price.rst', suite.addTests(doctest.DocFileSuite('scenario_sale_recompute_price.rst',
setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8', tearDown=doctest_teardown, encoding='utf-8',
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE,
checker=doctest_checker)) checker=doctest_checker))
return suite return suite

18
tox.ini Normal file
View file

@ -0,0 +1,18 @@
[tox]
envlist = {py27,py34,py35,py36}-{sqlite,postgresql,mysql},pypy-{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
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 --find-links https://trydevpi.tryton.org/ --process-dependency-links {opts} {packages}

View file

@ -1,5 +1,5 @@
[tryton] [tryton]
version=4.1.0 version=4.7.0
depends: depends:
sale sale
xml: xml:

View file

@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- 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. -->
<form string="Recompute Price" col="4"> <form col="4">
<image name="tryton-dialog-information" xexpand="0" xfill="0"/> <image name="tryton-dialog-information" xexpand="0" xfill="0"/>
<label string="Recompute the price for the selected sale?" <label string="Recompute the price for the selected sale?"
id="advice" yalign="0.0" xalign="0.0" xexpand="1" colspan="3"/> id="advice" yalign="0.0" xalign="0.0" xexpand="1" colspan="3"/>