Index name will be derived at run time like say id_t1_t2 based on some field
How can i make the index name dynamic in
#Document(indexname="",type="news")
I guess you could simply use an alias.
I am creating one index a day, named my-index-[date] covered by an alias named my-index.
This gives :
#Document(indexname="my-index",type="news")
Note that some repository's functions won't work, like findOne(Object), instead you will want to use a custom findBy[...] method.
Related
I'm building a proper extension for the management of real estate, I would like to use the added "Image Metadata" field "Show in list view" as the extension tx_news does.
I can build this option in exactly as tx_news does but in case the site instalation uses both extensions, does this cause a conflict ? ( I'd use the same field name showinpreview )
Should I use a different field name to avoid trouble?
( I plan to use this feature in the exact same fashion, so I can easily share the use of the field in the "sys_file_reference" table ... if there was no other conflict there could be the case that an image was used in both extensions and the selection would be determined by one of the two extensions for both or do I misunderstand something here... )
anybody did experiments with this and can avoid me the trouble ?
I never had this use case but both ways are possible.
- use the same field: less code needed but your extension depends on news
- new field: also fine
You can use the same field as there also is a field which identifies the table the record belongs to.
Be sure to stay in sync with tx_news. either by a dependency, which might be a great overhead if you don't use tx_news otherwise, or with the same declaration as in tx_news, this can conflict if tx_news changes declaration unnoticed.
You have to declare your own access which will be independent as you use other namespace and context.
I am working with the product.product object. It has a field named qty_available, which indicates the available quantity of the product in stock, as its name says.
Normally, I would add an #api.depends('qty_available') decorator to the method I want to be executed. But I think this method will not be executed unless I create a computed field which calls it. The problem is that the field qty_available can be modified from a lot of different views, and it would be very uncomfortable to modify each of those views to add the computed field.
Is there any way to do this rightly?
If you need to do that when writing and no creating, you can re-define write function and check if that field is being writed.
#api.multi
def write(self, values):
if values.get('qty_available'):
#Your function here
return super(ResPartner, self).write(values)
since values contains a dictionary with the fields that are being changed, it will run only if qty_available had change. Take care as this wont work if qty_available is a function field. In that case, you should overwrite that function.
When using TemplaVoila, the template data structure is mapped to the HTML template file by pathes like
body[1]/INNER|div.grey[1] div.content_area[1] div.left_column[1] div.left_content[1]
while this is obviously as precise as possible, it is not very effective, because every change to an DOM element above the mapped one would break the mapping, which happens quite frequently and is totally pointless. I like to patch TemplaVoila to rely on the last matching path segments only, which will suffice in almost any condition, as my HTML is always tagged by id's or classes on the mapped elements.
For the start, it would be cool if it would maybe just use
.left_content[1]
instead of the path shown above. But maybe it don't work in a matching fashion like CSS selectors do.
I just can't figure out where to start. Can this be done by TS config? Are changes to TemplaVoila's PHP needed? Can a new extension do this?
Add an unique class or even better id to the desired element, so you won't need to count the occurrences. TemplaVoila hasn't possibility to use CSS-like selectors first, last etc.
The mapping does not rely on the full path, but tag name and id, if the element mapped has an id attribute set.
Having an (even unique) class attribute only forces TemplaVoila to map the absolute element path, as classes are not necessarily unique.
So no special configuration is needed, if all mapped elements have unique id attributes set.
I have created a parameter in iReport Value_DT with Date data type.
If I'm using expression "new java.util.Date("01-SEP-14") as default value it works fine but this is hard code.
I'd like to use user defined function from Oracle DB, i.e. it might be similar to "new java.util.Date(new java.util.Date($F{GETACCOUNTINGDATE})) where GETACCOUNTINGDATE is oracle function.
With such syntax I have an error "The constructor Date(Timestamp) is undefined".
What should be changed in order to use function from DB in default parameter?
I'm not sure of any way to do this directly in the default value expression without writing custom code. I believe you would need to write a custom class with a static method which connects to your database, calls GETACCOUNTINGDATE, and returns the date. You could then, bundle this as a JAR, put it in your classpath and call this method in your Default Value Expression.
That's quite a bit of work though, so alternatively you may be able to 'recreate' the date using Java Date Function libraries.
We've used apache dateUtils:
org.apache.commons.lang.time.DateUtils.addMonths(new Date(),0))
I know a colleague has used jchronic to use strings and create dates.
I would like rename a variable dynamically, Is there any way to do this in perl.
Thanks
Praveen
Do you want to use a reference? This gives you a reference to an existing object. Probably good enough.
Or, do you want to use a Type Glob? This allows you to directly modify the symbol table. There's probably no good reason for using it these days, but it does let you give a new name to an existing variable at a very fundamental level.