[Vtigercrm-developers] Inventory Record copying
Alan Lord
alanslists at gmail.com
Mon Nov 6 12:48:17 GMT 2017
This is driving me nuts!!!
This is on vt7.
I have a custom workflow function which uses only the Server API Create
function.
This is what we want to happen:
1. A user changes the Quote Stage of a Quote to "Accepted" and saves the
record
2. A custom workflow, set to only run once when the condition above is
met, creates a new Sales Order; essentially just like clicking on the
"Generate Sales Order" button, but we want it automated.
The problem is this.
If I save a Quote's Quote Stage field in detail view, or summary view,
then my workflow works. It creates the new Sales Order and populates the
line items (using vtws_create). *But* if I am in Edit view when I save
the Quote, I get my new Sales Order OK, but it now has *two* sets of
line items.
I don't really have a way to tell which type of save is which (Detail or
Edit) from the data passed into the Custom Workflow function.
I don't believe that I can use the $focus->isLineItemUpdate value when
using the Server APIs.
How am I supposed to achieve this?
Al
On 06/11/17 10:52, Alan Lord wrote:
>> See function "saveInventoryProductDetails()" in
>> include/utils/InventoryUtils.php
>
> Sorry, I don't think I was very clear.
>
> In the Salesorder.php class in the save_module function is this bit of
> legacy code:
>
>> //in ajax save we should not call this function, because this
>> will delete all the existing product values
>> if($_REQUEST['action'] != 'SalesOrderAjax' &&
>> $_REQUEST['ajxaction'] != 'DETAILVIEW'
>> && $_REQUEST['action'] != 'MassEditSave' &&
>> $_REQUEST['action'] != 'ProcessDuplicates'
>> && $_REQUEST['action'] != 'SaveAjax' &&
>> $this->isLineItemUpdate != false) {
>> //Based on the total Number of rows we will save the
>> product relationship with this entity
>> saveInventoryProductDetails($this, 'SalesOrder');
>> }
>
> This calls saveInventoryProductDetails when the workflow is triggered
> when I save a Quote in Edit View, but NOT when I save a Quote in Detail
> View. And, of course, from a custom workflow function I do not have
> access to a request object. I could interrogate the $_REQUEST super
> global but that doesn't seem to be the right way seeing as very little
> of the vtiger MVC arch sine version 6 uses this any more.
>
> Al
>
> _______________________________________________
> http://www.vtiger.com/
>
More information about the vtigercrm-developers
mailing list