Models order in the graph (define priority ?)

Hi,

I need to overload a method which is already overloaded by another module. Those modules are not linked but both depends of a common module. How to know in which order those overloaded methods will be called ?

Concrete example:
In the module purchase request, there’s a method to create purchase and purchase line from selected purchase_request lines. In the module purchase_request_quotation this method (compute_purchase_line) is overloaded to add a unit_price if there’s a best quotation. I would like to add a such method on the purchase_requisition module, to take care of the unit_price of the purchase_requisition (if not empty of course) when creating the purchase. (but if there’s the purchase_request_quotation, i think the price of the best quotation should update the price of the requisition). So how to know or to define order for executing the purchase_requisition overloaded method before the purchase_request_quotation overloaded method ?

If the order of extension is important between the two modules, that means one depend on the other.
Maybe it is not a hard dependency, so you can just define it as extras_depend.

In my case both modules are depending of purchase_request, but they is no really dependency between purchase_requisition module and purchase_request_quotation.
Order is important if both modules are activated…
How to know if we are in such case in a method ?

This is the proof that they are not independent.

Even if i add extra_depends on both module, how to test in the overloaded method if one of the module is activated ?

You must find something that the other module modify or create. The best is to use something that is directly linked to the need of the module.

In fact, there’s already such case with the currency property:

There’s a an overload of the currency property in the purchase_requisition module:
http://hg.tryton.org/modules/purchase_requisition/file/default/purchase.py#l554

And also in the purchase_request_quotation module:
http://hg.tryton.org/modules/purchase_request_quotation/file/default/purchase.py#l577

So, if both modules are installed, there could be erroneous data if the overload of the currency property in the purchase_request_quotation module is executed before the purchase_requisition module (currency of the best quotation will be updated with the currency of the requisition…)

Well we may need to set purchase_requisition as extras_depend of purchase_request_quotation.
But indeed I think the purchase_requisition is wrong to define a currency (and also to extend _group_purchase_line_key). The value entered by the employee should not be taken as-is, it should only be used to validate or not the requisition.