Auto complete in text field in odoo - autocomplete

I would like to select a customer from the select box by start typing its phone number.
How can I do that?
I have seen some are using name_search method.But still i am confused how to use it in both front end and back end.
Or is there any other solution for this.

Override the name_search method of your model and the domain you want on the args variable. Take a look at addons/account/account.py around line 595 args += [('type', '=', type)] for a concrete implementation. Make sure that you return the appropriate data structure as documented in the method's docstring at openerp/models.py.

For Auto complete in odoo. It provides suggestion only in case of using Many2one field in any module.
If you want to show suggestion and autocomplete. Create a model to store the mobile numbers and then use that particular model as foreign key in existing model.
That will do for you.

Related

issue with DLOOKUP syntax error for new database

I have a database with 4 tables but primarily it is a diversion table/form (DiversionT/F) and a payback table/form (PaybackT/F). Basically, when my program loans parts to other programs in my organization a diversion is created in DiversionT. When the program want to payback they create a payback entry in PaybackT.
I have an issue that I am confused about: On PaybackF the user enters an NSN (long part code) that they want to payback. Ultimately, I want some of the form to auto populate with part info based on the NSN entered. The info is stored in DiversionT. I have created a few text boxes on PaybackF to show the info. The first text box I am trying to autofill based on the NSN is a textbox called PartName. It should search DiversionT for that NSN and fill in the appropriate PartName on PaybackF. In the control Source for the box I typed:
=DLookUp("[PartName]","[DiversionT]", "[PartName]=" & Forms![PaybackF]!NSN)
I get the following error:
The expression you entered contains invalid syntax.
To be perfectly honest I don't really understand VBA yet (spent my life until now with C, C++, Java, and Python) but looked up the function on the Microsoft site.
If I am not going about this right, please also let me know?
When using DLookup to get data, if you are dealing with text strings, you need to ensure that you use single quotes to wrap the text in.
Also, I think that your logic in the DLookup is slightly wrong. I think that this is what you are after:
=DLookUp("[PartName]","[DiversionT]", "[NSN]='" & Me!NSN & "'")
Regards,
You can't enter VBA in to form properties like source control. VBA is only used in procedural code in the VBE. That being said, there is a DLOOKUP function available to form fields and the syntax is similar. This is a cause of your confusion.
EXAMPLE SYNTAX FOR NUMBERS:
=DLookUp("[PartName]","DiversionT", "[PartName]=" & [NSN])
EXAMPLE SYNTAX FOR STRINGS:
=DLookUp("[PartName]","DiversionT", "[PartName]='" & [NSN] & "'")
NOTE:
I can't tell what form you are on or if NSN is from a parent form or subform. Basically, NSN needs to be readable from the same form where that text field exists.

How to create element from API with name from appropriate sequence?

I'd like to use EA to generate Requirement elements programatically. I need to use the same sequence numbering (REQ00000xy), as with the GUI when pressing "Auto" button in "Add Element ..." dialog in order to keep´consistent numbering for Requirement elements created either from GUI or from API.
Selecting the last used sequence number from already existing Requierement elements won't help, as it don't move the sequence number up and next Requirement created from GUI .
Is there a way to get (and properly use) the sequence number via EA API or EA SQL?
The table you're looking for is t_trxtypes. This contains something like (EA's output)
Description;NumericWeight;Notes;TRX;TRX_ID;Style;
Autocount;1,00;prefix=bla;suffix=x;active=1;active_a=0;counter=126;;Class;1; ;
You're interested in the column Notes which holds as CSV list like
prefix=bla;suffix=x;active=1;active_a=0;counter=126;
This is a test setting for a class which currently has the number 126. So the next created class would be named bla126x and the entry would change to
prefix=bla;suffix=x;active=1;active_a=0;counter=127;
Just keep the columne t_trxtypes.notes in synch with your creations.
Note EA does not (seem to) allow direct DB access. However, it has a proven back door:
Repository.Execute("UPDATE t_trxtypes SET Notes='prefix=bla;suffix=x;active=1;active_a=0;counter=127;' WHERE TRX_ID=<your id>")
will do the update (replace <your id> with the appropriate key). Though Execute is undocumented it works ever since and for sure Sparx will not limit it as nowadays everyone relies on it.
As a side note: This counter is not safe. There are lots of ways (the easiest is a simple rename) to break it. You'd need some script/add-in to have regular checks your numbering is still consistent. If you rely on requirement numbering you better use an external system like, I dare to say, DOORS.
Finally, RTFM....
For elements, where sequence is defined, if you use empty name in set =AddNew() function, EA generates the sequence upon .Update(). Not earlier. So if you plan to use the generated sequence and add some description, you need to create the element with empty name first, then Update() it and after that append your description to the content of the Name field.
As easy as this.

Automatically generate Date + 4-digit sequence number for ID in Access 2010+

I need to automatically generate a 12 character value for my Business Key. Without any user interaction.
8 character -> Today Date (yyyymmdd or ddmmyyyy).
+
4 character -> Sequential Number (0001,0002,0003).
The Sequential Number must reset on each new day.
Is it possible to do this in Microsoft Access 2010+ without any coding involved?
Since you are using Access 2010+ the best way to accomplish your goal would be to use a Before Change data macro like this
To create the Before Change macro, click the "Before Change" button on the "Table" tab of the ribbon when the table is open in Datasheet View:
For more details on Data Macros see
Create a data macro
Good question, thanks for the challenge!
After some search, it seems it's possible to do that.
You can prefix the AutoNuber value by processing like the explanation available here: http://www.databasedev.co.uk/add_prefix.html
You can try to specify in the format of the field a format(now(),"ddmmyyyy").
Check this page for more informations, another user seems to have the same problem and got a solution: http://bytes.com/topic/access/answers/695188-custom-made-autonumber-show-todays-date
Hope it's helping you!

Data Processing, how to approach

I have the following Problem, given this XML Datastructure:
<level1>
<level2ElementTypeA></level2ElementTypeA>
<level2ElementTypeB>
<level3ElementTypeA>String1Ineed<level3ElementTypeB>
</level2ElementTypeB>
...
<level2ElementTypeC>
<level3ElementTypeB attribute1>
<level4ElementTypeA>String2Ineed<level4ElementTypeA>
<level3ElementTypeB>
<level2ElementTypeC>
...
<level2ElementTypeD></level2ElementTypeD>
</level1>
<level1>...</level1>
I need to create an Entity which contain: String1Ineed and String2Ineed.
So every time I came across a level3ElementTypeB with a certain value in attribute1, I have my String2Ineed. The ugly part is how to obtain String1Ineed, which is located in the first element of type level2ElementTypeB above the current level2ElementTypeC.
My 'imperative' solution looks like that that I always keep an variable with the last value of String1Ineed and if I hit criteria for String2Ineed, I simply use that. If we look at this from a plain collection processing point of view. How would you model the backtracking logic between String1Ineed and String2Ineed? Using the State Monad?
Isn't this what XPATH is for? You can find String2Ineed and then change the axis to search back for String1Ineed.

How do I create a manual link on a tree in Oracle APEX when Session State Protection is turned on?

Friends,
I'm facing another challenge in APEX and I hope you can help.
I have created a tree using the method described in John & Scott's superb book, "Pro Application Express" whereby the page link is stored in a table. Below is an example:
go to a page passing some parameters
f?p=&APP_ID.:3:&SESSION.::::P3_IDENTIFIER,P3_FAMILY_NAME:&P2_IDENTIFIER.,&P2_FAMILY_NAME.
When the page is run this works as expected. I can expand the tree and navigate to the page passing parameters if required.
However when I turned on session state protection these "hand crafted" links stopped working. Which I expected because the link contains no checksum.
After some investigation I see I have to use APEX_UTIL.PREPARE_URL to generate the URL with a checksum. Unfortunately this is where I run into problems. I can't seem to be able to pass the parameters values to the calling page.
The original tree query was:
select "IDENTIFIER" id,
"PARENT_IDENTIFIER" pid,
"TITLE" name,
"LINK" link,
null a1,
null a2
from <some table>
I then changed this to use APEX_UTIL.PREPARE_URL:
....
APEX_UTIL.PREPARE_URL('f?p='||:APP_ID||':3:'||:APP_SESSION||'::::P3_IDENTIFIER,P3_FAMILY_NAME:&P2_IDENTIFIER.,&P2_FAMILY_NAME.') link,
...
and this works, the page is called and I can see the values of the parameters passed. But I can't use this method as it is restricted to the one page!
Finally I tried storing the page number, parameters and parameter values in different columns of the table that the tree is based on and then bring them together:
...
APEX_UTIL.PREPARE_URL('f?p='||:APP_ID||':'||navigate_to_page||':'||:APP_SESSION||'::::'||parameters||':'||parameter_values) link,
...
Where:
navigate to page has the value of: 3
parameters has the value of: P3_IDENTIFIER,P3_FAMILY_NAME
parameter_values has the values of: &P2_IDENTIFIER.,&P2_FAMILY_NAME.
This now calls the page, but the parameter values have become literals. so where I'm expecting an identifier I see &P2_IDENTIFIER and ditto for family name.
What am I doing wrong? How can I pass values to my called page using apex_util_prepare_url?
In case of need, my environment details are: Apex 3.2.1, Oracle Application Server 10.1.2.3. Oracle Database 10.2.0.3
Thanks in advance for any help you may be able to provide.
I think you'll need to resolve those variables, using the v() function:
APEX_UTIL.PREPARE_URL('f?p='||:APP_ID
||':'||navigate_to_page
||':'||:APP_SESSION
||'::::'||parameters
||':'||v('P2_IDENTIFIER')||','||v('P2_FAMILY_NAME')) link,
On a side note, you might need to be careful about P2_FAMILY_NAME since it's being used in the url; it sounds like a plain text field which contains user-entered data?