# Models order in the graph (define priority ?)

**URL:** https://discuss.tryton.org/t/models-order-in-the-graph-define-priority/967
**Category:** Developer
**Created:** [December 18, 2018, 9:43am UTC](https://discuss.tryton.org/t/models-order-in-the-graph-define-priority/967 "2018-12-18T09:43:47Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)
#### Post date: [December 18, 2018, 9:43am UTC](https://discuss.tryton.org/t/models-order-in-the-graph-define-priority/967/1 "2018-12-18T09:43:47Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 18, 2018, 10:59am UTC](https://discuss.tryton.org/t/models-order-in-the-graph-define-priority/967/2 "2018-12-18T10:59:35Z")

</div>

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`.

---

<div class="post-metadata">

### Author: ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)
#### Post date: [December 18, 2018, 11:05am UTC](https://discuss.tryton.org/t/models-order-in-the-graph-define-priority/967/3 "2018-12-18T11:05:54Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 18, 2018, 11:06am UTC](https://discuss.tryton.org/t/models-order-in-the-graph-define-priority/967/4 "2018-12-18T11:06:52Z")

</div>

> [@maxx](#):
>
> Order is important if both modules are activated…

This is the proof that they are not independent.

---

<div class="post-metadata">

### Author: ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)
#### Post date: [December 18, 2018, 11:09am UTC](https://discuss.tryton.org/t/models-order-in-the-graph-define-priority/967/5 "2018-12-18T11:09:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 18, 2018, 11:16am UTC](https://discuss.tryton.org/t/models-order-in-the-graph-define-priority/967/6 "2018-12-18T11:16:58Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)
#### Post date: [December 18, 2018, 2:14pm UTC](https://discuss.tryton.org/t/models-order-in-the-graph-define-priority/967/7 "2018-12-18T14:14:38Z")

</div>

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](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](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…)

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 18, 2018, 6:41pm UTC](https://discuss.tryton.org/t/models-order-in-the-graph-define-priority/967/8 "2018-12-18T18:41:17Z")

</div>

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.
