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

Jonathan Sardo sardoj at gmail.com
Fri Dec 5 23:17:06 GMT 2014


Hi!

To do this, I simply make a SQL query to update values.

Regards,

Jonathan SARDO
[image: Images intégrées 5]

2014-12-03 23:19 GMT+01:00 Hamono, Chris (DPC) <Chris.Hamono at sa.gov.au>:

> 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> 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/
>
>
>
> _______________________________________________
> http://www.vtiger.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20141206/e2ed8eed/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 4223 bytes
Desc: not available
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20141206/e2ed8eed/attachment.png>


More information about the vtigercrm-developers mailing list