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

Custom Fields in Purchase Order Lines

By
Vishal Mehra
on 5/1/16, 3:02 AM 650 views

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. 


Regards,

Vishal

Hi, what these changes you want to make and set ? what version you're using ... more details will be helpful to get the answer

Ahmed M.Elmubarak
on 5/1/16, 3:29 AM
0

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 5/2/16, 9:12 AM

Hello Vishal,
Thanks for the feedback
As I got; you're trying to fetch a value from a sale order line to the automatically generated purchase order [by using procurement method such as MTO then Buy]. 

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 ....

0

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 5/1/16, 11:38 AM

Hi,

I hope you want to get the "preferred account number"  field value on adding a product in sale order line or purchase order line, like unit price.

Then you need to override the methods, product_id_change() in sale.order.line and onchange_product_id() in purchase.order.line.



0
Vishal Mehra
On 5/1/16, 3:32 AM

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.

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

2 follower(s)

Stats

Asked: 5/1/16, 3:02 AM
Seen: 650 times
Last updated: 8/27/16, 3:56 AM