I have added custom fields in Sales Order Line and the same to Purchase Order Line. Which method should I override to be able to set these correctly? I tried inheriting purchase.order, but while navigating through the purchase order line items, it does not let me make those changes.
If what I get is correct then it is not simple ... lots of logic should be considered as:
First: for each sale order line a procurement order created. Then after running the procurement order(s) new stock moves will be created. Those stock moves will be confirmed and new procurement orders will be created from those stock moves. Those new procurement orders will generate the purchase orders. And this why there is 2 procurement orders will be generated if you confirmed the Sale order [one is running "the first one generated by the Sale order, the Second one "Confirmed" generated by the Stock move].So its as: SaleOrder->Procurement Order->Stock Move->New Procurement Order->Purchase Order..IMHO, there are two options to solve this: using context or do few modifications in some models and functions.
I didn't debug both options but I think using context will not work because running procurement can be for more than one procurement order.
So I think you need to modify some methods.
Actually the procurement.order contains a field called 'sale_line_id' and this will be automatically filled by the first first generation of the procurement order by this function . So we need to pass this field to the newly generated stock.move
So we need to add a new column to stock move and that is 'sale_line_id' then set this field in the function that will generate the stock move from the procurement . You can simple get the sale_line_id by using procurement.sale_line_id.id
after that we need to fill the sale_line_id again to the new procurement generated by the confirmation of the stock move in the _prepare_procurement_from_move . Then the new created procurement order will contains the sale_line_id that contains your new field 'preferred account number'. The last step is to fill the purchase order line with this field by using _get_po_line_values_from_proc .
I know this seems somehow complex . But I didn't know more simpler way to do it :( . And it'll be great if someone else can give an idea ...
Hope it can help ...
Waiting for your feedback ....
I have added a "preferred account number" field to the sales order line and I would like the same to be reflected in the purchase.order.line. There are no calculations involved, but just lookups.
At this time, I am looking at overriding create_procurement_purchase_order method in procurement.order.
Using Odoo 8.
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
|Asked: 5/1/16, 3:02 AM|
|Seen: 646 times|
|Last updated: 8/27/16, 3:56 AM|