Odoo 8 "message_id" column in "mail_message" table - odoo-8

I was writing an external app in python that uses the message system in odoo.
So, I need to use, the mail_message, and the mail_notification tables.
I tried to put elements individually via INSERT into the table filling the necessary elements to make this work, and it works perfectly, the messages appear in the "inbox" of messages in Odoo and the notification appears correctly.
But checking the rest of the fields in this table, I see that message_id got a tag format (between <>) and a series of numbers (that I haven't found any correlation) followed by "-openerp-'res_id'-'model'-#'company'".
So, I don't know how to fill this field, my proofs determined that is not a necessary field, but in a serious implementation I don't know if left this field empty can cause some issues.
Anyone can explain me the reason of this field and how to fill it?
Thanks

You can check the code in tools/mail.py and do something similar
def generate_tracking_message_id(res_id):
"""Returns a string that can be used in the Message-ID RFC822 header field
Used to track the replies related to a given object thanks to the "In-Reply-To"
or "References" fields that Mail User Agents will set.
"""
try:
rnd = random.SystemRandom().random()
except NotImplementedError:
rnd = random.random()
rndstr = ("%.15f" % rnd)[2:]
return "<%.15f.%s-openerp-%s#%s>" % (time.time(), rndstr, res_id, socket.gethostname())

Related

Parse email subject office 365 flows

I am trying to get some data parsed out of a subject line in Office 365 Flows. I have an email that has a consistent format:
Help Desk [Ticket #12345]
I want to get the number '12345' for use in later steps in the flow. So far, I've attempted to use the substring expression in a compose connector:
substring(triggerBody()?['Subject'], 20, 5)
But I get an error about the string being null.
Besides the index being incorrect (to retrieve '12345' from Help Desk [Ticket #12345] you need to use substring(value, 0, 5) as the index is 0-based), the expression looks correct. But you can take a step-by-step approach to see what is wrong.
To start, take a look at the flow run to see exactly what the trigger outputs are:
If you see the Subject field (as I do in my case), create a variable containing that value only to make sure that you don't have any typo:
If it works correctly, then you should see in the flow run the subject:
If everything is still good at that point, create a new variable with the substring that you want:
And again, check the value.
If you got to this point, then you should be able to retrieve the ticket id.

What means "Name=SWEIPS" Parametr in Siebel

Writing script in LR for Siebel Open UI. All my requests contains this parameter, with different values. What does it mean?
Examples (from different requests):
"Name=SWEIPS", Value = #0'0'1'0'GetProfileAttr'3'attrName'SBRF Position Id'"
"Name=SWEIPS", Value = #0'0''0'3'1-SQE21A, 1-SQL21E, 1SQE31"
And so on.
Can I simple delete it?
Can I simply delete it? - No, you’re not supposed to delete it.
Compare SWEIPS value by recording twice or trice with different data sets, check is there any date/time values in SWEIPS. If there is nothing to correlate leave as it is, no need to delete.
Ensure to correlate values like SWET,ROWID,SWECount,SWEC and so on.

Best practice to show custom fields on dynpro?

I am assigned to implement new custom fields. The possible entries have to be selected from a value table. The value table holds the key and a explaning text. The dynpro is build like that:
Input for new field (zzfield) | Output-only field for explaining text. (zzfield_text)
What I want my dynpro to do:
a) Show text in output field based on entered key
b) Update text after ENTER/SAVE from user
c) Update text directly after a new key has been selected from the value table
My current solution is this:
" in the dynpro
PROCESS BEFORE OUTPUT.
MODULE GET_ZZFIELD_TEXT.
" in the module
DATA: zzfield_text TYPE string.
SELECT SINGLE text
FROM value_table
INTO zzfield_text
WHERE zzfield = mara-zzfield.
This works well for the cases a) and b) I have listed above. However, beeing in a PBO, it does not work for case c). My colleage suggested to use something like this:
" in the dynpro
PROCESS AFTER INPUT.
field: zzfield MODULE get_zzfield_text_pai ON REQUEST.
I can not duplicate my code in the module get_zzfield_text_pai, because the of the DATA declaration of zzfield_text. It is reported to be unknown in the PAI (besides it is already defined in the PBO module) but it is also reported to be duplicated if I declare it again in the PAI. Further, I dont know how to implement new global fields into my function group. Using another include creates again issues of that zzfield_text beeing unknown.
In general, I am not happy about my solution and would be very thankfull for each suggestion about how to code this feature.

Best way to architect unique identifier generation

I have an API in rails that will handle a lot of requests. Lets say millions a day. I want to be able to assign a unique id to each of these requests. The way i am doing it is starting with a uid of 3 letters/numbers and continue up till 9 letters/numbers when the previous bracket is all taken.
One one i am doing it is generate the uid in real time when the request comes, so the app will try to find the first available uid and assign it. But after a while i have the impression that this will impact the performance of the app.
The second way I am thinking is to auto-generate all the possible uids in advance and have a flag assigned to them [free/taken] so that when a request comes in i assign the first free uid to it, which should be very fast if that filed is indexed.
Any suggestions are much appreciated. Thank you
I would just generate a random string and assign it while it doesn't exist. Before I get into that let me just mention that SecureRandom.uuid is the best way to go. It generates random uuids whose chance of collision are mathematically improbable.
Anyway, here is a way to use your own custom random string generator that will only assign if it doesn't already exist:
def generate_random_uid
begin
uid = my_custom_random_string_method
object.uid = uid
end while ObjectModel.exists? uid: uid
object.save
end
The do while block will execute once and set a variable called uid to be a random string you generate in the method my_custom_random_string_method, then in the while part it checks if a record exists whose uid attribute matches the random uid you just generated, if it does it runs the do block again, rinse and repeat until the expression in the while part returns false meaning the uid doesn't exists, then your object is saved and the uid written to the db. This guarantees that you will only ever save the object with a uid that doesn't exist in your db.

Type mismatch error while reading lotus notes document in vb6

Am trying to read the lotus notes document using VB6.I can able to read the values of the but suddenly type mismatch error is throwed.When i reintialise the vb6 variable it works but stops after certain point.
ex; address field in lotus notes
lsaddress=ImsField(doc.address)
private function ImsField(pValue)
ImsField=pValue(0)
end function
Like this I am reading the remaining fields but at certain point the runtime error "13" type mismatch error throwed.
I have to manually reintialize by
set doc=view.getdocumentbykey(doclist)
The type mismatch error occurs for a certain field. The issue should be a data type incompatibility. Try to figure out which field causes the error.
Use GetItemValue() instead of short notation for accessing fields and don't use ImsField():
lsaddress=doc.GetItemValue("address")(0)
The type mismatch is occurring because you are encountering a case where pValue is not an array. That will occur when you attempt to reference a NotesItem that does not exist. I.e., doc.MissingItem.
You should not use the shorthand notation doc.itemName. It is convenient, but it leads to sloppy coding. You should use getItemValue as everyone else is suggesting, and also you should check to see if the NotesItem exists. I.e.,
if doc.hasItem("myItem") then
lsaddress=doc.getItemValue("myItem")(0)
end if
Notes and Domino are schema-less. There are no data integrity checks other than what you write yourself. You may think that the item always has to be there, but the truth is that there is nothing that will ever guarantee that, so it is always up to you to write your code so that it doesn't assume anything.
BTW: There are other checks that you might want to perform besides just whether or not the field exists. You might want to check the field's type as well, but to do that requires going one more level up the object chain and using getFirstItem instead of getItemValue, which I'm not going to get into here. And the reason, once again, is that Notes and Domino are schema-less. You might think that a given item must always be a text list, but all it takes is someone writing sloppy code in an one-time fix-it agent and you could end up having a document in which that item is numeric!
Checking your fields is actually a good reason (sometimes) to encapsulate your field access in a function, much like the way you have attempted to do. The reason I added "sometimes" above is that your code's behavior for a missing field isn't necessarily always going to be the same, but for cases where you just want to return a default value when the field doesn't exist you can use something like this:
lsaddress ImsField("address","")
private function ImsField(fieldName,defaultValue)
if doc.hasItem(fieldName) then
lsaddress=doc.getItemValue(fieldName)(0)
else
lsaddress=defaultValue
end if
end function
Type mismatch comes,
When you try to set values from one kind of datatype variable to different datatype of another variable.
Eg:-
dim x as String
Dim z as variant
z= Split("Test:XXX",":")
x=z
The above will through the error what you mentioned.
So check the below code...
lsaddress = ImsField(doc.address)
What is the datatype of lsaddress?
What is the return type of ImsField(doc.address)?
If the above function parameter is a string, then you should pass the parameter like (doc.address(0))

Resources