[Vtigercrm-developers] Saving an invoice - What am I doing wrong?
Satish Dvnk
satish.dvnk at vtiger.com
Wed Dec 3 06:47:04 GMT 2014
Hi Chris,
While saving the details of Invoice line items, we are removing the
existing information of line items and expecting the updated line items
information from $_REQUEST.
*regards,Satish.Dvnk*
On Wed, Dec 3, 2014 at 9:54 AM, Hamono, Chris (DPC) <Chris.Hamono at sa.gov.au>
wrote:
> I am programmatically updating a couple of fields in an invoice. When I
> save the invoice the changes are correctly recorded but it loses the
> attached product.
>
> I am using the following code what am I doing wrong?
>
>
> // create the model from the record id
> $invoiceModel = Vtiger_Record_Model::getInstanceById($invoiceid,
> "Invoice");
>
> if ($invoiceModel) {
> // set the fields as supplied
> foreach ($fields as $key=>$value){
> $invoiceModel->set($key, $value);
> }
>
> // set mode to edit
> $invoiceModel->set('mode', 'edit');
>
> // save
> $invoiceModel->save();
>
> return $invoiceModel->getData();
> }
>
> If I var dump the array returned by getData() it correctly shows the
> product and the changes.
>
> e.g.
>
> ['invoicestatus'] =>'Paid' <= status changed
> ['cf_738'] =>'BZ-0025028687' <= custom field being updated
> ['invoice_no'] =>'INV405'
> ['productid'] =>2175
> ['quantity'] =>1.000
> ['listprice'] =>605.00000000
>
>
> If I then go to the invoice detail page. The changes I have made are
> correctly saved (in the above I am setting the status field to ‘Paid’ and
> setting a custom field) but the invoice no longer has any products attached
> to it.
>
>
> Chris
>
>
>
> _______________________________________________
> http://www.vtiger.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20141203/0eb2afb3/attachment-0001.html>
More information about the vtigercrm-developers
mailing list