Commit 412c5411 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: erp5_item: Migrate Item Document from FS and its Unit Test.

Deleted Device Document as it is not used anywhere and not really useful:
Item can be used instead.

Migrated SubscriptionItem from FS to erp5_open_trade: this is the contract as
in https://www.erp5.com/erp5-TechnicalNote.Open.Order#contract and make
erp5_payroll depends on erp5_open_trade as Employment Contract is a
SubscriptionItem and, per design, Payroll is kind of an Open Order.
parent 8ac90175
Pipeline #8491 passed with stage
in 0 seconds
......@@ -28,7 +28,7 @@
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.Item import Item
from erp5.component.document.Item import Item
class ComputerPartition(Item):
"""Computer partition represents usage of Computer"""
......
......@@ -34,7 +34,7 @@ from Acquisition import aq_base
from Products.ERP5Type import Permissions, PropertySheet
from erp5.component.tool.ConfiguratorTool import _validateFormToRequest
from Products.ERP5.Document.Item import Item
from erp5.component.document.Item import Item
## Workflow states definitions
INITIAL_STATE_TITLE = 'Start'
......
......@@ -38,7 +38,7 @@ from Products.ERP5Type.DateUtils import addToDate, getClosestDate, roundDate
from Products.ERP5Type.DateUtils import getRoundedMonthBetween, millis
from Products.ERP5Type.DateUtils import getAccountableYearFraction
from Products.ERP5.Document.Amount import Amount
from Products.ERP5.Document.Item import Item
from erp5.component.document.Item import Item
from Products.CMFCore.utils import getToolByName
from Products.ERP5.Document.ImmobilisationMovement import (
UNIMMOBILISING_METHOD, NO_CHANGE_METHOD, AMORTISATION_METHOD_PREFIX )
......
......@@ -26,7 +26,7 @@
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Products.ERP5.Document.Item import Item
from erp5.component.document.Item import Item
from Products.ERP5.mixin.mail_message import MailMessageMixin
import email
......
......@@ -31,7 +31,6 @@ import unittest
from DateTime import DateTime
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import reindex
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testInvoice import TestSaleInvoiceMixin
from Products.ERP5.tests.utils import newSimulationExpectedFailure
......@@ -142,7 +141,6 @@ class TestItemMixin(TestSaleInvoiceMixin):
def stepCreateItemList(self, sequence=None, sequence_list=None, **kw):
""" Create some items """
item_module = self.getPortal().item_module
resource = sequence.get('resource')
item = item_module.newContent(portal_type=self.item_portal_type)
sequence.edit(item_list=[item])
......@@ -1057,42 +1055,42 @@ class TestItemScripts(ERP5TypeTestCase):
# with line
def test_Item_getResourceValue(self):
self.assertEqual(None, self.item.Item_getResourceValue())
line = self._makeSalePackingListLine()
self._makeSalePackingListLine()
self.assertEqual(self.product, self.item.Item_getResourceValue())
self.assertEqual(None, self.item.Item_getResourceValue(
at_date=DateTime() - 2))
def test_Item_getResourceTitle(self):
self.assertEqual(None, self.item.Item_getResourceTitle())
line = self._makeSalePackingListLine()
self._makeSalePackingListLine()
self.assertEqual('Product', self.item.Item_getResourceTitle())
self.assertEqual(None, self.item.Item_getResourceTitle(
at_date=DateTime() - 2))
def test_Item_getCurrentOwnerValue(self):
self.assertEqual(None, self.item.Item_getCurrentOwnerValue())
line = self._makeSalePackingListLine()
self._makeSalePackingListLine()
self.assertEqual(self.section, self.item.Item_getCurrentOwnerValue())
self.assertEqual(None,
self.item.Item_getCurrentOwnerValue(at_date=DateTime() - 2))
def test_Item_getCurrentOwnerTitle(self):
self.assertEqual(None, self.item.Item_getCurrentOwnerTitle())
line = self._makeSalePackingListLine()
self._makeSalePackingListLine()
self.assertEqual('Section', self.item.Item_getCurrentOwnerTitle())
self.assertEqual(None,
self.item.Item_getCurrentOwnerTitle(at_date=DateTime() - 2))
def test_Item_getCurrentSiteValue(self):
self.assertEqual(None, self.item.Item_getCurrentSiteValue())
line = self._makeSalePackingListLine()
self._makeSalePackingListLine()
self.assertEqual(self.node, self.item.Item_getCurrentSiteValue())
self.assertEqual(None, self.item.Item_getCurrentSiteValue(
at_date=DateTime() - 2))
def test_Item_getCurrentSiteTitle(self):
self.assertEqual(None, self.item.Item_getCurrentSiteTitle())
line = self._makeSalePackingListLine()
self._makeSalePackingListLine()
self.assertEqual('Node', self.item.Item_getCurrentSiteTitle())
self.assertEqual(None,
self.item.Item_getCurrentSiteTitle(at_date=DateTime() - 2))
......@@ -1160,7 +1158,7 @@ class TestItemScripts(ERP5TypeTestCase):
destination_section_value=self.section,
specialise_value=self.portal.business_process_module.erp5_default_business_process,
start_date=DateTime() - 1,)
line = packing_list.newContent(
packing_list.newContent(
portal_type='Sale Packing List Line',
quantity=1,
resource_value=self.product,
......
<?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>testItem</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testItem</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testItem</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>
test.erp5.testItem
\ No newline at end of file
erp5_core_proxy_field_legacy
erp5_full_text_mroonga_catalog
erp5_base
erp5_pdm
erp5_simulation
erp5_trade
erp5_apparel
erp5_project
erp5_configurator_standard_solver
erp5_configurator_standard_trade_template
erp5_simulation_test
erp5_administration
erp5_dummy_movement
erp5_accounting
erp5_invoicing
erp5_simplified_invoicing
erp5_configurator_standard_accounting_template
erp5_configurator_standard_invoicing_template
erp5_trade_proxy_field_legacy
\ No newline at end of file
......@@ -31,16 +31,13 @@ import zope.interface
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.Document.Item import Item
from erp5.component.document.Item import Item
from Products.ERP5.mixin.composition import CompositionMixin
from Products.ERP5.mixin.simulable import SimulableMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.mixin.periodicity import PeriodicityMixin
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5Type.Base import Base
from zLOG import LOG
class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin,
SimulableMixin, PeriodicityMixin):
"""
......@@ -111,7 +108,6 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin,
TODO: clever handling of quantity (based on the nature
of resource, ie. float or unit)
"""
from Products.ERP5Type.Document import newTempMovement
result = []
# Try to find the source open order
......@@ -147,7 +143,9 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin,
next_date = self.getNextPeriodicalDate(current_date)
if next_date > stop_date:
next_date = stop_date
generated_movement = newTempMovement(self, 'subscription_%s' % id_index)
generated_movement = self.newContent(temp_object=True,
portal_type='Movement',
id='subscription_%s' % id_index)
generated_movement._edit( aggregate_value=self,
resource=resource,
quantity=quantity,
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SubscriptionItem</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.Document.SubscriptionItem</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.SubscriptionItem</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document 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>
<string>W:229, 2: Arguments number differs from overridden \'getPrice\' method (arguments-differ)</string>
<string>W:265, 58: Redefining built-in \'filter\' (redefined-builtin)</string>
</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>
document.erp5.OpenOrder
document.erp5.OpenOrderCell
document.erp5.OpenOrderLine
\ No newline at end of file
document.erp5.OpenOrderLine
document.erp5.SubscriptionItem
\ No newline at end of file
......@@ -27,7 +27,7 @@
##############################################################################
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.SubscriptionItem import SubscriptionItem
from erp5.component.document.SubscriptionItem import SubscriptionItem
from AccessControl import ClassSecurityInfo
from Products.ERP5Type.DateUtils import addToDate, atTheEndOfPeriod
from DateTime import DateTime
......
erp5_core (>= 5.4.3)
erp5_trade
erp5_accounting
\ No newline at end of file
erp5_accounting
erp5_open_trade
\ No newline at end of file
......@@ -29,7 +29,7 @@
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.Item import Item
from erp5.component.document.Item import Item
from Products.ERP5.Document.TextDocument import TextDocument
class SoftwareLicence(TextDocument, Item):
......
##############################################################################
#
# Copyright (c) 2003 Nexedi SARL and Contributors. All Rights Reserved.
# Guillaume Michon <guillaume@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.Item import Item
class Device(Item):
"""
Devices represent equipments with one network interface
"""
meta_type = 'ERP5 Device'
portal_type = 'Device'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Price
, PropertySheet.Resource
, PropertySheet.Item
, PropertySheet.Amount
, PropertySheet.Reference
, PropertySheet.Device
)
......@@ -35,65 +35,65 @@ from Products.ERP5.Document.Amount import Amount
class Item(XMLObject, Amount):
"""
Items in ERP5 are intended to provide a way to track objects
"""
meta_type = 'ERP5 Item'
portal_type = 'Item'
add_permission = Permissions.AddPortalContent
"""
Items in ERP5 are intended to provide a way to track objects
"""
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
meta_type = 'ERP5 Item'
portal_type = 'Item'
add_permission = Permissions.AddPortalContent
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Price
, PropertySheet.Item
, PropertySheet.Amount
, PropertySheet.Reference
)
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
if 0:
# The following code is disabled. The original intention was to generate
# an unique reference for each item. We now use reference instead of id,
# so this is not applicable any longer. We need something different for
# reference.
security.declareProtected(Permissions.ModifyPortalContent,'generateNewId')
def generateNewId(self, id_group='item_id_group', default=None, method=None):
"""
We want a different id for all Item
"""
return XMLObject.generateNewId(self, id_group=id_group, default=default, method=method)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Price
, PropertySheet.Item
, PropertySheet.Amount
, PropertySheet.Reference
)
security.declareProtected(Permissions.AccessContentsInformation, 'getPrice')
def getPrice(self,context=None,**kw):
if 0:
# The following code is disabled. The original intention was to generate
# an unique reference for each item. We now use reference instead of id,
# so this is not applicable any longer. We need something different for
# reference.
security.declareProtected(Permissions.ModifyPortalContent,'generateNewId')
def generateNewId(self, id_group='item_id_group', default=None, method=None):
"""
Get the Price in the context.
If price is not stored locally, lookup a price
We want a different id for all Item
"""
local_price = self._baseGetPrice()
if local_price is None:
# We must find a price for this movement
# XXX we should not set a resource on item
resource = self.getResourceValue()
if resource is not None:
local_price = resource.getPrice(self.asContext( context=context, **kw))
return local_price
security.declareProtected(Permissions.AccessContentsInformation,
'getRemainingQuantity')
def getRemainingQuantity(self):
"""
Computes the quantity of an item minus quantity of all sub_items
"""
sub_quantity = 0
for sub_item in self.objectValues():
if sub_item.isItem():
sub_quantity += sub_item.getQuantity()
return self.getQuantity() - sub_quantity
return XMLObject.generateNewId(self, id_group=id_group, default=default, method=method)
security.declareProtected(Permissions.AccessContentsInformation, 'getPrice')
def getPrice(self,context=None,**kw):
"""
Get the Price in the context.
If price is not stored locally, lookup a price
"""
local_price = self._baseGetPrice()
if local_price is None:
# We must find a price for this movement
# XXX we should not set a resource on item
resource = self.getResourceValue()
if resource is not None:
local_price = resource.getPrice(self.asContext( context=context, **kw))
return local_price
security.declareProtected(Permissions.AccessContentsInformation,
'getRemainingQuantity')
def getRemainingQuantity(self):
"""
Computes the quantity of an item minus quantity of all sub_items
"""
sub_quantity = 0
for sub_item in self.objectValues():
if sub_item.isItem():
sub_quantity += sub_item.getQuantity()
return self.getQuantity() - sub_quantity
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>Item</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.Document.Item</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.Item</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document 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>
document.erp5.Item
document.erp5.ScriptConstraint
\ No newline at end of file
......@@ -461,6 +461,7 @@ class TestXHTML(TestXHTMLMixin):
'erp5_mrp',
'erp5_open_trade',
'erp5_payroll',
'erp5_project',
......
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