Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd

As the below code achieves the dynamic domain condition, this is what i want to achieve but this will get the Deprecation Warning in odoo v16, so if anybody knows the solutions that achieves similar functionality. Please comment it.
 @api.onchange('customer', 'picking_type_code') 


def _onchange_customer(self):


​if self.picking_type_code == 'outgoing' and self.customer:


​​ return {'domain': {'move_ids.product_id': ​[('picking_id.picking_type_code', ​ ​ ​ ​ ​'=', 'incoming'), ('picking_id.customer', '=', self.customer)]}} ​

​ else: 


​ ​ ​return {'domain': {'move_ids.product_id': []}}

Avatar
Annuleer
Beste antwoord

Hi,

Returning a domain using onchange method has been deprecated from Odoo 14.The standard solution is to use fields domain parameter.You can also use the custom module from OCA https://odoo-community.org/shop/web-domain-field-4368#attr=22677



Avatar
Annuleer
Beste antwoord

Hi Srushti


Instead of using Ochange method and returning domain in the return of the method, you should use _search() method of odoo base.


As you want the domain on move_ids which means the comodel ins "stock.move" so in that model you inherit the _search() method and this method contains serveral parameters and you should pass your domain in check below example : 

Please find code example in comment. 

I hope this will help you. 

Thanks & Regards,
Email:   odoo@aktivsoftware.com      

Skype: kalpeshmaheshwari

Avatar
Annuleer

Please find code example here :-

@api.model
def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None):
if self.picking_type_code == 'outgoing' and self.customer:
args = [(Your if condition domain)]
else:
args = [(Your else condition domain)]

return super(SaleOrder, self)._search(args, offset=0, limit=None, order=None, count=False,
access_rights_uid=None)

Auteur Beste antwoord

Thanks Kiran for the answer.

I solved that using the compute method , Actually I have tried copute method before also but i was getting some issues, I troubleshoot it. Just with same logic just change method to compute and use @api.depends. Asssigned the values which i'm returning here using domain to a many2many field and then added that fields inside the domain attribute for product_id and lot_number field definition. This will work..

Avatar
Annuleer
Beste antwoord

Hi  Srushti,

Returning the domain using the onchange method is deprecated.

Check this method,

https://github.com/odoo/odoo/pull/41918#issuecomment-824946980

Hope it helps,
Kiran K

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
dec. 23
1570
3
okt. 23
3980
1
mrt. 19
5448
1
jan. 24
1811
0
apr. 23
2176