Update to 4.7
This commit is contained in:
parent
847625d6d3
commit
0583a43807
64
.drone.yml
64
.drone.yml
|
@ -1,9 +1,57 @@
|
|||
image: python:all
|
||||
env:
|
||||
- POSTGRESQL_URI=postgresql://postgres@127.0.0.1:5432/
|
||||
- MYSQL_URI=mysql://root@127.0.0.1:3306/
|
||||
script:
|
||||
- pip install tox
|
||||
- tox -e "{py27,py33,py34,py35}-{sqlite,postgresql}" --skip-missing-interpreters
|
||||
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}"
|
||||
notify:
|
||||
image: drillster/drone-email
|
||||
from: drone@localhost
|
||||
host: smtp
|
||||
port: 25
|
||||
skip_verify: true
|
||||
when:
|
||||
status: [ changed, failure ]
|
||||
|
||||
services:
|
||||
- postgres
|
||||
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
|
||||
|
|
10
__init__.py
10
__init__.py
|
@ -3,13 +3,13 @@
|
|||
# copyright notices and license terms.
|
||||
|
||||
from trytond.pool import Pool
|
||||
from .shop import *
|
||||
from .product import *
|
||||
from . import shop
|
||||
from . import product
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
SaleShop,
|
||||
Template,
|
||||
Product,
|
||||
shop.SaleShop,
|
||||
product.Template,
|
||||
product.Product,
|
||||
module='product_special_price', type_='model')
|
||||
|
|
54
product.py
54
product.py
|
@ -1,11 +1,15 @@
|
|||
# This file is part of product_special_price module for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
from trytond import backend
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.model import fields
|
||||
from trytond.model import ModelSQL, fields
|
||||
from trytond.pyson import Eval
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.config import config as config_
|
||||
from trytond.tools.multivalue import migrate_property
|
||||
|
||||
from trytond.modules.product.product import price_digits
|
||||
from trytond.modules.company.model import CompanyValueMixin
|
||||
|
||||
__all__ = ['Template', 'Product']
|
||||
|
||||
|
@ -13,17 +17,52 @@ STATES = {
|
|||
'readonly': ~Eval('active', True),
|
||||
}
|
||||
DEPENDS = ['active']
|
||||
DIGITS = config_.getint('product', 'price_decimal', default=4)
|
||||
|
||||
|
||||
class Template:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'product.template'
|
||||
special_price = fields.Property(fields.Numeric('Special Price',
|
||||
states=STATES, digits=(16, DIGITS), depends=DEPENDS))
|
||||
special_price = fields.MultiValue(fields.Numeric(
|
||||
"Special Price", digits=price_digits,
|
||||
states=STATES, depends=DEPENDS))
|
||||
special_price_from = fields.Date('Special Price From')
|
||||
special_price_to = fields.Date('Special Price To')
|
||||
|
||||
@classmethod
|
||||
def multivalue_model(cls, field):
|
||||
pool = Pool()
|
||||
if field == 'special_price':
|
||||
return pool.get('product.special_price')
|
||||
return super(Template, cls).multivalue_model(field)
|
||||
|
||||
|
||||
class ProductSpecialPrice(ModelSQL, CompanyValueMixin):
|
||||
"Product Special Price"
|
||||
__name__ = 'product.special_price'
|
||||
|
||||
template = fields.Many2One(
|
||||
'product.template', "Template", ondelete='CASCADE', select=True)
|
||||
special_price = fields.Numeric("Special Price", digits=price_digits)
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
exist = TableHandler.table_exist(cls._table)
|
||||
|
||||
super(ProductSpecialPrice, cls).__register__(module_name)
|
||||
|
||||
if not exist:
|
||||
cls._migrate_property([], [], [])
|
||||
|
||||
@classmethod
|
||||
def _migrate_property(cls, field_names, value_names, fields):
|
||||
field_names.append('special_price')
|
||||
value_names.append('special_price')
|
||||
fields.append('company')
|
||||
migrate_property(
|
||||
'product.template', field_names, cls, value_names,
|
||||
parent='template', fields=fields)
|
||||
|
||||
|
||||
class Product:
|
||||
__metaclass__ = PoolMeta
|
||||
|
@ -65,7 +104,8 @@ class Product:
|
|||
else:
|
||||
special_price = product.special_price
|
||||
|
||||
if special_price != 0.0 and special_price != None and \
|
||||
special_price < prices[product.id]:
|
||||
if (special_price != 0.0
|
||||
and special_price is not None
|
||||
and special_price < prices[product.id]):
|
||||
prices[product.id] = special_price
|
||||
return prices
|
||||
|
|
43
setup.py
43
setup.py
|
@ -12,7 +12,11 @@ try:
|
|||
except ImportError:
|
||||
from ConfigParser import ConfigParser
|
||||
|
||||
MODULE2PREFIX = {}
|
||||
MODULE = 'product_special_price'
|
||||
PREFIX = 'trytonzz'
|
||||
MODULE2PREFIX = {
|
||||
'sale_shop': 'trytonzz',
|
||||
}
|
||||
|
||||
|
||||
def read(fname):
|
||||
|
@ -20,6 +24,7 @@ def read(fname):
|
|||
os.path.join(os.path.dirname(__file__), fname),
|
||||
'r', encoding='utf-8').read()
|
||||
|
||||
|
||||
def get_require_version(name):
|
||||
if minor_version % 2:
|
||||
require = '%s >= %s.%s.dev0, < %s.%s'
|
||||
|
@ -29,6 +34,7 @@ def get_require_version(name):
|
|||
major_version, minor_version + 1)
|
||||
return require
|
||||
|
||||
|
||||
config = ConfigParser()
|
||||
config.readfp(open('tryton.cfg'))
|
||||
info = dict(config.items('tryton'))
|
||||
|
@ -39,8 +45,6 @@ version = info.get('version', '0.0.1')
|
|||
major_version, minor_version, _ = version.split('.', 2)
|
||||
major_version = int(major_version)
|
||||
minor_version = int(minor_version)
|
||||
name = 'trytonzz_product_special_price'
|
||||
download_url = 'https://bitbucket.org/zikzakmedia/trytond-product_special_price'
|
||||
|
||||
requires = []
|
||||
for dep in info.get('depends', []):
|
||||
|
@ -50,27 +54,40 @@ for dep in info.get('depends', []):
|
|||
requires.append(get_require_version('trytond'))
|
||||
|
||||
tests_require = []
|
||||
dependency_links = []
|
||||
series = '%s.%s' % (major_version, minor_version)
|
||||
if minor_version % 2:
|
||||
branch = 'default'
|
||||
else:
|
||||
branch = series
|
||||
dependency_links = [
|
||||
('hg+https://bitbucket.org/zikzakmedia/'
|
||||
'trytond-sale_shop@%(branch)s'
|
||||
'#egg=trytonzz-sale_shop-%(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=name,
|
||||
setup(name='%s_%s' % (PREFIX, MODULE),
|
||||
version=version,
|
||||
description='Tryton Product Special Price Module',
|
||||
long_description=read('README'),
|
||||
author='Zikzakmedia SL',
|
||||
author_email='zikzak@zikzakmedia.com',
|
||||
url='https://bitbucket.org/zikzakmedia/',
|
||||
download_url=download_url,
|
||||
download_url='https://bitbucket.org/zikzakmedia/trytond-%s' % MODULE,
|
||||
keywords='',
|
||||
package_dir={'trytond.modules.product_special_price': '.'},
|
||||
package_dir={'trytond.modules.%s' % MODULE: '.'},
|
||||
packages=[
|
||||
'trytond.modules.product_special_price',
|
||||
'trytond.modules.product_special_price.tests',
|
||||
'trytond.modules.%s' % MODULE,
|
||||
'trytond.modules.%s.tests' % MODULE,
|
||||
],
|
||||
package_data={
|
||||
'trytond.modules.product_special_price': (info.get('xml', [])
|
||||
'trytond.modules.%s' % MODULE: (info.get('xml', [])
|
||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.odt',
|
||||
'icons/*.svg', 'tests/*.rst']),
|
||||
},
|
||||
|
@ -97,9 +114,9 @@ setup(name=name,
|
|||
'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 :: Implementation :: CPython',
|
||||
'Programming Language :: Python :: Implementation :: PyPy',
|
||||
'Topic :: Office/Business',
|
||||
|
@ -110,8 +127,8 @@ setup(name=name,
|
|||
zip_safe=False,
|
||||
entry_points="""
|
||||
[trytond.modules]
|
||||
product_special_price = trytond.modules.product_special_price
|
||||
""",
|
||||
%s = trytond.modules.%s
|
||||
""" % (MODULE, MODULE),
|
||||
test_suite='tests',
|
||||
test_loader='trytond.test_loader:Loader',
|
||||
tests_require=tests_require,
|
||||
|
|
2
shop.py
2
shop.py
|
@ -19,7 +19,7 @@ class SaleShop:
|
|||
], 'Special Price', states={
|
||||
'required': Eval('special_price', True),
|
||||
}, depends=['special_price'])
|
||||
special_pricelist = fields.Many2One('product.price_list',
|
||||
special_pricelist = fields.Many2One('product.price_list',
|
||||
'Special Pricelist', states={
|
||||
'required': Eval('type_special_price') == 'pricelist',
|
||||
}, depends=['type_special_price'])
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# This file is part of product_special_price module for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
|
||||
from .test_product_special_price import suite
|
||||
try:
|
||||
from trytond.modules.product_special_price.tests.test_product_special_price import suite
|
||||
except ImportError:
|
||||
from .test_product_special_price import suite
|
||||
|
||||
__all__ = ['suite']
|
||||
|
|
|
@ -15,4 +15,4 @@ def suite():
|
|||
suite = trytond.tests.test_tryton.suite()
|
||||
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
|
||||
ProductSpecialPriceTestCase))
|
||||
return suite
|
||||
return suite
|
||||
|
|
7
tox.ini
7
tox.ini
|
@ -1,12 +1,13 @@
|
|||
[tox]
|
||||
envlist = {py27,py33,py34,py35}-{sqlite,postgresql,mysql},pypy-{sqlite,postgresql}
|
||||
envlist = {py27,py34,py35,py36}-{sqlite,postgresql,mysql},pypy-{sqlite,postgresql}
|
||||
|
||||
[testenv]
|
||||
commands = {envpython} setup.py test
|
||||
deps =
|
||||
{py27,py33,py34,py35}-postgresql: psycopg2 >= 2.5
|
||||
{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://}
|
||||
|
@ -14,4 +15,4 @@ setenv =
|
|||
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/ {opts} {packages}
|
||||
install_command = pip install --pre --find-links https://trydevpi.tryton.org/ --process-dependency-links {opts} {packages}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=4.1.0
|
||||
version=4.7.0
|
||||
depends:
|
||||
product_price_list
|
||||
sale_shop
|
||||
|
|
Loading…
Reference in New Issue