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

how to recover the information of the original selected records before executing the wizard?

By
Mihai Marius
on 9/12/14, 4:41 AM 735 views

Hi guys,

Update: I'm using web 6.1

step1: I have form 1 - button 1 opening form2

step2: From form 2 button 2 is opening form 3

step3: from form 3 (where users are selecting some values) i return to form 2 using the values selected in form 3.

The issue is how can i use the initial context that i had on step2 (i need id and values from form 1). In step 3 i'm using the context['active_ids'] but when returning to form2 i'm not able to find form1 id in context.

 

Many thanks!

Related is the following but i don't know how to do this:

 

https://answers.launchpad.net/openobject-server/+question/116262

0
Mihai Marius
On 9/12/14, 11:34 AM

Hi,

I got it working!

Form 2 xml file in declaring action i have the context:

<field name="context">{'res_id': active_ids}</field>

And in form 3 i have context.update({'res1_id': context['active_ids']})

Now in the py file of form 2 wizard i'm able to use context['res_id'] to get the id of form 1.

Many thanks!

1

Brett Lehrer

--Brett Lehrer--
1252
| 5 4 8
Milwaukee, United States
--Brett Lehrer--
Director of IT and open source enthusiast.
Brett Lehrer
On 9/13/14, 12:34 PM

Is this all the same wizard object, just different forms?  Because it sounds like you could just be storing your info in the wizard object directly.  As long as it takes less than 30 minutes to go from start to finish you shouldn't run into problems with osv_autovacuum deleting old wizard records, but I suppose you could also just edit the scheduler to run every hour, 8 hours, or even just daily.  Make sure the form buttons are type="object" and not type="action" and you should be fine.  Button from form 3 to form 2:

<button name="return_to_form_2" type="object" string="Continue" class="oe_highlight"/>

Then the python code:

def return_to_form_2(self, cr, uid, ids, context=None):
    if context is None: context = {}
    # Values on the form when the button is pressed are saved automatically
    # --- Any additional code necessary ---
    return {
        'type': 'ir.actions.act_window',
        'view_type': 'form',
        'view_mode': 'form',
        'res_model': self._name,
        'res_id': ids[0],
        'target': 'new',
        'context': context,
    }

Even if you're jumping from completely different wizard objects, you can always just create the new wizard record in advance, then load it via the return action:

def return_to_form_2_of_different_wizard(self, cr, uid, ids, context=None):
    if context is None: context = {}
    # --- Any additional code ---
    wizard_id = self.pool['different.wizard'].create(cr, uid, {'value_from_form_3': xyz}, context=context)
    return {
        'type': 'ir.actions.act_window',
        'view_type': 'form',
        'view_mode': 'form',
        'res_model': 'different.wizard',
        'res_id': wizard_id,
        'target': 'new',
        'context': context,
    }

You might also want to specify the form view to load, if you're dealing with multiple form views for a single wizard object:

def return_to_form_2_of_different_wizard(self, cr, uid, ids, context=None):
    if context is None: context = {}
    # --- Any additional code ---
    wizard_id = self.pool['different.wizard'].create(cr, uid, {'value_from_form_3': xyz}, context=context)
    # Get a specific form view via XML ID rather than just selecting whichever is first
    form_2_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'some_module_name', 'different_wizard_form_2')[1]
    return {
        'type': 'ir.actions.act_window',
        'view_type': 'form',
        'view_mode': 'form',
        'views': [(form_2_id, 'form')],
        'res_model': 'different.wizard',
        'res_id': wizard_id,
        'target': 'new',
        'context': context,
    }

Many thanks!

Mihai Marius
on 9/15/14, 12:50 AM
1

Ludo - Neobis

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

Ludo - Neobis
On 9/12/14, 9:47 AM

Basically I think you have 2 options:

  1. Make a temp object in OpenERP that you can create records for within the wizard. This object can be a regular osv.osv object. Then when you need values, just performa a search on the object to return the values. Delete the data when you no longer need it.
  2. Pass the data in the context along as you move over the steps of the wizard. Make sure you also keep track of your point-of-entry (for form 2 this can be from form 1 OR from form 3).

I do not know that you are currently building, but this sounds like something that can be solved by using "states" on your object.

Hi, First many thanks for the reply! What i want to do is a simple data filling of a o2m field in form 2 with user selected partners. Starting from this point i was hopping to achive this by adding a new form to select partners, which is working fine, but when comming back to form 2 (all fields are filled ok) the context i used is not usebale (id of form 1 is lost). As i'm new to OpenERP, can you please point me to the direction ofpassing the data to context? please consider that form 2 and form 3 are 2 different wizards. Also if there is a better way of selecting many partners in form2 02m field please let me know. Many thanks again!

Mihai Marius
on 9/12/14, 10:56 AM

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: 9/12/14, 4:41 AM
Seen: 735 times
Last updated: 3/16/15, 8:10 AM