Hello Community,
At the time of sale confirmation i want to run Reordering Rule for that Sale order's Products. For that i have wrote below code :
@api.multi def action_confirm(self):
res = super(SaleOrder, self).action_confirm()
self.env['procurement.orderpoint.compute'].with_context(ctx).procure_calculation()
return True It works fine. But takes too much load because it all Odoo Products So that i have done following changes :
@api.multi def action_confirm(self):
res = super(SaleOrder, self).action_confirm()
---------------- changes ------------
pro_list = [] # List of sale order products
for order_line in self.order_line:
pro_list.append(order_line.product_id.id)
ctx = self._context.copy()
ctx.update({'product_list': pro_list})
self.env['procurement.orderpoint.compute'].with_context(ctx).procure_calculation()
return True
# override Procument Order Method to update domain(only for sale order products)
def _procure_orderpoint_confirm(self, cr, uid, use_new_cursor=False, company_id=False, context=None):
dom = company_id and [('company_id', '=', company_id)] or []
if context.get('product_list'):
dom.append(('product_id', 'in', context.get('product_list')))
orderpoint_ids = orderpoint_obj.search(cr, uid, dom, order="location_id")
But it didn't work for me. Can anyone suggest me proper solution to achieve this ?
Quick help is much appreciated!
Thanks in advance.