Plone:新订单中的字段数与架构中的字段数不同

时间:2016-02-17 12:56:46

标签: python-2.7 widget plone plone-4.x

我有一个 batch.py​​ 文件,其中包含许多字段。所以我正在尝试按照我的要求在batch.py​​中添加一个新的ReferenceField。

ExtReferenceField('Asfield',
        required = 0,
        multiValued=1,
        allowed_types = ('AnalysisService',),
        referenceClass = HoldingReference,
        relationship = 'BatchAsfield',
        widget=SearchAnalysisWidget(
            label=_("AS Search"),
            description="",
            render_own_label=False,
            visible={'edit': 'visible', 'view': 'visible'},
            #visible=True,
            base_query={'inactive_state': 'active'},
            catalog_name='portal_catalog',
            showOn=True,
            colModel = [{'columnName':'AsCode','width':'20','label':_('Code')},
                        {'columnName':'AsName','width':'80','label':_('Name')},
                        {'columnName':'AsDate','width':'80','label':_('Date')},
                        {'columnName':'AsTat','width':'80','label':_('TAT')},
                        {'columnName':'AsLocation','width':'80','label':_('Location')},
                        ],
        ),
    ),

它给我一个错误:

  

ValueError:新订单中的字段数与   架构中的字段数。

1 个答案:

答案 0 :(得分:3)

我得到了这个错误的解决方案。此错误即将发生,因为我未在 batch.py​​ 文件的 getOrder 方法中添加 Asfield

实际上我们的小部件需要在浏览器上显示特定的顺序。因此,通过使用 getOrder 方法,我们可以在浏览器中维护所有小部件(字段)的顺序。此getOrder在同一文件 batch.py​​ 中定义。

def getOrder(self, schematas):
        schematas['default'] = ['id',
                                'title',
                                'description',
                                'BatchID',
                                'ClientPatientID',
                                'Patient',
                                'Client',
                                'Doctor',
                                'Asfield',
                                'ClientBatchID',
                                'ReceiptNo',
                                'AmountPaid',
                                'BatchDate',
                                'OnsetDate',
                                'PatientAgeAtCaseOnsetDate',

                                 ]
        return schematas

我只需在Doctor之后添加 Asfield (ReferenceField)(在浏览器中此Referencewidget将在Doctor之后显示)。您可以将小部件添加到所需的位置。

此值错误的解决方案很简单。