Odoo Help


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.


How to pass custom data from sale order to Purchase order in button click [Closed]

on 3/12/15, 3:45 AM 508 views

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

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)
                   'view_type': 'form',
                   'view_mode': 'form',
                   'res_model': 'purchase.order',
                   'context': context,
                   'type': 'ir.actions.act_window',
#                 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">
                   <field name="so_number"/>
                    <field name="project_name" />
                     <field name="client_po_number"/>

class purchase_order(osv.Model):



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

Try replacing your line

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


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

what is default_so_number u mentioned in above code

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

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

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)


Asked: 3/12/15, 3:45 AM
Seen: 508 times
Last updated: 3/16/15, 8:10 AM