Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Delay computing stock minimum rules until user set a custom flag

By
Ahmed Ababneh
on 3/7/16, 3:58 AM 317 views

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


0
Ahmed Ababneh
On 3/7/16, 8:11 AM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/7/16, 3:58 AM
Seen: 317 times
Last updated: 3/7/16, 8:11 AM