Menu

#1567 Wrong usage of ModelValidator on LiberoValidator

Beta
closed-fixed
nobody
3
2008-12-02
2008-11-06
Carlos Ruiz
No

Hi, I'm just checking LiberoValidator.java - I see there is a wrong usage of ModelValidator for the C_Order table.

Case:

on initialize there is this line
engine.addModelChange(MOrder.Table_Name, this);

on modelChange the check is:
if (po.get_TableName().equals(MOrder.Table_Name) && (type == TYPE_AFTER_CHANGE ))
{
MOrder order = (MOrder)po;
if(order.getDocStatus().equals(MOrder.DOCSTATUS_InProgress) || order.getDocStatus().equals(MOrder.DOCSTATUS_Completed))
MPPMRP.C_Order((MOrder)po, false);

This is incorrect and error prone - the model change is catched for ALL CHANGES. Even changing Description of a completed order will trigger this code - and will call MPPMRP.C_Order and MPPMRP.C_OrderLine

I don't know the consequences of calling this many times - after the order is completed - but the correct usage must be:

on initialize:
engine.addDocValidate(MOrder.Table_Name, this);

on docValidate:
if (po.get_TableName().equals(MOrder.Table_Name) && (timing == TIMING_BEFORE_COMPLETE ))

Cordially,

Carlos Ruiz

Discussion

  • Carlos Ruiz

    Carlos Ruiz - 2008-11-06

    Same behavior found some lines below with C_OrderLine table.

    Cordially,

    Carlos Ruiz

     
  • Teo Sarca

    Teo Sarca - 2008-11-07

    Hmmm, yes and no :)

    I think it's very useful to generate drafted documents and update them when C_Order/C_OrderLine changes.
    The problem is (as you pointed out), there are a lot of fields that do not influence the generated document, you the "trigger" should be called just for relevant fields.

    Wondering how users from similar production environment will prefer things... What do you think ?

    PS: considering your suggestion, which document status transitions will you suggest ?

    Best regards,
    Teo Sarca - www.arhipac.ro

     
  • Carlos Ruiz

    Carlos Ruiz - 2008-11-07

    Hi Teo,

    > I think it's very useful to generate drafted documents and update them
    > when C_Order/C_OrderLine changes.

    That's not the current behavior.

    The modelvalidator is checking this for InProgress or Completed status.

    I suppose PP_MRP is something like a read-only table. If it's not a read-only (you just created today a window, but I don't know if it's readonly or not) - then it would be dangerous to have maintenance for PP_MRP on draft status from a draft order.

    Regards,

    Carlos Ruiz

     
  • Bayu Cahya P

    Bayu Cahya P - 2008-11-08

    Hi Victor,

    This is not related with manufacturing.

    Could you check line 128? (Rev 6903)

    While performing matching po-receipt, we got
    ===========> MOrderLine.saveError: Error - org.compiere.model.MOrderLine cannot be cast to org.compiere.model.MOrder [11]

    I didn't know the implication, but I have replaced to MPPMRP.C_OrderLine(ol, false); and we can continue matching po-receipt.

    Thanks
    Bayu
    http://sistematika.web.id

     
  • Carlos Ruiz

    Carlos Ruiz - 2008-11-17

    Fixed with revisions 6903, 6976, 7057

    Regards,

    Carlos Ruiz

     
  • Carlos Ruiz

    Carlos Ruiz - 2008-11-17
    • status: open --> pending-fixed
     
  • SourceForge Robot

    • status: pending-fixed --> closed-fixed
     
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     

Log in to post a comment.

MongoDB Logo MongoDB