Commit 8e9bd755 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: erp5_trade: Migrate TestOrder{Mixin} and all Unit Tests...

ZODB Components: erp5_trade: Migrate TestOrder{Mixin} and all Unit Tests inheriting from these classes.

Also, Split testInvoice to a Module Component in erp5_invoicing for Mixins used
by several other tests and Test Component in erp5_simplified_invoicing (initially
everything was migrated to erp5_invoicing but this does not work as Alarm_buildInvoice
is different in simplified and advanced invoicing).
parent db5d183b
...@@ -36,8 +36,8 @@ from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase ...@@ -36,8 +36,8 @@ from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testInvoice import TestSaleInvoiceMixin
from Products.ERP5.tests.utils import newSimulationExpectedFailure from Products.ERP5.tests.utils import newSimulationExpectedFailure
from erp5.component.module.TestInvoiceMixin import TestSaleInvoiceMixin
class TestAdvancedInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase): class TestAdvancedInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase):
"""Test methods for sale and purchase invoice. """Test methods for sale and purchase invoice.
...@@ -149,7 +149,7 @@ class TestAdvancedInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase): ...@@ -149,7 +149,7 @@ class TestAdvancedInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase):
invoice.start() invoice.start()
self.assertEqual('started', invoice.getSimulationState()) self.assertEqual('started', invoice.getSimulationState())
def stepAddInvoiceTransactionLines(self, sequence=None, sequence_list=[]): def stepAddInvoiceTransactionLines(self, sequence=None, sequence_list=None):
""" """
add some invoice and accounting lines to the invoice add some invoice and accounting lines to the invoice
""" """
...@@ -164,7 +164,7 @@ class TestAdvancedInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase): ...@@ -164,7 +164,7 @@ class TestAdvancedInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase):
id='income', source='account_module/sale', id='income', source='account_module/sale',
destination='account_module/purchase', quantity=1665) destination='account_module/purchase', quantity=1665)
def stepAddInvoiceLinesManyTransactions(self, sequence=None, sequence_list=[]): def stepAddInvoiceLinesManyTransactions(self, sequence=None, sequence_list=None):
""" """
add some invoice and accounting lines to the invoice add some invoice and accounting lines to the invoice
""" """
...@@ -384,10 +384,10 @@ class TestAdvancedInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase): ...@@ -384,10 +384,10 @@ class TestAdvancedInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase):
source_section_value=vendor, source_section_value=vendor,
destination_value=client, destination_value=client,
destination_section_value=client) destination_section_value=client)
line = invoice.newContent(portal_type=self.invoice_line_portal_type, invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=10, quantity=10,
price=3) price=3)
invoice.confirm() invoice.confirm()
self.tic() self.tic()
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testAdvancedInvoicing</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testAdvancedInvoicing</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testAdvancedInvoicing</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testAdvancedInvoicing
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_core_proxy_field_legacy
erp5_base
erp5_simulation
erp5_apparel
erp5_project
erp5_simulation_test
erp5_configurator_standard_solver
erp5_configurator_standard_accounting_template
erp5_configurator_standard_invoicing_template
erp5_configurator_standard_trade_template
\ No newline at end of file
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testOrder import TestOrderMixin from erp5.component.test.testOrder import TestOrderMixin
class TestApparelTransformation(TestOrderMixin, ERP5TypeTestCase): class TestApparelTransformation(TestOrderMixin, ERP5TypeTestCase):
""" """
......
...@@ -32,7 +32,7 @@ import unittest ...@@ -32,7 +32,7 @@ import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testOrder import TestOrderMixin from erp5.component.test.testOrder import TestOrderMixin
from Products.ERP5.tests.utils import newSimulationExpectedFailure from Products.ERP5.tests.utils import newSimulationExpectedFailure
class TestProductionOrderApparelMixin(TestOrderMixin): class TestProductionOrderApparelMixin(TestOrderMixin):
......
##############################################################################
#
# Copyright (c) 2004-2008 Nexedi SA and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com>
# Jerome Perrin <jerome@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility 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
# guarantees 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.
#
##############################################################################
from Products.DCWorkflow.DCWorkflow import ValidationFailed
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Acquisition import aq_parent
from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList
from erp5.component.test.testPackingList import TestPackingListMixin
class TestInvoiceMixin(TestPackingListMixin):
"""Test methods for invoices
"""
default_region = "europe/west/france"
vat_gap = 'fr/pcg/4/44/445/4457/44571'
vat_rate = 0.196
sale_gap = 'fr/pcg/7/70/707/7071/70712'
customer_gap = 'fr/pcg/4/41/411'
bank_gap = 'fr/pcg/5/51/512'
mail_delivery_mode = 'by_mail'
cpt_incoterm = 'cpt'
unit_piece_quantity_unit = 'unit/piece'
mass_quantity_unit = 'mass/kg'
oldMailhost = None
# (account_id, account_gap, account_type)
account_definition_list = (
('receivable_vat', vat_gap, 'liability/payable/collected_vat',),
('sale', sale_gap, 'income'),
('customer', customer_gap, 'asset/receivable'),
('refundable_vat', vat_gap, 'asset/receivable/refundable_vat'),
('purchase', sale_gap, 'expense'),
('supplier', customer_gap, 'liability/payable'),
('bank', bank_gap, 'asset/cash/bank'),
)
# (line_id, source_account_id, destination_account_id, line_quantity)
transaction_line_definition_list = (
('income', 'sale', 'purchase', 1.0),
('receivable', 'customer', 'supplier', -1.0 - vat_rate),
('collected_vat', 'receivable_vat', 'refundable_vat', vat_rate),
)
def getTitle(self):
return "Invoices"
def getBusinessTemplateList(self):
return super(TestInvoiceMixin, self).getBusinessTemplateList() + (
'erp5_accounting', 'erp5_invoicing', 'erp5_simplified_invoicing',
'erp5_configurator_standard_accounting_template',
'erp5_configurator_standard_invoicing_template')
@UnrestrictedMethod
def createCategories(self):
"""Create the categories for our test. """
# pull in the TestOrderMixin categories first
super(TestInvoiceMixin, self).createCategories()
for cat_string in self.getNeededCategoryList() :
base_cat = cat_string.split("/")[0]
path = self.getPortal().portal_categories[base_cat]
for cat in cat_string.split("/")[1:] :
if not cat in path.objectIds() :
path = path.newContent(
portal_type='Category',
id=cat,)
else:
path = path[cat]
# check categories have been created
for cat_string in self.getNeededCategoryList() :
self.assertNotEquals(None,
self.getCategoryTool().restrictedTraverse(cat_string),
cat_string)
def getNeededCategoryList(self):
"""return a list of categories that should be created."""
return ('region/%s' % self.default_region,
'gap/%s' % self.vat_gap,
'gap/%s' % self.sale_gap,
'gap/%s' % self.customer_gap,
'gap/%s' % self.bank_gap,
'delivery_mode/%s' % self.mail_delivery_mode,
'incoterm/%s' % self.cpt_incoterm,
'quantity_unit/%s' % self.unit_piece_quantity_unit,
'quantity_unit/%s' % self.mass_quantity_unit,
'base_amount/tax1',
'base_amount/tax2',
'base_amount/tax3',
'use/trade/tax',
)
def afterSetUp(self):
self.createUser('test_user',
['Assignee', 'Assignor', 'Member',
'Associate', 'Auditor', 'Author'])
self.createUser('manager', ['Manager'])
self.loginByUserName('manager')
self.createCategories()
self.validateRules()
self.createBusinessProcess()
self.loginByUserName('test_user')
def beforeTearDown(self):
self.abort()
self.loginByUserName('manager')
super(TestInvoiceMixin, self).beforeTearDown()
for folder in (self.portal.accounting_module,
self.portal.organisation_module,
self.portal.sale_order_module,
self.portal.purchase_order_module,
self.portal.sale_packing_list_module,
self.portal.purchase_packing_list_module,
self.portal.portal_simulation,):
folder.manage_delObjects([x for x in folder.objectIds() if x not in ('organisation_1','organisation_2','ppl_1','ppl_2')])
self.tic()
def stepCreateSaleInvoiceTransactionRule(self, sequence, **kw) :
pass # see createBusinessProcess
## XXX move this to "Sequence class"
def playSequence(self, sequence_string, quiet=0) :
sequence_list = SequenceList()
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
def createBusinessProcess(self):
portal = self.portal
business_process_id = self.__class__.__name__
try:
business_process = portal.business_process_module[business_process_id]
except KeyError:
business_process = portal.business_process_module.newContent(
business_process_id, 'Business Process',
specialise=self.__class__.business_process)
kw = dict(portal_type='Trade Model Path',
trade_phase='default/accounting',
trade_date='trade_phase/default/invoicing',
membership_criterion_base_category_list=('destination_region',
'product_line'),
membership_criterion_category=(
'destination_region/region/' + self.default_region,
'product_line/apparel'))
account_module = portal.account_module
for account_id, account_gap, account_type in self.account_definition_list:
if not account_module.has_key(account_id):
account = account_module.newContent(account_id, gap=account_gap,
account_type=account_type)
account.validate()
for line_id, line_source_id, line_destination_id, line_ratio in \
self.transaction_line_definition_list:
trade_model_path = business_process.newContent(
reference='accounting_' + line_id,
efficiency=line_ratio,
source_value=account_module[line_source_id],
destination_value=account_module[line_destination_id],
**kw)
# A trade model path already exist for root simulation movements
# (Accounting Transaction Root Simulation Rule).
# The ones we are creating are for Invoice Transaction Simulation Rule.
trade_model_path._setCriterionPropertyList(('portal_type',))
trade_model_path.setCriterion('portal_type', 'Simulation Movement')
self.business_process = business_process.getRelativeUrl()
def stepCreateEntities(self, sequence, **kw) :
"""Create a vendor and two clients. """
self.stepCreateOrganisation1(sequence, **kw)
self.stepCreateOrganisation2(sequence, **kw)
self.stepCreateOrganisation3(sequence, **kw)
self.stepCreateProject1(sequence, **kw)
self.stepCreateProject2(sequence, **kw)
vendor = sequence.get('organisation1')
vendor.setRegion(self.default_region)
vendor.validate()
sequence.edit(vendor=vendor)
client1 = sequence.get('organisation2')
client1.setRegion(self.default_region)
self.assertNotEquals(client1.getRegionValue(), None)
client1.validate()
sequence.edit(client1=client1)
client2 = sequence.get('organisation3')
self.assertEqual(client2.getRegionValue(), None)
client2.validate()
sequence.edit(client2=client2)
def stepCheckOrderRule(self, sequence=None, sequence_list=None, **kw):
"""Check we have a related Order Rule"""
order = sequence.get('order')
simulation_tool = self.getSimulationTool()
# Check that there is an applied rule for our packing list
rule_list = [x for x in simulation_tool.objectValues()
if x.getCausalityValue()==order]
self.assertNotEquals(len(rule_list), 0)
sequence.edit(order_rule_list = rule_list)
self.assertEqual(len(order.getMovementList()),
sum([len(rule.objectIds()) for rule in rule_list]))
def stepCheckInvoicingRule(self, sequence=None, sequence_list=None, **kw):
"""
Checks that the invoicing rule is applied and its values are correct.
"""
order_rule_list = sequence.get('order_rule_list')
invoicing_rule_list = []
invoice_transaction_rule_list = []
for order_rule in order_rule_list :
for order_simulation_movement in order_rule.objectValues() :
temp_invoicing_rule_list = [ar for ar in order_simulation_movement.objectValues()[0].objectValues()[0].objectValues()
if ar.getSpecialiseValue().getPortalType() == 'Invoice Simulation Rule']
self.assertEqual(len(temp_invoicing_rule_list), 1)
invoicing_rule_list.extend(temp_invoicing_rule_list)
sequence.edit(invoicing_rule_list=invoicing_rule_list)
invoicing_rule = invoicing_rule_list[0]
sequence.edit(invoicing_rule = invoicing_rule)
for invoicing_rule in invoicing_rule_list:
self.assertEqual(invoicing_rule.getSpecialiseReference(),
'default_invoicing_rule')
self.assertEqual(invoicing_rule.getPortalType(),
'Applied Rule')
simulation_movement_list = invoicing_rule.objectValues()
self.assertNotEquals(len(simulation_movement_list), 0)
for simulation_movement in simulation_movement_list :
invoice_transaction_rule_list.extend([applied_rule for applied_rule
in simulation_movement.objectValues() if applied_rule \
.getSpecialiseValue().getPortalType()
== 'Invoice Transaction Simulation Rule'])
resource_list = sequence.get('resource_list')
self.assertEqual(simulation_movement.getPortalType(),
'Simulation Movement')
self.assertTrue(simulation_movement.getResourceValue() in
resource_list)
self.assertTrue(simulation_movement.isConvergent())
# TODO: What is the invoice dates supposed to be ?
# is this done through profiles ?
#self.assertEqual(simulation_movement.getStartDate(),
# sequence.get('order').getStartDate())
#self.assertEqual(simulation_movement.getStopDate(),
# sequence.get('order').getStopDate())
sequence.edit(invoice_transaction_rule_list=invoice_transaction_rule_list)
def stepCheckInvoiceTransactionRule(self, sequence=None, sequence_list=None,
**kw):
"""
Checks that the applied invoice_transaction_rule is expanded and its movements are
consistent with its parent movement
"""
invoice_transaction_rule_list = \
sequence.get('invoice_transaction_rule_list')
for applied_invoice_transaction_rule in invoice_transaction_rule_list:
parent_movement = aq_parent(applied_invoice_transaction_rule)
self.assertEqual(3, len(applied_invoice_transaction_rule.objectValues()))
for _, line_source_id, line_destination_id, line_ratio in \
self.transaction_line_definition_list:
movement = None
for simulation_movement in \
applied_invoice_transaction_rule.objectValues():
if simulation_movement.getSourceId() == line_source_id and\
simulation_movement.getDestinationId() == line_destination_id:
movement = simulation_movement
break
self.assertTrue(movement is not None)
self.assertEqual(movement.getCorrectedQuantity(), parent_movement.getPrice() *
parent_movement.getCorrectedQuantity() * line_ratio)
self.assertEqual(movement.getStartDate(),
parent_movement.getStartDate())
self.assertEqual(movement.getStopDate(),
parent_movement.getStopDate())
def modifyPackingListState(self, transition_name,
sequence,packing_list=None):
""" calls the workflow for the packing list """
if packing_list is None:
packing_list = sequence.get('packing_list')
packing_list.portal_workflow.doActionFor(packing_list, transition_name)
def stepSetReadyPackingList(self, sequence=None, sequence_list=None, **kw):
""" set the Packing List as Ready. This must build the invoice. """
self.modifyPackingListState('set_ready_action', sequence=sequence)
packing_list = sequence.get('packing_list')
self.assertEqual(packing_list.getSimulationState(), 'ready')
def stepSetReadyNewPackingList(self, sequence=None,
sequence_list=None, **kw):
""" set the Packing List as Ready. This must build the invoice. """
packing_list = sequence.get('new_packing_list')
self.modifyPackingListState('set_ready_action', sequence=sequence,
packing_list=packing_list)
self.assertEqual(packing_list.getSimulationState(), 'ready')
def stepStartPackingList(self, sequence=None, sequence_list=None, **kw):
self.modifyPackingListState('start_action', sequence=sequence)
packing_list = sequence.get('packing_list')
self.assertEqual(packing_list.getSimulationState(), 'started')
def stepStartNewPackingList(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('new_packing_list')
self.modifyPackingListState('start_action', sequence=sequence,
packing_list=packing_list)
self.assertEqual(packing_list.getSimulationState(), 'started')
def stepStopPackingList(self, sequence=None, sequence_list=None, **kw):
self.modifyPackingListState('stop_action', sequence=sequence)
packing_list = sequence.get('packing_list')
self.assertEqual(packing_list.getSimulationState(), 'stopped')
def stepDeliverPackingList(self, sequence=None, sequence_list=None, **kw):
self.modifyPackingListState('deliver_action', sequence=sequence)
packing_list = sequence.get('packing_list')
self.assertEqual(packing_list.getSimulationState(), 'delivered')
def stepCancelPackingList(self, sequence=None, sequence_list=None, **kw):
self.modifyPackingListState('cancel_action', sequence=sequence)
packing_list = sequence.get('packing_list')
self.assertEqual(packing_list.getSimulationState(), 'cancelled')
def modifyInvoiceState(self, transition_name,
sequence,invoice=None):
""" calls the workflow for the invoice """
if invoice is None:
invoice = sequence.get('invoice')
invoice.portal_workflow.doActionFor(invoice, transition_name)
def stepStartInvoice(self, sequence=None, sequence_list=None, **kw):
self.modifyInvoiceState('start_action', sequence=sequence)
invoice = sequence.get('invoice')
self.assertEqual(invoice.getSimulationState(), 'started')
def stepStartNewInvoice(self, sequence=None, sequence_list=None, **kw):
invoice = sequence.get('new_invoice')
self.modifyInvoiceState('start_action', sequence=sequence,
invoice=invoice)
self.assertEqual(invoice.getSimulationState(), 'started')
def stepStopInvoice(self, sequence=None, sequence_list=None, **kw):
self.modifyInvoiceState('stop_action', sequence=sequence)
invoice = sequence.get('invoice')
self.assertEqual(invoice.getSimulationState(), 'stopped')
def stepDeliverInvoice(self, sequence=None, sequence_list=None, **kw):
self.modifyInvoiceState('deliver_action', sequence=sequence)
invoice = sequence.get('invoice')
self.assertEqual(invoice.getSimulationState(), 'delivered')
def stepCancelInvoice(self, sequence=None, sequence_list=None, **kw):
self.modifyInvoiceState('cancel_action', sequence=sequence)
invoice = sequence.get('invoice')
self.assertEqual(invoice.getSimulationState(), 'cancelled')
def stepSwitchPackingLists(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('packing_list')
new_packing_list = sequence.get('new_packing_list')
#invoice = new_packing_list.getDefaultCausalityRelatedValue(
#portal_type=self.invoice_portal_type)
sequence.edit(packing_list=new_packing_list,
new_packing_list=packing_list)#, invoice=invoice)
def stepSwitchInvoices(self, sequence=None, sequence_list=None, **kw):
invoice = sequence.get('invoice')
new_invoice = sequence.get('new_invoice')
sequence.edit(invoice=new_invoice, new_invoice=invoice)
def stepCheckPackingListSimulation(self, sequence=None, sequence_list=None, **kw):
""" checks that simulation movements related to the packing list are OK """
packing_list = sequence.get('packing_list')
order = sequence.get('order')
order_root_applied_rule = order.getCausalityRelatedValueList(
portal_type = 'Applied Rule')[0]
# check simulation movements from this packing list
for movement in packing_list.getMovementList() :
simulation_movement_list = movement.getOrderRelatedValueList()
self.assertNotEquals(len(simulation_movement_list), 0)
total_quantity = 0
for simulation_movement in simulation_movement_list :
total_quantity += simulation_movement.getQuantity()
# check that those movements come from the same root applied
# rule than the order.
self.assertEqual( simulation_movement.getRootAppliedRule(),
order_root_applied_rule)
self.assertEqual(total_quantity, movement.getQuantity())
def checkMirrorAcquisition(self, obj, acquired_object):
"""
Check if properties are well acquired for mirrored case
"""
# packing_list_movement, simulation_movement
self.assertEqual(acquired_object.getStartDate(), obj.getStopDate())
self.assertEqual(acquired_object.getStopDate(), obj.getStartDate())
self.assertEqual(acquired_object.getSourceValue(), \
obj.getDestinationValue())
self.assertEqual(acquired_object.getDestinationValue(), \
obj.getSourceValue())
self.assertEqual(acquired_object.getSourceSectionValue(), \
obj.getDestinationSectionValue())
self.assertEqual(acquired_object.getDestinationSectionValue(), \
obj.getSourceSectionValue())
def stepCheckInvoiceBuilding(self, sequence=None, sequence_list=None, **kw):
"""
checks that the invoice is built with the default_invoice_builder
"""
packing_list = sequence.get('packing_list')
related_invoice_list = packing_list.getCausalityRelatedValueList(
portal_type=self.invoice_portal_type)
if packing_list.getPortalType() == 'Purchase Packing List':
packing_list_building_state = 'stopped'
else:
packing_list_building_state = 'started'
packing_list_state = packing_list.getSimulationState()
if packing_list_state != packing_list_building_state :
self.assertEqual(0, len(related_invoice_list))
else:
self.assertEqual(1, len(related_invoice_list))
invoice = related_invoice_list[0].getObject()
self.assertTrue(invoice is not None)
# Invoices created by Delivery Builder are in confirmed state
self.assertEqual(invoice.getSimulationState(), 'confirmed')
# Get the list of simulation movements of packing list ...
packing_list_simulation_movement_list = []
for packing_list_movement in packing_list.getMovementList():
packing_list_simulation_movement_list.extend(
packing_list_movement.getDeliveryRelatedValueList())
# ... invoice simulation movement are their childrens.
simulation_movement_list = []
for p_l_simulation_movement in packing_list_simulation_movement_list :
for applied_rule in p_l_simulation_movement.objectValues() :
simulation_movement_list.extend(applied_rule.objectValues())
# First, test if each Simulation Movement is related to an
# Invoice Movement
invoice_relative_url = invoice.getRelativeUrl()
for simulation_movement in simulation_movement_list:
invoice_movement_list = simulation_movement.getDeliveryValueList()
self.assertEqual(len(invoice_movement_list), 1)
invoice_movement = invoice_movement_list[0]
self.assertTrue(invoice_movement is not None)
self.assert_(invoice_movement.getRelativeUrl().\
startswith(invoice_relative_url))
# Then, test if each Invoice movement is equals to the sum of somes
# Simulation Movements
for invoice_movement in invoice.getMovementList(portal_type = [
self.invoice_cell_portal_type,
self.invoice_line_portal_type]) :
related_simulation_movement_list = invoice_movement.\
getDeliveryRelatedValueList(portal_type='Simulation Movement')
quantity = 0
total_price = 0
invoice_movement_quantity = invoice_movement.getQuantity()
for related_simulation_movement in related_simulation_movement_list:
quantity += related_simulation_movement.getQuantity()
total_price += related_simulation_movement.getPrice() *\
related_simulation_movement.getQuantity()
# Test resource
self.assertEqual(invoice_movement.getResource(), \
related_simulation_movement.getResource())
# Test resource variation
self.assertEqual(invoice_movement.getVariationText(), \
related_simulation_movement.getVariationText())
self.assertEqual(invoice_movement.getVariationCategoryList(), \
related_simulation_movement.getVariationCategoryList())
# Test acquisition
self.checkAcquisition(invoice_movement,
related_simulation_movement)
# Test delivery ratio
self.assertEqual(related_simulation_movement.getQuantity() /\
invoice_movement_quantity, \
related_simulation_movement.getDeliveryRatio())
self.assertEqual(quantity, invoice_movement.getQuantity())
# Test price
self.assertEqual(total_price / quantity, invoice_movement.getPrice())
sequence.edit(invoice = invoice)
# Test causality
self.assertEqual(len(invoice.getCausalityValueList(
portal_type = self.packing_list_portal_type)), 1)
self.assertEqual(invoice.getCausalityValue(), packing_list)
# Finally, test getTotalQuantity and getTotalPrice on Invoice
self.assertEqual(packing_list.getTotalQuantity(),
invoice.getTotalQuantity())
self.assertEqual(packing_list.getTotalPrice(),
invoice.getTotalPrice())
def stepCheckInvoicesConsistency(self, sequence=None, sequence_list=None,
**kw):
"""
Checks that all invoices are consistent:
- transaction lines match invoice lines
- no movement is divergent
"""
invoice_list = self.getPortal()['accounting_module'].objectValues()
for invoice in invoice_list:
accounting_state_list = \
list(self.getPortal().getPortalCurrentInventoryStateList())
accounting_state_list.append('cancelled')
if invoice.getSimulationState() in accounting_state_list:
invoice_line_list = invoice.contentValues(
portal_type=self.invoice_line_portal_type)
invoice_transaction_line_list = invoice.contentValues(
portal_type=self.invoice_transaction_line_portal_type)
self.assertEqual(3, len(invoice_transaction_line_list))
expected_price = 0.0
for line in invoice_line_list:
expected_price += line.getTotalPrice()
for line_id, line_source, line_dest, line_ratio in \
self.transaction_line_definition_list:
for line in invoice.contentValues(
portal_type=self.invoice_transaction_line_portal_type):
if line.getSource() == 'account_module/%s' % line_source and \
line.getDestination() == 'account_module/%s' % line_dest:
break
else:
self.fail('No line found that matches %s' % line_id)
resource_precision = line.getResourceValue().getQuantityPrecision()
self.assertEqual(round(line.getQuantity(), resource_precision),
round(expected_price * line_ratio, resource_precision))
def stepCheckInvoiceLineHasReferenceAndIntIndex(self, sequence=None, **kw):
"""Check that the unique invoice line in the invoice has reference and int
index.
"""
invoice = sequence.get('invoice')
invoice_line_list = invoice.contentValues(
portal_type=self.invoice_line_portal_type)
self.assertEqual(1, len(invoice_line_list))
invoice_line = invoice_line_list[0]
self.assertEqual(1, invoice_line.getIntIndex())
self.assertEqual('1', invoice_line.getReference())
def stepCheckPackingListInvoice(
self, sequence=None, sequence_list=None, **kw):
""" Checks if the delivery builder is working as expected,
coping the atributes from packing list to invoice."""
packing_list = sequence.get('packing_list')
related_invoice_list = packing_list.getCausalityRelatedValueList(
portal_type=self.invoice_portal_type)
self.assertEqual(len(related_invoice_list), 1)
invoice = related_invoice_list[0]
self.assertEqual(packing_list.getSource(), invoice.getSource())
self.assertEqual(packing_list.getDestination(), invoice.getDestination())
self.assertEqual(packing_list.getDestinationSection(), \
invoice.getDestinationSection())
self.assertEqual(packing_list.getSourceSection(), \
invoice.getSourceSection())
self.assertEqual(packing_list.getDestinationDecision(), \
invoice.getDestinationDecision())
self.assertEqual(packing_list.getSourceDecision(), \
invoice.getSourceDecision())
self.assertEqual(packing_list.getDestinationAdministration(), \
invoice.getDestinationAdministration())
self.assertEqual(packing_list.getSourceAdministration(), \
invoice.getSourceAdministration())
self.assertEqual(packing_list.getDestinationProject(), \
invoice.getDestinationProject())
self.assertEqual(packing_list.getSourceProject(), \
invoice.getSourceProject())
self.assertEqual(packing_list.getPriceCurrency(), \
invoice.getPriceCurrency())
def stepCheckDeliveryRuleForDeferred(
self, sequence=None, sequence_list=None, **kw):
""" Checks that a delivery rule has been created when we took 'split
and defer' decision on the divergeant Packing List. """
# TODO
def stepCheckDeliveryRuleIsEmpty(
self, sequence=None, sequence_list=None, **kw):
""" Checks that an empty delivery rule is created for the
convergeant Packing List"""
packing_list = sequence.get('packing_list')
self.assertTrue(packing_list is not None)
simulation_tool = self.getSimulationTool()
# Check that there is an applied rule for our packing list
rule_list = [x for x in simulation_tool.objectValues()
if x.getCausalityValue()==packing_list]
self.assertEqual(len(rule_list),1)
packing_list_rule = rule_list[0]
sequence.edit(packing_list_rule=packing_list_rule)
rule_line_list = packing_list_rule.objectValues()
packing_list_line_list = packing_list.objectValues()
self.assertEqual(len(packing_list_line_list),
len(rule_line_list))
self.assertEqual(1, len(rule_line_list))
rule_line = rule_line_list[0]
packing_list_line = packing_list_line_list[0]
self.assertEqual(rule_line.getQuantity(), 10)
self.assertEqual(rule_line.getPrice(), 100)
self.assertEqual(rule_line.getDeliveryValue(),
packing_list_line)
self.assertEqual(rule_line.getStartDate(),
packing_list_line.getStartDate())
self.assertEqual(rule_line.getStopDate(),
packing_list_line.getStopDate())
self.assertEqual(rule_line.getPortalType(),
'Simulation Movement')
def stepCheckPackingList(self,sequence=None, sequence_list=None,**kw):
""" """
packing_list_module = self.getSalePackingListModule()
order = sequence.get('order')
sale_packing_list_list = []
for o in packing_list_module.objectValues():
if o.getCausalityValue() == order:
sale_packing_list_list.append(o)
self.assertEqual(len(sale_packing_list_list), 1)
sale_packing_list = sale_packing_list_list[0]
sale_packing_list_line_list = sale_packing_list.objectValues()
self.assertEqual(len(sale_packing_list_line_list),1)
sale_packing_list_line = sale_packing_list_line_list[0]
product = sequence.get('resource')
self.assertEqual(sale_packing_list_line.getResourceValue(),
product)
self.assertEqual(sale_packing_list_line.getPrice(),
self.price1)
LOG('sale_packing_list_line.showDict()',0,
sale_packing_list_line.showDict())
self.assertEqual(sale_packing_list_line.getQuantity(),
self.quantity1)
self.assertEqual(sale_packing_list_line.getTotalPrice(),
self.total_price1)
sequence.edit(packing_list = sale_packing_list)
def stepCheckTwoInvoices(self,sequence=None, sequence_list=None, **kw):
""" checks invoice properties are well set. """
# Now we will check that we have two invoices created
for x in '', 'new_':
packing_list = sequence.get(x + 'packing_list')
invoice, = packing_list.getCausalityRelatedValueList(
portal_type=self.invoice_portal_type)
self.assertEqual(invoice.getSimulationState(), 'confirmed')
sequence.set(x + 'invoice', invoice)
def stepStartTwoInvoices(self,sequence=None, sequence_list=None, **kw):
""" start both invoices. """
portal = self.getPortal()
invoice = sequence.get('invoice')
new_invoice = sequence.get('new_invoice')
portal.portal_workflow.doActionFor(invoice, 'start_action')
portal.portal_workflow.doActionFor(new_invoice, 'start_action')
def stepCheckTwoInvoicesTransactionLines(self,sequence=None,
sequence_list=None, **kw):
""" checks invoice properties are well set. """
invoice = sequence.get('invoice')
new_invoice = sequence.get('new_invoice')
self.assertEqual(3,len(invoice.objectValues(
portal_type=self.invoice_transaction_line_portal_type)))
self.assertEqual(3,len(new_invoice.objectValues(
portal_type=self.invoice_transaction_line_portal_type)))
found_dict = {}
for line in invoice.objectValues(
portal_type=self.invoice_transaction_line_portal_type):
source_id = line.getSourceId()
found_dict[source_id] = line.getQuantity()
total_price = (self.default_quantity-1) * self.default_price
expected_dict = {
'sale' : total_price,
'receivable_vat' : total_price * self.vat_rate,
'customer' : - (total_price + total_price * self.vat_rate)
}
self.failIfDifferentSet(expected_dict.keys(),found_dict.keys())
for key in found_dict.keys():
self.assertAlmostEquals(expected_dict[key],found_dict[key],places=2)
found_dict = {}
for line in new_invoice.objectValues(
portal_type=self.invoice_transaction_line_portal_type):
source_id = line.getSourceId()
found_dict[source_id] = line.getQuantity()
total_price = 1 * self.default_price
expected_dict = {
'sale' : total_price,
'receivable_vat' : total_price * self.vat_rate,
'customer' : - (total_price + total_price * self.vat_rate)
}
self.failIfDifferentSet(expected_dict.keys(), found_dict.keys())
for key in found_dict.keys():
self.assertAlmostEquals(expected_dict[key], found_dict[key], places=2)
def stepRebuildAndCheckNothingIsCreated(self, sequence=None,
sequence_list=None, **kw):
"""Rebuilds with sale_invoice_builder and checks nothing more is
created. """
accounting_module = self.portal.accounting_module
portal_type_list = ('Sale Invoice Transaction', 'Purchase Invoice Transaction')
sale_invoice_transaction_count = len(accounting_module.objectValues(
portal_type=portal_type_list))
for builder in self.getPortal().portal_deliveries.objectValues():
builder.build()
self.assertEqual(sale_invoice_transaction_count,
len(accounting_module.objectValues(
portal_type=portal_type_list)))
def stepModifyInvoicesDate(self, sequence=None,
sequence_list=None, **kw):
"""Change invoice date"""
invoice = sequence.get('invoice')
new_invoice = sequence.get('new_invoice')
invoice.edit(start_date=self.datetime,
stop_date=self.datetime+1)
new_invoice.edit(start_date=self.datetime,
stop_date=self.datetime+1)
def stepEditInvoice(self, sequence=None, sequence_list=None, **kw):
"""Edit the current invoice, to trigger updateSimulation."""
invoice = sequence.get('invoice')
invoice.edit(description='This invoice was edited!')
def stepCheckInvoiceRuleNotAppliedOnInvoiceEdit(self,
sequence=None, sequence_list=None, **kw):
"""If we call edit on the invoice, invoice rule should not be
applied on lines created by delivery builder."""
invoice = sequence.get('invoice')
self.assertEqual([], invoice.getCausalityRelatedValueList())
def stepEditPackingList(self, sequence=None, sequence_list=None, **kw):
"""Edit the current packing list, to trigger updateSimulation."""
packing_list = sequence.get('packing_list')
packing_list.edit(description='This packing list was edited!')
def stepAcceptDecisionDescriptionPackingList(self,sequence=None, sequence_list=None):
packing_list = sequence.get('packing_list')
self._solveDivergence(packing_list, 'description', 'Accept Solver')
def stepAssertCausalityStateIsNotSolvedInConsistencyMessage(self,
sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('packing_list')
self.assertEqual(
['Causality State is not "Solved". Please wait or take action'
+ ' for causality state to reach "Solved".'],
[str(message.message) for message in packing_list.checkConsistency()])
def stepSetReadyWorkflowTransitionIsBlockByConsistency(self,
sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('packing_list')
with self.assertRaisesRegexp(ValidationFailed,
'.*Causality State is not "Solved"*'):
self.getPortal().portal_workflow.doActionFor(
packing_list, 'set_ready_action')
def stepCheckDeliveryRuleNotAppliedOnPackingListEdit(self,
sequence=None, sequence_list=None, **kw):
"""If we call edit on the packing list, delivery rule should not be
applied on lines created by delivery builder."""
packing_list = sequence.get('packing_list')
self.assertEqual([], packing_list.getCausalityRelatedValueList())
def stepDecreaseInvoiceLineQuantity(self, sequence=None, sequence_list=None,
**kw):
"""
Set a decreased quantity on invoice lines
"""
invoice = sequence.get('invoice')
quantity = sequence.get('line_quantity',default=self.default_quantity)
quantity = quantity - 1
sequence.edit(line_quantity=quantity)
for invoice_line in invoice.objectValues(
portal_type=self.invoice_line_portal_type):
invoice_line.edit(quantity=quantity)
sequence.edit(last_delta = sequence.get('last_delta', 0.0) - 1.0)
def stepIncreaseInvoiceLineQuantity(self, sequence=None, sequence_list=None,
**kw):
"""
Set a Increased quantity on invoice lines
"""
invoice = sequence.get('invoice')
quantity = sequence.get('line_quantity',default=self.default_quantity)
quantity = quantity + 1
sequence.edit(line_quantity=quantity)
for invoice_line in invoice.objectValues(
portal_type=self.invoice_line_portal_type):
invoice_line.edit(quantity=quantity)
sequence.edit(last_delta = sequence.get('last_delta', 0.0) + 1.0)
def stepSetInvoiceLineQuantityToZero(self, sequence=None, sequence_list=None,
**kw):
"""
Set the quantity on invoice lines to zero
"""
invoice = sequence.get('invoice')
#default_quantity = sequence.get('line_quantity',default_quantity)
quantity = 0.0
sequence.edit(line_quantity=quantity)
for invoice_line in invoice.objectValues(
portal_type=self.invoice_line_portal_type):
invoice_line.edit(quantity=quantity)
sequence.edit(last_delta = - self.default_quantity)
def stepChangeInvoiceStartDate(self, sequence=None, sequence_list=None, **kw):
"""
Change the start_date of the invoice.
"""
invoice = sequence.get('invoice')
invoice.edit(start_date=self.datetime + 15)
def stepCheckInvoiceIsCalculating(self, sequence=None, sequence_list=None,
**kw):
"""
Test if invoice is calculating
"""
invoice = sequence.get('invoice')
self.assertEqual('calculating',invoice.getCausalityState())
def stepCheckInvoiceIsDiverged(self, sequence=None, sequence_list=None,
**kw):
"""
Test if invoice is diverged
"""
invoice = sequence.get('invoice')
self.assertEqual('diverged',invoice.getCausalityState())
def stepCheckInvoiceIsSolved(self, sequence=None, sequence_list=None,
**kw):
"""
Test if invoice is solved
"""
invoice = sequence.get('invoice')
self.assertEqual('solved', invoice.getCausalityState(),
invoice.getDivergenceList())
def stepCheckInvoiceIsDivergent(self, sequence=None, sequence_list=None,
**kw):
"""
Test if invoice is divergent
"""
invoice = sequence.get('invoice')
self.assertTrue(invoice.isDivergent())
def stepCheckInvoiceIsNotDivergent(self, sequence=None, sequence_list=None,
**kw):
"""
Test if invoice is not divergent
"""
invoice = sequence.get('invoice')
if invoice.isDivergent():
self.fail(invoice.getDivergenceList())
def stepSplitAndDeferInvoice(self, sequence=None, sequence_list=None,
**kw):
invoice = sequence.get('invoice')
solver_process = self.portal.portal_solver_processes.newSolverProcess(invoice)
quantity_solver_decision, = [x for x in solver_process.contentValues()
if x.getCausalityValue().getTestedProperty() == 'quantity']
# use Quantity Split Solver.
quantity_solver_decision.setSolverValue(self.portal.portal_solvers['Quantity Split Solver'])
# configure for Quantity Split Solver.
kw = {'delivery_solver':'FIFO Delivery Solver',
'start_date':self.datetime + 15,
'stop_date':self.datetime + 25}
quantity_solver_decision.updateConfiguration(**kw)
solver_process.buildTargetSolverList()
solver_process.solve()
def stepUnifyStartDateWithDecisionInvoice(self, sequence=None,
sequence_list=None):
invoice = sequence.get('invoice')
self._solveDivergence(invoice, 'start_date', 'Unify Solver',
value=invoice.getStartDate())
def stepAdoptPrevisionQuantityInvoice(self,sequence=None, sequence_list=None):
invoice = sequence.get('invoice')
self._solveDivergence(invoice, 'quantity', 'Adopt Solver')
def stepAcceptDecisionQuantityInvoice(self,sequence=None, sequence_list=None):
invoice = sequence.get('invoice')
self._solveDivergence(invoice, 'quantity', 'Accept Solver')
def stepAcceptDecisionInvoice(self, sequence=None, sequence_list=None,
**kw):
"""
accept decision at the invoice level
"""
invoice = sequence.get('invoice')
invoice.portal_workflow.doActionFor(invoice,'accept_decision_action')
def stepCheckInvoiceSplitted(self, sequence=None, sequence_list=None, **kw):
"""
Test if invoice was splitted
"""
packing_list = sequence.get('packing_list')
invoice_list = packing_list.getCausalityRelatedValueList(
portal_type=self.invoice_portal_type)
self.assertEqual(2,len(invoice_list))
invoice1 = None
invoice2 = None
for invoice in invoice_list:
if invoice.getUid() == sequence.get('invoice').getUid():
invoice1 = invoice
else:
invoice2 = invoice
sequence.edit(new_invoice=invoice2)
for line in invoice1.objectValues(
portal_type=self.invoice_line_portal_type):
self.assertEqual(self.default_quantity-1,line.getQuantity())
for line in invoice2.objectValues(
portal_type=self.invoice_line_portal_type):
self.assertEqual(1,line.getQuantity())
def stepCheckInvoiceNotSplitted(self, sequence=None, sequence_list=None, **kw):
"""
Test if invoice was not splitted
"""
packing_list = sequence.get('packing_list')
invoice_list = packing_list.getCausalityRelatedValueList(
portal_type=self.invoice_portal_type)
self.assertEqual(1,len(invoice_list))
invoice1 = None
for invoice in invoice_list:
if invoice.getUid() == sequence.get('invoice').getUid():
invoice1 = invoice
last_delta = sequence.get('last_delta', 0.0)
for line in invoice1.objectValues(
portal_type=self.invoice_line_portal_type):
self.assertEqual(self.default_quantity + last_delta,
line.getQuantity())
def stepAddInvoiceLines(self, sequence=None, sequence_list=None):
"""
add some invoice and accounting lines to the invoice
"""
invoice = sequence.get('invoice')
invoice.newContent(portal_type='Invoice Line',
resource_value=sequence.get('resource'), quantity=3, price=555)
invoice.newContent(portal_type='Sale Invoice Transaction Line',
id ='receivable', source='account_module/customer',
destination='account_module/supplier', quantity=-1665)
invoice.newContent(portal_type='Sale Invoice Transaction Line',
id='income', source='account_module/sale',
destination='account_module/purchase', quantity=1665)
def stepAddWrongInvoiceLines(self, sequence=None, sequence_list=None):
"""
add some wrong invoice and accounting lines to the invoice
"""
invoice = sequence.get('invoice')
invoice.newContent(portal_type='Sale Invoice Transaction Line',
id='bad_movement', source='account_module/sale',
destination='account_module/purchase', quantity=2, price=4)
invoice.newContent(portal_type='Sale Invoice Transaction Line',
id='counter_bad_movement', source='account_module/sale',
destination='account_module/purchase', quantity=-2, price=4)
for movement in invoice.getMovementList():
movement.edit(resource_value=sequence.get('resource'))
def stepCheckStartInvoiceFail(self, sequence=None, sequence_list=None):
"""
checks that it's not possible to start an invoice with really wrong
lines
"""
try:
self.tic()
except RuntimeError, exc:
invoice = sequence.get('invoice')
# check which activities are failing
self.assertTrue(str(exc).startswith('tic is looping forever.'),
'%s does not start with "tic is looping forever."' % str(exc))
msg_list = [('/'.join(x.object_path), x.method_id)
for x in self.getActivityTool().getMessageList()]
self.assertTrue((invoice.getPath(), '_localBuild') in msg_list, msg_list)
# flush failing activities
activity_tool = self.getActivityTool()
activity_tool.manageClearActivities(keep=0)
else:
self.fail("Error: stepStartInvoice didn't fail, the builder script"
+ " InvoiceTransaction_postTransactionLineGeneration should have"
+ " complained that accounting movements use multiple resources")
def stepCheckSimulationTrees(self, sequence=None, sequence_list=None):
"""
check that rules are created in the order we expect them
"""
applied_rule_set = set()
invoice = sequence.get('invoice')
for movement in invoice.getMovementList():
for sm in movement.getDeliveryRelatedValueList():
applied_rule_set.add(sm.getRootAppliedRule())
rule_dict = {
'Order Root Simulation Rule': {
'movement_type_list': ['Sale Order Line', 'Sale Order Cell'],
'next_rule_list': ['Delivery Simulation Rule', ],
},
'Delivery Simulation Rule': {
'movement_type_list': ['Sale Packing List Line', 'Sale Packing List Cell'],
'next_rule_list': ['Invoice Simulation Rule', ],
},
'Trade Model Simulation Rule': {
'next_rule_list': ['Invoice Transaction Simulation Rule'],
},
'Invoice Simulation Rule': {
'movement_type_list': invoice.getPortalInvoiceMovementTypeList() \
+ invoice.getPortalAccountingMovementTypeList(),
'next_rule_list': ['Invoice Transaction Simulation Rule', 'Payment Simulation Rule',
'Trade Model Simulation Rule'],
},
'Invoice Transaction Simulation Rule': {
'parent_movement_type_list': invoice.getPortalInvoiceMovementTypeList(),
'movement_type_list': invoice.getPortalAccountingMovementTypeList(),
'next_rule_list': ['Payment Simulation Rule'],
},
'Payment Simulation Rule': {
'parent_movement_type_list': invoice.getPortalAccountingMovementTypeList(),
'next_rule_list': [],
},
}
def checkTree(rule):
"""
checks the tree recursively
"""
rule_type = rule.getSpecialiseValue().getPortalType()
rule_def = rule_dict.get(rule_type, {})
for k, v in rule_def.iteritems():
if k == 'movement_type_list':
for movement in rule.objectValues():
if movement.getDeliveryValue() is not None:
self.assertTrue(movement.getDeliveryValue().getPortalType() in v,
'looking for %s in %s on %s' % (
movement.getDeliveryValue().getPortalType(), v,
movement.getPath()))
elif k == 'next_rule_list':
for movement in rule.objectValues():
found_rule_dict = {}
for next_rule in movement.objectValues():
next_rule_type = next_rule.getSpecialiseValue().getPortalType()
self.assertTrue(next_rule_type in v,
'looking for %s in %s on %s' % (
next_rule_type, v, next_rule.getPath()))
n = found_rule_dict.get(next_rule_type, 0)
found_rule_dict[next_rule_type] = n + 1
# for each movement, we want to make sure that each rule is not
# instanciated more than once
if len(found_rule_dict):
self.assertEqual(set(found_rule_dict.itervalues()), {1})
elif k == 'parent_movement_type_list':
if rule.getParentValue().getDeliveryValue() is not None:
parent_type = rule.getParentValue().getDeliveryValue().getPortalType()
self.assertTrue(parent_type in v, 'looking for %s in %s on %s' % (
parent_type, v, rule.getParentValue().getPath()))
elif k == 'parent_id_list':
self.assertTrue(rule.getParentId() in v, 'looking for %s in %s on %s'
% (rule.getParentId(), v, rule.getPath()))
for movement in rule.objectValues():
for next_rule in movement.objectValues():
checkTree(next_rule)
for applied_rule in applied_rule_set:
checkTree(applied_rule)
def stepAddInvoiceLinesManyTransactions(self, sequence=None, sequence_list=None):
"""
add some invoice and accounting lines to the invoice
"""
invoice = sequence.get('invoice')
invoice_line = invoice.newContent(portal_type='Invoice Line')
transaction_line_1 = invoice.newContent(portal_type='Sale Invoice Transaction Line')
transaction_line_2 = invoice.newContent(portal_type='Sale Invoice Transaction Line')
self.tic()
invoice_line.edit(resource_value=sequence.get('resource'), quantity=3,
price=555)
transaction_line_1.edit(id ='receivable', source='account_module/customer',
destination='account_module/supplier', quantity=-1665)
transaction_line_2.edit(
id='income', source='account_module/sale',
destination='account_module/purchase', quantity=1665)
def stepInvoiceBuilderAlarm(self, sequence=None,
sequence_list=None, **kw):
self.portal.portal_alarms.invoice_builder_alarm.activeSense()
class TestSaleInvoiceMixin(TestInvoiceMixin,
ERP5TypeTestCase):
"""Test sale invoice are created from orders then packing lists.
Those tests methods only work for sale, because sale and purchase invoice
are not built at the same time on packing list workflow.
"""
quiet = 0
invoice_portal_type = 'Sale Invoice Transaction'
invoice_line_portal_type = 'Invoice Line'
invoice_cell_portal_type = 'Invoice Cell'
invoice_transaction_line_portal_type = 'Sale Invoice Transaction Line'
payment_portal_type = 'Payment Transaction'
# default sequence for one line of not varianted resource.
PACKING_LIST_DEFAULT_SEQUENCE = """
stepCreateEntities
stepCreateCurrency
stepCreateOrder
stepSetOrderProfile
stepSetOrderPriceCurrency
stepCreateNotVariatedResource
stepTic
stepCreateOrderLine
stepSetOrderLineResource
stepSetOrderLineDefaultValues
stepOrderOrder
stepTic
stepCheckDeliveryBuilding
stepConfirmOrder
stepTic
stepPackingListBuilderAlarm
stepTic
stepCheckOrderRule
stepCheckOrderSimulation
stepCheckDeliveryBuilding
stepAddPackingListContainer
stepAddPackingListContainerLine
stepSetContainerLineFullQuantity
stepTic
stepCheckPackingListIsPacked
"""
# default sequence for two lines of not varianted resource.
PACKING_LIST_TWO_LINES_DEFAULT_SEQUENCE = """
stepCreateEntities
stepCreateCurrency
stepCreateOrder
stepSetOrderProfile
stepSetOrderPriceCurrency
stepCreateNotVariatedResource
stepTic
stepCreateOrderLine
stepSetOrderLineResource
stepSetOrderLineDefaultValues
stepCreateNotVariatedResource
stepTic
stepCreateOrderLine
stepSetOrderLineResource
stepSetOrderLineDefaultValues
stepOrderOrder
stepTic
stepCheckDeliveryBuilding
stepConfirmOrder
stepTic
stepPackingListBuilderAlarm
stepTic
stepCheckOrderRule
stepCheckOrderSimulation
stepCheckDeliveryBuilding
stepAddPackingListContainer
stepAddPackingListContainerLine
stepTic
stepSetContainerFullQuantity
stepTic
stepCheckPackingListIsPacked
"""
# default sequence for one line of not varianted resource.
TWO_PACKING_LIST_DEFAULT_SEQUENCE = """
stepCreateEntities
stepCreateCurrency
stepCreateOrder
stepSetOrderProfile
stepSetOrderPriceCurrency
stepCreateNotVariatedResource
stepTic
stepCreateOrderLine
stepSetOrderLineResource
stepSetOrderLineDefaultValues
stepOrderOrder
stepTic
stepCheckDeliveryBuilding
stepConfirmOrder
stepTic
stepPackingListBuilderAlarm
stepTic
stepCheckOrderRule
stepCheckOrderSimulation
stepCheckDeliveryBuilding
stepDecreasePackingListLineQuantity
stepCheckPackingListIsCalculating
stepTic
stepCheckPackingListIsDiverged
stepSplitAndDeferPackingList
stepTic
stepCheckPackingListIsSolved
stepCheckPackingListSplitted
stepAddPackingListContainer
stepAddPackingListContainerLine
stepSetContainerLineFullQuantity
stepTic
stepCheckPackingListIsPacked
stepDefineNewPackingListContainer
stepTic
stepCheckNewPackingListIsPacked
"""
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>TestInvoiceMixin</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testInvoice</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.TestInvoiceMixin</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
import unittest import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.ERP5.tests.testOrder import TestOrderMixin from erp5.component.test.testOrder import TestOrderMixin
class TestRuleMixin(TestOrderMixin): class TestRuleMixin(TestOrderMixin):
""" """
...@@ -138,7 +138,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : ...@@ -138,7 +138,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) :
test that when a rule's test method returns False, it will not apply test that when a rule's test method returns False, it will not apply
""" """
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
skin = createZODBPythonScript(skin_folder, 'wrong_script', 'rule', createZODBPythonScript(skin_folder, 'wrong_script', 'rule',
'return False') 'return False')
delivery_rule = self.getRule('default_delivery_rule') delivery_rule = self.getRule('default_delivery_rule')
delivery_rule.setTestMethodId('wrong_script') delivery_rule.setTestMethodId('wrong_script')
...@@ -154,7 +154,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : ...@@ -154,7 +154,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) :
test that when a rule's test method returns True, it will apply test that when a rule's test method returns True, it will apply
""" """
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
skin = createZODBPythonScript(skin_folder, 'good_script', 'rule', createZODBPythonScript(skin_folder, 'good_script', 'rule',
'return True') 'return True')
delivery_rule = self.getRule('default_delivery_rule') delivery_rule = self.getRule('default_delivery_rule')
delivery_rule.setTestMethodId('good_script') delivery_rule.setTestMethodId('good_script')
...@@ -171,7 +171,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : ...@@ -171,7 +171,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) :
a good script a good script
""" """
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
skin = createZODBPythonScript(skin_folder, 'good_script', 'rule', createZODBPythonScript(skin_folder, 'good_script', 'rule',
'return True') 'return True')
delivery_rule = self.getRule('default_delivery_rule') delivery_rule = self.getRule('default_delivery_rule')
delivery_rule.setTestMethodId('good_script') delivery_rule.setTestMethodId('good_script')
...@@ -189,7 +189,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : ...@@ -189,7 +189,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) :
it will not apply it will not apply
""" """
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
skin = createZODBPythonScript(skin_folder, 'good_script', 'rule', createZODBPythonScript(skin_folder, 'good_script', 'rule',
'return True') 'return True')
delivery_rule = self.getRule('default_delivery_rule') delivery_rule = self.getRule('default_delivery_rule')
delivery_rule.setTestMethodId('good_script') delivery_rule.setTestMethodId('good_script')
...@@ -208,7 +208,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : ...@@ -208,7 +208,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) :
apply apply
""" """
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
skin = createZODBPythonScript(skin_folder, 'good_script', 'rule', createZODBPythonScript(skin_folder, 'good_script', 'rule',
'return True') 'return True')
delivery_rule = self.getRule('default_delivery_rule') delivery_rule = self.getRule('default_delivery_rule')
delivery_rule.setTestMethodId('good_script') delivery_rule.setTestMethodId('good_script')
...@@ -359,7 +359,7 @@ return context.generatePredicate( ...@@ -359,7 +359,7 @@ return context.generatePredicate(
XXX as expand is triggered here, make sure rules won't be created forever XXX as expand is triggered here, make sure rules won't be created forever
""" """
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
skin = createZODBPythonScript(skin_folder, 'rule_script', 'rule', createZODBPythonScript(skin_folder, 'rule_script', 'rule',
"return False") "return False")
# wrong reference # wrong reference
...@@ -408,11 +408,11 @@ return context.generatePredicate( ...@@ -408,11 +408,11 @@ return context.generatePredicate(
XXX as expand is triggered here, make sure rules won't be created forever XXX as expand is triggered here, make sure rules won't be created forever
""" """
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
skin = createZODBPythonScript(skin_folder, 'delivery_rule_script', 'rule', createZODBPythonScript(skin_folder, 'delivery_rule_script', 'rule',
"return False") "return False")
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
skin = createZODBPythonScript(skin_folder, 'invoice_rule_script', 'rule', createZODBPythonScript(skin_folder, 'invoice_rule_script', 'rule',
"return context.getParentValue().getSpecialiseReference() == 'default_delivery_rule'") "return context.getParentValue().getSpecialiseReference() == 'default_delivery_rule'")
delivery_rule = self.getRule('default_delivery_rule') delivery_rule = self.getRule('default_delivery_rule')
...@@ -536,11 +536,11 @@ return context.generatePredicate( ...@@ -536,11 +536,11 @@ return context.generatePredicate(
- test that nothing is changed if at least one child is delivered - test that nothing is changed if at least one child is delivered
""" """
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
skin = createZODBPythonScript(skin_folder, 'delivery_rule_script', 'rule', createZODBPythonScript(skin_folder, 'delivery_rule_script', 'rule',
"return False") "return False")
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
skin = createZODBPythonScript(skin_folder, 'invoice_rule_script', 'rule', createZODBPythonScript(skin_folder, 'invoice_rule_script', 'rule',
"return context.getParentValue().getSpecialiseReference() == 'default_delivery_rule'") "return context.getParentValue().getSpecialiseReference() == 'default_delivery_rule'")
delivery_rule = self.getRule('default_delivery_rule') delivery_rule = self.getRule('default_delivery_rule')
...@@ -622,11 +622,11 @@ return context.generatePredicate( ...@@ -622,11 +622,11 @@ return context.generatePredicate(
- test that nothing is changed if at least one child is delivered - test that nothing is changed if at least one child is delivered
""" """
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
skin = createZODBPythonScript(skin_folder, 'delivery_rule_script', 'rule', createZODBPythonScript(skin_folder, 'delivery_rule_script', 'rule',
"return False") "return False")
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
skin = createZODBPythonScript(skin_folder, 'invoice_rule_script', 'rule', createZODBPythonScript(skin_folder, 'invoice_rule_script', 'rule',
"return context.getParentValue().getSpecialiseReference() == 'default_delivery_rule'") "return context.getParentValue().getSpecialiseReference() == 'default_delivery_rule'")
delivery_rule = self.getRule('default_delivery_rule') delivery_rule = self.getRule('default_delivery_rule')
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testRule</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testRule</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testRule</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
module.erp5.TestInvoiceMixin
\ No newline at end of file
test.erp5.testRule
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_core_proxy_field_legacy
erp5_base
erp5_apparel
erp5_project
erp5_configurator_standard_solver
erp5_simulation_test_trade_template
erp5_simulation_test
erp5_administration
erp5_dummy_movement
erp5_configurator_standard_accounting_template
erp5_configurator_standard_invoicing_template
\ No newline at end of file
...@@ -32,7 +32,7 @@ from DateTime import DateTime ...@@ -32,7 +32,7 @@ from DateTime import DateTime
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import reindex from Products.ERP5Type.tests.utils import reindex
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testInvoice import TestSaleInvoiceMixin from erp5.component.module.TestInvoiceMixin import TestSaleInvoiceMixin
from Products.ERP5.tests.utils import newSimulationExpectedFailure from Products.ERP5.tests.utils import newSimulationExpectedFailure
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
......
...@@ -34,7 +34,7 @@ import unittest ...@@ -34,7 +34,7 @@ import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testOrder import TestOrderMixin from erp5.component.test.testOrder import TestOrderMixin
from Products.ERP5.tests.utils import newSimulationExpectedFailure from Products.ERP5.tests.utils import newSimulationExpectedFailure
class TestProductionOrderMixin(TestOrderMixin): class TestProductionOrderMixin(TestOrderMixin):
......
...@@ -33,7 +33,7 @@ import unittest ...@@ -33,7 +33,7 @@ import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from erp5.component.test.testProductionOrder import TestProductionOrderMixin from erp5.component.test.testProductionOrder import TestProductionOrderMixin
from Products.ERP5.tests.testPackingList import TestPackingListMixin from erp5.component.test.testPackingList import TestPackingListMixin
from Products.ERP5.tests.utils import newSimulationExpectedFailure from Products.ERP5.tests.utils import newSimulationExpectedFailure
class TestProductionPackingReportListMixin(TestProductionOrderMixin, TestPackingListMixin, \ class TestProductionPackingReportListMixin(TestProductionOrderMixin, TestPackingListMixin, \
......
...@@ -32,7 +32,7 @@ from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod ...@@ -32,7 +32,7 @@ from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.ERP5.tests.testInvoice import TestSaleInvoiceMixin from erp5.component.module.TestInvoiceMixin import TestSaleInvoiceMixin
from Products.ERP5.tests.utils import newSimulationExpectedFailure from Products.ERP5.tests.utils import newSimulationExpectedFailure
class TestNestedLineMixin(TestSaleInvoiceMixin): class TestNestedLineMixin(TestSaleInvoiceMixin):
...@@ -335,7 +335,8 @@ class TestNestedLine(TestNestedLineMixin, ERP5TypeTestCase): ...@@ -335,7 +335,8 @@ class TestNestedLine(TestNestedLineMixin, ERP5TypeTestCase):
return True return True
return False return False
self.tic(stop_condition=stop_condition) self.tic(stop_condition=stop_condition)
update_causality_message_uid, = prioritize_uid_list self.assertEqual(len(prioritize_uid_list), 1)
update_causality_message_uid = prioritize_uid_list[0]
for table in 'message', 'message_queue': for table in 'message', 'message_queue':
self.portal.cmf_activity_sql_connection.manage_test(""" self.portal.cmf_activity_sql_connection.manage_test("""
update %s update %s
...@@ -348,7 +349,7 @@ class TestNestedLine(TestNestedLineMixin, ERP5TypeTestCase): ...@@ -348,7 +349,7 @@ class TestNestedLine(TestNestedLineMixin, ERP5TypeTestCase):
@expectedFailure @expectedFailure
def test_04_MergingMultipleSaleOrders(self, quiet=quiet): def test_04_MergingMultipleSaleOrders(self, quiet=quiet):
sequence_list = SequenceList() sequence_list = SequenceList()
sequence = sequence_list.addSequenceString(self.DEFAULT_SEQUENCE + \ sequence_list.addSequenceString(self.DEFAULT_SEQUENCE + \
""" """
stepCreateOrder stepCreateOrder
stepSetOrderProfile stepSetOrderProfile
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testDeliveryBuilderToSupportMultipleLines</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testDeliveryBuilderToSupportMultipleLines</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testDeliveryBuilderToSupportMultipleLines</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -33,1095 +33,15 @@ ...@@ -33,1095 +33,15 @@
import xml.dom.minidom import xml.dom.minidom
import zipfile import zipfile
from Products.DCWorkflow.DCWorkflow import ValidationFailed
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import FileUpload from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5OOo.OOoUtils import OOoParser from Products.ERP5OOo.OOoUtils import OOoParser
from AccessControl.SecurityManagement import newSecurityManager
from DateTime import DateTime from DateTime import DateTime
from Acquisition import aq_parent
from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from testPackingList import TestPackingListMixin from erp5.component.test.testPackingList import TestPackingListMixin
from Products.ERP5.tests.utils import newSimulationExpectedFailure from Products.ERP5.tests.utils import newSimulationExpectedFailure
from erp5.component.module.TestInvoiceMixin import TestInvoiceMixin, TestSaleInvoiceMixin
class TestInvoiceMixin(TestPackingListMixin):
"""Test methods for invoices
"""
default_region = "europe/west/france"
vat_gap = 'fr/pcg/4/44/445/4457/44571'
vat_rate = 0.196
sale_gap = 'fr/pcg/7/70/707/7071/70712'
customer_gap = 'fr/pcg/4/41/411'
bank_gap = 'fr/pcg/5/51/512'
mail_delivery_mode = 'by_mail'
cpt_incoterm = 'cpt'
unit_piece_quantity_unit = 'unit/piece'
mass_quantity_unit = 'mass/kg'
oldMailhost = None
# (account_id, account_gap, account_type)
account_definition_list = (
('receivable_vat', vat_gap, 'liability/payable/collected_vat',),
('sale', sale_gap, 'income'),
('customer', customer_gap, 'asset/receivable'),
('refundable_vat', vat_gap, 'asset/receivable/refundable_vat'),
('purchase', sale_gap, 'expense'),
('supplier', customer_gap, 'liability/payable'),
('bank', bank_gap, 'asset/cash/bank'),
)
# (line_id, source_account_id, destination_account_id, line_quantity)
transaction_line_definition_list = (
('income', 'sale', 'purchase', 1.0),
('receivable', 'customer', 'supplier', -1.0 - vat_rate),
('collected_vat', 'receivable_vat', 'refundable_vat', vat_rate),
)
def getTitle(self):
return "Invoices"
def getBusinessTemplateList(self):
return super(TestInvoiceMixin, self).getBusinessTemplateList() + (
'erp5_accounting', 'erp5_invoicing', 'erp5_simplified_invoicing',
'erp5_configurator_standard_accounting_template',
'erp5_configurator_standard_invoicing_template')
@UnrestrictedMethod
def createCategories(self):
"""Create the categories for our test. """
# pull in the TestOrderMixin categories first
super(TestInvoiceMixin, self).createCategories()
for cat_string in self.getNeededCategoryList() :
base_cat = cat_string.split("/")[0]
path = self.getPortal().portal_categories[base_cat]
for cat in cat_string.split("/")[1:] :
if not cat in path.objectIds() :
path = path.newContent(
portal_type='Category',
id=cat,)
else:
path = path[cat]
# check categories have been created
for cat_string in self.getNeededCategoryList() :
self.assertNotEquals(None,
self.getCategoryTool().restrictedTraverse(cat_string),
cat_string)
def getNeededCategoryList(self):
"""return a list of categories that should be created."""
return ('region/%s' % self.default_region,
'gap/%s' % self.vat_gap,
'gap/%s' % self.sale_gap,
'gap/%s' % self.customer_gap,
'gap/%s' % self.bank_gap,
'delivery_mode/%s' % self.mail_delivery_mode,
'incoterm/%s' % self.cpt_incoterm,
'quantity_unit/%s' % self.unit_piece_quantity_unit,
'quantity_unit/%s' % self.mass_quantity_unit,
'base_amount/tax1',
'base_amount/tax2',
'base_amount/tax3',
'use/trade/tax',
)
def afterSetUp(self):
self.createUser('test_user',
['Assignee', 'Assignor', 'Member',
'Associate', 'Auditor', 'Author'])
self.createUser('manager', ['Manager'])
self.loginByUserName('manager')
self.createCategories()
self.validateRules()
self.createBusinessProcess()
self.loginByUserName('test_user')
def beforeTearDown(self):
self.abort()
self.loginByUserName('manager')
super(TestInvoiceMixin, self).beforeTearDown()
for folder in (self.portal.accounting_module,
self.portal.organisation_module,
self.portal.sale_order_module,
self.portal.purchase_order_module,
self.portal.sale_packing_list_module,
self.portal.purchase_packing_list_module,
self.portal.portal_simulation,):
folder.manage_delObjects([x for x in folder.objectIds() if x not in ('organisation_1','organisation_2','ppl_1','ppl_2')])
self.tic()
def stepCreateSaleInvoiceTransactionRule(self, sequence, **kw) :
pass # see createBusinessProcess
## XXX move this to "Sequence class"
def playSequence(self, sequence_string, quiet=0) :
sequence_list = SequenceList()
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
def createBusinessProcess(self):
portal = self.portal
business_process_id = self.__class__.__name__
try:
business_process = portal.business_process_module[business_process_id]
except KeyError:
business_process = portal.business_process_module.newContent(
business_process_id, 'Business Process',
specialise=self.__class__.business_process)
kw = dict(portal_type='Trade Model Path',
trade_phase='default/accounting',
trade_date='trade_phase/default/invoicing',
membership_criterion_base_category_list=('destination_region',
'product_line'),
membership_criterion_category=(
'destination_region/region/' + self.default_region,
'product_line/apparel'))
account_module = portal.account_module
for account_id, account_gap, account_type in self.account_definition_list:
if not account_module.has_key(account_id):
account = account_module.newContent(account_id, gap=account_gap,
account_type=account_type)
account.validate()
for line_id, line_source_id, line_destination_id, line_ratio in \
self.transaction_line_definition_list:
trade_model_path = business_process.newContent(
reference='accounting_' + line_id,
efficiency=line_ratio,
source_value=account_module[line_source_id],
destination_value=account_module[line_destination_id],
**kw)
# A trade model path already exist for root simulation movements
# (Accounting Transaction Root Simulation Rule).
# The ones we are creating are for Invoice Transaction Simulation Rule.
trade_model_path._setCriterionPropertyList(('portal_type',))
trade_model_path.setCriterion('portal_type', 'Simulation Movement')
self.business_process = business_process.getRelativeUrl()
def stepCreateEntities(self, sequence, **kw) :
"""Create a vendor and two clients. """
self.stepCreateOrganisation1(sequence, **kw)
self.stepCreateOrganisation2(sequence, **kw)
self.stepCreateOrganisation3(sequence, **kw)
self.stepCreateProject1(sequence, **kw)
self.stepCreateProject2(sequence, **kw)
vendor = sequence.get('organisation1')
vendor.setRegion(self.default_region)
vendor.validate()
sequence.edit(vendor=vendor)
client1 = sequence.get('organisation2')
client1.setRegion(self.default_region)
self.assertNotEquals(client1.getRegionValue(), None)
client1.validate()
sequence.edit(client1=client1)
client2 = sequence.get('organisation3')
self.assertEqual(client2.getRegionValue(), None)
client2.validate()
sequence.edit(client2=client2)
def stepCheckOrderRule(self, sequence=None, sequence_list=None, **kw):
"""Check we have a related Order Rule"""
order = sequence.get('order')
simulation_tool = self.getSimulationTool()
# Check that there is an applied rule for our packing list
rule_list = [x for x in simulation_tool.objectValues()
if x.getCausalityValue()==order]
self.assertNotEquals(len(rule_list), 0)
sequence.edit(order_rule_list = rule_list)
self.assertEqual(len(order.getMovementList()),
sum([len(rule.objectIds()) for rule in rule_list]))
def stepCheckInvoicingRule(self, sequence=None, sequence_list=None, **kw):
"""
Checks that the invoicing rule is applied and its values are correct.
"""
order_rule_list = sequence.get('order_rule_list')
invoicing_rule_list = []
invoice_transaction_rule_list = []
for order_rule in order_rule_list :
for order_simulation_movement in order_rule.objectValues() :
temp_invoicing_rule_list = [ar for ar in order_simulation_movement.objectValues()[0].objectValues()[0].objectValues()
if ar.getSpecialiseValue().getPortalType() == 'Invoice Simulation Rule']
self.assertEqual(len(temp_invoicing_rule_list), 1)
invoicing_rule_list.extend(temp_invoicing_rule_list)
sequence.edit(invoicing_rule_list=invoicing_rule_list)
invoicing_rule = invoicing_rule_list[0]
sequence.edit(invoicing_rule = invoicing_rule)
for invoicing_rule in invoicing_rule_list:
self.assertEqual(invoicing_rule.getSpecialiseReference(),
'default_invoicing_rule')
self.assertEqual(invoicing_rule.getPortalType(),
'Applied Rule')
simulation_movement_list = invoicing_rule.objectValues()
self.assertNotEquals(len(simulation_movement_list), 0)
for simulation_movement in simulation_movement_list :
invoice_transaction_rule_list.extend([applied_rule for applied_rule
in simulation_movement.objectValues() if applied_rule \
.getSpecialiseValue().getPortalType()
== 'Invoice Transaction Simulation Rule'])
resource_list = sequence.get('resource_list')
self.assertEqual(simulation_movement.getPortalType(),
'Simulation Movement')
self.assertTrue(simulation_movement.getResourceValue() in
resource_list)
self.assertTrue(simulation_movement.isConvergent())
# TODO: What is the invoice dates supposed to be ?
# is this done through profiles ?
#self.assertEqual(simulation_movement.getStartDate(),
# sequence.get('order').getStartDate())
#self.assertEqual(simulation_movement.getStopDate(),
# sequence.get('order').getStopDate())
sequence.edit(invoice_transaction_rule_list=invoice_transaction_rule_list)
def stepCheckInvoiceTransactionRule(self, sequence=None, sequence_list=None,
**kw):
"""
Checks that the applied invoice_transaction_rule is expanded and its movements are
consistent with its parent movement
"""
invoice_transaction_rule_list = \
sequence.get('invoice_transaction_rule_list')
for applied_invoice_transaction_rule in invoice_transaction_rule_list:
parent_movement = aq_parent(applied_invoice_transaction_rule)
invoice_transaction_rule = \
applied_invoice_transaction_rule.getSpecialiseValue()
self.assertEqual(3, len(applied_invoice_transaction_rule.objectValues()))
for line_id, line_source_id, line_destination_id, line_ratio in \
self.transaction_line_definition_list:
movement = None
for simulation_movement in \
applied_invoice_transaction_rule.objectValues():
if simulation_movement.getSourceId() == line_source_id and\
simulation_movement.getDestinationId() == line_destination_id:
movement = simulation_movement
break
self.assertTrue(movement is not None)
self.assertEqual(movement.getCorrectedQuantity(), parent_movement.getPrice() *
parent_movement.getCorrectedQuantity() * line_ratio)
self.assertEqual(movement.getStartDate(),
parent_movement.getStartDate())
self.assertEqual(movement.getStopDate(),
parent_movement.getStopDate())
def modifyPackingListState(self, transition_name,
sequence,packing_list=None):
""" calls the workflow for the packing list """
if packing_list is None:
packing_list = sequence.get('packing_list')
packing_list.portal_workflow.doActionFor(packing_list, transition_name)
def stepSetReadyPackingList(self, sequence=None, sequence_list=None, **kw):
""" set the Packing List as Ready. This must build the invoice. """
self.modifyPackingListState('set_ready_action', sequence=sequence)
packing_list = sequence.get('packing_list')
self.assertEqual(packing_list.getSimulationState(), 'ready')
def stepSetReadyNewPackingList(self, sequence=None,
sequence_list=None, **kw):
""" set the Packing List as Ready. This must build the invoice. """
packing_list = sequence.get('new_packing_list')
self.modifyPackingListState('set_ready_action', sequence=sequence,
packing_list=packing_list)
self.assertEqual(packing_list.getSimulationState(), 'ready')
def stepStartPackingList(self, sequence=None, sequence_list=None, **kw):
self.modifyPackingListState('start_action', sequence=sequence)
packing_list = sequence.get('packing_list')
self.assertEqual(packing_list.getSimulationState(), 'started')
def stepStartNewPackingList(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('new_packing_list')
self.modifyPackingListState('start_action', sequence=sequence,
packing_list=packing_list)
self.assertEqual(packing_list.getSimulationState(), 'started')
def stepStopPackingList(self, sequence=None, sequence_list=None, **kw):
self.modifyPackingListState('stop_action', sequence=sequence)
packing_list = sequence.get('packing_list')
self.assertEqual(packing_list.getSimulationState(), 'stopped')
def stepDeliverPackingList(self, sequence=None, sequence_list=None, **kw):
self.modifyPackingListState('deliver_action', sequence=sequence)
packing_list = sequence.get('packing_list')
self.assertEqual(packing_list.getSimulationState(), 'delivered')
def stepCancelPackingList(self, sequence=None, sequence_list=None, **kw):
self.modifyPackingListState('cancel_action', sequence=sequence)
packing_list = sequence.get('packing_list')
self.assertEqual(packing_list.getSimulationState(), 'cancelled')
def modifyInvoiceState(self, transition_name,
sequence,invoice=None):
""" calls the workflow for the invoice """
if invoice is None:
invoice = sequence.get('invoice')
invoice.portal_workflow.doActionFor(invoice, transition_name)
def stepStartInvoice(self, sequence=None, sequence_list=None, **kw):
self.modifyInvoiceState('start_action', sequence=sequence)
invoice = sequence.get('invoice')
self.assertEqual(invoice.getSimulationState(), 'started')
def stepStartNewInvoice(self, sequence=None, sequence_list=None, **kw):
invoice = sequence.get('new_invoice')
self.modifyInvoiceState('start_action', sequence=sequence,
invoice=invoice)
self.assertEqual(invoice.getSimulationState(), 'started')
def stepStopInvoice(self, sequence=None, sequence_list=None, **kw):
self.modifyInvoiceState('stop_action', sequence=sequence)
invoice = sequence.get('invoice')
self.assertEqual(invoice.getSimulationState(), 'stopped')
def stepDeliverInvoice(self, sequence=None, sequence_list=None, **kw):
self.modifyInvoiceState('deliver_action', sequence=sequence)
invoice = sequence.get('invoice')
self.assertEqual(invoice.getSimulationState(), 'delivered')
def stepCancelInvoice(self, sequence=None, sequence_list=None, **kw):
self.modifyInvoiceState('cancel_action', sequence=sequence)
invoice = sequence.get('invoice')
self.assertEqual(invoice.getSimulationState(), 'cancelled')
def stepSwitchPackingLists(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('packing_list')
new_packing_list = sequence.get('new_packing_list')
#invoice = new_packing_list.getDefaultCausalityRelatedValue(
#portal_type=self.invoice_portal_type)
sequence.edit(packing_list=new_packing_list,
new_packing_list=packing_list)#, invoice=invoice)
def stepSwitchInvoices(self, sequence=None, sequence_list=None, **kw):
invoice = sequence.get('invoice')
new_invoice = sequence.get('new_invoice')
sequence.edit(invoice=new_invoice, new_invoice=invoice)
def stepCheckPackingListSimulation(self, sequence=None, sequence_list=None, **kw):
""" checks that simulation movements related to the packing list are OK """
packing_list = sequence.get('packing_list')
order = sequence.get('order')
order_root_applied_rule = order.getCausalityRelatedValueList(
portal_type = 'Applied Rule')[0]
# check simulation movements from this packing list
for movement in packing_list.getMovementList() :
simulation_movement_list = movement.getOrderRelatedValueList()
self.assertNotEquals(len(simulation_movement_list), 0)
total_quantity = 0
for simulation_movement in simulation_movement_list :
total_quantity += simulation_movement.getQuantity()
# check that those movements come from the same root applied
# rule than the order.
self.assertEqual( simulation_movement.getRootAppliedRule(),
order_root_applied_rule)
self.assertEqual(total_quantity, movement.getQuantity())
def checkMirrorAcquisition(self, object, acquired_object):
"""
Check if properties are well acquired for mirrored case
"""
# packing_list_movement, simulation_movement
self.assertEqual(acquired_object.getStartDate(), object.getStopDate())
self.assertEqual(acquired_object.getStopDate(), object.getStartDate())
self.assertEqual(acquired_object.getSourceValue(), \
object.getDestinationValue())
self.assertEqual(acquired_object.getDestinationValue(), \
object.getSourceValue())
self.assertEqual(acquired_object.getSourceSectionValue(), \
object.getDestinationSectionValue())
self.assertEqual(acquired_object.getDestinationSectionValue(), \
object.getSourceSectionValue())
def stepCheckInvoiceBuilding(self, sequence=None, sequence_list=None, **kw):
"""
checks that the invoice is built with the default_invoice_builder
"""
packing_list = sequence.get('packing_list')
related_invoice_list = packing_list.getCausalityRelatedValueList(
portal_type=self.invoice_portal_type)
if packing_list.getPortalType() == 'Purchase Packing List':
packing_list_building_state = 'stopped'
else:
packing_list_building_state = 'started'
packing_list_state = packing_list.getSimulationState()
if packing_list_state != packing_list_building_state :
self.assertEqual(0, len(related_invoice_list))
else:
self.assertEqual(1, len(related_invoice_list))
invoice = related_invoice_list[0].getObject()
self.assertTrue(invoice is not None)
# Invoices created by Delivery Builder are in confirmed state
self.assertEqual(invoice.getSimulationState(), 'confirmed')
# Get the list of simulation movements of packing list ...
packing_list_simulation_movement_list = []
for packing_list_movement in packing_list.getMovementList():
packing_list_simulation_movement_list.extend(
packing_list_movement.getDeliveryRelatedValueList())
# ... invoice simulation movement are their childrens.
simulation_movement_list = []
for p_l_simulation_movement in packing_list_simulation_movement_list :
for applied_rule in p_l_simulation_movement.objectValues() :
simulation_movement_list.extend(applied_rule.objectValues())
# First, test if each Simulation Movement is related to an
# Invoice Movement
invoice_relative_url = invoice.getRelativeUrl()
for simulation_movement in simulation_movement_list:
invoice_movement_list = simulation_movement.getDeliveryValueList()
self.assertEqual(len(invoice_movement_list), 1)
invoice_movement = invoice_movement_list[0]
self.assertTrue(invoice_movement is not None)
self.assert_(invoice_movement.getRelativeUrl().\
startswith(invoice_relative_url))
# Then, test if each Invoice movement is equals to the sum of somes
# Simulation Movements
for invoice_movement in invoice.getMovementList(portal_type = [
self.invoice_cell_portal_type,
self.invoice_line_portal_type]) :
related_simulation_movement_list = invoice_movement.\
getDeliveryRelatedValueList(portal_type='Simulation Movement')
quantity = 0
total_price = 0
invoice_movement_quantity = invoice_movement.getQuantity()
for related_simulation_movement in related_simulation_movement_list:
quantity += related_simulation_movement.getQuantity()
total_price += related_simulation_movement.getPrice() *\
related_simulation_movement.getQuantity()
# Test resource
self.assertEqual(invoice_movement.getResource(), \
related_simulation_movement.getResource())
# Test resource variation
self.assertEqual(invoice_movement.getVariationText(), \
related_simulation_movement.getVariationText())
self.assertEqual(invoice_movement.getVariationCategoryList(), \
related_simulation_movement.getVariationCategoryList())
# Test acquisition
self.checkAcquisition(invoice_movement,
related_simulation_movement)
# Test delivery ratio
self.assertEqual(related_simulation_movement.getQuantity() /\
invoice_movement_quantity, \
related_simulation_movement.getDeliveryRatio())
self.assertEqual(quantity, invoice_movement.getQuantity())
# Test price
self.assertEqual(total_price / quantity, invoice_movement.getPrice())
sequence.edit(invoice = invoice)
# Test causality
self.assertEqual(len(invoice.getCausalityValueList(
portal_type = self.packing_list_portal_type)), 1)
self.assertEqual(invoice.getCausalityValue(), packing_list)
# Finally, test getTotalQuantity and getTotalPrice on Invoice
self.assertEqual(packing_list.getTotalQuantity(),
invoice.getTotalQuantity())
self.assertEqual(packing_list.getTotalPrice(),
invoice.getTotalPrice())
def stepCheckInvoicesConsistency(self, sequence=None, sequence_list=None,
**kw):
"""
Checks that all invoices are consistent:
- transaction lines match invoice lines
- no movement is divergent
"""
invoice_list = self.getPortal()['accounting_module'].objectValues()
for invoice in invoice_list:
accounting_state_list = \
list(self.getPortal().getPortalCurrentInventoryStateList())
accounting_state_list.append('cancelled')
if invoice.getSimulationState() in accounting_state_list:
invoice_line_list = invoice.contentValues(
portal_type=self.invoice_line_portal_type)
invoice_transaction_line_list = invoice.contentValues(
portal_type=self.invoice_transaction_line_portal_type)
self.assertEqual(3, len(invoice_transaction_line_list))
expected_price = 0.0
for line in invoice_line_list:
expected_price += line.getTotalPrice()
for line_id, line_source, line_dest, line_ratio in \
self.transaction_line_definition_list:
for line in invoice.contentValues(
portal_type=self.invoice_transaction_line_portal_type):
if line.getSource() == 'account_module/%s' % line_source and \
line.getDestination() == 'account_module/%s' % line_dest:
break
else:
self.fail('No line found that matches %s' % line_id)
resource_precision = line.getResourceValue().getQuantityPrecision()
self.assertEqual(round(line.getQuantity(), resource_precision),
round(expected_price * line_ratio, resource_precision))
def stepCheckInvoiceLineHasReferenceAndIntIndex(self, sequence=None, **kw):
"""Check that the unique invoice line in the invoice has reference and int
index.
"""
invoice = sequence.get('invoice')
invoice_line_list = invoice.contentValues(
portal_type=self.invoice_line_portal_type)
self.assertEqual(1, len(invoice_line_list))
invoice_line = invoice_line_list[0]
self.assertEqual(1, invoice_line.getIntIndex())
self.assertEqual('1', invoice_line.getReference())
def stepCheckPackingListInvoice(
self, sequence=None, sequence_list=None, **kw):
""" Checks if the delivery builder is working as expected,
coping the atributes from packing list to invoice."""
packing_list = sequence.get('packing_list')
related_invoice_list = packing_list.getCausalityRelatedValueList(
portal_type=self.invoice_portal_type)
self.assertEqual(len(related_invoice_list), 1)
invoice = related_invoice_list[0]
self.assertEqual(packing_list.getSource(), invoice.getSource())
self.assertEqual(packing_list.getDestination(), invoice.getDestination())
self.assertEqual(packing_list.getDestinationSection(), \
invoice.getDestinationSection())
self.assertEqual(packing_list.getSourceSection(), \
invoice.getSourceSection())
self.assertEqual(packing_list.getDestinationDecision(), \
invoice.getDestinationDecision())
self.assertEqual(packing_list.getSourceDecision(), \
invoice.getSourceDecision())
self.assertEqual(packing_list.getDestinationAdministration(), \
invoice.getDestinationAdministration())
self.assertEqual(packing_list.getSourceAdministration(), \
invoice.getSourceAdministration())
self.assertEqual(packing_list.getDestinationProject(), \
invoice.getDestinationProject())
self.assertEqual(packing_list.getSourceProject(), \
invoice.getSourceProject())
self.assertEqual(packing_list.getPriceCurrency(), \
invoice.getPriceCurrency())
def stepCheckDeliveryRuleForDeferred(
self, sequence=None, sequence_list=None, **kw):
""" Checks that a delivery rule has been created when we took 'split
and defer' decision on the divergeant Packing List. """
# TODO
def stepCheckDeliveryRuleIsEmpty(
self, sequence=None, sequence_list=None, **kw):
""" Checks that an empty delivery rule is created for the
convergeant Packing List"""
packing_list = sequence.get('packing_list')
self.assertTrue(packing_list is not None)
simulation_tool = self.getSimulationTool()
# Check that there is an applied rule for our packing list
rule_list = [x for x in simulation_tool.objectValues()
if x.getCausalityValue()==packing_list]
self.assertEqual(len(rule_list),1)
packing_list_rule = rule_list[0]
sequence.edit(packing_list_rule=packing_list_rule)
rule_line_list = packing_list_rule.objectValues()
packing_list_line_list = packing_list.objectValues()
self.assertEqual(len(packing_list_line_list),
len(rule_line_list))
self.assertEqual(1, len(rule_line_list))
rule_line = rule_line_list[0]
packing_list_line = packing_list_line_list[0]
self.assertEqual(rule_line.getQuantity(), 10)
self.assertEqual(rule_line.getPrice(), 100)
self.assertEqual(rule_line.getDeliveryValue(),
packing_list_line)
self.assertEqual(rule_line.getStartDate(),
packing_list_line.getStartDate())
self.assertEqual(rule_line.getStopDate(),
packing_list_line.getStopDate())
self.assertEqual(rule_line.getPortalType(),
'Simulation Movement')
def stepCheckPackingList(self,sequence=None, sequence_list=None,**kw):
""" """
packing_list_module = self.getSalePackingListModule()
order_rule = sequence.get('order_rule')
order = sequence.get('order')
sale_packing_list_list = []
for o in packing_list_module.objectValues():
if o.getCausalityValue() == order:
sale_packing_list_list.append(o)
self.assertEqual(len(sale_packing_list_list), 1)
sale_packing_list = sale_packing_list_list[0]
sale_packing_list_line_list = sale_packing_list.objectValues()
self.assertEqual(len(sale_packing_list_line_list),1)
sale_packing_list_line = sale_packing_list_line_list[0]
product = sequence.get('resource')
self.assertEqual(sale_packing_list_line.getResourceValue(),
product)
self.assertEqual(sale_packing_list_line.getPrice(),
self.price1)
LOG('sale_packing_list_line.showDict()',0,
sale_packing_list_line.showDict())
self.assertEqual(sale_packing_list_line.getQuantity(),
self.quantity1)
self.assertEqual(sale_packing_list_line.getTotalPrice(),
self.total_price1)
sequence.edit(packing_list = sale_packing_list)
def stepCheckTwoInvoices(self,sequence=None, sequence_list=None, **kw):
""" checks invoice properties are well set. """
# Now we will check that we have two invoices created
for x in '', 'new_':
packing_list = sequence.get(x + 'packing_list')
invoice, = packing_list.getCausalityRelatedValueList(
portal_type=self.invoice_portal_type)
self.assertEqual(invoice.getSimulationState(), 'confirmed')
sequence.set(x + 'invoice', invoice)
def stepStartTwoInvoices(self,sequence=None, sequence_list=None, **kw):
""" start both invoices. """
portal = self.getPortal()
invoice = sequence.get('invoice')
new_invoice = sequence.get('new_invoice')
portal.portal_workflow.doActionFor(invoice, 'start_action')
portal.portal_workflow.doActionFor(new_invoice, 'start_action')
def stepCheckTwoInvoicesTransactionLines(self,sequence=None,
sequence_list=None, **kw):
""" checks invoice properties are well set. """
invoice = sequence.get('invoice')
new_invoice = sequence.get('new_invoice')
self.assertEqual(3,len(invoice.objectValues(
portal_type=self.invoice_transaction_line_portal_type)))
self.assertEqual(3,len(new_invoice.objectValues(
portal_type=self.invoice_transaction_line_portal_type)))
account_module = self.portal.account_module
found_dict = {}
for line in invoice.objectValues(
portal_type=self.invoice_transaction_line_portal_type):
source_id = line.getSourceId()
found_dict[source_id] = line.getQuantity()
total_price = (self.default_quantity-1) * self.default_price
expected_dict = {
'sale' : total_price,
'receivable_vat' : total_price * self.vat_rate,
'customer' : - (total_price + total_price * self.vat_rate)
}
self.failIfDifferentSet(expected_dict.keys(),found_dict.keys())
for key in found_dict.keys():
self.assertAlmostEquals(expected_dict[key],found_dict[key],places=2)
found_dict = {}
for line in new_invoice.objectValues(
portal_type=self.invoice_transaction_line_portal_type):
source_id = line.getSourceId()
found_dict[source_id] = line.getQuantity()
total_price = 1 * self.default_price
expected_dict = {
'sale' : total_price,
'receivable_vat' : total_price * self.vat_rate,
'customer' : - (total_price + total_price * self.vat_rate)
}
self.failIfDifferentSet(expected_dict.keys(), found_dict.keys())
for key in found_dict.keys():
self.assertAlmostEquals(expected_dict[key], found_dict[key], places=2)
def stepRebuildAndCheckNothingIsCreated(self, sequence=None,
sequence_list=None, **kw):
"""Rebuilds with sale_invoice_builder and checks nothing more is
created. """
accounting_module = self.portal.accounting_module
portal_type_list = ('Sale Invoice Transaction', 'Purchase Invoice Transaction')
sale_invoice_transaction_count = len(accounting_module.objectValues(
portal_type=portal_type_list))
for builder in self.getPortal().portal_deliveries.objectValues():
builder.build()
self.assertEqual(sale_invoice_transaction_count,
len(accounting_module.objectValues(
portal_type=portal_type_list)))
def stepModifyInvoicesDate(self, sequence=None,
sequence_list=None, **kw):
"""Change invoice date"""
invoice = sequence.get('invoice')
new_invoice = sequence.get('new_invoice')
invoice.edit(start_date=self.datetime,
stop_date=self.datetime+1)
new_invoice.edit(start_date=self.datetime,
stop_date=self.datetime+1)
def stepEditInvoice(self, sequence=None, sequence_list=None, **kw):
"""Edit the current invoice, to trigger updateSimulation."""
invoice = sequence.get('invoice')
invoice.edit(description='This invoice was edited!')
def stepCheckInvoiceRuleNotAppliedOnInvoiceEdit(self,
sequence=None, sequence_list=None, **kw):
"""If we call edit on the invoice, invoice rule should not be
applied on lines created by delivery builder."""
invoice = sequence.get('invoice')
self.assertEqual([], invoice.getCausalityRelatedValueList())
def stepEditPackingList(self, sequence=None, sequence_list=None, **kw):
"""Edit the current packing list, to trigger updateSimulation."""
packing_list = sequence.get('packing_list')
packing_list.edit(description='This packing list was edited!')
def stepAcceptDecisionDescriptionPackingList(self,sequence=None, sequence_list=None):
packing_list = sequence.get('packing_list')
self._solveDivergence(packing_list, 'description', 'Accept Solver')
def stepAssertCausalityStateIsNotSolvedInConsistencyMessage(self,
sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('packing_list')
self.assertEqual(
['Causality State is not "Solved". Please wait or take action'
+ ' for causality state to reach "Solved".'],
[str(message.message) for message in packing_list.checkConsistency()])
def stepSetReadyWorkflowTransitionIsBlockByConsistency(self,
sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('packing_list')
with self.assertRaisesRegexp(ValidationFailed,
'.*Causality State is not "Solved"*'):
self.getPortal().portal_workflow.doActionFor(
packing_list, 'set_ready_action')
def stepCheckDeliveryRuleNotAppliedOnPackingListEdit(self,
sequence=None, sequence_list=None, **kw):
"""If we call edit on the packing list, delivery rule should not be
applied on lines created by delivery builder."""
packing_list = sequence.get('packing_list')
self.assertEqual([], packing_list.getCausalityRelatedValueList())
def stepDecreaseInvoiceLineQuantity(self, sequence=None, sequence_list=None,
**kw):
"""
Set a decreased quantity on invoice lines
"""
invoice = sequence.get('invoice')
quantity = sequence.get('line_quantity',default=self.default_quantity)
quantity = quantity - 1
sequence.edit(line_quantity=quantity)
for invoice_line in invoice.objectValues(
portal_type=self.invoice_line_portal_type):
invoice_line.edit(quantity=quantity)
sequence.edit(last_delta = sequence.get('last_delta', 0.0) - 1.0)
def stepIncreaseInvoiceLineQuantity(self, sequence=None, sequence_list=None,
**kw):
"""
Set a Increased quantity on invoice lines
"""
invoice = sequence.get('invoice')
quantity = sequence.get('line_quantity',default=self.default_quantity)
quantity = quantity + 1
sequence.edit(line_quantity=quantity)
for invoice_line in invoice.objectValues(
portal_type=self.invoice_line_portal_type):
invoice_line.edit(quantity=quantity)
sequence.edit(last_delta = sequence.get('last_delta', 0.0) + 1.0)
def stepSetInvoiceLineQuantityToZero(self, sequence=None, sequence_list=None,
**kw):
"""
Set the quantity on invoice lines to zero
"""
invoice = sequence.get('invoice')
#default_quantity = sequence.get('line_quantity',default_quantity)
quantity = 0.0
sequence.edit(line_quantity=quantity)
for invoice_line in invoice.objectValues(
portal_type=self.invoice_line_portal_type):
invoice_line.edit(quantity=quantity)
sequence.edit(last_delta = - self.default_quantity)
def stepChangeInvoiceStartDate(self, sequence=None, sequence_list=None, **kw):
"""
Change the start_date of the invoice.
"""
invoice = sequence.get('invoice')
invoice.edit(start_date=self.datetime + 15)
def stepCheckInvoiceIsCalculating(self, sequence=None, sequence_list=None,
**kw):
"""
Test if invoice is calculating
"""
invoice = sequence.get('invoice')
self.assertEqual('calculating',invoice.getCausalityState())
def stepCheckInvoiceIsDiverged(self, sequence=None, sequence_list=None,
**kw):
"""
Test if invoice is diverged
"""
invoice = sequence.get('invoice')
self.assertEqual('diverged',invoice.getCausalityState())
def stepCheckInvoiceIsSolved(self, sequence=None, sequence_list=None,
**kw):
"""
Test if invoice is solved
"""
invoice = sequence.get('invoice')
self.assertEqual('solved', invoice.getCausalityState(),
invoice.getDivergenceList())
def stepCheckInvoiceIsDivergent(self, sequence=None, sequence_list=None,
**kw):
"""
Test if invoice is divergent
"""
invoice = sequence.get('invoice')
self.assertTrue(invoice.isDivergent())
def stepCheckInvoiceIsNotDivergent(self, sequence=None, sequence_list=None,
**kw):
"""
Test if invoice is not divergent
"""
invoice = sequence.get('invoice')
if invoice.isDivergent():
self.fail(invoice.getDivergenceList())
def stepSplitAndDeferInvoice(self, sequence=None, sequence_list=None,
**kw):
invoice = sequence.get('invoice')
solver_process = self.portal.portal_solver_processes.newSolverProcess(invoice)
quantity_solver_decision, = [x for x in solver_process.contentValues()
if x.getCausalityValue().getTestedProperty() == 'quantity']
# use Quantity Split Solver.
quantity_solver_decision.setSolverValue(self.portal.portal_solvers['Quantity Split Solver'])
# configure for Quantity Split Solver.
kw = {'delivery_solver':'FIFO Delivery Solver',
'start_date':self.datetime + 15,
'stop_date':self.datetime + 25}
quantity_solver_decision.updateConfiguration(**kw)
solver_process.buildTargetSolverList()
solver_process.solve()
def stepUnifyStartDateWithDecisionInvoice(self, sequence=None,
sequence_list=None):
invoice = sequence.get('invoice')
self._solveDivergence(invoice, 'start_date', 'Unify Solver',
value=invoice.getStartDate())
def stepAdoptPrevisionQuantityInvoice(self,sequence=None, sequence_list=None):
invoice = sequence.get('invoice')
self._solveDivergence(invoice, 'quantity', 'Adopt Solver')
def stepAcceptDecisionQuantityInvoice(self,sequence=None, sequence_list=None):
invoice = sequence.get('invoice')
self._solveDivergence(invoice, 'quantity', 'Accept Solver')
def stepAcceptDecisionInvoice(self, sequence=None, sequence_list=None,
**kw):
"""
accept decision at the invoice level
"""
invoice = sequence.get('invoice')
invoice.portal_workflow.doActionFor(invoice,'accept_decision_action')
def stepCheckInvoiceSplitted(self, sequence=None, sequence_list=None, **kw):
"""
Test if invoice was splitted
"""
packing_list = sequence.get('packing_list')
invoice_list = packing_list.getCausalityRelatedValueList(
portal_type=self.invoice_portal_type)
self.assertEqual(2,len(invoice_list))
invoice1 = None
invoice2 = None
for invoice in invoice_list:
if invoice.getUid() == sequence.get('invoice').getUid():
invoice1 = invoice
else:
invoice2 = invoice
sequence.edit(new_invoice=invoice2)
for line in invoice1.objectValues(
portal_type=self.invoice_line_portal_type):
self.assertEqual(self.default_quantity-1,line.getQuantity())
for line in invoice2.objectValues(
portal_type=self.invoice_line_portal_type):
self.assertEqual(1,line.getQuantity())
def stepCheckInvoiceNotSplitted(self, sequence=None, sequence_list=None, **kw):
"""
Test if invoice was not splitted
"""
packing_list = sequence.get('packing_list')
invoice_list = packing_list.getCausalityRelatedValueList(
portal_type=self.invoice_portal_type)
self.assertEqual(1,len(invoice_list))
invoice1 = None
for invoice in invoice_list:
if invoice.getUid() == sequence.get('invoice').getUid():
invoice1 = invoice
last_delta = sequence.get('last_delta', 0.0)
for line in invoice1.objectValues(
portal_type=self.invoice_line_portal_type):
self.assertEqual(self.default_quantity + last_delta,
line.getQuantity())
def stepAddInvoiceLines(self, sequence=None, sequence_list=[]):
"""
add some invoice and accounting lines to the invoice
"""
invoice = sequence.get('invoice')
invoice.newContent(portal_type='Invoice Line',
resource_value=sequence.get('resource'), quantity=3, price=555)
invoice.newContent(portal_type='Sale Invoice Transaction Line',
id ='receivable', source='account_module/customer',
destination='account_module/supplier', quantity=-1665)
invoice.newContent(portal_type='Sale Invoice Transaction Line',
id='income', source='account_module/sale',
destination='account_module/purchase', quantity=1665)
def stepAddWrongInvoiceLines(self, sequence=None, sequence_list=[]):
"""
add some wrong invoice and accounting lines to the invoice
"""
invoice = sequence.get('invoice')
invoice.newContent(portal_type='Sale Invoice Transaction Line',
id='bad_movement', source='account_module/sale',
destination='account_module/purchase', quantity=2, price=4)
invoice.newContent(portal_type='Sale Invoice Transaction Line',
id='counter_bad_movement', source='account_module/sale',
destination='account_module/purchase', quantity=-2, price=4)
for movement in invoice.getMovementList():
movement.edit(resource_value=sequence.get('resource'))
def stepCheckStartInvoiceFail(self, sequence=None, sequence_list=[]):
"""
checks that it's not possible to start an invoice with really wrong
lines
"""
try:
self.tic()
except RuntimeError, exc:
invoice = sequence.get('invoice')
# check which activities are failing
self.assertTrue(str(exc).startswith('tic is looping forever.'),
'%s does not start with "tic is looping forever."' % str(exc))
msg_list = [('/'.join(x.object_path), x.method_id)
for x in self.getActivityTool().getMessageList()]
self.assertTrue((invoice.getPath(), '_localBuild') in msg_list, msg_list)
# flush failing activities
activity_tool = self.getActivityTool()
activity_tool.manageClearActivities(keep=0)
else:
self.fail("Error: stepStartInvoice didn't fail, the builder script"
+ " InvoiceTransaction_postTransactionLineGeneration should have"
+ " complained that accounting movements use multiple resources")
def stepCheckSimulationTrees(self, sequence=None, sequence_list=[]):
"""
check that rules are created in the order we expect them
"""
applied_rule_set = set()
invoice = sequence.get('invoice')
for movement in invoice.getMovementList():
for sm in movement.getDeliveryRelatedValueList():
applied_rule_set.add(sm.getRootAppliedRule())
rule_dict = {
'Order Root Simulation Rule': {
'movement_type_list': ['Sale Order Line', 'Sale Order Cell'],
'next_rule_list': ['Delivery Simulation Rule', ],
},
'Delivery Simulation Rule': {
'movement_type_list': ['Sale Packing List Line', 'Sale Packing List Cell'],
'next_rule_list': ['Invoice Simulation Rule', ],
},
'Invoice Simulation Rule': {
'movement_type_list': invoice.getPortalInvoiceMovementTypeList(),
'next_rule_list': ['Invoice Transaction Simulation Rule', 'Trade Model Simulation Rule'],
},
'Trade Model Simulation Rule': {
'next_rule_list': ['Invoice Transaction Simulation Rule'],
},
'Invoice Simulation Rule': {
'movement_type_list': invoice.getPortalInvoiceMovementTypeList() \
+ invoice.getPortalAccountingMovementTypeList(),
'next_rule_list': ['Invoice Transaction Simulation Rule', 'Payment Simulation Rule',
'Trade Model Simulation Rule'],
},
'Invoice Transaction Simulation Rule': {
'parent_movement_type_list': invoice.getPortalInvoiceMovementTypeList(),
'movement_type_list': invoice.getPortalAccountingMovementTypeList(),
'next_rule_list': ['Payment Simulation Rule'],
},
'Payment Simulation Rule': {
'parent_movement_type_list': invoice.getPortalAccountingMovementTypeList(),
'next_rule_list': [],
},
}
def checkTree(rule):
"""
checks the tree recursively
"""
rule_type = rule.getSpecialiseValue().getPortalType()
rule_def = rule_dict.get(rule_type, {})
for k, v in rule_def.iteritems():
if k == 'movement_type_list':
for movement in rule.objectValues():
if movement.getDeliveryValue() is not None:
self.assertTrue(movement.getDeliveryValue().getPortalType() in v,
'looking for %s in %s on %s' % (
movement.getDeliveryValue().getPortalType(), v,
movement.getPath()))
elif k == 'next_rule_list':
for movement in rule.objectValues():
found_rule_dict = {}
for next_rule in movement.objectValues():
next_rule_type = next_rule.getSpecialiseValue().getPortalType()
self.assertTrue(next_rule_type in v,
'looking for %s in %s on %s' % (
next_rule_type, v, next_rule.getPath()))
n = found_rule_dict.get(next_rule_type, 0)
found_rule_dict[next_rule_type] = n + 1
# for each movement, we want to make sure that each rule is not
# instanciated more than once
if len(found_rule_dict):
self.assertEqual(set(found_rule_dict.itervalues()), {1})
elif k == 'parent_movement_type_list':
if rule.getParentValue().getDeliveryValue() is not None:
parent_type = rule.getParentValue().getDeliveryValue().getPortalType()
self.assertTrue(parent_type in v, 'looking for %s in %s on %s' % (
parent_type, v, rule.getParentValue().getPath()))
elif k == 'parent_id_list':
self.assertTrue(rule.getParentId() in v, 'looking for %s in %s on %s'
% (rule.getParentId(), v, rule.getPath()))
for movement in rule.objectValues():
for next_rule in movement.objectValues():
checkTree(next_rule)
for applied_rule in applied_rule_set:
checkTree(applied_rule)
def stepAddInvoiceLinesManyTransactions(self, sequence=None, sequence_list=[]):
"""
add some invoice and accounting lines to the invoice
"""
invoice = sequence.get('invoice')
invoice_line = invoice.newContent(portal_type='Invoice Line')
transaction_line_1 = invoice.newContent(portal_type='Sale Invoice Transaction Line')
transaction_line_2 = invoice.newContent(portal_type='Sale Invoice Transaction Line')
self.tic()
invoice_line.edit(resource_value=sequence.get('resource'), quantity=3,
price=555)
transaction_line_1.edit(id ='receivable', source='account_module/customer',
destination='account_module/supplier', quantity=-1665)
transaction_line_2.edit(
id='income', source='account_module/sale',
destination='account_module/purchase', quantity=1665)
def stepInvoiceBuilderAlarm(self, sequence=None,
sequence_list=None, **kw):
self.portal.portal_alarms.invoice_builder_alarm.activeSense()
class TestInvoice(TestInvoiceMixin): class TestInvoice(TestInvoiceMixin):
"""Test methods for sale and purchase invoice. """Test methods for sale and purchase invoice.
...@@ -1162,7 +82,7 @@ class TestInvoice(TestInvoiceMixin): ...@@ -1162,7 +82,7 @@ class TestInvoice(TestInvoiceMixin):
start_date=DateTime(2008, 1, 1), start_date=DateTime(2008, 1, 1),
price_currency_value=currency, price_currency_value=currency,
title='Order') title='Order')
order_line = order.newContent(portal_type=self.order_line_portal_type, order.newContent(portal_type=self.order_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=1, quantity=1,
price=2) price=2)
...@@ -1594,42 +514,42 @@ class TestInvoice(TestInvoiceMixin): ...@@ -1594,42 +514,42 @@ class TestInvoice(TestInvoiceMixin):
source_section_value=vendor, source_section_value=vendor,
destination_value=client, destination_value=client,
destination_section_value=client) destination_section_value=client)
product_line1 = invoice.newContent(portal_type=self.invoice_line_portal_type, invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=10, quantity=10,
base_contribution='base_amount/tax1', base_contribution='base_amount/tax1',
price=3) price=3)
product_line2 = invoice.newContent(portal_type=self.invoice_line_portal_type, invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=20, quantity=20,
base_contribution='base_amount/tax1', base_contribution='base_amount/tax1',
price=5) price=5)
product_line3 = invoice.newContent(portal_type=self.invoice_line_portal_type, invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=60, quantity=60,
base_contribution='base_amount/tax2', base_contribution='base_amount/tax2',
price=5) price=5)
product_line4 = invoice.newContent(portal_type=self.invoice_line_portal_type, invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=60, quantity=60,
price=3) price=3)
product_line5 = invoice.newContent(portal_type=self.invoice_line_portal_type, invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=7, quantity=7,
price=20) price=20)
tax_line1 = invoice.newContent(portal_type=self.invoice_line_portal_type, invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource_tax, resource_value=resource_tax,
use='trade/tax', use='trade/tax',
base_contribution='base_amount/tax1', base_contribution='base_amount/tax1',
quantity=130, quantity=130,
price=0.2) price=0.2)
tax_line2 = invoice.newContent(portal_type=self.invoice_line_portal_type, invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource_tax, resource_value=resource_tax,
use='trade/tax', use='trade/tax',
base_contribution='base_amount/tax2', base_contribution='base_amount/tax2',
quantity=300, quantity=300,
price=0.05) price=0.05)
tax_line3 = invoice.newContent(portal_type=self.invoice_line_portal_type, invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource_tax, resource_value=resource_tax,
use='trade/tax', use='trade/tax',
base_contribution='base_amount/tax3', base_contribution='base_amount/tax3',
...@@ -1679,8 +599,8 @@ class TestInvoice(TestInvoiceMixin): ...@@ -1679,8 +599,8 @@ class TestInvoice(TestInvoiceMixin):
title='Resource',) title='Resource',)
client = self.portal.organisation_module.newContent( client = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Client') portal_type='Organisation', title='Client')
client_logo = client.newContent(portal_type='Embedded File', client.newContent(portal_type='Embedded File',
id='default_image') id='default_image')
vendor = self.portal.organisation_module.newContent( vendor = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Vendor') portal_type='Organisation', title='Vendor')
vendor_logo = vendor.newContent(portal_type='Embedded File', vendor_logo = vendor.newContent(portal_type='Embedded File',
...@@ -1697,7 +617,7 @@ class TestInvoice(TestInvoiceMixin): ...@@ -1697,7 +617,7 @@ class TestInvoice(TestInvoiceMixin):
source_section_value=vendor, source_section_value=vendor,
destination_value=client, destination_value=client,
destination_section_value=client) destination_section_value=client)
line = invoice.newContent(portal_type=self.invoice_line_portal_type, invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=10, quantity=10,
price=3) price=3)
...@@ -1722,15 +642,16 @@ class TestInvoice(TestInvoiceMixin): ...@@ -1722,15 +642,16 @@ class TestInvoice(TestInvoiceMixin):
self.resource_portal_type).newContent( self.resource_portal_type).newContent(
portal_type=self.resource_portal_type, portal_type=self.resource_portal_type,
title='Resource',) title='Resource',)
file_data = FileUpload(__file__) import Products.ERP5Type
file_data = FileUpload(Products.ERP5Type.__file__)
client = self.portal.organisation_module.newContent( client = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Client') portal_type='Organisation', title='Client')
client_logo = client.newContent(portal_type='Embedded File', client.newContent(portal_type='Embedded File',
id='default_image', id='default_image',
file=file_data) file=file_data)
vendor = self.portal.organisation_module.newContent( vendor = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Vendor') portal_type='Organisation', title='Vendor')
vendor_logo = vendor.newContent(portal_type='Embedded File', vendor.newContent(portal_type='Embedded File',
id='default_image', id='default_image',
file=file_data) file=file_data)
...@@ -1748,7 +669,7 @@ class TestInvoice(TestInvoiceMixin): ...@@ -1748,7 +669,7 @@ class TestInvoice(TestInvoiceMixin):
source_section_value=vendor, source_section_value=vendor,
destination_value=client, destination_value=client,
destination_section_value=client) destination_section_value=client)
line = invoice.newContent(portal_type=self.invoice_line_portal_type, invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=10, quantity=10,
price=3) price=3)
...@@ -1770,7 +691,6 @@ class TestInvoice(TestInvoiceMixin): ...@@ -1770,7 +691,6 @@ class TestInvoice(TestInvoiceMixin):
).newContent( ).newContent(
portal_type=self.resource_portal_type, portal_type=self.resource_portal_type,
title='Resource',) title='Resource',)
file_data = FileUpload(__file__)
client = self.portal.organisation_module.newContent( client = self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
title='Client') title='Client')
...@@ -2229,7 +1149,7 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent( ...@@ -2229,7 +1149,7 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent(
delivery_mode=self.mail_delivery_mode, delivery_mode=self.mail_delivery_mode,
incoterm=self.cpt_incoterm, incoterm=self.cpt_incoterm,
title='Order') title='Order')
order_line = order.newContent(portal_type=self.order_line_portal_type, order.newContent(portal_type=self.order_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=5, quantity=5,
price=2) price=2)
...@@ -2361,9 +1281,6 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent( ...@@ -2361,9 +1281,6 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent(
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
packing_list_line = packing_list.getMovementList()[0]
previous_quantity = packing_list_line.getQuantity()
packing_list.setReady() packing_list.setReady()
packing_list.start() packing_list.start()
packing_list.stop() packing_list.stop()
...@@ -2577,124 +1494,6 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent( ...@@ -2577,124 +1494,6 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent(
sale_invoice_brain, = self.portal.portal_catalog(uid=sale_invoice.getUid(), select_list=["specialise_trade_condition_title"], limit=1) sale_invoice_brain, = self.portal.portal_catalog(uid=sale_invoice.getUid(), select_list=["specialise_trade_condition_title"], limit=1)
self.assertEqual(sale_invoice_brain.specialise_trade_condition_title, sale_trade_condition_title) self.assertEqual(sale_invoice_brain.specialise_trade_condition_title, sale_trade_condition_title)
class TestSaleInvoiceMixin(TestInvoiceMixin,
ERP5TypeTestCase):
"""Test sale invoice are created from orders then packing lists.
Those tests methods only work for sale, because sale and purchase invoice
are not built at the same time on packing list workflow.
"""
quiet = 0
invoice_portal_type = 'Sale Invoice Transaction'
invoice_line_portal_type = 'Invoice Line'
invoice_cell_portal_type = 'Invoice Cell'
invoice_transaction_line_portal_type = 'Sale Invoice Transaction Line'
payment_portal_type = 'Payment Transaction'
# default sequence for one line of not varianted resource.
PACKING_LIST_DEFAULT_SEQUENCE = """
stepCreateEntities
stepCreateCurrency
stepCreateOrder
stepSetOrderProfile
stepSetOrderPriceCurrency
stepCreateNotVariatedResource
stepTic
stepCreateOrderLine
stepSetOrderLineResource
stepSetOrderLineDefaultValues
stepOrderOrder
stepTic
stepCheckDeliveryBuilding
stepConfirmOrder
stepTic
stepPackingListBuilderAlarm
stepTic
stepCheckOrderRule
stepCheckOrderSimulation
stepCheckDeliveryBuilding
stepAddPackingListContainer
stepAddPackingListContainerLine
stepSetContainerLineFullQuantity
stepTic
stepCheckPackingListIsPacked
"""
# default sequence for two lines of not varianted resource.
PACKING_LIST_TWO_LINES_DEFAULT_SEQUENCE = """
stepCreateEntities
stepCreateCurrency
stepCreateOrder
stepSetOrderProfile
stepSetOrderPriceCurrency
stepCreateNotVariatedResource
stepTic
stepCreateOrderLine
stepSetOrderLineResource
stepSetOrderLineDefaultValues
stepCreateNotVariatedResource
stepTic
stepCreateOrderLine
stepSetOrderLineResource
stepSetOrderLineDefaultValues
stepOrderOrder
stepTic
stepCheckDeliveryBuilding
stepConfirmOrder
stepTic
stepPackingListBuilderAlarm
stepTic
stepCheckOrderRule
stepCheckOrderSimulation
stepCheckDeliveryBuilding
stepAddPackingListContainer
stepAddPackingListContainerLine
stepTic
stepSetContainerFullQuantity
stepTic
stepCheckPackingListIsPacked
"""
# default sequence for one line of not varianted resource.
TWO_PACKING_LIST_DEFAULT_SEQUENCE = """
stepCreateEntities
stepCreateCurrency
stepCreateOrder
stepSetOrderProfile
stepSetOrderPriceCurrency
stepCreateNotVariatedResource
stepTic
stepCreateOrderLine
stepSetOrderLineResource
stepSetOrderLineDefaultValues
stepOrderOrder
stepTic
stepCheckDeliveryBuilding
stepConfirmOrder
stepTic
stepPackingListBuilderAlarm
stepTic
stepCheckOrderRule
stepCheckOrderSimulation
stepCheckDeliveryBuilding
stepDecreasePackingListLineQuantity
stepCheckPackingListIsCalculating
stepTic
stepCheckPackingListIsDiverged
stepSplitAndDeferPackingList
stepTic
stepCheckPackingListIsSolved
stepCheckPackingListSplitted
stepAddPackingListContainer
stepAddPackingListContainerLine
stepSetContainerLineFullQuantity
stepTic
stepCheckPackingListIsPacked
stepDefineNewPackingListContainer
stepTic
stepCheckNewPackingListIsPacked
"""
class TestSaleInvoice(TestSaleInvoiceMixin, TestInvoice, ERP5TypeTestCase): class TestSaleInvoice(TestSaleInvoiceMixin, TestInvoice, ERP5TypeTestCase):
"""Tests for sale invoice. """Tests for sale invoice.
""" """
...@@ -2755,9 +1554,9 @@ class TestSaleInvoice(TestSaleInvoiceMixin, TestInvoice, ERP5TypeTestCase): ...@@ -2755,9 +1554,9 @@ class TestSaleInvoice(TestSaleInvoiceMixin, TestInvoice, ERP5TypeTestCase):
title='Resource', title='Resource',
sale_supply_line_source_account="account_module/sale", sale_supply_line_source_account="account_module/sale",
product_line='apparel') product_line='apparel')
product_line = invoice.newContent(portal_type="Invoice Line", invoice.newContent(portal_type="Invoice Line",
resource_value=resource, quantity=1, price=0.014) resource_value=resource, quantity=1, price=0.014)
product_line = invoice.newContent(portal_type="Invoice Line", invoice.newContent(portal_type="Invoice Line",
resource_value=resource, quantity=1, price=0.014) resource_value=resource, quantity=1, price=0.014)
self.tic() self.tic()
invoice.plan() invoice.plan()
...@@ -3671,9 +2470,6 @@ class TestSaleInvoice(TestSaleInvoiceMixin, TestInvoice, ERP5TypeTestCase): ...@@ -3671,9 +2470,6 @@ class TestSaleInvoice(TestSaleInvoiceMixin, TestInvoice, ERP5TypeTestCase):
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
packing_list_line = packing_list.getMovementList()[0]
previous_quantity = packing_list_line.getQuantity()
packing_list.setReady() packing_list.setReady()
packing_list.start() packing_list.start()
self.assertEqual('started', packing_list.getSimulationState()) self.assertEqual('started', packing_list.getSimulationState())
...@@ -3811,26 +2607,26 @@ class TestPurchaseInvoice(TestInvoice, ERP5TypeTestCase): ...@@ -3811,26 +2607,26 @@ class TestPurchaseInvoice(TestInvoice, ERP5TypeTestCase):
""" """
class OpenDocumentTextFile : class OpenDocumentTextFile :
def __init__ (self, filelikeobj) : def __init__ (self, filelikeobj):
zip = zipfile.ZipFile(filelikeobj) with zipfile.ZipFile(filelikeobj) as z:
self.content = xml.dom.minidom.parseString(zip.read("content.xml")) self.content = xml.dom.minidom.parseString(z.read("content.xml"))
def toString (self) : def toString (self) :
""" Converts the document to a string. """ """ Converts the document to a string. """
buffer = u"" buffer_ = u""
for val in ["text:p", "text:h", "text:list"]: for val in ["text:p", "text:h", "text:list"]:
for paragraph in self.content.getElementsByTagName(val) : for paragraph in self.content.getElementsByTagName(val) :
buffer += self.textToString(paragraph) + "\n" buffer_ += self.textToString(paragraph) + "\n"
return buffer return buffer_
def textToString(self, element) : def textToString(self, element) :
buffer = u"" buffer_ = u""
for node in element.childNodes : for node in element.childNodes :
if node.nodeType == xml.dom.Node.TEXT_NODE : if node.nodeType == xml.dom.Node.TEXT_NODE :
buffer += node.nodeValue buffer_ += node.nodeValue
elif node.nodeType == xml.dom.Node.ELEMENT_NODE : elif node.nodeType == xml.dom.Node.ELEMENT_NODE :
buffer += self.textToString(node) buffer_ += self.textToString(node)
return buffer return buffer_
import unittest import unittest
def test_suite(): def test_suite():
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testInvoice</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testInvoice</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testDeliveryBuilderToSupportMultipleLines
test.erp5.testInvoice
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_core_proxy_field_legacy
erp5_base
erp5_simulation
erp5_apparel
erp5_project
erp5_configurator_standard_solver
erp5_simulation_test_trade_template
erp5_simulation_test
erp5_administration
erp5_dummy_movement
erp5_configurator_standard_accounting_template
erp5_configurator_standard_invoicing_template
\ No newline at end of file
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
import unittest import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import Sequence from Products.ERP5Type.tests.Sequence import Sequence
from Products.ERP5.tests.testPackingList import TestPackingListMixin from erp5.component.test.testPackingList import TestPackingListMixin
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase): class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
...@@ -65,7 +65,7 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase): ...@@ -65,7 +65,7 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
@UnrestrictedMethod @UnrestrictedMethod
def stepResetDeliveringRule(self, sequence): def stepResetDeliveringRule(self, sequence):
original_rule = rule = self.getDeliveringRule() rule = self.getDeliveringRule()
self.assertEqual(rule.getId(), 'new_delivery_simulation_rule') self.assertEqual(rule.getId(), 'new_delivery_simulation_rule')
# We clone the rule and clean it up to be able to experiment with it # We clone the rule and clean it up to be able to experiment with it
portal_rules = self.portal.portal_rules portal_rules = self.portal.portal_rules
...@@ -97,7 +97,6 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase): ...@@ -97,7 +97,6 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
packing_list = sequence['packing_list'] packing_list = sequence['packing_list']
# XXX-Leo can't we just use sequence['packing_list_line']? # XXX-Leo can't we just use sequence['packing_list_line']?
movement = packing_list.getMovementList()[0] movement = packing_list.getMovementList()[0]
rule = self.getDeliveringRule()
sequence.edit( sequence.edit(
packing_list=packing_list, packing_list=packing_list,
movement=movement, movement=movement,
...@@ -108,7 +107,6 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase): ...@@ -108,7 +107,6 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
""" """
Modify the quantity of the delivery movement Modify the quantity of the delivery movement
""" """
packing_list = sequence.get('packing_list')
movement = sequence.get('movement') movement = sequence.get('movement')
movement.setQuantity(movement.getQuantity()+1234) movement.setQuantity(movement.getQuantity()+1234)
...@@ -442,7 +440,6 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase): ...@@ -442,7 +440,6 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
def stepSetNewPrice(self, sequence=None, def stepSetNewPrice(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
packing_list = sequence.get('packing_list')
movement = sequence.get('movement') movement = sequence.get('movement')
movement.setPrice(movement.getPrice()+1234) movement.setPrice(movement.getPrice()+1234)
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testDivergenceTester</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testDivergenceTester</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testDivergenceTester</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -32,7 +32,7 @@ This test is experimental for new simulation implementation. ...@@ -32,7 +32,7 @@ This test is experimental for new simulation implementation.
from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from testPackingList import TestPackingListMixin from erp5.component.test.testPackingList import TestPackingListMixin
from Products.PythonScripts.Utility import allow_class from Products.PythonScripts.Utility import allow_class
class DummySolverConfiguration(object): class DummySolverConfiguration(object):
...@@ -97,9 +97,9 @@ class TestERP5Simulation(TestPackingListMixin, SecurityTestCase): ...@@ -97,9 +97,9 @@ class TestERP5Simulation(TestPackingListMixin, SecurityTestCase):
solver_process_tool = self.portal.portal_solver_processes solver_process_tool = self.portal.portal_solver_processes
solver_process = solver_process_tool.newSolverProcess(packing_list) solver_process = solver_process_tool.newSolverProcess(packing_list)
sequence.edit(solver_process=solver_process) sequence.edit(solver_process=solver_process)
quantity_solver_decision = filter( quantity_solver_decision = [
lambda x:x.getCausalityValue().getTestedProperty()=='quantity', x for x in solver_process.contentValues()
solver_process.contentValues())[0] if x.getCausalityValue().getTestedProperty()=='quantity'][0]
# use Quantity Split Solver. # use Quantity Split Solver.
quantity_solver_decision.setSolverValue( quantity_solver_decision.setSolverValue(
self.portal.portal_solvers['Quantity Split Solver']) self.portal.portal_solvers['Quantity Split Solver'])
...@@ -113,8 +113,6 @@ class TestERP5Simulation(TestPackingListMixin, SecurityTestCase): ...@@ -113,8 +113,6 @@ class TestERP5Simulation(TestPackingListMixin, SecurityTestCase):
# build split deliveries manually. XXX ad-hoc # build split deliveries manually. XXX ad-hoc
previous_tag = None previous_tag = None
for delivery_builder in packing_list.getBuilderList(): for delivery_builder in packing_list.getBuilderList():
this_builder_tag = '%s_split_%s' % (packing_list.getPath(),
delivery_builder.getId())
after_tag = [] after_tag = []
if previous_tag: if previous_tag:
after_tag.append(previous_tag) after_tag.append(previous_tag)
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testERP5Simulation</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testERP5Simulation</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testERP5Simulation</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
import unittest import unittest
from testPurchaseOrder import TestPurchaseOrder from erp5.component.test.testPurchaseOrder import TestPurchaseOrder
class TestInternalOrder(TestPurchaseOrder): class TestInternalOrder(TestPurchaseOrder):
""" """
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testInternalOrder</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testInternalOrder</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testInternalOrder</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,7 +50,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase ...@@ -50,7 +50,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from DateTime import DateTime from DateTime import DateTime
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testOrder import TestOrderMixin from erp5.component.test.testOrder import TestOrderMixin
from Products.ERP5Form.Selection import DomainSelection from Products.ERP5Form.Selection import DomainSelection
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from textwrap import dedent from textwrap import dedent
...@@ -96,7 +96,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -96,7 +96,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
preference.enable() preference.enable()
self.tic() self.tic()
def afterSetUp(self, quiet=1, run=run_all_test): def afterSetUp(self):
self.login() self.login()
self.category_tool = self.getCategoryTool() self.category_tool = self.getCategoryTool()
self.createCategories() self.createCategories()
...@@ -122,13 +122,13 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -122,13 +122,13 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
self.tic() self.tic()
def createCategory(self, parent, id_list): def createCategory(self, parent, id_list):
last_category = None last_category = None
for category_id in id_list: for category_id in id_list:
if type(category_id) == type('a'): if isinstance(category_id, str):
last_category = parent.newContent(portal_type='Category', last_category = parent.newContent(portal_type='Category',
id=category_id) id=category_id)
else: else:
self.createCategory(last_category, category_id) self.createCategory(last_category, category_id)
def stepCreateItemList(self, sequence=None, sequence_list=None, **kw): def stepCreateItemList(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -245,7 +245,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -245,7 +245,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
inventory = self.createInventory(sequence=sequence) inventory = self.createInventory(sequence=sequence)
inventory_list = sequence.get('inventory_list',[]) inventory_list = sequence.get('inventory_list',[])
inventory.edit(full_inventory=True) inventory.edit(full_inventory=True)
inventory_line = inventory.newContent( inventory.newContent(
portal_type = self.inventory_line_portal_type, portal_type = self.inventory_line_portal_type,
resource_value = sequence.get("second_resource"), resource_value = sequence.get("second_resource"),
inventory = 101) inventory = 101)
...@@ -260,7 +260,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -260,7 +260,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
inventory = self.createInventory(sequence=sequence) inventory = self.createInventory(sequence=sequence)
inventory_list = sequence.get('inventory_list',[]) inventory_list = sequence.get('inventory_list',[])
inventory.edit(full_inventory=False) inventory.edit(full_inventory=False)
inventory_line = inventory.newContent( inventory.newContent(
portal_type = self.inventory_line_portal_type, portal_type = self.inventory_line_portal_type,
resource_value = sequence.get("second_resource"), resource_value = sequence.get("second_resource"),
inventory = 101) inventory = 101)
...@@ -272,7 +272,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -272,7 +272,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
Test partial inventory behavior with multiple resource Test partial inventory behavior with multiple resource
""" """
inventory_list = sequence.get('inventory_list')
simulation = self.getPortal().portal_simulation simulation = self.getPortal().portal_simulation
# First resource, must not have changed # First resource, must not have changed
...@@ -353,7 +352,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -353,7 +352,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
section = sequence.get('section') section = sequence.get('section')
mirror_node = sequence.get('mirror_node') mirror_node = sequence.get('mirror_node')
mirror_section = sequence.get('mirror_section') mirror_section = sequence.get('mirror_section')
resource = sequence.get('resource')
packing_list_module = self.getPortal().getDefaultModule( packing_list_module = self.getPortal().getDefaultModule(
portal_type=self.packing_list_portal_type) portal_type=self.packing_list_portal_type)
packing_list = packing_list_module.newContent( packing_list = packing_list_module.newContent(
...@@ -478,7 +476,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -478,7 +476,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
- node 9 - node 9
""" """
organisation_list = [] organisation_list = []
for i in range(10): for _ in range(10):
self.stepCreateOrganisation(sequence=sequence, sequence_list=sequence_list, **kw) self.stepCreateOrganisation(sequence=sequence, sequence_list=sequence_list, **kw)
organisation_list.append(sequence.get('organisation')) organisation_list.append(sequence.get('organisation'))
...@@ -500,7 +498,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -500,7 +498,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
Create some variated resources to manipulate during the test Create some variated resources to manipulate during the test
""" """
resource_list = [] resource_list = []
for i in range(3): for _ in range(3):
self.stepCreateVariatedResource(sequence=sequence, sequence_list=sequence_list, **kw) self.stepCreateVariatedResource(sequence=sequence, sequence_list=sequence_list, **kw)
resource_list.append(sequence.get('resource')) resource_list.append(sequence.get('resource'))
sequence.edit( sequence.edit(
...@@ -647,7 +645,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -647,7 +645,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
delivery_line_list = [] delivery_line_list = []
organisation_list = sequence.get('organisation_list') organisation_list = sequence.get('organisation_list')
resource_list = sequence.get('resource_list') resource_list = sequence.get('resource_list')
order = sequence.get('order')
packing_list_module = self.getPortal().getDefaultModule(self.packing_list_portal_type) packing_list_module = self.getPortal().getDefaultModule(self.packing_list_portal_type)
for data in data_list: for data in data_list:
...@@ -662,7 +659,8 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -662,7 +659,8 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
[x for x in data.items() if x[0] in ('start_date',)] [x for x in data.items() if x[0] in ('start_date',)]
property_dict = {} property_dict = {}
property_dict['price_currency'] = self.price_currency property_dict['price_currency'] = self.price_currency
for (id, value) in property_list: property_dict[id] = value for (id_, value) in property_list:
property_dict[id_] = value
packing_list.edit(**property_dict) packing_list.edit(**property_dict)
for line in data['lines']: for line in data['lines']:
# Create Packing List Line # Create Packing List Line
...@@ -920,7 +918,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -920,7 +918,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
""" """
simulation = self.getPortal().portal_simulation
delivery = sequence.get('packing_list_list')[0] delivery = sequence.get('packing_list_list')[0]
expected_values_list = [ expected_values_list = [
{'text':delivery['1']['movement_0_0_0'], {'text':delivery['1']['movement_0_0_0'],
...@@ -1113,7 +1110,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1113,7 +1110,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
Test getInventory with a section_category argument Test getInventory with a section_category argument
""" """
organisation_list = sequence.get('organisation_list')
expected_values_list = [ expected_values_list = [
{'id':'testing_category/a/aa', 'values':[{'inventory':274.5},] }, {'id':'testing_category/a/aa', 'values':[{'inventory':274.5},] },
{'id':'testing_category/z/zc', 'values':[{'inventory':152.},] }, {'id':'testing_category/z/zc', 'values':[{'inventory':152.},] },
...@@ -1135,7 +1131,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1135,7 +1131,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
Test getInventory with a payment_category argument Test getInventory with a payment_category argument
""" """
organisation_list = sequence.get('organisation_list')
expected_values_list = [ expected_values_list = [
{'id':'testing_category/a/aa', 'values':[{'inventory':274.5},] }, {'id':'testing_category/a/aa', 'values':[{'inventory':274.5},] },
{'id':'testing_category/z/zc', 'values':[{'inventory':-426.5},] }, {'id':'testing_category/z/zc', 'values':[{'inventory':-426.5},] },
...@@ -1157,7 +1152,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1157,7 +1152,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
Test getInventory with a node_category argument Test getInventory with a node_category argument
""" """
organisation_list = sequence.get('organisation_list')
expected_values_list = [ expected_values_list = [
{'id':'testing_category/z/zb/zba', 'values':[{'inventory':162.},] }, {'id':'testing_category/z/zb/zba', 'values':[{'inventory':162.},] },
{'id':'testing_category/z/zb/zbb', 'values':[{'inventory':112.5},] }, {'id':'testing_category/z/zb/zbb', 'values':[{'inventory':112.5},] },
...@@ -1178,7 +1172,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1178,7 +1172,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
Test getInventory with a section_category argument Test getInventory with a section_category argument
""" """
organisation_list = sequence.get('organisation_list')
expected_values_list = [ expected_values_list = [
{'id':'testing_category/a/aa', 'values':[{'inventory':-274.5},] }, {'id':'testing_category/a/aa', 'values':[{'inventory':-274.5},] },
{'id':'testing_category/z/zc', 'values':[{'inventory':-152.},] }, {'id':'testing_category/z/zc', 'values':[{'inventory':-152.},] },
...@@ -1308,7 +1301,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1308,7 +1301,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
if method is None: if method is None:
LOG('TEST ERROR : Simulation Tool has no %s method' LOG('TEST ERROR : Simulation Tool has no %s method'
% method_name, 0, '') % method_name, 0, '')
self.assertTrue(0) raise AssertionError
a_inventory = method(section=organisation_url, a_inventory = method(section=organisation_url,
omit_transit=omit_transit, omit_transit=omit_transit,
transit_simulation_state=transit_simulation_state, transit_simulation_state=transit_simulation_state,
...@@ -1705,12 +1698,12 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1705,12 +1698,12 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
if not hasattr(inventory, attr): if not hasattr(inventory, attr):
LOG('TEST ERROR : Result of getInventoryList has no %s attribute' % attr, 0, '') LOG('TEST ERROR : Result of getInventoryList has no %s attribute' % attr, 0, '')
LOG('SQL Query was : ', 0, repr(simulation.getInventoryList(src__=1, **kw))) LOG('SQL Query was : ', 0, repr(simulation.getInventoryList(src__=1, **kw)))
self.assertTrue(0) raise RuntimeError
a_attributes[attr] = getattr(inventory, attr) a_attributes[attr] = getattr(inventory, attr)
a_inventory = inventory.inventory a_inventory = inventory.inventory
# Build a function to filter on attributes # Build a function to filter on attributes
def cmpfunction(item): def cmpfunction(item):
for (key, value) in a_attributes.items(): for (key, value) in a_attributes.items(): # pylint: disable=cell-var-from-loop
if item[key] != value: if item[key] != value:
return 0 return 0
return 1 return 1
...@@ -1722,7 +1715,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1722,7 +1715,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
expected_list.append(dict(exp)) expected_list.append(dict(exp))
expected_list[-1].update({'id':i}) expected_list[-1].update({'id':i})
# Now, look in these lines for one which has the same inventory # Now, look in these lines for one which has the same inventory
found_list = filter(lambda x:x['inventory'] == a_inventory, expected_list) found_list = [x for x in expected_list if x['inventory'] == a_inventory]
if len(found_list) == 0: if len(found_list) == 0:
LOG('TEST ERROR : Found a line with getInventoryList which is not expected.', 0, 'Found line : %s (inventory : %s) ; expected values with these attributes : %s' % (a_attributes, a_inventory, expected_list)) LOG('TEST ERROR : Found a line with getInventoryList which is not expected.', 0, 'Found line : %s (inventory : %s) ; expected values with these attributes : %s' % (a_attributes, a_inventory, expected_list))
LOG('SQL Query was : ', 0, repr(simulation.getInventoryList(src__=1, **kw))) LOG('SQL Query was : ', 0, repr(simulation.getInventoryList(src__=1, **kw)))
...@@ -1757,7 +1750,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1757,7 +1750,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
Test Inventory Module behavior Test Inventory Module behavior
""" """
resource = sequence.get('resource')
variation_category_list = sequence.get('variation_1') variation_category_list = sequence.get('variation_1')
quantity = 1 quantity = 1
self.checkVariatedInventory(variation_category_list=variation_category_list, self.checkVariatedInventory(variation_category_list=variation_category_list,
...@@ -1771,7 +1763,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1771,7 +1763,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
Test Inventory Module behavior Test Inventory Module behavior
""" """
resource = sequence.get('resource')
variation_category_list = sequence.get('variation_1') variation_category_list = sequence.get('variation_1')
quantity = 100 quantity = 100
self.checkVariatedInventory(variation_category_list=variation_category_list, self.checkVariatedInventory(variation_category_list=variation_category_list,
...@@ -1785,7 +1776,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1785,7 +1776,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
Test Inventory Module behavior Test Inventory Module behavior
""" """
resource = sequence.get('resource')
variation_category_list = sequence.get('variation_1') variation_category_list = sequence.get('variation_1')
quantity = 5 quantity = 5
self.checkVariatedInventory(variation_category_list=variation_category_list, self.checkVariatedInventory(variation_category_list=variation_category_list,
...@@ -1799,7 +1789,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1799,7 +1789,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
Test Inventory Module behavior Test Inventory Module behavior
""" """
resource = sequence.get('resource')
variation_category_list = sequence.get('variation_1') variation_category_list = sequence.get('variation_1')
quantity = 5 quantity = 5
self.checkVariatedInventory(variation_category_list=variation_category_list, self.checkVariatedInventory(variation_category_list=variation_category_list,
...@@ -1813,7 +1802,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1813,7 +1802,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
Test full inventory with variated resource Test full inventory with variated resource
""" """
resource = sequence.get('resource')
variation_category_list = sequence.get('variation_1') variation_category_list = sequence.get('variation_1')
# Test first resource # Test first resource
quantity = 55 quantity = 55
...@@ -1862,7 +1850,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1862,7 +1850,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
Test Full inventory behavior Test Full inventory behavior
""" """
inventory_list = sequence.get('inventory_list') sequence.get('inventory_list')
simulation = self.getPortal().portal_simulation simulation = self.getPortal().portal_simulation
# First resource, must be zero # First resource, must be zero
...@@ -1935,27 +1923,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -1935,27 +1923,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
resource_value.setProductLine('level1/level2') resource_value.setProductLine('level1/level2')
sequence.edit(first_resource=resource_value) sequence.edit(first_resource=resource_value)
def stepCreateTwoResourceFullInventory(self,
sequence=None,
sequence_list=None,
**kw):
""" Create a full Inventory which includes two inventory lines """
inventory = self.createInventory(sequence=sequence)
inventory_list = sequence.get('inventory_list',[])
inventory.edit(full_inventory=True)
inventory_line = inventory.newContent(
portal_type = self.inventory_line_portal_type,
resource_value = sequence.get("first_resource"),
inventory = 10)
inventory_line = inventory.newContent(
portal_type = self.inventory_line_portal_type,
resource_value = sequence.get("second_resource"),
inventory = 100)
inventory.deliver()
inventory_list.append(inventory)
sequence.edit(inventory_list=inventory_list)
def stepTestFullInventoryWithResourceCategory(self, def stepTestFullInventoryWithResourceCategory(self,
sequence=None, sequence=None,
sequence_list=None, sequence_list=None,
...@@ -2035,7 +2002,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -2035,7 +2002,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
Make sure that we can use section_category parameter with Full inventory. Make sure that we can use section_category parameter with Full inventory.
""" """
node = sequence.get('node') node = sequence.get('node')
section = sequence.get('section')
getInventory = self.getSimulationTool().getInventory getInventory = self.getSimulationTool().getInventory
self.assertEqual(202, getInventory(node_uid=node.getUid())) self.assertEqual(202, getInventory(node_uid=node.getUid()))
self.assertEqual(101, getInventory(section_category='group/level1/level2', self.assertEqual(101, getInventory(section_category='group/level1/level2',
...@@ -2065,7 +2031,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -2065,7 +2031,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
""" """
Make sure that we can use node_category parameter with Full inventory. Make sure that we can use node_category parameter with Full inventory.
""" """
node = sequence.get('node')
section = sequence.get('section') section = sequence.get('section')
getInventory = self.getSimulationTool().getInventory getInventory = self.getSimulationTool().getInventory
self.assertEqual(202, getInventory(section_uid=section.getUid())) self.assertEqual(202, getInventory(section_uid=section.getUid()))
...@@ -2097,7 +2062,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -2097,7 +2062,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
destination_section_value=sequence.get('section'), destination_section_value=sequence.get('section'),
destination_value=destination_value, destination_value=destination_value,
start_date=start_date) start_date=start_date)
inventory_line = inventory.newContent( inventory.newContent(
portal_type = self.inventory_line_portal_type, portal_type = self.inventory_line_portal_type,
resource_value = resource_value, resource_value = resource_value,
inventory = 100) inventory = 100)
...@@ -2301,7 +2266,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -2301,7 +2266,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
inventory = self.createInventory(sequence=sequence, inventory = self.createInventory(sequence=sequence,
full=False, start_date=start_date) full=False, start_date=start_date)
inventory_list = sequence.get('inventory_list',[]) inventory_list = sequence.get('inventory_list',[])
inventory_line = inventory.newContent( inventory.newContent(
portal_type=self.inventory_line_portal_type, portal_type=self.inventory_line_portal_type,
resource_value=resource_value, resource_value=resource_value,
inventory=inventory_quantity) inventory=inventory_quantity)
...@@ -2416,11 +2381,11 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -2416,11 +2381,11 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
inventory = self.createInventory(sequence=sequence) inventory = self.createInventory(sequence=sequence)
inventory_list = sequence.get('inventory_list',[]) inventory_list = sequence.get('inventory_list',[])
inventory.edit(full_inventory=True) inventory.edit(full_inventory=True)
inventory_line = inventory.newContent( inventory.newContent(
portal_type = self.inventory_line_portal_type, portal_type = self.inventory_line_portal_type,
resource_value = sequence.get("first_resource"), resource_value = sequence.get("first_resource"),
inventory = 10) inventory = 10)
inventory_line = inventory.newContent( inventory.newContent(
portal_type = self.inventory_line_portal_type, portal_type = self.inventory_line_portal_type,
resource_value = sequence.get("second_resource"), resource_value = sequence.get("second_resource"),
inventory = 100) inventory = 100)
...@@ -2439,7 +2404,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -2439,7 +2404,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
if kw.get('inventory1', None) is not None: if kw.get('inventory1', None) is not None:
inventory1 = kw['inventory1'] inventory1 = kw['inventory1']
else: else:
inventory_1 = 10 inventory1 = 10
if kw.get('inventory2', None) is not None: if kw.get('inventory2', None) is not None:
inventory2 = kw['inventory2'] inventory2 = kw['inventory2']
else: else:
...@@ -2449,11 +2414,11 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -2449,11 +2414,11 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
inventory_list = sequence.get('inventory_list',[]) inventory_list = sequence.get('inventory_list',[])
inventory.edit(full_inventory=True, inventory.edit(full_inventory=True,
start_date=start_date) start_date=start_date)
inventory_line = inventory.newContent( inventory.newContent(
portal_type = self.inventory_line_portal_type, portal_type = self.inventory_line_portal_type,
resource_value = sequence.get("resource"), resource_value = sequence.get("resource"),
inventory = inventory1) inventory = inventory1)
inventory_line = inventory.newContent( inventory.newContent(
portal_type = self.inventory_line_portal_type, portal_type = self.inventory_line_portal_type,
resource_value = sequence.get("second_resource"), resource_value = sequence.get("second_resource"),
inventory = inventory2) inventory = inventory2)
...@@ -2558,7 +2523,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -2558,7 +2523,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
to_date=DateTime(self.two_resource_full_inventory2_start_date) to_date=DateTime(self.two_resource_full_inventory2_start_date)
self.getPortalObject().portal_simulation.getCurrentInventoryList( self.getPortalObject().portal_simulation.getCurrentInventoryList(
to_date=to_date, to_date=to_date,
section=section_value.getRelativeUrl(), section=section_value.getRelativeUrl(), # pylint: disable=undefined-variable
node=node_value.getRelativeUrl(), node=node_value.getRelativeUrl(),
group_by_variation=1, group_by_variation=1,
group_by_sub_variation=1, group_by_sub_variation=1,
...@@ -3279,7 +3244,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase): ...@@ -3279,7 +3244,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
def test_15_FullInventoryCanCreatesManyVirtualCompensationMovement(self, quiet=0, run=run_all_test): def test_15_FullInventoryCanCreatesManyVirtualCompensationMovement(self, quiet=0, run=run_all_test):
organisation = self.portal.organisation_module.newContent(portal_type='Organisation') organisation = self.portal.organisation_module.newContent(portal_type='Organisation')
resource_value_list = [] resource_value_list = []
for i in range(2000): for _ in range(2000):
resource_value_list.append(self.portal.product_module.newContent(portal_type='Product')) resource_value_list.append(self.portal.product_module.newContent(portal_type='Product'))
self.commit() self.commit()
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testInventory</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testInventory</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testInventory</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -30,7 +30,7 @@ import unittest ...@@ -30,7 +30,7 @@ import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testOrder import TestOrderMixin from erp5.component.test.testOrder import TestOrderMixin
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
...@@ -275,7 +275,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -275,7 +275,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
We will put default values for an inventory We will put default values for an inventory
""" """
date = DateTime(self.first_date_string) date = DateTime(self.first_date_string)
inventory = self.createInventory(start_date=date,sequence=sequence) self.createInventory(start_date=date,sequence=sequence)
quantity = self.default_quantity quantity = self.default_quantity
self.createVariatedInventoryLine(start_date=date, self.createVariatedInventoryLine(start_date=date,
sequence=sequence, quantity=quantity) sequence=sequence, quantity=quantity)
...@@ -286,7 +286,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -286,7 +286,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
We will put default values for an inventory We will put default values for an inventory
""" """
date = DateTime(self.second_date_string) date = DateTime(self.second_date_string)
inventory = self.createInventory(start_date=date,sequence=sequence) self.createInventory(start_date=date,sequence=sequence)
quantity = self.default_quantity - 10 quantity = self.default_quantity - 10
self.createVariatedInventoryLine(start_date=date, self.createVariatedInventoryLine(start_date=date,
sequence=sequence, quantity=quantity) sequence=sequence, quantity=quantity)
...@@ -392,7 +392,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -392,7 +392,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
- size/Child/34 100 item1,item2 - size/Child/34 100 item1,item2
""" """
date = DateTime(self.first_date_string) date = DateTime(self.first_date_string)
inventory = self.createInventory(start_date=date,sequence=sequence) self.createInventory(start_date=date,sequence=sequence)
quantity = self.default_quantity quantity = self.default_quantity
self.createVariatedInventoryLine(start_date=date, self.createVariatedInventoryLine(start_date=date,
sequence=sequence, quantity=quantity) sequence=sequence, quantity=quantity)
...@@ -464,7 +464,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -464,7 +464,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
- size/Child/34 90 item1 - size/Child/34 90 item1
""" """
date = DateTime(self.second_date_string) date = DateTime(self.second_date_string)
inventory = self.createInventory(start_date=date,sequence=sequence) self.createInventory(start_date=date,sequence=sequence)
quantity = self.default_quantity - 10 quantity = self.default_quantity - 10
item_list = sequence.get('item_list') item_list = sequence.get('item_list')
self.createVariatedInventoryLine(start_date=date, self.createVariatedInventoryLine(start_date=date,
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testInventoryModule</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testInventoryModule</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testInventoryModule</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -30,8 +30,7 @@ import unittest ...@@ -30,8 +30,7 @@ import unittest
from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testOrder import TestOrderMixin from erp5.component.test.testOrder import TestOrderMixin
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
class TestInventoryReportModule(TestOrderMixin, SecurityTestCase): class TestInventoryReportModule(TestOrderMixin, SecurityTestCase):
""" """
...@@ -44,7 +43,6 @@ class TestInventoryReportModule(TestOrderMixin, SecurityTestCase): ...@@ -44,7 +43,6 @@ class TestInventoryReportModule(TestOrderMixin, SecurityTestCase):
""" """
""" """
return super(TestInventoryReportModule, self).getBusinessTemplateList() + ('erp5_accounting', 'erp5_mrp',) return super(TestInventoryReportModule, self).getBusinessTemplateList() + ('erp5_accounting', 'erp5_mrp',)
def getTitle(self): def getTitle(self):
return "Inventory Report Module" return "Inventory Report Module"
...@@ -858,5 +856,5 @@ class TestInventoryReportModule(TestOrderMixin, SecurityTestCase): ...@@ -858,5 +856,5 @@ class TestInventoryReportModule(TestOrderMixin, SecurityTestCase):
def _test_suite(): def _test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestInventoryModule)) suite.addTest(unittest.makeSuite(TestInventoryReportModule))
return suite return suite
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testInventoryReportModule</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testInventoryReportModule</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testInventoryReportModule</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -39,7 +39,8 @@ from DateTime import DateTime ...@@ -39,7 +39,8 @@ from DateTime import DateTime
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.CMFCore.utils import getToolByName
import Products.ERP5.tests
class TestOrderMixin(SubcontentReindexingWrapper): class TestOrderMixin(SubcontentReindexingWrapper):
...@@ -106,7 +107,7 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -106,7 +107,7 @@ class TestOrderMixin(SubcontentReindexingWrapper):
self.createUser('manager', ['Manager']) self.createUser('manager', ['Manager'])
self.loginByUserName('manager') self.loginByUserName('manager')
self.category_tool = self.getCategoryTool() self.category_tool = self.getCategoryTool()
portal_catalog = self.getCatalogTool() #portal_catalog = self.getCatalogTool()
#portal_catalog.manage_catalogClear() #portal_catalog.manage_catalogClear()
self.createCategories() self.createCategories()
self.validateRules() self.validateRules()
...@@ -138,30 +139,30 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -138,30 +139,30 @@ class TestOrderMixin(SubcontentReindexingWrapper):
size_category_list = ['Baby', 'Child', 'Man', 'Woman'] size_category_list = ['Baby', 'Child', 'Man', 'Woman']
if len(category_tool.size.contentValues()) == 0 : if len(category_tool.size.contentValues()) == 0 :
for category_id in size_category_list: for category_id in size_category_list:
o = category_tool.size.newContent(portal_type='Category', category_tool.size.newContent(portal_type='Category',
id=category_id) id=category_id)
for category_id in ['32', '34']: for category_id in ['32', '34']:
o = category_tool.size.Child.newContent(portal_type='Category', category_tool.size.Child.newContent(portal_type='Category',
id=category_id) id=category_id)
colour_category_list = ['blue', 'green'] colour_category_list = ['blue', 'green']
if len(category_tool.colour.contentValues()) == 0 : if len(category_tool.colour.contentValues()) == 0 :
for category_id in colour_category_list: for category_id in colour_category_list:
o = category_tool.colour.newContent(portal_type='Category', category_tool.colour.newContent(portal_type='Category',
id=category_id) id=category_id)
industrial_phase_category_list = ['phase1', 'phase2', industrial_phase_category_list = ['phase1', 'phase2',
'supply_phase1', 'supply_phase2'] 'supply_phase1', 'supply_phase2']
if len(category_tool.industrial_phase.contentValues()) == 0: if len(category_tool.industrial_phase.contentValues()) == 0:
for category_id in industrial_phase_category_list: for category_id in industrial_phase_category_list:
o = category_tool.industrial_phase.newContent( category_tool.industrial_phase.newContent(
portal_type='Category', portal_type='Category',
id=category_id) id=category_id)
product_line_category_list = ['apparel', 'cancel'] product_line_category_list = ['apparel', 'cancel']
if len(category_tool.product_line.contentValues()) == 0: if len(category_tool.product_line.contentValues()) == 0:
for category_id in product_line_category_list: for category_id in product_line_category_list:
o = category_tool.product_line.newContent( category_tool.product_line.newContent(
portal_type='Category', portal_type='Category',
id=category_id) id=category_id)
...@@ -311,9 +312,9 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -311,9 +312,9 @@ class TestOrderMixin(SubcontentReindexingWrapper):
portal_type=organisation_portal_type) portal_type=organisation_portal_type)
organisation = organisation_module.newContent( \ organisation = organisation_module.newContent( \
portal_type=organisation_portal_type) portal_type=organisation_portal_type)
bank_account = organisation.newContent(id='bank', organisation.newContent(id='bank',
portal_type='Bank Account', portal_type='Bank Account',
title='bank%s' % organisation.getId()) title='bank%s' % organisation.getId())
organisation.setDefaultAddressStreetAddress('rue xv') organisation.setDefaultAddressStreetAddress('rue xv')
organisation.setDefaultAddressZipCode('12345') organisation.setDefaultAddressZipCode('12345')
if title is None: if title is None:
...@@ -420,7 +421,7 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -420,7 +421,7 @@ class TestOrderMixin(SubcontentReindexingWrapper):
Check if the matrix of the current order line is empty. Check if the matrix of the current order line is empty.
""" """
order_line = sequence.get('order_line') order_line = sequence.get('order_line')
base_id = 'movement' # base_id = 'movement'
# vcl = list(order_line.getVariationCategoryList()) # vcl = list(order_line.getVariationCategoryList())
# cell_key_list = order_line.getCellKeyList(base_id=base_id) # cell_key_list = order_line.getCellKeyList(base_id=base_id)
cell_list = order_line.objectValues(portal_type=self.order_cell_portal_type) cell_list = order_line.objectValues(portal_type=self.order_cell_portal_type)
...@@ -450,22 +451,21 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -450,22 +451,21 @@ class TestOrderMixin(SubcontentReindexingWrapper):
""" """
order_line = sequence.get('order_line') order_line = sequence.get('order_line')
cell_list = order_line.objectValues(portal_type=self.order_cell_portal_type) cell_list = order_line.objectValues(portal_type=self.order_cell_portal_type)
order_line.deleteContent( map(lambda x: x.getId(), cell_list) ) order_line.deleteContent([x.getId() for x in cell_list])
def stepSetOrderLineEmptyVCL(self,sequence=None, sequence_list=None, **kw): def stepSetOrderLineEmptyVCL(self,sequence=None, sequence_list=None, **kw):
""" """
Delete the current order line's variation category list Delete the current order line's variation category list
""" """
order_line = sequence.get('order_line') order_line = sequence.get('order_line')
resource = sequence.get('resource')
order_line.setVariationCategoryList([]) order_line.setVariationCategoryList([])
def splitList(self, list): def splitList(self, l):
""" """
Split a list and return tuple with the 2 half Split a list and return tuple with the 2 half
""" """
middle = len(list)/2 + len(list)%2 middle = len(l)/2 + len(l)%2
return ( list[:middle] , list[middle:] ) return ( l[:middle] , l[middle:] )
def stepSetOrderLineHalfVCL(self,sequence=None, sequence_list=None, **kw): def stepSetOrderLineHalfVCL(self,sequence=None, sequence_list=None, **kw):
""" """
...@@ -509,13 +509,13 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -509,13 +509,13 @@ class TestOrderMixin(SubcontentReindexingWrapper):
cell_range = order_line.OrderLine_asCellRange(matrixbox=0) cell_range = order_line.OrderLine_asCellRange(matrixbox=0)
l = len(vcl) l = len(vcl)
s = sum(map(lambda x: len(x), cell_range)) s = sum([len(x) for x in cell_range])
self.assertEqual(l,s) self.assertEqual(l,s)
cell_key_list = order_line.getCellKeyList(base_id=base_id) cell_key_list = order_line.getCellKeyList(base_id=base_id)
if cell_range == []: if cell_range == []:
self.assertEqual(len(cell_key_list), 0) self.assertEqual(len(cell_key_list), 0)
else: else:
len_range = map(lambda x: len(x), cell_range) len_range = [len(x) for x in cell_range]
self.assertEqual(len(cell_key_list), reduce(lambda x,y: x*y, len_range)) self.assertEqual(len(cell_key_list), reduce(lambda x,y: x*y, len_range))
def stepCompleteOrderLineMatrix(self,sequence=None, sequence_list=None, \ def stepCompleteOrderLineMatrix(self,sequence=None, sequence_list=None, \
...@@ -550,8 +550,8 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -550,8 +550,8 @@ class TestOrderMixin(SubcontentReindexingWrapper):
cell_key_list.sort() cell_key_list.sort()
cell_list = order_line.objectValues(portal_type=self.order_cell_portal_type) cell_list = order_line.objectValues(portal_type=self.order_cell_portal_type)
self.assertEqual(len(cell_list), len(cell_key_list)) self.assertEqual(len(cell_list), len(cell_key_list))
price = 100 # price = 100
quantity = 200 # quantity = 200
for cell_key in cell_key_list: for cell_key in cell_key_list:
self.assertTrue(order_line.hasCell(base_id=base_id, *cell_key)) self.assertTrue(order_line.hasCell(base_id=base_id, *cell_key))
cell = order_line.getCell(base_id=base_id, *cell_key) cell = order_line.getCell(base_id=base_id, *cell_key)
...@@ -561,8 +561,8 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -561,8 +561,8 @@ class TestOrderMixin(SubcontentReindexingWrapper):
# self.assertEqual(quantity, cell.getProperty('quantity')) # self.assertEqual(quantity, cell.getProperty('quantity'))
# self.failIfDifferentSet(cell.getMembershipCriterionCategoryList(), # self.failIfDifferentSet(cell.getMembershipCriterionCategoryList(),
# cell_key) # cell_key)
price += 1 # price += 1
quantity += 1 # quantity += 1
def stepCheckOrderLineVRCL(self, sequence=None, sequence_list=None, **kw): def stepCheckOrderLineVRCL(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -586,7 +586,7 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -586,7 +586,7 @@ class TestOrderMixin(SubcontentReindexingWrapper):
order_line = sequence.get('order_line') order_line = sequence.get('order_line')
vrcl = order_line.getVariationRangeCategoryList() vrcl = order_line.getVariationRangeCategoryList()
vrcil = order_line.getVariationRangeCategoryItemList() vrcil = order_line.getVariationRangeCategoryItemList()
self.failIfDifferentSet(vrcl, map(lambda x: x[1], vrcil)) self.failIfDifferentSet(vrcl, [x[1] for x in vrcil])
def stepSetOrderLineDefaultValues(self, sequence=None, \ def stepSetOrderLineDefaultValues(self, sequence=None, \
sequence_list=None, **kw): sequence_list=None, **kw):
...@@ -715,7 +715,7 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -715,7 +715,7 @@ class TestOrderMixin(SubcontentReindexingWrapper):
order = sequence.get('order') order = sequence.get('order')
order_line_list = order.objectValues( \ order_line_list = order.objectValues( \
portal_type=self.order_line_portal_type) portal_type=self.order_line_portal_type)
order_line_list = map(lambda x: x.getObject(), order_line_list) order_line_list = [x.getObject() for x in order_line_list]
total_quantity = 0 total_quantity = 0
for order_line in order_line_list: for order_line in order_line_list:
total_quantity += order_line.getTotalQuantity() total_quantity += order_line.getTotalQuantity()
...@@ -735,7 +735,7 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -735,7 +735,7 @@ class TestOrderMixin(SubcontentReindexingWrapper):
order = sequence.get('order') order = sequence.get('order')
order_line_list = order.objectValues( \ order_line_list = order.objectValues( \
portal_type=self.order_line_portal_type) portal_type=self.order_line_portal_type)
order_line_list = map(lambda x: x.getObject(), order_line_list) order_line_list = [x.getObject() for x in order_line_list]
total_price = 0 total_price = 0
for order_line in order_line_list: for order_line in order_line_list:
total_price += order_line.getTotalPrice() total_price += order_line.getTotalPrice()
...@@ -755,7 +755,7 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -755,7 +755,7 @@ class TestOrderMixin(SubcontentReindexingWrapper):
order = sequence.get('order') order = sequence.get('order')
order_line_list = order.objectValues( \ order_line_list = order.objectValues( \
portal_type=self.order_line_portal_type) portal_type=self.order_line_portal_type)
order_line_list = map(lambda x: x.getObject(), order_line_list) order_line_list = [x.getObject() for x in order_line_list]
total_price = 0 total_price = 0
for order_line in order_line_list: for order_line in order_line_list:
total_price += order_line.getTotalPrice() total_price += order_line.getTotalPrice()
...@@ -800,24 +800,24 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -800,24 +800,24 @@ class TestOrderMixin(SubcontentReindexingWrapper):
order = sequence.get('order') order = sequence.get('order')
self.assertEqual('planned', order.getSimulationState()) self.assertEqual('planned', order.getSimulationState())
def checkAcquisition(self, object, acquired_object): def checkAcquisition(self, obj, acquired_object):
""" """
Check if properties are well acquired Check if properties are well acquired
""" """
# packing_list_movement, simulation_movement # packing_list_movement, simulation_movement
self.assertEqual(acquired_object.getStartDate(), object.getStartDate()) self.assertEqual(acquired_object.getStartDate(), obj.getStartDate())
self.assertEqual(acquired_object.getStopDate(), object.getStopDate()) self.assertEqual(acquired_object.getStopDate(), obj.getStopDate())
self.assertEqual(acquired_object.getSourceValue(), \ self.assertEqual(acquired_object.getSourceValue(), \
object.getSourceValue()) obj.getSourceValue())
self.assertEqual(acquired_object.getDestinationValue(), \ self.assertEqual(acquired_object.getDestinationValue(), \
object.getDestinationValue()) obj.getDestinationValue())
self.assertEqual(acquired_object.getSourceSectionValue(), \ self.assertEqual(acquired_object.getSourceSectionValue(), \
object.getSourceSectionValue()) obj.getSourceSectionValue())
self.assertEqual(acquired_object.getDestinationSectionValue(), \ self.assertEqual(acquired_object.getDestinationSectionValue(), \
object.getDestinationSectionValue()) obj.getDestinationSectionValue())
def stepCheckOrderLineAcquisition(self, sequence=None, \ def stepCheckOrderLineAcquisition(self, sequence=None, \
sequence_list=None, **kw): sequence_list=None, **kw):
...@@ -880,7 +880,6 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -880,7 +880,6 @@ class TestOrderMixin(SubcontentReindexingWrapper):
self.assertTrue(applied_rule is not None) self.assertTrue(applied_rule is not None)
# Test if applied rule has a specialise value with passed rule_reference # Test if applied rule has a specialise value with passed rule_reference
portal_rules = getToolByName(order, 'portal_rules')
self.assertEqual(rule_reference, self.assertEqual(rule_reference,
applied_rule.getSpecialiseReference()) applied_rule.getSpecialiseReference())
...@@ -2254,7 +2253,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2254,7 +2253,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
# Create recursively sub lines, and check that the ovement number # Create recursively sub lines, and check that the ovement number
# is still the same. # is still the same.
for i in range(5): for _ in range(5):
sub_order_line = sub_order_line.newContent( sub_order_line = sub_order_line.newContent(
portal_type=self.order_line_portal_type) portal_type=self.order_line_portal_type)
self.assertEqual(2, len(order.getMovementList())) self.assertEqual(2, len(order.getMovementList()))
...@@ -2287,9 +2286,9 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2287,9 +2286,9 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
cell_key_list = list(sub_order_line.getCellKeyList(base_id=base_id)) cell_key_list = list(sub_order_line.getCellKeyList(base_id=base_id))
cell_key_list.sort() cell_key_list.sort()
for cell_key in cell_key_list: for cell_key in cell_key_list:
cell = sub_order_line.newCell(base_id=base_id, sub_order_line.newCell(base_id=base_id,
portal_type=self.order_cell_portal_type, portal_type=self.order_cell_portal_type,
*cell_key) *cell_key)
self.assertEqual(2-1+len(cell_key_list), len(order.getMovementList())) self.assertEqual(2-1+len(cell_key_list), len(order.getMovementList()))
# Check that cells defined on a non leaf line are not returned. # Check that cells defined on a non leaf line are not returned.
...@@ -2301,9 +2300,9 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2301,9 +2300,9 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
cell_key_list = list(order_line.getCellKeyList(base_id=base_id)) cell_key_list = list(order_line.getCellKeyList(base_id=base_id))
cell_key_list.sort() cell_key_list.sort()
for cell_key in cell_key_list: for cell_key in cell_key_list:
cell = order_line.newCell(base_id=base_id, order_line.newCell(base_id=base_id,
portal_type=self.order_cell_portal_type, portal_type=self.order_cell_portal_type,
*cell_key) *cell_key)
self.assertEqual(2-1+len(cell_key_list), len(order.getMovementList())) self.assertEqual(2-1+len(cell_key_list), len(order.getMovementList()))
# Make sure that portal_type argument works correctly. # Make sure that portal_type argument works correctly.
...@@ -2491,7 +2490,6 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2491,7 +2490,6 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
# add sub_cell to sub_line, only sub_cell is movement # add sub_cell to sub_line, only sub_cell is movement
sub_order_line.setVariationCategoryList(order_line_vcl) sub_order_line.setVariationCategoryList(order_line_vcl)
sub_cell_key = sub_order_line.getCellKeyList(base_id=base_id)[0]
sub_cell = sub_order_line.newCell( sub_cell = sub_order_line.newCell(
base_id=base_id, base_id=base_id,
portal_type=self.order_cell_portal_type, portal_type=self.order_cell_portal_type,
...@@ -2740,10 +2738,10 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2740,10 +2738,10 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
destination_value=client, destination_value=client,
destination_section_value=client) destination_section_value=client)
order.setReference('OrderReference') order.setReference('OrderReference')
line = order.newContent(portal_type=self.order_line_portal_type, order.newContent(portal_type=self.order_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=10, quantity=10,
price=3) price=3)
order.confirm() order.confirm()
self.tic() self.tic()
...@@ -2776,10 +2774,10 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2776,10 +2774,10 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
source_section_value=vendor, source_section_value=vendor,
destination_value=client, destination_value=client,
destination_section_value=client) destination_section_value=client)
line = order.newContent(portal_type=self.order_line_portal_type, order.newContent(portal_type=self.order_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=10, quantity=10,
price=3) price=3)
order.confirm() order.confirm()
self.tic() self.tic()
...@@ -2797,7 +2795,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2797,7 +2795,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
self.resource_portal_type).newContent( self.resource_portal_type).newContent(
portal_type=self.resource_portal_type, portal_type=self.resource_portal_type,
title='Resource',) title='Resource',)
image = FileUpload(os.path.join(os.path.dirname(__file__), image = FileUpload(os.path.join(os.path.dirname(Products.ERP5.tests.__file__),
'test_data', 'images', 'erp5_logo.png')) 'test_data', 'images', 'erp5_logo.png'))
client = self.portal.organisation_module.newContent( client = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Client', portal_type='Organisation', title='Client',
...@@ -2814,10 +2812,10 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2814,10 +2812,10 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
source_section_value=vendor, source_section_value=vendor,
destination_value=client, destination_value=client,
destination_section_value=client) destination_section_value=client)
line = order.newContent(portal_type=self.order_line_portal_type, order.newContent(portal_type=self.order_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=10, quantity=10,
price=3) price=3)
order.confirm() order.confirm()
self.tic() self.tic()
...@@ -2834,7 +2832,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2834,7 +2832,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
self.resource_portal_type).newContent( self.resource_portal_type).newContent(
portal_type=self.resource_portal_type, portal_type=self.resource_portal_type,
title='Resource',) title='Resource',)
image = FileUpload(os.path.join(os.path.dirname(__file__), image = FileUpload(os.path.join(os.path.dirname(Products.ERP5.tests.__file__),
'test_data', 'images', 'erp5_logo.bmp')) 'test_data', 'images', 'erp5_logo.bmp'))
client = self.portal.organisation_module.newContent( client = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Client', portal_type='Organisation', title='Client',
...@@ -2844,7 +2842,6 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2844,7 +2842,6 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
vendor = self.portal.organisation_module.newContent( vendor = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Vendor', portal_type='Organisation', title='Vendor',
default_image_file=image) default_image_file=image)
from OFS.Image import Pdata
self.assertTrue(isinstance(vendor.getDefaultImageValue().data, Pdata)) self.assertTrue(isinstance(vendor.getDefaultImageValue().data, Pdata))
order = self.portal.getDefaultModule(self.order_portal_type).newContent( order = self.portal.getDefaultModule(self.order_portal_type).newContent(
portal_type=self.order_portal_type, portal_type=self.order_portal_type,
...@@ -2855,10 +2852,10 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2855,10 +2852,10 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
source_section_value=vendor, source_section_value=vendor,
destination_value=client, destination_value=client,
destination_section_value=client) destination_section_value=client)
line = order.newContent(portal_type=self.order_line_portal_type, order.newContent(portal_type=self.order_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=10, quantity=10,
price=3) price=3)
order.confirm() order.confirm()
self.tic() self.tic()
...@@ -2898,11 +2895,11 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2898,11 +2895,11 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
source_section_value=vendor, source_section_value=vendor,
destination_value=client, destination_value=client,
destination_section_value=client) destination_section_value=client)
line = order.newContent(portal_type=self.order_line_portal_type, order.newContent(portal_type=self.order_line_portal_type,
reference='à', reference='à',
resource_value=resource, resource_value=resource,
quantity=10, quantity=10,
price=3) price=3)
order.confirm() order.confirm()
self.tic() self.tic()
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testOrder</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testOrder</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testOrder</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -27,14 +27,11 @@ ...@@ -27,14 +27,11 @@
# #
############################################################################## ##############################################################################
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testOrder import TestOrderMixin from erp5.component.test.testOrder import TestOrderMixin
from Products.ERP5.tests.testInventoryAPI import InventoryAPITestCase from Products.ERP5.tests.testInventoryAPI import InventoryAPITestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestOrderBuilderMixin(TestOrderMixin, InventoryAPITestCase): class TestOrderBuilderMixin(TestOrderMixin, InventoryAPITestCase):
...@@ -425,9 +422,6 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -425,9 +422,6 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
sequence_list.play(self) sequence_list.play(self)
def createSelectMethodForBuilder(self):
portal = self.getPortal()
def checkOrderBuilderStockOptimisationResult(self, expected_result, **kw): def checkOrderBuilderStockOptimisationResult(self, expected_result, **kw):
result_list = [(x.getResource(), x.getVariationText(), x.getQuantity(), result_list = [(x.getResource(), x.getVariationText(), x.getQuantity(),
x.getStartDate().strftime("%Y/%m/%d"), x.getStartDate().strftime("%Y/%m/%d"),
...@@ -449,7 +443,6 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -449,7 +443,6 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
self.pinDateTime(fixed_date) self.pinDateTime(fixed_date)
self.createOrderBuilder() self.createOrderBuilder()
self.fillOrderBuilder() self.fillOrderBuilder()
node_1_uid = node_1.getUid()
self.checkOrderBuilderStockOptimisationResult([], node_uid=node_1.getUid()) self.checkOrderBuilderStockOptimisationResult([], node_uid=node_1.getUid())
self._makeMovement(quantity=-3, destination_value=node_1, simulation_state='confirmed') self._makeMovement(quantity=-3, destination_value=node_1, simulation_state='confirmed')
resource_url = self.resource.getRelativeUrl() resource_url = self.resource.getRelativeUrl()
...@@ -465,7 +458,6 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -465,7 +458,6 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
""" """
node_1 = self.node_1 node_1 = self.node_1
node_2 = self.node_2 node_2 = self.node_2
resource = self.resource
self.createOrderBuilder() self.createOrderBuilder()
self.fillOrderBuilder() self.fillOrderBuilder()
fixed_date = DateTime('2016/08/10') fixed_date = DateTime('2016/08/10')
...@@ -506,7 +498,6 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -506,7 +498,6 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
fixed_date = DateTime('2018/01/03') fixed_date = DateTime('2018/01/03')
self.pinDateTime(fixed_date) self.pinDateTime(fixed_date)
resource_url = self.resource.getRelativeUrl() resource_url = self.resource.getRelativeUrl()
node_uid_list = [node_1.getUid(), self.node_2.getUid()]
self.checkOrderBuilderStockOptimisationResult([], node_uid=node_1.getUid()) self.checkOrderBuilderStockOptimisationResult([], node_uid=node_1.getUid())
movement = self._makeMovement(quantity=3, destination_value=node_1, simulation_state='delivered', movement = self._makeMovement(quantity=3, destination_value=node_1, simulation_state='delivered',
start_date=DateTime('2018/01/10'), variation_category_list=variation_category_list) start_date=DateTime('2018/01/10'), variation_category_list=variation_category_list)
...@@ -549,7 +540,6 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -549,7 +540,6 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.assertTrue('auto_planned' in self.portal.getPortalFutureInventoryStateList()) self.assertTrue('auto_planned' in self.portal.getPortalFutureInventoryStateList())
# end of patch # end of patch
resource = self.resource
self.createOrderBuilder() self.createOrderBuilder()
self.fillOrderBuilder() self.fillOrderBuilder()
fixed_date = DateTime('2018/09/21') fixed_date = DateTime('2018/09/21')
...@@ -563,10 +553,10 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -563,10 +553,10 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
self._makeMovement(quantity=-5, destination_value=self.node_1, simulation_state='confirmed', self._makeMovement(quantity=-5, destination_value=self.node_1, simulation_state='confirmed',
start_date=DateTime('2018/09/21')) start_date=DateTime('2018/09/21'))
checkStockOptimisationForTwoNodes([(resource_url, '', 5.0, '2018/09/21', '2018/09/21')]) checkStockOptimisationForTwoNodes([(resource_url, '', 5.0, '2018/09/21', '2018/09/21')])
auto_planned_one = self._makeMovement(quantity=3, destination_value=self.node_2, simulation_state='auto_planned', self._makeMovement(quantity=3, destination_value=self.node_2, simulation_state='auto_planned',
start_date=DateTime('2018/09/18')) start_date=DateTime('2018/09/18'))
checkStockOptimisationForTwoNodes([(resource_url, '', 2.0, '2018/09/21', '2018/09/21')]) checkStockOptimisationForTwoNodes([(resource_url, '', 2.0, '2018/09/21', '2018/09/21')])
auto_planned_two = self._makeMovement(quantity=2, destination_value=self.node_1, simulation_state='auto_planned', self._makeMovement(quantity=2, destination_value=self.node_1, simulation_state='auto_planned',
start_date=DateTime('2018/09/19')) start_date=DateTime('2018/09/19'))
checkStockOptimisationForTwoNodes([]) checkStockOptimisationForTwoNodes([])
# But if we more stock than expected, auto planned movements should be reduced # But if we more stock than expected, auto planned movements should be reduced
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testOrderBuilder</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testOrderBuilder</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testOrderBuilder</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -34,7 +34,7 @@ from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod ...@@ -34,7 +34,7 @@ from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5.Document.BusinessTemplate import getChainByType from Products.ERP5.Document.BusinessTemplate import getChainByType
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testOrder import TestOrderMixin from erp5.component.test.testOrder import TestOrderMixin
from DateTime import DateTime from DateTime import DateTime
def getTree(self): def getTree(self):
...@@ -526,7 +526,6 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -526,7 +526,6 @@ class TestPackingListMixin(TestOrderMixin):
simulation_movement_list = applied_rule.objectValues() simulation_movement_list = applied_rule.objectValues()
self.assertEqual(len(simulation_movement_list),1) self.assertEqual(len(simulation_movement_list),1)
order_line = sequence.get('order_line') order_line = sequence.get('order_line')
packing_list = sequence.get('packing_list')
packing_list_line = sequence.get('packing_list_line') packing_list_line = sequence.get('packing_list_line')
for simulation_movement in simulation_movement_list: for simulation_movement in simulation_movement_list:
self.assertEqual(simulation_movement.getDeliveryValue(), order_line) self.assertEqual(simulation_movement.getDeliveryValue(), order_line)
...@@ -679,16 +678,16 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -679,16 +678,16 @@ class TestPackingListMixin(TestOrderMixin):
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
self._solveDivergence(packing_list, 'quantity', 'Adopt Solver') self._solveDivergence(packing_list, 'quantity', 'Adopt Solver')
def _solveDivergence(self, document, property, solver, **kw): def _solveDivergence(self, document, property_, solver, **kw):
"""Solve divergence by using solver tool""" """Solve divergence by using solver tool"""
solver_process_tool = self.portal.portal_solver_processes solver_process_tool = self.portal.portal_solver_processes
solver_process = solver_process_tool.newSolverProcess(document) solver_process = solver_process_tool.newSolverProcess(document)
solver_decision, = [x for x in solver_process.contentValues() solver_decision, = [x for x in solver_process.contentValues()
if x.getCausalityValue().getTestedProperty() == property] if x.getCausalityValue().getTestedProperty() == property_]
# use Quantity Accept Solver. # use Quantity Accept Solver.
solver_decision.setSolverValue(self.portal.portal_solvers[solver]) solver_decision.setSolverValue(self.portal.portal_solvers[solver])
# configure for Accept Solver. # configure for Accept Solver.
solver_decision.updateConfiguration(tested_property_list=[property], **kw) solver_decision.updateConfiguration(tested_property_list=[property_], **kw)
solver_process.buildTargetSolverList() solver_process.buildTargetSolverList()
solver_process.solve() solver_process.solve()
...@@ -729,8 +728,6 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -729,8 +728,6 @@ class TestPackingListMixin(TestOrderMixin):
""" """
Look if the packing list has new previsions Look if the packing list has new previsions
""" """
old_packing_list_line = sequence.get('packing_list_line')
packing_list_line = old_packing_list_line.aq_parent[str(int(old_packing_list_line.getId())-1)]
resource = sequence.get('resource') resource = sequence.get('resource')
for line in sequence.get('packing_list').getMovementList(): for line in sequence.get('packing_list').getMovementList():
self.assertEqual(line.getResourceValue(), resource) self.assertEqual(line.getResourceValue(), resource)
...@@ -1033,7 +1030,6 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -1033,7 +1030,6 @@ class TestPackingListMixin(TestOrderMixin):
def checkLineSet(delivery, expected_set): def checkLineSet(delivery, expected_set):
line_list = delivery.getMovementList() line_list = delivery.getMovementList()
self.assertEqual(len(line_list), len(expected_set)) self.assertEqual(len(line_list), len(expected_set))
found_set = set([(x.getResource(), x.getQuantity(), x.getPrice()) for x in line_list])
expected_set = set([(resource, self.default_quantity, 555), expected_set = set([(resource, self.default_quantity, 555),
(resource, self.default_quantity+1, 555)]) (resource, self.default_quantity+1, 555)])
checkLineSet(packing_list1, expected_set) checkLineSet(packing_list1, expected_set)
...@@ -1780,7 +1776,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : ...@@ -1780,7 +1776,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
source_section_value=vendor, source_section_value=vendor,
destination_value=client, destination_value=client,
destination_section_value=client) destination_section_value=client)
line = packing_list.newContent( packing_list.newContent(
portal_type=self.packing_list_line_portal_type, portal_type=self.packing_list_line_portal_type,
resource_value=resource, resource_value=resource,
quantity=10, quantity=10,
...@@ -1865,11 +1861,11 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : ...@@ -1865,11 +1861,11 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
self.assertEqual('cancelled', simulation_movement.getSimulationState()) self.assertEqual('cancelled', simulation_movement.getSimulationState())
def stepCreateSourceAccount(self, sequence=None, **kw): def stepCreateSourceAccount(self, sequence=None, **kw):
organisation = self.stepCreateOrganisation(sequence, None, 'dummy_source') self.stepCreateOrganisation(sequence, None, 'dummy_source')
sequence.edit(source_account = sequence.get('dummy_source')['bank']) sequence.edit(source_account = sequence.get('dummy_source')['bank'])
def stepCreateDestinationAccount(self, sequence=None, **kw): def stepCreateDestinationAccount(self, sequence=None, **kw):
organisation = self.stepCreateOrganisation(sequence, None, self.stepCreateOrganisation(sequence, None,
'dummy_destination') 'dummy_destination')
sequence.edit(destination_account = sequence.get('dummy_destination') sequence.edit(destination_account = sequence.get('dummy_destination')
['bank']) ['bank'])
...@@ -2238,7 +2234,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : ...@@ -2238,7 +2234,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
class TestSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase): class TestSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase):
quiet = 0 quiet = 0
def afterSetUp(self, quiet=1, run=1): def afterSetUp(self):
TestPackingListMixin.afterSetUp(self) TestPackingListMixin.afterSetUp(self)
solver_process_type_info = self.portal.portal_types['Solver Process'] solver_process_type_info = self.portal.portal_types['Solver Process']
self.original_allowed_content_types = \ self.original_allowed_content_types = \
...@@ -2246,7 +2242,7 @@ class TestSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase): ...@@ -2246,7 +2242,7 @@ class TestSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase):
self.added_target_solver_list = [] self.added_target_solver_list = []
@UnrestrictedMethod @UnrestrictedMethod
def beforeTearDown(self, quiet=1, run=1): def beforeTearDown(self):
super(TestSolvingPackingList, self).beforeTearDown() super(TestSolvingPackingList, self).beforeTearDown()
self.portal.portal_rules.new_delivery_simulation_rule.quantity_tester.edit( self.portal.portal_rules.new_delivery_simulation_rule.quantity_tester.edit(
solver=()) solver=())
...@@ -2317,9 +2313,10 @@ class TestSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase): ...@@ -2317,9 +2313,10 @@ class TestSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase):
sequence_list=None): sequence_list=None):
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
order = packing_list.getCausalityValue() order = packing_list.getCausalityValue()
new_packing_list = filter(lambda x:x != packing_list, new_packing_list = [
order.getCausalityRelatedValueList( x for x in order.getCausalityRelatedValueList(
portal_type=packing_list.getPortalType()))[0] portal_type=packing_list.getPortalType())
if x != packing_list][0]
self.assertEqual(len(packing_list.getMovementList()), self.assertEqual(len(packing_list.getMovementList()),
len(order.getMovementList()) - 10) len(order.getMovementList()) - 10)
self.assertEqual(len(new_packing_list.getMovementList()), 10) self.assertEqual(len(new_packing_list.getMovementList()), 10)
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testPackingList</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testPackingList</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testPackingList</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
############################################################################## ##############################################################################
import unittest import unittest
from testPackingList import TestPackingList from erp5.component.test.testPackingList import TestPackingList
class TestPackingListRoundingPrecision(TestPackingList): class TestPackingListRoundingPrecision(TestPackingList):
""" """
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testPackingListRoundingPrecision</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testPackingListRoundingPrecision</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testPackingListRoundingPrecision</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
import unittest import unittest
from testOrder import TestOrder from erp5.component.test.testOrder import TestOrder
class TestPurchaseOrder(TestOrder): class TestPurchaseOrder(TestOrder):
""" """
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testPurchaseOrder</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testPurchaseOrder</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testPurchaseOrder</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
import unittest import unittest
from testOrder import TestOrder from erp5.component.test.testOrder import TestOrder
class TestReturnedSaleOrder(TestOrder): class TestReturnedSaleOrder(TestOrder):
""" """
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testReturnedOrder</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testReturnedOrder</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testReturnedOrder</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -31,7 +31,7 @@ import unittest ...@@ -31,7 +31,7 @@ import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testPackingList import TestPackingListMixin from erp5.component.test.testPackingList import TestPackingListMixin
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.Errors import UnsupportedWorkflowMethod from Products.ERP5Type.Errors import UnsupportedWorkflowMethod
from Products.ERP5.tests.utils import newSimulationExpectedFailure from Products.ERP5.tests.utils import newSimulationExpectedFailure
...@@ -60,7 +60,6 @@ class ReturnedSalePackingListMixin(TestPackingListMixin): ...@@ -60,7 +60,6 @@ class ReturnedSalePackingListMixin(TestPackingListMixin):
def beforeTearDown(self): def beforeTearDown(self):
self.abort() self.abort()
self.tic()
for folder in (self.portal.organisation_module, for folder in (self.portal.organisation_module,
self.portal.sale_order_module, self.portal.sale_order_module,
self.portal.inventory_module, self.portal.inventory_module,
...@@ -84,9 +83,8 @@ class ReturnedSalePackingListMixin(TestPackingListMixin): ...@@ -84,9 +83,8 @@ class ReturnedSalePackingListMixin(TestPackingListMixin):
user = uf.getUserById('member').__of__(uf) user = uf.getUserById('member').__of__(uf)
newSecurityManager(None, user) newSecurityManager(None, user)
def afterSetUp(self, quiet=1, run=1): def afterSetUp(self):
self.loginAsManager() self.loginAsManager()
portal = self.getPortal()
self.createCategories() self.createCategories()
self.validateRules() self.validateRules()
self.setUpPreferences() self.setUpPreferences()
...@@ -231,7 +229,6 @@ class ReturnedSalePackingListMixin(TestPackingListMixin): ...@@ -231,7 +229,6 @@ class ReturnedSalePackingListMixin(TestPackingListMixin):
""" """
create a inventory create a inventory
""" """
portal = self.getPortal()
organisation = sequence.get('organisation1') organisation = sequence.get('organisation1')
inventory = self._getInventoryModule().newContent() inventory = self._getInventoryModule().newContent()
inventory.edit(start_date=self.first_date_string, inventory.edit(start_date=self.first_date_string,
...@@ -407,7 +404,7 @@ class ReturnedSalePackingListMixin(TestPackingListMixin): ...@@ -407,7 +404,7 @@ class ReturnedSalePackingListMixin(TestPackingListMixin):
portal_type=self.returned_packing_list_cell_portal_type) portal_type=self.returned_packing_list_cell_portal_type)
self.assertEqual(2, len(cell_list)) self.assertEqual(2, len(cell_list))
# delete cells # delete cells
rplwc_line.deleteContent(map(lambda x: x.getId(), cell_list)) rplwc_line.deleteContent([x.getId() for x in cell_list])
self.commit() self.commit()
cell_list = rplwc_line.objectValues( cell_list = rplwc_line.objectValues(
...@@ -518,8 +515,8 @@ class TestReturnedSalePackingList(ReturnedSalePackingListMixin, ERP5TypeTestCase ...@@ -518,8 +515,8 @@ class TestReturnedSalePackingList(ReturnedSalePackingListMixin, ERP5TypeTestCase
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
try: try:
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
except UnsupportedWorkflowMethod, e: except UnsupportedWorkflowMethod:
self.assertTrue(True) pass
def test_04_ReturnedSalePackingListCreating(self, quiet=quiet, def test_04_ReturnedSalePackingListCreating(self, quiet=quiet,
run=run_all_test): run=run_all_test):
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testReturnedSalePackingList</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testReturnedSalePackingList</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testReturnedSalePackingList</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
interface.erp5.IBusinessLink
interface.erp5.ITradeModelPath
interface.erp5.IBuildableBusinessLinkProcess interface.erp5.IBuildableBusinessLinkProcess
interface.erp5.IBusinessLink
interface.erp5.IBusinessLinkProcess interface.erp5.IBusinessLinkProcess
interface.erp5.IBusinessProcessUnionProvider interface.erp5.IBusinessProcessUnionProvider
interface.erp5.ISimulationMovementProcess interface.erp5.ISimulationMovementProcess
interface.erp5.ITradeModelPath
interface.erp5.ITradeModelPathProcess interface.erp5.ITradeModelPathProcess
interface.erp5.ITradePhaseProcess interface.erp5.ITradePhaseProcess
interface.erp5.ITradeStateProcess interface.erp5.ITradeStateProcess
\ No newline at end of file
test.erp5.testDeliveryNode test.erp5.testDeliveryNode
\ No newline at end of file test.erp5.testDivergenceTester
test.erp5.testERP5Simulation
test.erp5.testInternalOrder
test.erp5.testInventory
test.erp5.testInventoryModule
test.erp5.testInventoryReportModule
test.erp5.testOrder
test.erp5.testOrderBuilder
test.erp5.testPackingList
test.erp5.testPackingListRoundingPrecision
test.erp5.testPurchaseOrder
test.erp5.testReturnedOrder
test.erp5.testReturnedSalePackingList
\ No newline at end of file
erp5_full_text_myisam_catalog erp5_full_text_myisam_catalog
\ No newline at end of file erp5_core_proxy_field_legacy
erp5_apparel
erp5_project
erp5_configurator_standard_solver
erp5_simulation_test_trade_template
erp5_simulation_test
erp5_administration
erp5_mrp
erp5_accounting
erp5_dummy_movement
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment