Default invoice type based on menu action in version 7.6

In version 7.4 when a user opens the list of “Supplier Invoices” from the menu, the ir.action.act_window will push a value “type” = ”in” into the context, so when a user clicks on “Add” a new invoice, the default value for invoice.type would be obtained from this value in the context.

However staring on version 7.6 this “type” = “in” was removed and no longer added to the context, but in the code that returns the default value for type is still fetching from the context. Despite putting a watch on this value on the server side, it always return None (as expected since it has been removed). But the SAO client somehow knows the correct default type for the invoice when a new one is added. I tried analyzing the xhr communication and could not understand how it works. I am puzzled how the client knows the default invoice type.

I would like to know how this is working, because I have code that depends the “type” value from the context, but now that it has been removed, I need to implement a work around.

Can anyone share some knowledge on how the default invoice.type works in version 7.6? I noticed that the client initiates a “on_change_with” xhr with the correct invoice type value, but I can’t find where it got this value, all previous xhr responses none of them tells the client about the type.

Many thanks in advanced for the assistance.

This behavior happens thanks to what we call “domain inversion”.
When an action (or a field) has a domain defined, the client “invert” it to detect if some field can have only a single value possible to be valid with it. If there is such single value, the client set it to the field automatically.

FYI I created Remove default invoice type using the context (!2969) · Merge requests · Tryton / Tryton · GitLab to remove the legacy of this context hack.

Thank you @ced for this information, it makes all clear now.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.