This question has been flagged
1 Reply
3531 Views

Hi all,

how to fetch the value of my current fields as my default value when creating new records.

let say in my product model i have existing value of my fields which is field1 = 5 and field2 = 10 period Jan 1- 7, 2014.

what I want to achieve is on the next period dated Jan 8 - 14, 2014 or the next enter of the new inventory record for product1 else product2. I want to fetch previous value of field1 and field2 as the default value of my new field1 and field2.

currently i have custom product and inventory modules and 2 reserve fields in inventory module but Im stuck. I dont know how to implement. is very complicated because that 2 fields always been change, my Idea is to update that fields but I think I cant go back to my previous reports after created the new inventory records for the specific product because the value is changed. 

anybody here who can give Idea on how to do it and best way to implement this?.

This for custom weekly period monitoring inventory to my custom product

Thanks for reading

Avatar
Discard
Author

any suggestion here?

Author

hello world, any updates here?

Author

Hi odoo community please help me, need your help to figure it out what has to be done this?

Best Answer

Hi Philip , while creating the record for the period jan 8 -14 2014 for a specific product , you can check whether there is any record has been created previously for the product.

If created then you can get the value from that record order by date descending and get the values for field 1 and field2 from that record else the value for field 1 and field 2 will be empty in case this is a new record for the product

steps:

Let us take the example of Class A

1) In create method, check the class if already any record exists order by id or not

2) if records exists, then browse the value from searched record and update it to your newly creating record.

3) if record does not exist, then you can give your own values to the fields.

Is this Clear
 

Avatar
Discard
Author

could you please give an simple example, I am new in odoo7 thanks for the response

Author

sir can I have your personal email address

Author

Sir I am very thankful if you give a simple understandable code sample or working code. thanks for your kind

Author

update please

Updated the answer

Author

yes clear very, if you could give us simple working code much better, other also can benefit. Thanks