Odoo Help

1

[V8] Overriding _prepare_invoice

By
Aurélien Rivet
on 3/14/16, 5:23 AM 482 views

Hi,

I am overriding _prepare_invoice in a custom module to copy the value of a sale order field to an invoice one.

But it doesn't work.

This is my code:

class XOrder(models.Model):

    _inherit = 'sale.order'

    payment_method = fields.Selection([

        ('transfer', 'Transfer'),

        ('credit_card', 'Credit Card'),

        ('check', 'Check'),

        ('cash', 'Cash')

    ])

    @api.v7

    def _prepare_invoice(self, cr, uid, order, lines, context=None):

        res = super(XOrder, self)._prepare_invoice(cr, uid, order, lines, context=context)

        res.update({'payment_method' : order.payment_method})

        return res    

class XInvoice(models.Model):

    _inherit = 'account.invoice'

    payment_method = fields.Selection([

        ('transfer', 'Transfer'),

        ('credit_card', 'Credit Card'),

        ('check', 'Check'),

        ('cash', 'Cash')

    ])


Could someone help ?

If I also override _make_invoice it works but I don't know if it is the right way.

Aurélien Rivet
on 3/14/16, 5:42 AM
0
Aurélien Rivet
On 3/14/16, 5:31 AM

I was completely wrong, such a newbie I am. I was using some sale order who was transformed to a stock picking form. It was normal that my field wasn't transmitted. If I make a new sale order and transform it to an Invoice, it wokrs as expected


0
Axel Mendoza
On 3/14/16, 5:28 AM

Just remove this line:

@api.v7

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

1 follower(s)

Stats

Asked: 3/14/16, 5:23 AM
Seen: 482 times
Last updated: 4/14/16, 8:14 AM