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
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.Item import Item from erp5.component.document.Item import Item
class ComputerPartition(Item): class ComputerPartition(Item):
"""Computer partition represents usage of Computer""" """Computer partition represents usage of Computer"""
......
...@@ -34,7 +34,7 @@ from Acquisition import aq_base ...@@ -34,7 +34,7 @@ from Acquisition import aq_base
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from erp5.component.tool.ConfiguratorTool import _validateFormToRequest from erp5.component.tool.ConfiguratorTool import _validateFormToRequest
from Products.ERP5.Document.Item import Item from erp5.component.document.Item import Item
## Workflow states definitions ## Workflow states definitions
INITIAL_STATE_TITLE = 'Start' INITIAL_STATE_TITLE = 'Start'
......
...@@ -38,7 +38,7 @@ from Products.ERP5Type.DateUtils import addToDate, getClosestDate, roundDate ...@@ -38,7 +38,7 @@ from Products.ERP5Type.DateUtils import addToDate, getClosestDate, roundDate
from Products.ERP5Type.DateUtils import getRoundedMonthBetween, millis from Products.ERP5Type.DateUtils import getRoundedMonthBetween, millis
from Products.ERP5Type.DateUtils import getAccountableYearFraction from Products.ERP5Type.DateUtils import getAccountableYearFraction
from Products.ERP5.Document.Amount import Amount 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.CMFCore.utils import getToolByName
from Products.ERP5.Document.ImmobilisationMovement import ( from Products.ERP5.Document.ImmobilisationMovement import (
UNIMMOBILISING_METHOD, NO_CHANGE_METHOD, AMORTISATION_METHOD_PREFIX ) UNIMMOBILISING_METHOD, NO_CHANGE_METHOD, AMORTISATION_METHOD_PREFIX )
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
############################################################################## ##############################################################################
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions 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 from Products.ERP5.mixin.mail_message import MailMessageMixin
import email import email
......
...@@ -31,7 +31,6 @@ import unittest ...@@ -31,7 +31,6 @@ import unittest
from DateTime import DateTime 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 AccessControl.SecurityManagement import newSecurityManager
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.testInvoice import TestSaleInvoiceMixin
from Products.ERP5.tests.utils import newSimulationExpectedFailure from Products.ERP5.tests.utils import newSimulationExpectedFailure
...@@ -142,7 +141,6 @@ class TestItemMixin(TestSaleInvoiceMixin): ...@@ -142,7 +141,6 @@ class TestItemMixin(TestSaleInvoiceMixin):
def stepCreateItemList(self, sequence=None, sequence_list=None, **kw): def stepCreateItemList(self, sequence=None, sequence_list=None, **kw):
""" Create some items """ """ Create some items """
item_module = self.getPortal().item_module item_module = self.getPortal().item_module
resource = sequence.get('resource')
item = item_module.newContent(portal_type=self.item_portal_type) item = item_module.newContent(portal_type=self.item_portal_type)
sequence.edit(item_list=[item]) sequence.edit(item_list=[item])
...@@ -1057,42 +1055,42 @@ class TestItemScripts(ERP5TypeTestCase): ...@@ -1057,42 +1055,42 @@ class TestItemScripts(ERP5TypeTestCase):
# with line # with line
def test_Item_getResourceValue(self): def test_Item_getResourceValue(self):
self.assertEqual(None, self.item.Item_getResourceValue()) self.assertEqual(None, self.item.Item_getResourceValue())
line = self._makeSalePackingListLine() self._makeSalePackingListLine()
self.assertEqual(self.product, self.item.Item_getResourceValue()) self.assertEqual(self.product, self.item.Item_getResourceValue())
self.assertEqual(None, self.item.Item_getResourceValue( self.assertEqual(None, self.item.Item_getResourceValue(
at_date=DateTime() - 2)) at_date=DateTime() - 2))
def test_Item_getResourceTitle(self): def test_Item_getResourceTitle(self):
self.assertEqual(None, self.item.Item_getResourceTitle()) self.assertEqual(None, self.item.Item_getResourceTitle())
line = self._makeSalePackingListLine() self._makeSalePackingListLine()
self.assertEqual('Product', self.item.Item_getResourceTitle()) self.assertEqual('Product', self.item.Item_getResourceTitle())
self.assertEqual(None, self.item.Item_getResourceTitle( self.assertEqual(None, self.item.Item_getResourceTitle(
at_date=DateTime() - 2)) at_date=DateTime() - 2))
def test_Item_getCurrentOwnerValue(self): def test_Item_getCurrentOwnerValue(self):
self.assertEqual(None, self.item.Item_getCurrentOwnerValue()) self.assertEqual(None, self.item.Item_getCurrentOwnerValue())
line = self._makeSalePackingListLine() self._makeSalePackingListLine()
self.assertEqual(self.section, self.item.Item_getCurrentOwnerValue()) self.assertEqual(self.section, self.item.Item_getCurrentOwnerValue())
self.assertEqual(None, self.assertEqual(None,
self.item.Item_getCurrentOwnerValue(at_date=DateTime() - 2)) self.item.Item_getCurrentOwnerValue(at_date=DateTime() - 2))
def test_Item_getCurrentOwnerTitle(self): def test_Item_getCurrentOwnerTitle(self):
self.assertEqual(None, self.item.Item_getCurrentOwnerTitle()) self.assertEqual(None, self.item.Item_getCurrentOwnerTitle())
line = self._makeSalePackingListLine() self._makeSalePackingListLine()
self.assertEqual('Section', self.item.Item_getCurrentOwnerTitle()) self.assertEqual('Section', self.item.Item_getCurrentOwnerTitle())
self.assertEqual(None, self.assertEqual(None,
self.item.Item_getCurrentOwnerTitle(at_date=DateTime() - 2)) self.item.Item_getCurrentOwnerTitle(at_date=DateTime() - 2))
def test_Item_getCurrentSiteValue(self): def test_Item_getCurrentSiteValue(self):
self.assertEqual(None, self.item.Item_getCurrentSiteValue()) self.assertEqual(None, self.item.Item_getCurrentSiteValue())
line = self._makeSalePackingListLine() self._makeSalePackingListLine()
self.assertEqual(self.node, self.item.Item_getCurrentSiteValue()) self.assertEqual(self.node, self.item.Item_getCurrentSiteValue())
self.assertEqual(None, self.item.Item_getCurrentSiteValue( self.assertEqual(None, self.item.Item_getCurrentSiteValue(
at_date=DateTime() - 2)) at_date=DateTime() - 2))
def test_Item_getCurrentSiteTitle(self): def test_Item_getCurrentSiteTitle(self):
self.assertEqual(None, self.item.Item_getCurrentSiteTitle()) self.assertEqual(None, self.item.Item_getCurrentSiteTitle())
line = self._makeSalePackingListLine() self._makeSalePackingListLine()
self.assertEqual('Node', self.item.Item_getCurrentSiteTitle()) self.assertEqual('Node', self.item.Item_getCurrentSiteTitle())
self.assertEqual(None, self.assertEqual(None,
self.item.Item_getCurrentSiteTitle(at_date=DateTime() - 2)) self.item.Item_getCurrentSiteTitle(at_date=DateTime() - 2))
...@@ -1160,7 +1158,7 @@ class TestItemScripts(ERP5TypeTestCase): ...@@ -1160,7 +1158,7 @@ class TestItemScripts(ERP5TypeTestCase):
destination_section_value=self.section, destination_section_value=self.section,
specialise_value=self.portal.business_process_module.erp5_default_business_process, specialise_value=self.portal.business_process_module.erp5_default_business_process,
start_date=DateTime() - 1,) start_date=DateTime() - 1,)
line = packing_list.newContent( packing_list.newContent(
portal_type='Sale Packing List Line', portal_type='Sale Packing List Line',
quantity=1, quantity=1,
resource_value=self.product, 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 ...@@ -31,16 +31,13 @@ import zope.interface
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces 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.composition import CompositionMixin
from Products.ERP5.mixin.simulable import SimulableMixin from Products.ERP5.mixin.simulable import SimulableMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.mixin.periodicity import PeriodicityMixin from Products.ERP5.mixin.periodicity import PeriodicityMixin
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
from zLOG import LOG
class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin, class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin,
SimulableMixin, PeriodicityMixin): SimulableMixin, PeriodicityMixin):
""" """
...@@ -111,7 +108,6 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin, ...@@ -111,7 +108,6 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin,
TODO: clever handling of quantity (based on the nature TODO: clever handling of quantity (based on the nature
of resource, ie. float or unit) of resource, ie. float or unit)
""" """
from Products.ERP5Type.Document import newTempMovement
result = [] result = []
# Try to find the source open order # Try to find the source open order
...@@ -147,7 +143,9 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin, ...@@ -147,7 +143,9 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin,
next_date = self.getNextPeriodicalDate(current_date) next_date = self.getNextPeriodicalDate(current_date)
if next_date > stop_date: if next_date > stop_date:
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, generated_movement._edit( aggregate_value=self,
resource=resource, resource=resource,
quantity=quantity, 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.OpenOrder
document.erp5.OpenOrderCell document.erp5.OpenOrderCell
document.erp5.OpenOrderLine document.erp5.OpenOrderLine
document.erp5.SubscriptionItem
\ No newline at end of file
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
############################################################################## ##############################################################################
from Products.ERP5Type import Permissions, PropertySheet 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 AccessControl import ClassSecurityInfo
from Products.ERP5Type.DateUtils import addToDate, atTheEndOfPeriod from Products.ERP5Type.DateUtils import addToDate, atTheEndOfPeriod
from DateTime import DateTime from DateTime import DateTime
......
erp5_core (>= 5.4.3) erp5_core (>= 5.4.3)
erp5_trade erp5_trade
erp5_accounting erp5_accounting
erp5_open_trade
\ No newline at end of file
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet 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 from Products.ERP5.Document.TextDocument import TextDocument
class SoftwareLicence(TextDocument, Item): 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
)
<?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 document.erp5.ScriptConstraint
\ No newline at end of file
...@@ -461,6 +461,7 @@ class TestXHTML(TestXHTMLMixin): ...@@ -461,6 +461,7 @@ class TestXHTML(TestXHTMLMixin):
'erp5_mrp', 'erp5_mrp',
'erp5_open_trade',
'erp5_payroll', 'erp5_payroll',
'erp5_project', '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