Community mailing list archives

community@mail.odoo.com

Re: Capability of triggering action from an onchange, or similar functionality

by
Numa Extreme Systems, Gustavo Marino
- 11/16/2015 07:38:57
It seems to me that a lookup into another table can be achieved w/o modifing the client/controller:
I see the followiing alternatives:
  • If what you look for is a many2one in the custom table with a domain (only certain set of all the data should be visible), just return a proper domain the custom many2one in the onchange
  • If you want a list of records, use a computed field in the custom field ( a Many2many or One2many) based on product_id, set the list in the onchange and it will be properly displayed
If you limit yourself to change in sale.order.line fields, they will be properly handled (be sure only that the changed record set is used in your view, even as an invisible field. If you don't use in your view - not an implied tree or form, your view -, no change will be carried to the UI interface)

You can properly debug what is updated or not with a breakpoint on the method onchange in openerp/models

Regards

Gustavo Adrian Marino

 

Mobile:  +54 911 5498 2515

Email: gamarino@numaes.com

Skype: gustavo.adrian.marino

 

<img border="0" width="213" height="94" src="cid:image001.jpg@01CC37F5.99B4CD20" alt="Descripción: Numa Logo V 1-0">



2015-11-16 1:47 GMT-03:00 OpenERP Master <openerpmaster@gmail.com>:
Thank you for the response. I already knew before I asked the question the level of difficulty involved. There are some of these types of problems in Odoo where it may be functionally supported in other software, but seems impossible in Odoo because of how the application was engineered.(no disrespect intended to Odoo). This most likely would involve some sort of javascript development.

I understand the reason for the button not appearing because there is no id, however, a sale order line existing in the database is not actually required to execute the functionality. From a data perspective, one would only need the value of the field product_id to look up the products related information (custom module I developed), which is supported in an on_change event. Because of how things are so tightly woven together and there are many layers of abstraction makes it difficult to alter the existing functionality to do something else.

The only thing I can do is communicate to the client that what they want cannot easily be done and to find some other way or hack to produce the required functionality.

On Sun, Nov 15, 2015 at 5:12 AM, Gustavo Marino <gamarino@numaes.com> wrote:
Hello:
It is related with the fact that during the creation of a record, data live only in the user interface (the browser front end). So, no real id is assigned to the record till it is written into the database. Thus, no action could be called because no id is available! (and this is the reason to show buttons in grey).

A workaround was implemented when you are at the main object level (for example, the sales order). Before calling the button action, the record is first created in database.

The workaround is not implemented if you are in a sub-record of the main object, and thus all buttons are grey till you save the record.

The solution is not simple. In the front end, the same workaround used in the main object should be available for sub-records. That means, show active buttons, but before calling the button's action, create the object hierarchy in the database. This is not so simple because on creation in database you can not correlate sub-records with actual ids of the newly created objects (in the simpler case the follow the same order, but is possible to change the order or create additional objects in a create method override).

The problem is not easy unless you are ready to face a major re-engineering of the UI code and associated web controller methods, and most probably the wire methods.

Are you completely sure you can not get an equivalent result with one2many computed fields? This case is supported!

Regards

Gustavo Adrian Marino

 

Mobile:  +54 911 5498 2515

Email: gamarino@numaes.com

Skype: gustavo.adrian.marino

 

<img border="0" width="213" height="94" src="cid:image001.jpg@01CC37F5.99B4CD20" alt="Descripción: Numa Logo V 1-0">



2015-11-15 1:27 GMT-03:00 OpenERP Master <openerpmaster@gmail.com>:
Hello,

This is not the same. I have reviewed this functionality. It is a warning parameter that is built into the on_change method and is only capable of returning a message.

On Sat, Nov 14, 2015 at 8:42 PM, Caudal Eric <caudaleric@gmail.com> wrote:

It is similar to the warning about out of stock in SOL.
You could get your inspiration there


On Sun, Nov 15, 2015, 02:31 OpenERP Master <openerpmaster@gmail.com> wrote:
Hello,

I am using version 8.0

Is it possible for a scenario where business user adds a new line to a sale order, and entering the sku or changing the quantity triggers a popup window, (action) that displays them related products to add to the sale order.

I already have this as a button on the sale order line, but you cannot click the button until you save the sale order, which is no good. The customer needs to be able to select from related products immediately after adding the sale.order.line

Looking for onchange event trigger action, but some other way possible I would consider

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

--

Eric  Caudal (from my mobile)

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


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


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


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