Closed bwrsandman closed 9 years ago
Why don't you use ref('module.xml_id')
to refer to an specific id?
@pedrobaeza I tried that, it doesn't work inside of arch / inside of domains
No? It's strange, because I remembered to do something similar. Put the domain at field level then:
'baggage_weight': fields.float('Baggage Weight', help='Weight of baggage.', domain="[('category_id', '=', ref('product.product_uom_categ_kgm')]"),
@pedrobaeza well that's in the .py code and you would need to define ref
. It would only be run at initiation which may or may not have the model data declared already
It's an idea worth considering, thanks!
No, if you enclose it into "
, the evaluation is done where is needed. It's a trick I am using a lot in OdooMRP to perform some advanced filters. See an example here: https://github.com/odoomrp/odoomrp-wip/blob/8.0/sale_product_variants/models/sale_order.py#L51
About ref
, it that doesn't work (I'm not sure if you have got that function declared on view environment), then use self.ref.
@pedrobaeza I will try it, let you know what I find.
@pedrobaeza still have NameError: name 'ref' is not defined
This workaround is the only thing that works so far...
I can't find a way to do it also, so I must resign and admit the hack you're doing having no better solution. I have restart Travis builds, because I'm finding an strange error with related selection fields, to see if it's due to the new Odoo revision.
@bwrsandman
I think in such case, you need to use %(xml_id)d
in domain instead of ref()
:
domain="[('category_id', '=', %(product.product_uom_categ_kgm)d)]"/>
Thanks for the correction @yvaucher
:+1:
:+1:
@pedrobaeza @ehdem It was not fixed ...
No? Are you sure? I checked it and works for me
@pedrobaeza I'm talking about my previous comment. We don't need that extra field here.
https://github.com/OCA/vertical-travel/pull/12#issuecomment-71009572
I tried that also and got the same error. Have you tried?
@pedrobaeza this wasn't properly reviewed and didn't follow the community standards
@bwrsandman, please don't come with this periodically argued claim again.
Anyways, this doesn't break anything, so where's the problem? And it so, we can fast-track a revert.
With these kind of things, you are discouraging me a lot to review your work...
The problem is that the PR did not need to be rushed and needed fixing. I didn't add the needs fixing tag and you missed @yvaucher's comment.
The reason why I stress these rules is because I want to be reviewed by not only by one person, but the rest of the community. This is why we need multiple community reviewers on a Pull Request so that the better practice can be implemented and real discussion can be had.
1 approve from the reviewer team and 1 external approve could have waited a little before merging.
As for the fixup, who is going to do it?
@bwrsandman Just did it @ #27
I might have needed to put this in need fixing it would have been more clear that we shouldn't merge this yet.
In non-english interfaces the
domain="[('category_id.name', '=', 'Weight')]"
returns nothing sincecategory_id.name == 'Poids'
There does not seem to be any way to refer to model datas within
arch
of a view, soproduct_uom_categ_kgm_ref
was created to only point at the ID ofproduct.product_uom_categ_kgm