Migrate to 3.6

This commit is contained in:
Sergio Morillo 2015-04-29 21:13:04 +02:00
parent e8774bd82e
commit ce3bf8e3ae
11 changed files with 266 additions and 29 deletions

View File

@ -1,2 +1 @@
Version 3.2.1 - 2014-07-20
* Initial release

View File

@ -1,4 +1,4 @@
Copyright (C) 2014 Datalife S.Coop.
Copyright (C) 2014 NaN·tic
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

16
INSTALL
View File

@ -1,19 +1,16 @@
Installing trytond-stock_storage_space
==========================================
Installing
==========
Prerequisites
-------------
* Python 2.7 or later (http://www.python.org/)
* trytond (http://www.tryton.org/)
* trytond-stock (http://www.tryton.org/)
* see setup.py file
Installation
------------
Once you've downloaded and unpacked the
trytond-stock_storage_space source release, enter the directory
where the archive was unpacked, and run:
Once you've downloaded and unpacked the source release, enter the
directory where the archive was unpacked, and run:
python setup.py install
@ -27,5 +24,4 @@ documentation:
http://peak.telecommunity.com/DevCenter/EasyInstall
http://docs.python.org/inst/inst.html
To use without installation, extract the archive into ``trytond/modules`` with
the directory name party.
To use without installation, extract the archive into ``trytond/modules``.

View File

@ -6,4 +6,8 @@ include LICENSE
include tryton.cfg
include *.xml
include view/*.xml
include *.odt
include locale/*.po
include doc/*
include icons/*
include tests/*.rst

21
README
View File

@ -1,7 +1,7 @@
trytond-stock_storage_space
===============================
The stock_storage_space module of the Tryton application platform.
This Module runs with the Tryton application platform.
This module is developed and tested over a Tryton server and core modules.
Installing
----------
@ -12,13 +12,14 @@ Support
-------
If you encounter any problems with this module, please don't hesitate to ask
questions on the Datalife bug tracker, mailing list, wiki or IRC channel:
questions on the Tryton bug tracker, mailing list,
wiki or IRC channel:
http://bugs.tryton.org/
http://groups.tryton.org/
http://wiki.tryton.org/
irc://irc.freenode.net/tryton
http://bitbucket.org/datalife_sco
* http://doc.tryton-erp.es/
* http://bitbucket.org/datalife_sco/trytond-stock_storage_space
* http://groups.tryton.org/
* http://wiki.tryton.org/
* irc://irc.freenode.net/tryton
License
-------
@ -33,4 +34,4 @@ See COPYRIGHT
For more information please visit the Datalife web site:
http://www.datalife.com.es
http://www.datalife.com.es/

99
setup.py Normal file
View File

@ -0,0 +1,99 @@
#!/usr/bin/env python
# encoding: utf-8
from setuptools import setup
import re
import os
import ConfigParser
MODULE = 'stock_storage_space'
PREFIX = 'datalife'
MODULE2PREFIX = {}
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
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.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()
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):
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(get_require_version('trytond'))
tests_require = [get_require_version('proteus')]
setup(name='%s_%s' % (PREFIX, MODULE),
version=version,
description='',
long_description=read('README'),
author='NaN·tic',
author_email='info@nan-tic.com',
url='http://www.nan-tic.com/',
download_url="https://bitbucket.org/datalife/trytond-%s" % MODULE,
package_dir={'trytond.modules.%s' % MODULE: '.'},
packages=[
'trytond.modules.%s' % MODULE,
'trytond.modules.%s.tests' % MODULE,
],
package_data={
'trytond.modules.%s' % MODULE: (info.get('xml', [])
+ ['tryton.cfg', 'locale/*.po', 'tests/*.rst']),
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Plugins',
'Framework :: Tryton',
'Intended Audience :: Developers',
'Intended Audience :: Financial and Insurance Industry',
'Intended Audience :: Legal Industry',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Natural Language :: Bulgarian',
'Natural Language :: Catalan',
'Natural Language :: Czech',
'Natural Language :: Dutch',
'Natural Language :: English',
'Natural Language :: French',
'Natural Language :: German',
'Natural Language :: Russian',
'Natural Language :: Spanish',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Office/Business',
],
license='GPL-3',
install_requires=requires,
zip_safe=False,
entry_points="""
[trytond.modules]
%s = trytond.modules.%s
""" % (MODULE, MODULE),
test_suite='tests',
test_loader='trytond.test_loader:Loader',
tests_require=tests_require,
)

View File

@ -49,7 +49,8 @@ class Location:
depends=['type', 'control_space'])
available_space = fields.Function(fields.Float('Available space at date'), 'get_available_space')
space = fields.Function(fields.Float('Space capacity',
digits=(16, Eval('width_digits', 2))),
digits=(16, Eval('space_unit_digits', 2)),
depends=['space_unit_digits']),
'get_space')
space_unit = fields.Function(
fields.Many2One('product.uom', 'Space UOM',
@ -110,10 +111,10 @@ class Location:
@fields.depends('control_space')
def on_change_control_space(self):
if not self.control_space:
return {}
return {'space_measure': 'length',
'overload_behavior': 'warn',
'space_unit': self.get_space_unit()}
return
self.space_measure = 'length'
self.overload_behavior = 'warn'
self.space_unit = self.get_space_unit()
def get_space_unit(self, name=None):
pool = Pool()
@ -296,7 +297,7 @@ class Move:
Product = pool.get('product.product')
if 'location' not in grouping:
raise ValueError('Grouping param has no field "location"')
raise ValueError('Grouping param has not field "location"')
if len(grouping) > 1 and 'date' not in grouping:
raise ValueError('Given grouping fields are not supported (%s)' % grouping)

3
tests/__init__.py Normal file
View File

@ -0,0 +1,3 @@
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
from .test_storage_space import suite

View File

@ -0,0 +1,110 @@
=============
Storage space
=============
Imports::
>>> import datetime
>>> from dateutil.relativedelta import relativedelta
>>> from decimal import Decimal
>>> from trytond.modules.company.tests.tools import create_company, \
... get_company
>>> from trytond.exceptions import UserError, UserWarning
>>> from proteus import config, Model, Wizard
>>> today = datetime.date.today()
Create database::
>>> config = config.set_trytond()
>>> config.pool.test = True
Install stock storage space Module::
>>> Module = Model.get('ir.module.module')
>>> module, = Module.find([('name', '=', 'stock_storage_space')])
>>> module.click('install')
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
Create company::
>>> _ = create_company()
>>> company = get_company()
Reload the context::
>>> User = Model.get('res.user')
>>> config._context = User.get_preferences(True, config.context)
Create product::
>>> ProductUom = Model.get('product.uom')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> ProductTemplate = Model.get('product.template')
>>> Product = Model.get('product.product')
>>> ProductCategory = Model.get('product.category')
>>> category = ProductCategory(name='Category 1')
>>> category.save()
>>> template = ProductTemplate()
>>> product = Product()
>>> template.name = 'Tray'
>>> template.type = 'goods'
>>> template.category = category
>>> template.default_uom = unit
>>> template.list_price = Decimal(10)
>>> template.cost_price = Decimal(5)
>>> template.occupy_space = True
>>> template.save() # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
UserError: ...
>>> template.length = Decimal(0.5)
>>> meter, = ProductUom.find([('name', '=', 'Meter')], limit=1)
>>> template.length_uom = meter
>>> template.save()
>>> product.template = template
>>> product.save()
Create locations::
>>> Location = Model.get('stock.location')
>>> storage_loc, = Location.find([('code', '=', 'STO')])
>>> input_loc, = Location.find([('code', '=', 'IN')])
>>> storage_loc.control_space = True
>>> storage_loc.save() # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
UserError: ...
>>> storage_loc.length = Decimal(20)
>>> storage_loc.length_uom = meter
>>> storage_loc.overload_behavior = 'warn'
>>> storage_loc.save()
>>> storage_loc.space
20.0
>>> storage_loc.available_space
20.0
Create moves::
>>> StockMove = Model.get('stock.move')
>>> move = StockMove()
>>> move.product = product
>>> move.uom =unit
>>> move.quantity = 41
>>> move.from_location = input_loc
>>> move.to_location = storage_loc
>>> move.company = company
>>> move.planned_date = today
>>> move.unit_price = Decimal('1')
>>> move.currency = company.currency
>>> move.save()
>>> move.click('assign') # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
UserWarning: ...
>>> move.quantity = 40
>>> move.save()
>>> move.click('assign')
>>> move.click('do')
>>> loc1.reload()
>>> loc1.available_space
0.0

View File

@ -0,0 +1,24 @@
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
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
class StorageSpaceTestCase(ModuleTestCase):
"""Test module"""
module = 'stock_storage_space'
def setUp(self):
super(StorageSpaceTestCase, self).setUp()
def suite():
suite = trytond.tests.test_tryton.suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(StorageSpaceTestCase))
suite.addTests(doctest.DocFileSuite('scenario_storage_space.rst',
setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8',
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
return suite

View File

@ -1,5 +1,5 @@
[tryton]
version=3.2.1
version=3.6.1
depends:
product_measurements
stock_location_measurements