xTuple.com xTupleU Blog & News Customer Support

purchaseOrderItem

using Windows 5.1 version

I need to add custom scripting to the purchaseOrderItem screen.
Normally, I would use the

mywindow[“newId(int)”].connect(loadmydata);

but mywindow does not have this signal. Neither does mywidget or mydialog.

I also tried the comment tab as a hook, since the source code has the following

_comments->setId(_poitemid); but no joy

Does anyone have any idea what signal I need to use to fire up my custom code, once the purchase order item screen is filled.

perhaps a bit of a workaround you could use

mywindow.findChild("_item").newId.connect(loadmydata)

I believe that will fire after the purchaseOrderItem screen’s set() method is called.
just going off of another trigger.

Thank you Caleb,

But that wont work, because it is the user that selects the item. And my function adds the extra clause to set the correct item that the user will select.

I need a signal when the purchaseOrderItem is populated or ready for user input.

As a rant, I believe xTuple should standardize their code so signals are emitted when any screen is done.

Ah I see your problem.
I guess you are looking for something like an “onReady” signal.

The only other thing I can think of is to try and use the textChanged signal from the _poNumber field. and I don’t know if that is exposed.

Otherwise you will have to open the purchaseOrderItem from a custom script. so that you can control it more. not a bad thing for performance but a bit more coding for sure

hopefully someone else has a better answer then me.

But thinking on your rant. It might be nice if the set() function would emit a simple signal. It does not seem like a hard change at all and it may be of some help to people like us that want to load data right after the set function completes.

Thanks caleb,

I will try the textChanged signal.

Bob

I had to use the _taxtype combo

tax_type[“newID(int)”].connect(loadData);

glad to hear you got a easy work around. I figured there would be some field that would throw a signal.

We “recently” started adding the mywindow["newId(int)"] signal to windows so it is only available to some windows, not all unfortunately.

So the “correct” signal to use would depend on what you need for your custom script. If you need the poitemid then I would use the set() function which is always called for each window

var poitemid;

function set(input) {
  if ("poitem_id" in input) 
    poitemid = input.poitemid;

  myCustomFunction();
}

If there are multiple scripts on that window that call set() you can have difficulties but that is outside the scope of this reply.

Another function that is always called is showEvent() which is called after the screen is displayed (so after all the initialisation code has run) but this does not have inputs so you would have to read values from the widgets as appropriate.

So if set is defined in the script, will it fire when the core code calls set?

Yes - there are several events that are triggered automatically in a script. You do not have to explicitly call then or attach them to a widget signal, they will run regardless.

set(), showEvent(), closeEvent() I believe can be used in any screen.

1 Like

I found it easier to create my own PO screen by copying in the source purchaseOrder.ui into a new screen and add your required script. Then you can add your own controls easier.

All I have to do if segregate the trade PO that we need to customize versus normal Supply PO that xTuple is built for.