[Vtigercrm-developers] Inventory Record copying

Alan Lord alanslists at gmail.com
Thu Nov 2 14:21:58 GMT 2017


I am trying to replicate what happens when a user clicks on the Generate 
Sales Order button from within a quote, but in code, so it can be 
triggered from a custom workflow function.

Most of it works using the basic principles in the Inventory Edit View 
class, but what I can't get to work is the copying across of the line 
items. Whilst there is are methods to getProducts() and 
setRecordFieldvalues() there doesn't seem to be a solution to copying 
the line items. I am loathe to use the Server API revise because it 
fails to perform any final recalculations (see 
http://code.vtiger.com/vtiger/vtigercrm/issues/683).

Anyone managed to do this successfully?

TIA

Al

NB: Simone, I have read your bug report above but can't see what you 
mean. The if statement deals with the condition where $parentId could be 
a single id (string) or an array of multiple ids so it uses a different 
query. And I also fail to see how this would affect the calculation of 
the totals anyway. The tests is not "wrong" as far as I can tell. 
Although, if the $parentId is an array, then what gets passed into 
vtws_runQueryAsTransaction() would be the array of parentIds inside 
another array...


Al







More information about the vtigercrm-developers mailing list