[16.0][IMP] sale_packaging_default: Add context to support bypass setting default packaging#3249
Conversation
|
Hi @yajo, |
|
In which cases? |
2d72167 to
f128b8f
Compare
Hi @yajo , this context will be helpful for those cases:
|
If this is your use case, have you considered simply prepending a packaging of 1 to the list of packagings? It will be used by default in that product and give you the default Odoo behavior without any extra code. Otherwise, the fix is incomplete, as this won't allow a product to do that.
If this is your case, I think it is more appropriate to add this is in the PR where you add the glue module. Or at least, to keep it as draft until you open such PR. And please add some tests. |
| @api.depends("product_id", "product_uom_qty", "product_uom") | ||
| def _compute_product_packaging_id(self): | ||
| """Set a default packaging for sales if possible.""" | ||
| if not self.env.context.get("apply_default_packaging", True): |
There was a problem hiding this comment.
Depending on context for stored fields is usually bad. Maybe you can explain a little bit your use case ?
Hello @yajo @rousseldenis , actually, this is my case
I'll double-check for this one. Temporarily, marking this PR as |
|
@QuocDuong1306 any new on that PR ? can we go on with that ? |
In some cases, we don't want to get the default for packaging. This PR will provide a context to use for those cases.