Odoo Help

0

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

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

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

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

Register

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)

Stats

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