OK. I didn't included your test as is, but added a new version of
testPackingList with a float value.
Of course, it also shows the same issue.
Thanks.
Post by Åukasz K. NowakDnia 24-05-2007, czw o godzinie 18:52 +0200, Romain Courteaud
(...)
Post by Romain CourteaudThanks for your unit test, it's really good to quickly check.
It may be good to add it in the standard ERP5 tests, but as you didn't
specify the license of your test, I can not do anything with it.
Can you please add an licence header to your code, in order to let use
now if we can add it.
Ok, sure, it is GPL of course. Attached full file with license.
Luke
--
??ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...''
##############################################################################
#
# Copyright (c) 2007 ZPUH Ventis s.c. All Rights Reserved.
# Lukasz Nowak <lukasz.nowak at ventis.com.pl>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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 the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import os, sys
execfile(os.path.join(sys.path[0], 'framework.py'))
# Needed in order to have a log file inside the current folder
os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log')
os.environ['EVENT_LOG_SEVERITY'] = '-300'
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.Sequence import Sequence, SequenceList
from Testing import ZopeTestCase
from DateTime import DateTime
"""
Test for some rounding.
"""
organisations = {}
products = {}
currencies = {}
# float_number = 60.0 # with such value I'm able to pack SPL
float_number = 59.333333333333336 # with such - it is not possible
run_all_test = 1
return "VentisSPLPackingRounding"
"""
"""
return ('erp5_base','erp5_pdm', 'erp5_trade',)
self.login()
self.portal = self.getPortal()
self.tic()
self.createOrganisations()
self.createProducts()
self.createCurrencies()
uf = self.getPortal().acl_users
uf._doAddUser('rc', '',
['Manager', 'Member', 'Assignor', 'Assignee', 'Associate', 'Author','Auditor'], [])
user = uf.getUserById('rc').__of__(uf)
newSecurityManager(None, user)
module = self.getPortal().getDefaultModule(portal_type=portal_type)
data_kw['portal_type'] = portal_type
object = module.newContent(**data_kw)
get_transaction().commit()
self.tic()
return object
organisation = self.createObject('Organisation',{'title':title})
organisation.validate()
self.stepTic()
self.organisations[title] = organisation
product_kw = {'title':'productA'}
product = self.createObject('Product',product_kw)
product.validate()
self.stepTic()
self.products[product_kw['title']] = product
currency_kw = {
'title' : 'Euro',
'reference' : 'EUR',
'base_unit_quantity' : '2.0',
}
currency = self.createObject('Currency',currency_kw)
self.currencies[currency_kw['reference']] = currency
return {
'source_value' : self.organisations['producer_warehouse'],
'source_section_value' : self.organisations['producer'],
'destination_value' : self.organisations['customer_warehouse'],
'destination_section_value' : self.organisations['customer'],
'price_currency_value' : self.currencies['EUR'],
}
def modifyOrderState(self, transition_name, sequence=None,
sequence_list=None, order_name='order',
order = sequence.get(order_name)
order.portal_workflow.doActionFor(order, transition_name, \
wf_id=order_workflow)
#
# STEPS
#
get_transaction().commit()
self.tic()
import pdb
pdb.set_trace()
order_kw = {
'comment' : 'Simple Order',
'start_date' : DateTime('2007/01/01'),
'stop_date' : DateTime('2007/01/15'),
}
order_kw.update(self.getTypicalOrderDataKW())
order = self.createObject('Sale Order',order_kw)
line_list = [
{
'resource_value' : self.products['productA'],
'quantity' : self.float_number,
'price' : 100.0,
},
]
l = self.createObject('Sale Order Line',line_kw,order)
sequence.edit(simple_order = order)
order = sequence.get('simple_order')
spl = order.getCausalityRelatedValueList(portal_type='Sale Packing List')[0]
container = self.createObject('Container',{},spl)
container_line_kw = {
'resource_value' : self.products['productA'],
'quantity' : self.float_number,
}
container_line = self.createObject('Container Line',container_line_kw,container)
order = sequence.get('simple_order')
spl = order.getCausalityRelatedValueList(portal_type='Sale Packing List')[0]
self.assertEquals(spl.isPacked(),1) # why not packed? is it a bug?
self.modifyOrderState('order_action', sequence=sequence, order_name = 'simple_order')
self.modifyOrderState('confirm_action', sequence=sequence, order_name = 'simple_order')
#
# TESTS
#
"""
Checking for packing with rounding.
"""
if not run: return
sequence_list = SequenceList()
sequence_string = """
stepCreateSimpleOrder
stepTic
stepOrderSimpleOrder
stepTic
stepConfirmSimpleOrder
stepTic
stepPackSPL
stepTic
stepCheckSPLisPacked
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
framework()
import unittest
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVentisSPLPackingRounding))
return suite
_______________________________________________
Erp5-dev mailing list
Erp5-dev at erp5.org
http://erp5.org/mailman/listinfo/erp5-dev