Community: Framework mailing list archives

expert-framework@mail.odoo.com

Re: Edit domains with new API onchange

by
n.schmitt
- 01/06/2015 18:42:27
Yes, I was talking of the official documentation, because there is nothing about the domain and the warning mentionned.

About the @api.one, I thought that the @api.onchange never needed neither the @api.one nor the @api.multi. Am I mistaken?

On Tue, Jan 6, 2015 at 12:42 PM, Pedro Manuel Baeza Romero <pedro.baeza@gmail.com> wrote:
What documentation are you talking about? BTW, you can contribute to Odoo official documentation.

About the @api.one, if you want to restrict the method to only one record, you can put @api.multi, but use self.ensure_one() call inside the method to assure only one record or raise an error on contrary.

Regards.

2015-01-06 14:35 GMT+01:00 Nicolas Schmitt <n.schmitt@protelcotelsa.com>:
Do you think it would be possible to add this to the documentation?
And about the @api.one, does it ever make sense to put it on an onchange, knowing that it will always be on only one record?

On Tue, Jan 6, 2015 at 5:52 AM, Pedro Manuel Baeza Romero <pedro.baeza@gmail.com> wrote:

But don't put @api.one, because the return value will be encapsulated in a list.

Regards.

El 06/01/2015 08:31, "Guewen Baconnier" <guewen.baconnier@camptocamp.com> escribió:
On 01/05/2015 06:12 PM, Leonardo "LeartS" Donelli wrote: > With the old API, in an onchange function I could return a dictionary > with a 'domain' key to alter the domain of a field dynamically based > on the changed field. How can I do this with the new API? > > Here's the concrete example I'm working on: I've added a selection > field to products for their shelf life (fresh, dry, maybe others in > the future) and a similar selection field to sale order (goods_type: > fresh, dry, mixed, maybe others in the future). > > I want the domain of the product_id field of the order lines to change > according to selected goods_type of the sale order: fresh -> > ('shelf_life', '=', 'fresh'); dry -> ('shelf_life', '=', 'dry'); mixed > -> no domain > > Any ideas? > > _______________________________________________ > Mailing-List: https://www.odoo.com/groups/community-framework-62 > Post to: mailto:expert-framework@mail.odoo.com > Unsubscribe: https://www.odoo.com/groups?unsubscribe
> You can still return a dict from the methods decorated with @api.onchange, either with a 'domain' or a 'warning'. -- Guewen Baconnier Business Solutions Software Developer Camptocamp SA PSE A, CH-1015 Lausanne Phone: +41 21 619 10 39 Office: +41 21 619 10 10 http://www.camptocamp.com/

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-framework-62
Post to: mailto:expert-framework@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe