[Vtigercrm-developers] Saving an invoice - What am I doing wrong?

Hamono, Chris (DPC) Chris.Hamono at sa.gov.au
Wed Dec 3 22:19:32 GMT 2014


Thanks

I will say that’s just crazy. I assume this is a legacy code problem.

Chris

From: vtigercrm-developers-bounces at lists.vtigercrm.com [mailto:vtigercrm-developers-bounces at lists.vtigercrm.com] On Behalf Of Satish Dvnk
Sent: Wednesday, 3 December 2014 5:17 PM
To: vtigercrm-developers at lists.vtigercrm.com
Subject: Re: [Vtigercrm-developers] Saving an invoice - What am I doing wrong?

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<mailto: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/20141204/910979d2/attachment.html>


More information about the vtigercrm-developers mailing list