Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

We use re-ordering rules in order to automate generating purchase orders for products. 

However, we need to delay the generation of the purchase order until the user confirms the sales order by setting a custom flag on the sale order itself.

I am thinking of overriding the "procurement_order._procure_orderpoint_confirm" method in ordet to check the value of the custom flag before creating a new procurement order record. However, there is no "ids" parameter in the method "procurement_order._procure_orderpoint_confirm" signature. I need the "ids" parameter in order to be able to access the procurement order object.

How can I delay generating purchase orders based on reordering rules, until the users sets my custom flag on the sale order?

Thanks


Awatar
Odrzuć
Autor Najlepsza odpowiedź

Well, I do not like to answer my own questions. But this code seems to suffice:class

test_procurement_order(models.Model):

_inherit = "procurement.order"

def _product_virtual_get(self, cr, uid, order_point):

product_virtual_available = super(jamalon_auto_generate_po_procurement_order, self)._product_virtual_get(cr, uid, order_point)

not_confirmed_procurements = 0

for procurement_order in self.browse(cr, uid, self.search(cr, uid, [('product_id','=',order_point.product_id.id),('group_id','!=',False)])):

if not procurement_order.sale_line_id.order_id.x_distribution_confirmed:

not_confirmed_procurements += procurement_order.product_qty

product_virtual_available += not_confirmed_procurements

return product_virtual_available

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
mar 15
4652
1
sie 22
1627
0
wrz 15
5417
1
mar 24
3059
3
cze 18
7139