How delete Item from ArrayList in Firestore using Koltin - kotlin

I want to delete one item from the animeId. For example, if I need to remove the animeId[5] or I want to remove the item that the value is equal 5114, how can I do that? I alredy learned how I remove item like the entire animeIdbut not just one item.
Here's an print how the database is organized:

For updating some fields of a document, use the update() method.
If you want to remove a specific item from an Arraylist, you can use a call to:
.update("arrayfield", FieldValue.arrayRemove("itemtoremove"))
For example if you have an arraylist that contains three items as “abc”, “efg”, “xyz”.
And if you want to remove specific item called “efg” from an arraylist you should use a call to:
.update("arrayfield", FieldValue.arrayRemove("efg"))
Please also take a look at this Stackoverflow Link which explains clearly on
how to remove specific items from the array list in the firestore using kotlin.

Related

odoo filter one2many list

I have a long one2many list and want to show only a subset of this to the user, based on filters that the user may set.
My current approach is to have the original one2many field with all records, and another filtered one2many field.
I compute the filtered list by selecting the subset that is not filtered from the original list.
Further I apply the changes from the filtered list to the original list. So I search for new records in the list and create those as well in the original list. I search for deleted records and delete them from the original list.
This approach works actually, but it requires a bunch of code and only mimics what I would expect from either some native Odoo features or a filterable one2many widget.
Sadly all other approaches I tried did not work:
Searching in one2many lists does not work (e.g. setting search_default_ values in the context). I think it is not supported.
Using a domain to filter the second one2many list does not work (neither in xml nor python code). I think Odoo only allows this for many2many.
I would like to create a filterable one2many widget by extending the normal one. However I don't understand where in the js code the list is populated.
So question is: Is there an easier solution than my current approach to filter a one2many field with native Odoo features?
Or can you help me with the js code of a custom one2many widget to only show a subset of items? For instance, which method is called when the list is populated and in which field are the ids of the items?
Example
I want in my model something as the following:
# This is the original list, with all entries
schedule_entry_ids =
fields.One2many('mymodule.schedule_entry', 'schedule_id', string="Entries")
# This is the filtered list, to be used in the view
# Note: Sadly using the domain here does not work. It always shows all entries. But I hope you get the idea what I want to accomplish.
filtered_schedule_entry_ids =
fields.One2many('mymodule.schedule_entry', string="Filtered Entries", related='schedule_entry_ids', domain='[("phase_id", "=", filter_phase_id)]')
# This is the field that defines the filter
filter_phase_id =
fields.Many2one('mymodule.phase', string="Phase Filter")
Sadly using the domain filter does not work, so my approach at the moment is to create the filtered field as a computed field 'by hand':
filtered_schedule_entry_ids =
fields.One2many('mymodule.schedule_entry', string="Filtered Entries", compute='_compute_filter', inverse='_inverse_filter')
#api.onchange('filter_phase_id', 'schedule_entry_ids')
def _compute_filter(self):
# Populate the filtered list with the elements from the original list, for which the filter condition holds
def _inverse_filter(self):
# Remove elements from the original list if they should be present in the filtered list but aren't anymore (elements have been deleted from the filtered list).
# For all new elements in the filtered list, create a new element in the original list (elements have been created)
I tried all the tricks you mentioned with the same result...
The only workarounds (wich works!) I found is explained below:
1- You can use compute in ..._ids field definition
and put all the 'filtering stuff' in the def
but all lines on 'many' side will be read-only
(it's a problem for me because I need to edit these lines
2- You can define a new computed boolean field on the table wich is
on the "many" side (in your case 'mymodule.schedule_entry') and put
the 'filtering stuff' in the def. It works perfectly and the lines are editable !

Get item references

Using get item references returns just a few fields of the app item. If I then use Get item by app_item_id to drill down to all of the fields.
Is there a more efficient way of doing this so that I can just use one call instead of multiple calls to get the details of a referenced object? At the moment, the plan is to repeat the same calls for each of the referenced items.
Use case is that I have an 'Invoice' item in Podio, with one or more referenced 'Inventory' items. I am using this data to push those items through to Xero as seperate line items.
Thanks
Please bundle responses (that's super powerful technique to reduce number of requests). You can read more about bundling responses here: https://developers.podio.com/index/api (scroll page down)
Ruby example
item_id = <some item id>
item = Podio::Item.find(item_id, {'fields' => 'refs'})
puts item['refs']

remove duplicate VB.NET TreeVeiw node

any hint on how to add only one node to TreeVeiw control while many nodes with same name found in access database field ?
I can loop through the field but all the values add to TreeNode which is why i wanted to remove the duplicate.
Loop through the items and store them in an array while doing so.
If the current item in the loop, already exists in the array => duplicate => remove
You could try that, good luck.

Changing line item properties on cart in Shopify

Is it possible to change line item properties after they have been added to the cart? (Either via a normal form submission, or via AJAX?)
I've tried a POST to /cart/change with a "properties[MyProperty]" key, but no luck so far. This is coupled with the line parameter to denote the unique line item.
Any ideas? Or is it just a straight 'no'?
Using Shopify's API you can't use cart/change.js to change the properties of a line item. The reason is that cart/change.js uses 'properties' to find the line item you want. The API documentation omits this. Here is an example:
When I make a POST to cart/add.js with the following url encoded parameters:
quantity=9403&id=278440178&properties%5Bmy-property%5D=property%20BAR
The response will include,
"properties":{"my-property":"property BAR"}
When I go on to make a POST to cart/change.js to change the property from BAR to FOO,
id=278440178&properties%5Bmy-property%5D=property%20FOO
Then the response will include,
"properties":{"my-property":"property BAR"}
That is, I was unable to change the line item property this way. You may suspect that this is because there is some trick to the cart/change.js API, but this is not the case.
Notice, when I try to remove a line item by making a POST to cart/change.js and specifying quantity=0, like this:
quantity=0&id=278440178&properties%5Bmy-property%5D=property%20FOO
With the property property FOO being one that does not belong to any item (my cart only has an item with property BAR right now), the item is not removed from the cart. If on the other hand I do this:
POST: quantity=0&id=278440178&properties%5Bmy-property%5D=property%20BAR
The item is removed as normal.
Conclusion: in cart/change.js, shopify uses line-item properties in the same way it uses 'id', that is, to find the line item whose quantity you want to change. Just in the same way that you can't use cart/change.js to change the id of a line item, you can't use it to change the properties of one.

Content Organizer Rule Creation Issue

I am using the Content Organizer feature to move documents of a specific content type into a specific folder in a document library in the same site. I created a content organizaer rule with a property setting that uses the property testcolumn. Testcolumn is a site column defined as a lookup to column on a custom List, testlist, and then added to a site content type. The items in this list are displayed in the Value dropdown list and I can select the specific value I want to use for this rule.
The problem is that I can create and save rules provided that there are no more than 19 items in the testlist list. When I have 20 items in the testlist, it looks like the rule was saved by the UI. If I open the rule and go to edit it, the Value for the testcolumn property is (None). If I look at the item in powershell, the Value property is equal to '0' and not the ID of the item I saved in the UI. If I delete a record in the testlist so that the total number of items drops below 20, I can save the rule without issue. I have tried different combinaitions of items in the list in case it was a text issue, but when I have 20 items or more in the list, the rule is not saved.
I have looked at the ULS logs and it states the "Routing Engine: UpdateRule() has successfully updated the rule, rule.Name=TestRule1" when I save the rule.
Thanks for your help.
The answer is partially listed here. Looks like the page renders the control differently if the number of items is 20 or greater. The content organizer rule creation page does not handle this change and does not show any error when saving the information.
I was able to get around this limitation in the UI by adding the rules through code during my feature creation event. A link to creating rules through code is here.