Re:howto transf. customfields from proposal to order 8 Months ago
Karma: 6
Hello,
I am the developper of CustomFields.
I don't understand what you mean by quotation, could you provide more details about what module you are talking about?
About your question, no there's no automatic transfer of custom fields from modules to modules, because noone asked for such a feature before.
However, this may not be necessary. For example, orders that are converted to invoices produce a link between the order and the invoice. Thus, you can access the order's custom fields from the invoice. For example, if you want to print custom fields of your order but print them on the PDF generated from the invoice, this is totally possible.
CustomFields Free edition should also be able to do that, but it will be a lot more complex because the customfields_fill_object() function, which does a lot of the job for you, is not available in the Free edition.
If this is not a viable solution for what you want to achieve, please give me more details so that I can better understand your goal.
Re:howto transf. customfields from proposal to order 8 Months ago
Karma: 6
Ah ok thank's Humphrey. Your first translation quotation = propale was better in the context of Dolibarr since it's how the module is called
Ok then Tom, when you convert a quotation to order and then to invoice, every one of these gets linked inside the Dolibarr database in the table llx_element_element, so then you can easily recreate the link with CustomFields using customfields_fill_object() as indicated in the tutorial I've given you, thus avoiding you the need to transfer/copy the custom fields (which would not be very clean: with the method I present you, you can set different custom fields for every one of these modules, and still link them, fetch them and use them whenever you need).
Re:howto transf. customfields from proposal to order 8 Months ago
Karma: 0
Hi lrq3000, thank's for your answers.
1) since I am new to dolibarr I would like to know if it's a good way to use a trigger-event (e.g. ORDER_CREATE) to run customfields_fill_object() (as per "linking dolibarr objects from two diff. modules") to fill CustomFields of my new Order with CustomFields from my Quotation (=propale). I assume that I can see (and edit) these newly filled CustomFields afterwards in the invoice module.
2) Is there a way to distinguish in an ORDER_CREATE trigger event between a new order converted from a quote (propale) or a "blank" new order?
(maybe some kind of state information?)
Thanks in advance for helping me !
best regards
Tom
Re:howto transf. customfields from proposal to order 8 Months ago
Karma: 6
Hello Tom,
1) Yes that would be a pretty clean way to do that. You could make a trigger file on ORDER_CREATE which would fetch the Quotation's custom fiels using customfields_fill_object() and table llx_element_element (or maybe directly $object may contain the link) and create a new custom field for orders using createCustomField() by just passing the object returned by customfields_fill_object (just be sure that the $object->table_element = 'order' or 'commande' and not 'propal').
But as I said, copying custom fields is not necessary to fetch them since you can get the links using llx_element_element.
2) In any case you should be able to get the state using the table llx_element_element, but you may also find the quotation to be a sub-element of $object (order), but this is not necessarily the case! Objects linking in Dolibarr seems to be undergoing a refactoration to ease this kind of processing, but I'm not too sure about it.
An alternative would be to find the class where the orders are created from a quote, and add your own trigger there (eg: ORDER_CREATE_FROM_PROPAL), but it may already exists. Just look inside the *.class.php files.
Re:howto transf. customfields from proposal to order 7 Months, 3 Weeks ago
Karma: 0
Hello lrq3000,
thanks for your last reply, which is a while ago.
In the meantime I bought the Pro version of CustomFields to be able to use 'customfields_fill_object'.
To take some CustomFields from an existing ComercialProposal into an new CustomerOrder I created a trigger with action == 'ORDER_CREATE' and followed the example of the wiki you gave me a view posts above (Linking Dolibarr objects from two different modules) to get access to all the CustomFields (both 'propal' and 'commande') using customfields_fill_object.
Either you can just use 2 different objects with customfields_fill_object($object, $fromobject); where $fromobject is the propal object, and $object is the order object. Then you will be able to directly use $customfields->update($object).
For more information about the update() method and customfields_fill_object() function, please check the wiki (I've just updated the customfields_fill_object() chapter to describe its full specification):
because $object - which is passed to update() - must be an object containing the customfields data as its properties (and not another costomfields object).
Thanks again for your quick support.
Maybe I will need your help again when I'm going to extend dolibarr's project functionalities with TimeTracking features.
Re:howto transf. customfields from proposal to order 7 Months, 3 Weeks ago
Karma: 6
Hello Tom,
Thank you for the feedback, indeed my bad! I will add a compatibility layer to easy this kind of operation in the future, so that in future versions of CustomFields one will be able to just use $object->customfields or even $object->customfields->propal.
Feel free to contact me again, your TimeTracking sure seems interesting! Don't forget that if you make a module on top of the CustomFields class, it will also work with CustomFields Free normally (since both shares a lot of code in common).