Odoo Help


How to send a field value from purchase order to stock and invoice?

on 7/16/13, 3:43 PM 3,232 views

I successfully added 3 custom fields in Purchase order. now how can i send the values to stock picking and finally invoice.

On 7/17/13, 5:53 PM

Hi, Ray thanks for your answer. I followed your advice I think I understand in part. I generate this code but send me an error, maybe you can help me with this:

class account_invoice(osv.osv):

_inherit = 'account.invoice'
_name = 'account.invoice'

_columns = {
        'origen_pos_id': fields.many2one('pos.order', 'Relación Ticket', required=False),
        'origen_invoice_id': fields.many2one('account.invoice', 'Relación Factura', required=False),


class purchase_order(osv.osv):

_inherit = 'purchase.order'
#_name = 'purchase.order'

_columns = {
        'ref_oc': fields.char('Referencia OC', size=64, readonly=False),
        'ref_pos_id': fields.many2one('pos.order', 'Relación Ticket', required=False),
        'ref_invoice_id': fields.many2one('account.invoice', 'Relación Factura', required=False),

def action_invoice_create(self, cr, uid, ids, context=None):
    #  create invoice
    invoice_id = super(purchase_order, self).action_invoice_create(cr, uid, ids, context=context)

    # check

    vals = {}
    for order in self.brows(cr, uid, ids):
      if order.ref_pos_id:
        vals['origin_pos_id'] = order.ref_pos_id.id
      if order.ref_invoice_id:  
        vals['origin_invoice_id'] = order.ref_invoice_id.id

        if vals:
            # write to invoice
            self.pool.get('account.invoice').write(cr,uid, [invoice_id], vals)
            return invoice_id



File "/home/openerp/addons_linked/ref_oc/ref_oc.py", line 69, in action_invoice_create for order in self.brows(cr, uid, ids): AttributeError: 'purchase.order' object has no attribute 'brows'

This error indicates you have self.brows instead of self.browsE but I don't see this above - what is line 69 of rec_oc.py ?

Ray Carnes
on 7/17/13, 6:17 PM

line 69 --> for order in self.brows(cr, uid, ids):

on 7/17/13, 7:47 PM

As I posted already, It should be --> for order in self.browse(cr, uid, ids): --- you are not spelling browse correctly.

Ray Carnes
on 7/17/13, 8:00 PM

You was right. thanks Ray.

on 7/17/13, 8:15 PM

Ray Carnes

--Ray Carnes--
| 9 7 9
Keyport, United States
--Ray Carnes--

Senior ERP Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0.

Completed Odoo Functional and Technical Training.

Functional Areas:

  • CRM/Sales

  • Inventory

  • Manufacturing

  • Accounting

  • Purchasing

Major Skills:

  • Business Process Reengineering

  • Efficiency Consulting

  • User Needs and GAP Analysis;

  • Functional and Technical Design;

  • Prototyping and Proof of Concepts;

  • Requirements Specifications;

  • Agile Implementation;

  • Data Migration;

  • Configuration & Customization (UI and code);

  • Integration - Odoo and non Odoo Applications and Services;

  • Training and Knowledge Transfer;

  • Go Live Support;

  • Helpdesk;

  • Version Upgrades and Migration.

  • Accounting Expert.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

I am a skilled Communicator and I only take the serious things seriously!

Ray Carnes
On 7/16/13, 5:12 PM

You can only do this through a module - python code that defines the three custom fields on sale.order, stock.picking and account.invoice.

Have a look at http://v6apps.openerp.com/addon/6739

1) It adds a new custom field address_shipping_id to account.invoice

2) It overrides the _make_invoice function in sale.order to populate the shipping address by copying it over from the Sales Order.

About This Community

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


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 7/16/13, 3:43 PM
Seen: 3232 times
Last updated: 3/16/15, 8:10 AM