混合手动\自动编号序列

时间:2018-01-08 06:34:54

标签: acumatica

在编号序列设置(CS201010)中,有一个手动编号选项。

enter image description here

但是,取决于文档类型。有些情况下参考编号可以留空。如果它是空白的,我想要启动自动编号。或者在保存文档之前调用NextNumber()函数。可能吗 ?我该怎么做?

目前,如果我强制执行自动编号。例如,它不允许我在参考编号上键入任何内容。

TIA

1 个答案:

答案 0 :(得分:0)

有两种方式:简单和稍微复杂一点。简单的一个将附加到FieldDefaulting,并在该事件内部检查该字段是否为空,然后为其分配一些值。 另一种更好地实现Acumatica风格的方法是实现自己的AutoNumbering属性,然后将该Autonumbering属性应用于DAC类。注:你可以用你的PXCacheExtension替换Acumatica自动编号属性

下面是通过FieldDefaulting实现自动编号来删除默认自动编号的代码示例:

public class ARInvoiceEntryExt : PXGraphExtension<ARInvoiceEntry>
{
    [PXDBString(15, InputMask = ">CCCCCCCCCCCCCCC", IsKey = true, IsUnicode = true)]
    [PXDefault]
    [PXUIField(DisplayName = "Reference Nbr.", TabOrder = 1, Visibility = PXUIVisibility.SelectorVisible)]
    //[ARInvoiceType.RefNbr(typeof(Search2<ARRegisterAlias.refNbr, InnerJoinSingleTable<ARInvoice, On<ARInvoice.docType, Equal<ARRegisterAlias.docType>, And<ARInvoice.refNbr, Equal<ARRegisterAlias.refNbr>>>, InnerJoinSingleTable<Customer, On<ARRegisterAlias.customerID, Equal<Customer.bAccountID>>>>, Where<ARRegisterAlias.docType, Equal<Optional<ARInvoice.docType>>, And2<Where<ARRegisterAlias.origModule, Equal<BatchModule.moduleAR>, Or<ARRegisterAlias.released, Equal<True>>>, And<Match<Customer, Current<AccessInfo.userName>>>>>, OrderBy<Desc<ARRegisterAlias.refNbr>>>), Filterable = true, IsPrimaryViewCompatible = true)]
    //[ARInvoiceType.Numbering] 
    //This is example of throwing away Acumatica autonumbering
    //[ARInvoiceNbr]
    [PXFieldDescription]
    protected void ARInvoice_RefNbr_Cacheattached()
    {

    }

    protected void ARInvoice_RefNbr_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
    {
        //here you can implement your way of initialization of this field

    }
}

或者使用属性,你可以尝试这样的事情:

//somewhere in your code
public class RickAutonumberingAttribute : ARInvoiceNbrAttribute
{
    //Here you'll need to play with implementation of your autonumbering
}

public class ARInvoiceEntryExt : PXGraphExtension<ARInvoiceEntry>
{
    [PXDBString(15, InputMask = ">CCCCCCCCCCCCCCC", IsKey = true, IsUnicode = true)]
    [PXDefault]
    [PXUIField(DisplayName = "Reference Nbr.", TabOrder = 1, Visibility = PXUIVisibility.SelectorVisible)]
    [ARInvoiceType.RefNbr(typeof(Search2<ARRegisterAlias.refNbr, InnerJoinSingleTable<ARInvoice, On<ARInvoice.docType, Equal<ARRegisterAlias.docType>, And<ARInvoice.refNbr, Equal<ARRegisterAlias.refNbr>>>, InnerJoinSingleTable<Customer, On<ARRegisterAlias.customerID, Equal<Customer.bAccountID>>>>, Where<ARRegisterAlias.docType, Equal<Optional<ARInvoice.docType>>, And2<Where<ARRegisterAlias.origModule, Equal<BatchModule.moduleAR>, Or<ARRegisterAlias.released, Equal<True>>>, And<Match<Customer, Current<AccessInfo.userName>>>>>, OrderBy<Desc<ARRegisterAlias.refNbr>>>), Filterable = true, IsPrimaryViewCompatible = true)]
    //[ARInvoiceType.Numbering] 
    //This is example of throwing away Acumatica autonumbering
    [RickAutonumberingAttribute]
    [PXFieldDescription]
    protected void ARInvoice_RefNbr_Cacheattached()
    {
    }

}