I have a strange behaviour on my erpal platform installation and I am not very sure if it is a bug or a misconfiguration. But at first sight it looks to me familar to this bug: https://www.drupal.org/node/2497085

When installing the erpal platform you set usually your default vendor with his vendor address. This is later on changeable on */admin/erpal/settings/vendor

But after adding more contacts it happens something strange: The Vendor select field don't show any more the configured Vendor during installation - it is just set to "none" - In between the Vendor Vendor address field keeps linked to the configured Vendor.

When trying to select again the correct Vendor in the vendor field the selection only show selectable the last 10-20 contacts, just like in the inline editor field bug: https://www.drupal.org/node/2497085

There is no way to add again a Vendor name of former crm core organization addresses beyond the last 20 newly registered addresses.

Any explanation?

Comments

ChoY created an issue. See original summary.

bechtold’s picture

Status: Active » Postponed (maintainer needs more info)

I tried to reproduce it, so I created 25 contacts.
But everything is working fine.
The list shows all contacts and the vendor is not lost.
Is this still happening for you? If so, can you provide us with more information to recreate this?

ChoY’s picture

I try top explain again:
The Vendor Settings are configured during install and should be changeable at any later moment.
BUT: there is something wrong in the first field of: Vendor: (field_vendor?) on admin/erpal/settings/vendor
It only search the last 10 contact entries. No way to choose older contact entries. - And even worth if I set a new vendor address with a new contact & address this last vendor name is deleted as soon as I have new vontact entries.
However: The next field, Vendor Adress (field_vendor_address?) works perfect and still shows the Address linked to the contact of the address. -

Where in the code is to find the definition of these fields? Where in the database I could correct/enter manually the vendor settings - this knowledge may help me to find the bug ...

ChoY’s picture

To explain a little bit more:
In my case the vendor field is a select field, which seems to be configured to show only the last 10 entries.
I see exactly here the problem. It should be auto-complete field - and it isn't.

bechtold’s picture

I think I understand, but I still don't have the problem.
My select field shows all contacts available, in my case 25, not only 10.
So I think the problem is not on the select field.

Select field vs. autocomplete field is not about fixing the bug, it is about usability in my opinion.
Feel free to add a patch, to change the widget.

ChoY’s picture

again to explain clearer -
In one Erpal platform installation I can only select the last 10 (of around 500 entries)
in an other (newer) Erpal platform installation I can select the last 30 (of around 200 entries)
In no case I can use the autocomplete search for earlier entries - only those who appear in the viewable list are searchable and selectable.
However choosing a vendor in quote or order works perfectly (those fields are defined through UI) - only the admin site for Erpal vendor settings (defined anywhere in the code) show this bug
Where are the vendor field to find in the database? And/or where in the code I can find the definition of the vendor field for Erpal vendor settings? Eventually I can find than myself the bug (for there is no error message to find about). I searched all around and couldn't find the respective database entry - Thanks for a hint.

ChoY’s picture

Hi Bechthold this bug is still not solved. Do you have in between any suggestions how to get rid off?
Looking inrto the html code of the vendor settings the field "Vendor" only shwoing the last contact 25 entries is defined as

<form action="/admin/erpal/settings/vendor" method="post" id="erpal-commerce-vendor-settings-form" accept-charset="UTF-8"><div><fieldset class="form-wrapper" id="edit-erpal-vendor-settings"><legend><span class="fieldset-legend">Vendor settings</span></legend><div class="fieldset-wrapper">

Where I can find the definition of this form-id: "erpal-commerce-vendor-settings-form" and the fieldset class id "edit-erpal-vendor-settings"? I presume tje reason why the field shows up only a limited number of last cpntact entries is anywhere in the code related to these fotrm and fieldset

ChoY’s picture

Version: 7.x-3.0-alpha12 » 7.x-3.0-beta2
bechtold’s picture

Hey ChoY,
since we could not yet reproduce it we did not fix anything, that is correct.
You can find the form in profiles/erpal_platform/modules/profile/erpal_commerce/erpal_commerce.admin.inc it is the function erpal_commerce_vendor_settings_form($form, &$form_state).

I don't know why, but I just saw that this field is filled by utilizing a view. This view has a pager that is set to 30. I believe that might be the problem.
Could you check changing the pager on the view /admin/structure/views/view/erpal_crm_contacts/edit/panel_pane_4
Maybe this solves your problem. If so we should maybe not use the view.
I think using an autocomplete field would be nice anyways, would you be able to provide a patch maybe?

ChoY’s picture

Could you check changing the pager on the view /admin/structure/views/view/erpal_crm_contacts/edit/panel_pane_4
Maybe this solves your problem. If so we should maybe not use the view.

This is the point !!! - The view has to be set to unlimited! And the default vendor (usually contact/1) is back

But - as the same view is used for for the contacts overview ERPAL menu > Contacts -, it isn't recommendable to set the pager to 0
My proposal_
Solution 1 by the UI: Creating a view with a pager displaying all items or pager set to 0
Solution 2 by a code: Using an autocomplete field - to be defined at profiles/erpal_platform/modules/profile/erpal_commerce/erpal_commerce.admin.inc it function erpal_commerce_vendor_settings_form($form, &$form_state).

But sorry I don't see me able to send a patch. I just can ask my Drupal partner to do so.

bechtold’s picture

Status: Postponed (maintainer needs more info) » Needs work

Ok very nice. I'm glad we found the issue.
When I saw the reuse of that view I didn't like the chosen solution either.
But let's not look back.

I do prefer solution 2 as well.

If your Partner could have a look we might be able to fix this quicker, as we are quite busy atm.

bechtold’s picture

Unfortunately solution 2 is not working at the moment because there is no autocomplete field for crm_core_contacts via form api.
I opened an issue over at crm_core to find a solution for that #2604140: Form API autocomplete.
Let's wait a moment to see if there is a nice solution, if it doesn't workout we will implement solution 1.

Solution 1 would only be a workaround and not so nice for large numbers of contacts, because the list would be very long.
This would maybe cause some performance issues and the usability would not be as nice.
That's why I would prefer solution 2.

To bring up a possible solution 3:
We could implement our own ajax callback handler for crm contacts, but this would be much work and not help crm_core as an integration into existing modules would do.

ChoY’s picture

It is on my to do list - and not yet done. For the moment just for a best practice with solution 1
as you work currently on an import solution for erpal contacts. There will be also needed an export solutions for contacts. - This is relatively easy with the module views_data_export for xml/cvs or views_export_xls for excel-friends. Just create a views only needed for export of all contacts with one of this modules for all contacts and it it to the vendor settings.

bechtold’s picture

as you work currently on an import solution for erpal contacts. There will be also needed an export solutions for contacts. - This is relatively easy with the module views_data_export for xml/cvs or views_export_xls for excel-friends. Just create a views only needed for export of all contacts with one of this modules for all contacts and it it to the vendor settings.

Yep, as you mentioned it is very easy with those modules. Since it is again a very customized thing that everybody handles differently (different fields etc.) we will not include this in ERPAL platform. But I add it to the list of topics for the documentation. If you want to help with this or have any issues with this please create a different issue, this one is only for the default vendor settings.

bechtold’s picture

Status: Needs work » Needs review

Ok, i pushed some commits. It should work now.
You can try the dev version once it has a fresh build.

We need the latest dev version of crm_core. When updating make sure to run update.php.
And also I noticed that the name field used for auto complete is only updated when a contact is resaved.
So if your contact does not show up in the autocomplete results please edit and save the contact.

If this works for you you can set this to rtcb, thx.

ChoY’s picture

Doesn't work for me.
Install and update to last dev erpal_platform build ends up as usual in theme crash
Install and uodate to the last dev crm_core crash the whole erpal_platform installation

Best will be I just wait to your next erpal_platform beta/stable release (by the way when this will be?)
In between I consider the vendor settings still buggy ...

bechtold’s picture

Hm, that's sad.

The theme crash should be fixed a while ago and it worked fine. I will check again.

I already referenced one of the most recent commits of crm_core since this was needed for the autocomplete widget and it worked fine.
Can you tell me what you mean by "crash the whole installation"?

I will check again why the vendor settings didn't make it to the dev release, they should be in there.

Currently we don't have an exact date for a new release as we are quite busy with other customer projects.
I will try to make one till end of January though.

ChoY’s picture

Update my whole production ERPAL platform installation to a dev version or just to add a dev crm_core to the instalation I consider as too vulnerable.
A little change in the code should do it for now: Can you give me a hint what exactly you changed/ptached for the vendor settings? I will try it out to modify just that part of the code.

bechtold’s picture

Sorry, somehow d.o was not making a dev release with my last changes.
I hope d.o isn't broken.

The problem is, that we definitely need the latest version of crm_core otherwise it will not work. They haven't been making a release for a year now. and the dev release seems to be even older, so we do need to checkout the project via git.

Here is what I did:

http://cgit.drupalcode.org/erpal_platform/commit/?id=c55b8b2
Added entity_autocomplete.
With this patch: https://www.drupal.org/files/issues/entity_autocomplete-support-form-api...
And the latest dev release of crm_core

http://cgit.drupalcode.org/erpal_platform/commit/?id=5bc3f7d
In erpal_commerce.admin.inc I changed from

   $form['erpal_vendor_settings']['vendor_id'] = array(
     '#type' => 'select',
     '#title' => t('Vendor'),
     '#default_value' => isset($settings['vendor_id']) ? $settings['vendor_id'] : '',
     '#options' => $contacts,
     '#ajax' => $ajax,
     '#required' => TRUE,
   );

to

   $form['erpal_vendor_settings']['vendor_id'] = array(
     '#type' => 'entity_autocomplete',
     '#title' => t('Vendor'),
     '#default_value' => isset($settings['vendor_id']) ? $settings['vendor_id'] : '',
     '#entity_type' => 'crm_core_contact',
     '#ajax' => $ajax,
     '#required' => TRUE,
   );

I can't guarantee you that this will work right away, I didn't try it, I just copied the stuff I did from the commits. I hope I didn't miss anything.

bechtold’s picture

I fixed the dev branch: #2644084: Dev branch not building
Now in the dev branch the autocomplete works for contacts.

I just checked it and it corks for me, can you check it again?

ChoY’s picture

So far my test versions are able to update without problemes form beta2 to the dev version. - That is the good news. The strange news are: The vendor settings at admin/erpal/settings/vendor don't have anymore a vendor field to choose a default vendor. Only the vendor address (as defined during installation) is visible - but not eligible (just either none or given address).
I tried it out with seeveral versions of existing sides and with a new erpal platform installation - everywhere the same: no vendor field ...
With other words: Again it is not possible to change the vendor settings. This time just because their is no field to choose a vendor on the UI at admin/erpal/settings/vendor !!!

bechtold’s picture

Somehow the entity_autocomplete module is not enabled automatically when updating even though I set it as dependency for erpal_platform and erpal_commerce. So when you enable the module by hand it should work.
Sorry about that.

ChoY’s picture

I think your solution is not good. It fixed the vendor autocomplete issue but damaged all other Erpla platform defaulrt autocomplete fields. Now it recognize their only the last 10 or alternatively first ten entries.

Example: When I add now an activity to a person such as email and want to make a lookup for the participants og this email activity - only the last 10 contact entries are searchable - all others are not findable anymore ....
Similar is happening with any other entity_reference field configured with the autocomplete widget type.

So we switched now with this a little bug to a big bug.
The dev branch is under this conditions not recommendable for production.

bechtold’s picture

Oh no, that's weird.
That would mean, that the entity_autocomplete module breaks the other autocomplete fields.
I will have a look at it. Thanks for reporting.