mirror of
https://github.com/NaN-tic/trytond-sale_product_package.git
synced 2023-12-14 03:03:09 +01:00
Update to 4.7
This commit is contained in:
parent
1ef9e02888
commit
85bef60f6f
7 changed files with 73 additions and 35 deletions
|
@ -1,10 +1,10 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
from trytond.pool import Pool
|
||||
from .sale import *
|
||||
from . import sale
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
SaleLine,
|
||||
sale.SaleLine,
|
||||
module='sale_product_package', type_='model')
|
||||
|
|
6
sale.py
6
sale.py
|
@ -1,14 +1,14 @@
|
|||
#The COPYRIGHT file at the top level of this repository contains the full
|
||||
#copyright notices and license terms.
|
||||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
|
||||
__all__ = ['SaleLine']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
class SaleLine:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'sale.line'
|
||||
|
||||
product_has_packages = fields.Function(fields.Boolean(
|
||||
|
|
70
setup.py
70
setup.py
|
@ -4,38 +4,69 @@
|
|||
from setuptools import setup
|
||||
import re
|
||||
import os
|
||||
import ConfigParser
|
||||
import io
|
||||
try:
|
||||
from configparser import ConfigParser
|
||||
except ImportError:
|
||||
from ConfigParser import ConfigParser
|
||||
|
||||
MODULE = 'sale_product_package'
|
||||
PREFIX = 'nantic'
|
||||
MODULE2PREFIX = {}
|
||||
MODULE2PREFIX = {
|
||||
'product_package': 'nantic',
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
|
||||
config = ConfigParser.ConfigParser()
|
||||
|
||||
def get_require_version(name):
|
||||
if minor_version % 2:
|
||||
require = '%s >= %s.%s.dev0, < %s.%s'
|
||||
else:
|
||||
require = '%s >= %s.%s, < %s.%s'
|
||||
require %= (name, major_version, minor_version,
|
||||
major_version, minor_version + 1)
|
||||
return require
|
||||
|
||||
config = ConfigParser()
|
||||
config.readfp(open('tryton.cfg'))
|
||||
info = dict(config.items('tryton'))
|
||||
for key in ('depends', 'extras_depend', 'xml'):
|
||||
if key in info:
|
||||
info[key] = info[key].strip().splitlines()
|
||||
major_version, minor_version, _ = info.get('version', '0.0.1').split('.', 2)
|
||||
version = info.get('version', '0.0.1')
|
||||
major_version, minor_version, _ = version.split('.', 2)
|
||||
major_version = int(major_version)
|
||||
minor_version = int(minor_version)
|
||||
|
||||
requires = []
|
||||
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')
|
||||
requires.append('%s_%s >= %s.%s, < %s.%s' %
|
||||
(prefix, dep, major_version, minor_version,
|
||||
major_version, minor_version + 1))
|
||||
requires.append('trytond >= %s.%s, < %s.%s' %
|
||||
(major_version, minor_version, major_version, minor_version + 1))
|
||||
requires.append(get_require_version('%s_%s' % (prefix, dep)))
|
||||
requires.append(get_require_version('trytond'))
|
||||
|
||||
tests_require = ['proteus >= %s.%s, < %s.%s' %
|
||||
(major_version, minor_version, major_version, minor_version + 1)]
|
||||
tests_require = [get_require_version('proteus')]
|
||||
series = '%s.%s' % (major_version, minor_version)
|
||||
if minor_version % 2:
|
||||
branch = 'default'
|
||||
else:
|
||||
branch = series
|
||||
dependency_links = [
|
||||
('hg+https://bitbucket.org/nantic/'
|
||||
'trytond-product_package@%(branch)s'
|
||||
'#egg=nantic-product_package-%(series)s' % {
|
||||
'branch': branch,
|
||||
'series': series,
|
||||
}),
|
||||
]
|
||||
if minor_version % 2:
|
||||
# Add development index for testing with proteus
|
||||
dependency_links.append('https://trydevpi.tryton.org/')
|
||||
|
||||
setup(name='%s_%s' % (PREFIX, MODULE),
|
||||
version=info.get('version', '0.0.1'),
|
||||
|
@ -51,7 +82,7 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
|||
],
|
||||
package_data={
|
||||
'trytond.modules.%s' % MODULE: (info.get('xml', [])
|
||||
+ ['tryton.cfg', 'locale/*.po', 'tests/*.rst']),
|
||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', 'tests/*.rst']),
|
||||
},
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
|
@ -71,12 +102,17 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
|||
'Natural Language :: Russian',
|
||||
'Natural Language :: Spanish',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python :: 2.6',
|
||||
'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',
|
||||
],
|
||||
license='GPL-3',
|
||||
install_requires=requires,
|
||||
dependency_links=dependency_links,
|
||||
zip_safe=False,
|
||||
entry_points="""
|
||||
[trytond.modules]
|
||||
|
@ -85,4 +121,8 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
|||
test_suite='tests',
|
||||
test_loader='trytond.test_loader:Loader',
|
||||
tests_require=tests_require,
|
||||
use_2to3=True,
|
||||
convert_2to3_doctests=[
|
||||
'tests/scenario_sale_product_package.rst',
|
||||
],
|
||||
)
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
from .test_sale_product_package import suite
|
||||
try:
|
||||
from trytond.modules.sale_product_package.tests.test_sale_product_package import suite
|
||||
except ImportError:
|
||||
from .test_sale_product_package import suite
|
||||
|
||||
__all__ = ['suite']
|
||||
|
|
|
@ -9,6 +9,7 @@ Imports::
|
|||
>>> from decimal import Decimal
|
||||
>>> from operator import attrgetter
|
||||
>>> from proteus import config, Model, Wizard
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
>>> from trytond.modules.company.tests.tools import create_company, \
|
||||
... get_company
|
||||
>>> from trytond.modules.account.tests.tools import create_fiscalyear, \
|
||||
|
@ -17,17 +18,9 @@ Imports::
|
|||
... set_fiscalyear_invoice_sequences, create_payment_term
|
||||
>>> today = datetime.date.today()
|
||||
|
||||
Create database::
|
||||
|
||||
>>> config = config.set_trytond()
|
||||
>>> config.pool.test = True
|
||||
|
||||
Install sale_product_package::
|
||||
|
||||
>>> Module = Model.get('ir.module')
|
||||
>>> sale_module, = Module.find([('name', '=', 'sale_product_package')])
|
||||
>>> Module.install([sale_module.id], config.context)
|
||||
>>> Wizard('ir.module.install_upgrade').execute('upgrade')
|
||||
>>> config = activate_modules('sale_product_package')
|
||||
|
||||
Create company::
|
||||
|
||||
|
@ -122,10 +115,10 @@ Sale products with package::
|
|||
>>> line.amount
|
||||
Decimal('120.00')
|
||||
>>> line.quantity = 13
|
||||
>>> sale.save()
|
||||
>>> sale.save() # doctest: +IGNORE_EXCEPTION_DETAIL
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
UserError: ('UserError', (u'The quantity "13.0" of product "product" is not a multiple of it\'s package "Box" quantity "6.0".', ''))
|
||||
UserError: ...
|
||||
>>> line.quantity = 12
|
||||
>>> line.package_quantity
|
||||
2
|
||||
|
|
|
@ -5,7 +5,7 @@ import unittest
|
|||
import doctest
|
||||
import trytond.tests.test_tryton
|
||||
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
|
||||
from trytond.tests.test_tryton import doctest_checker
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ def suite():
|
|||
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestCase))
|
||||
suite.addTests(doctest.DocFileSuite(
|
||||
'scenario_sale_product_package.rst',
|
||||
setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8',
|
||||
tearDown=doctest_teardown, encoding='utf-8',
|
||||
checker=doctest_checker,
|
||||
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
|
||||
return suite
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=4.1.0
|
||||
version=4.7.0
|
||||
depends:
|
||||
product_package
|
||||
sale
|
||||
|
|
Loading…
Reference in a new issue