Clean Many2one field - odoo-8

hello I have a many2one object and would like to delete the data found in another many2one, but the method does not work
<field name="bodega_id"
colspan="2"
context="{'picking_types_from_user':True}"
on_change="onchange_bodega(bodega_id)"/>
Method
def onchange_bodega(self, cr, uid, ids, bodega_id=False, context=None):return {
'value': {'producto_requerimiento_ids': False}
}

Try this. Hope it's work for you:
return {'value': {'producto_requerimiento_ids': [('id', '=', False)]}}

Did you upgraded the module after you made changes.

Related

Trying to get specific row values from Monday.com using GraphQL

Trying to use this API to get column values for my board in GraphQL, I have a column named "Email" with the persons email address but I can't seem to query it - here is my query thus far.
query {
boards (ids: 341236641) {
items () {
id
name
column_values {
id
}
}
}
}
For some reason, it wont let me put the field "Email" underneath the items() or column_values
When I look at the output, the id of column_values prints out as
'column_values': [{'id': 'status'}, {'id': 'status84'}, {'id': 'average_check4'}, {'id': 'date'}, {'id': 'text9'}, {'id': 'location'}]}
I believe the "actual" column name is text9 but that doesnt seem to work either.
Anyone use this API successfully before?
Thanks!
i'm a developer at monday.com :)
The column_values fields returns a list of ColumnValue type object. In addition to the id (column ID) you've fetched for each, you could also ask for value (the json data of this cell), text (the textual representation of the value), title (The column's title) and additional_info.
Try:
query {
boards (ids: 341236641) {
items () {
id
name
column_values {
id
title
value
text
additional_info
}
}
}
}

Laravel Eloquent: how to add a column to a query response?

In other words, lets say i have a query like that:
return Location::valid()
->with('owners', 'gardeners')
->withCount('gardeners')
->get();
that returns some json :
[
{
name: 'LocationA',
nb_gardeners_max: 3,
owners: [...],
garderners: [...],
garderners_count: 2
}
]
in the json response i'd like to add some custom entry like is_full and available_places:
[
{
name: 'LocationA',
nb_gardeners_max: 3,
owners: [...],
garderners: [...],
garderners_count: 2,
...
is_full: false,
available_places: 1
}
]
I guess it has something to do with raw / join / aggregate... but i really don't understand how to do so. Any help will be greatly appreciated
EDIT
Minhajul answer is really usefull but it's not possible to do a WHERE clause on the appended attribute.
Location::where('is_full',true)->get() // NOT WORKING
Though it's still possible to do filter() on it, I'd like to use a JOIN for that to perform a single query
To do so, you can add attributes that do not have a corresponding column in your database.To do this, all you need to modify your model
public function getIsFullAttribute()
{
return $this->attributes['name'] == 'value';
}
After creating this accessor, you need to add this in your model.
protected $appends = ['is_full'];
Hopefully, it will help you.

Rethinkdb - Not Equal (ne) on multiple fields

I have a document that looks similar to the following
{
...
reactions: [
{
user: 'user_id',
reaction: 'reaction_name'
}, {
user: 'user_id',
reaction: 'reaction_name'
}
]
...
}
I'm trying to remove an item in the array reactions based on a combination of 'user' and 'reaction' which will be unique. How would I go about filtering the reactions array to remove that specific item in rethinkdb using the js driver?
I've tried this
r.db('db_name').table('messages').getAll(
get_single_message
).update({
reactions: r.row('reactions').filter( (item) => {
return item('reaction').ne(body.reaction).and(item('user').ne(body.user))
})
}).run(this._rdbConn)
I understand why it doesn't work (returns all reactions that don't have given reaction, then returns subset of that array that doesn't have certain user).
What I want is for those not equals to be performed in sync so it returns an array that doesn't include items that have the provided reaction AND user. Right now it functions more like reaction OR user.
A buddy helped me out. Here's a solution that works for what I was trying to accomplish, but it does not makes use of not equal. If anyone has another solution that makes use of not equal please share it.
r.db('db_name').table('messages').getAll(
get_single_message
).update({
reactions: r.row('reactions').filter(function (doc) {
return doc('reaction').eq(body.reaction).and(doc('user').eq(body.user)).not()
})
}).run(this._rdbConn)
Here's a possibly more simplified way to do this without .ne:
r.db('db_name').table('messages').getAll(
get_single_message
).update({
reactions: r.row('reactions').difference([{
reaction: body.reaction,
user: body.user
}])
}).run(this._rdbConn)
Just be warned that .difference will remove all instances of that object from the array, so this assumes that there are only single instances of unique combinations of reaction and user.
Or you could keep it closely to what you have already and use the different form of .and()
...
reactions: r.row('reactions').filter( (item) => {
return r.and(item('reaction').ne(body.reaction), item('user').ne(body.user))
})
...

raise TypeError(repr(o) + " is not JSON serializable

Can help me? i want to domain many2one field where id not show in other transaction
#api.multi
#api.onchange('batch_id')
def _onchange_batch_id(self):
if self:
tempt=[]
for record in self:
tempt.extend([record.batch_id])
culling = self.env['estate.nursery.cullinglinebatch'].search([('batch_id', '!=', list(tempt))])
return {
'domain': {'batch_id': [('batch_id','not in',culling),('qty_abnormal','>',0)]}
}
In ODOO8/9 search method always return object not the Id of object.
culling = self.env['estate.nursery.cullinglinebatch'].search([('batch_id', '!=', list(tempt))])
Here culling is the object of model 'estate.nursery.cullinglinebatch'
Your domain should be look like
'domain': {'batch_id': [('batch_id','not in',culling.ids),('qty_abnormal','>',0)]}
here i have uses culling.ids instead of culling.
I hope this will help you.

How do I return a hash with relational data using parse.com?

I have a Post class and I want to get the products associated to it. I'd like to write a single query that fetches all of the posts with the products associated to them. Below is a rough idea of what I'd like the hash to looks like.
Schema:
Post - objectId, title
PostItem - post(pointer), product(pointer)
Product - objectId, title, price
Output I want
{'results':
[{'objectId':'blah', 'title':'The Post',
'products':
[{'objectId':'14',
'title':'First product',
'price':'20'
},
{'objectId':'26',
'title':'Second product',
'price':'55'
}]
},
{'objectId':'blah2', 'title':'Second post',
[{'objectId':'38',
'title':'Some product',
'price':'54'
},
{'objectId':'26',
'title':'Another Product',
'price':'88'
}]
}]
}
Is this possible to do in one query? How would I do this using curl and parse.com?
If this is a many-to-many relationship, use a Parse relationship.
You'll want to use the include key option alongside pointers. Since it's been nearly a year since you posted, I assume you figured it out, but lurkers can read more about this (in Javascript) here.

Resources