Ir al contenido
Menú
Se marcó esta pregunta

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


Avatar
Descartar
Autor Mejor respuesta

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

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
mar 15
4643
1
ago 22
1624
0
sept 15
5416
1
mar 24
3059
3
jun 18
7134