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 send a field value from purchase order to stock and invoice?

By
luis
on 7/16/13, 3:43 PM 2,422 views

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

0

Ray Carnes

--Ray Carnes--
15717
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

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. 

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.

0
luis
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),
        }

account_invoice()

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):
    """
    Extended
    """
    #  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

purchase_order()

Error:

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 ?

Bista Solutions US, Ray Carnes
on 7/17/13, 6:17 PM

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

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

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

You was right. thanks Ray.

luis
on 7/17/13, 8:15 PM

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

0 follower(s)

Stats

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