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 pass custom data from sale order to Purchase order in button click [Closed]

By
Odoo
on 3/12/15, 3:45 AM 535 views

The Question has been closed for reason: too subjective and argumentative

by
Odoo
on 03/12/2015 14:53:07

Here is my code ,problem is when I click on  purchase_order_data1 button the sale order 'name' field should be add in   'so_number'  of purchase.order form( this is my custom field ).But its not coming .Need a help.......

<button name="purchase_order_data1" string="Test" type="object"/>


class sale_order(osv.Model):
    _inherit = "sale.order"
    _description = "Validate quote"
    _columns = {

}

 def purchase_order_data1(self,cr,uid,ids,context):
        if not context: context={}
        for id in ids:
            deg_obj=self.pool.get('sale.order').browse(cr,uid,id, context=context)
            my_id=deg_obj.name
            context.update({'default_so_number':deg_obj.name})
            return{
                   'view_type': 'form',
                   'view_mode': 'form',
                   'res_model': 'purchase.order',
                   'context': context,
                   'type': 'ir.actions.act_window',
                   'nodestroy':True,
                   'target':'inline',
                   }
#                 my_id=int(deg_obj.my_products)
#                 prr= int(deg_obj.categg_temp)
#                 pch= int(deg_obj.categ_temps)
#                 cch= int(deg_obj.categ_temp2)
                
 <record id="purchase_order_inherited" model="ir.ui.view">
                <field name="name">purchase</field>
                <field name="model">purchase.order</field>
                
                <field name="inherit_id" ref="purchase.purchase_order_form"/>
                <field name="arch" type="xml">
                <group>       
                   <field name="so_number"/>
                    <field name="project_name" />
                     <field name="client_po_number"/>
                
      </group>

class purchase_order(osv.Model):
    
    _inherit='purchase.order'


    _columns={
 'so_number':fields.integer('S.O.Number'),

}

0
Emanuel Cino
On 3/12/15, 4:41 AM

Try replacing your line

'context': context.update({'so_number': my_id}),

By:

'context': context.update({'default_so_number': my_id}),

what is default_so_number u mentioned in above code

Odoo
on 3/12/15, 4:54 AM

This is the way to pass a default value for a field when opening a form view on a record which is not yet stored. You simply prepend the field name with default_

Emanuel Cino
on 3/12/15, 5:00 AM

But its not working dear.....

Odoo
on 3/12/15, 5:20 AM

my_id=deg_obj.name is not correct. you should do my_id=deg_obj.id

Emanuel Cino
on 3/12/15, 6:38 AM

I tried Emaunel ,Based on your code that number is not coming into so_number custom field.its coming as empty

Odoo
on 3/12/15, 7:21 AM

But by doing 'default_so_number':deg_obj.name you assign a string to a field that should be integer... As well you should not return in a for loop. You cannot return many views, only one, for one object.

Emanuel Cino
on 3/13/15, 1:48 AM

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/12/15, 3:45 AM
Seen: 535 times
Last updated: 3/16/15, 8:10 AM