Odoo Aide

0

0
5 Answers
0
Bastien Bascou
05/05/2017 05:48

I found a way to solve my problem.
 
I needed to check the size of products to display only templates that can handle this list. Some can handle only one products and their field "multi" is set to False (or 0).
 
The domain i used to do this is :

['|',('multi','=',True),'&',('multi','=',False),('multi','=',len_products-1)]


Thank you again for your help ;)

1 Commentaires
IT Libertas
05/05/2017 06:47

Glad to hear!

1
Avatar

IT Libertas

--IT Libertas--
988
| 4 3 9
Saint Petersburg, Fédération de Russie
--IT Libertas--

Visit us: https://odootools.com/

IT Libertas is a team of developers and automation experts to help you to unlock Odoo ERP system's potential. We have been communicating with end users to whom the software became a main business tool since 2012. As a result, we are proud of dozens of successful Odoo apps developed.

We are open for new ideas and challenges to create the best Odoo tools for business needs all over the world

IT Libertas
04/05/2017 15:36

Hi,

I guess, you can't achieve desired behavior just using XML. 'label.products' is not good.
The easiest way is to make a computed field to calculate len and place this new field to a form. E.g.:

in your Model:
@api.multi
@api.depends('products')
def _compute_len_products(self):
  for label in self:
  label.len_products = len(label.products) len_products = fields.Integer(compute=_compute_len_products, store=True)

in XML:
<field name="len_products" invisible="1"/>
<field name="template" domain="[("len_products",'=',1)]"/>
2 Comments
Bastien Bascou
05/05/2017 03:41

Quite simple in fact .. :)

I though it could have been done in XML directly. Thank you !

Bastien Bascou
05/05/2017 04:05

It doesn't work :'(

it loads field 'len_products' from template class :

ValueError: Invalid field u'len_products' in leaf "<osv.ExtendedLeaf: (u'len_products', u'<=', 1) on label_template (ctx: )>"

Poser une question
Étiquettes
Keep Informed
1 Abonné(e)s
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now