Posts: 3,564
Threads: 36
Joined: Apr 2014
Reputation:
49
each record in the system has a unique ID, application-wide. These numbers come from the vtiger_crmentity table where you can find what type of record the ID is.
That is how the application knows, it writes it down :-)
Joe
TSolucio
Posts: 855
Threads: 238
Joined: Nov 2015
Reputation:
96
11-10-2015, 05:25 PM
(This post was last modified: 11-10-2015, 05:51 PM by Guido1982.)
Hehe, thanks. I'm going to start a new topic about using the global adb object.
Ah I see, the 'crmid' column corresponds with the ID in each individual table for quotes, invoices etc. and the 'setype' column tells you which module it relates to.
So let's see if I can set up some basic workflow here (and please tell me if you want me to start a different topic for this, I'll move this entry then):
Let's say I want to create an XML file that creates an entry for each invoice, and within that invoice entry I want to create an entry for each inventory line.
- I'll start by selecting from the invoices table all records, and place them into an array. No need to check for type 'invoice' against the 'crmentity' table because I know the ID's are unique.
- For each entry in the beforementioned array, I perform another query retrieving from the 'inventory details' table all records that are related to the invoice ID in the current iteration of the loop.
- I'll build an associative multi level array with all invoices and inventory lines.
- Then use DOMDocument to parse this into an XML structure.
- Save the XML file locally on the server.
- Setup a workflow that fires the creation of this file on every invoice's first save.
- Get the accounting software to read from this file every 15 minutes or so to keep it up to date.
Let me know if there are some logic errors here.
Posts: 855
Threads: 238
Joined: Nov 2015
Reputation:
96
I am in the process of making my XML file, going reasonable well, but I run into a problem and wonder if this is the correct behaviour:
'Inventory details' creates line every time an invoice, SO, etc. is saved. Let's say I edit an existing invoice. Then every product or service line is saved a second time in the database, basically double entries, maybe for keeping track of changes? Anyway, this is not so nice for my application, since it creates double product lines in my XML. Not saying this is a bad module, just not for what I'd like to use it for.
Now I see that in the table 'inventoryproduct_rel' there is a list of relations between similar numbers for an inventory, linked to different products. What I can't find out is how each 'inventoy' is linked to an entity like a quote of invoice.
Posts: 3,564
Threads: 36
Joined: Apr 2014
Reputation:
49
That is not how the inventory module should work. It currently implements the same logic of the product lines: each time you edit ALL associated records are deleted and then created new.
inventoryproduct_rel.id = invoiceid or quoteid or salesorderid or purchaseorderid
Joe
TSolucio
Posts: 855
Threads: 238
Joined: Nov 2015
Reputation:
96
I wait, I have mistaken it for a unique inventory ID, but it is one and the same as the crmentity ID.