Odoo Help

1

[V8] Overriding _prepare_invoice

By
Aurélien Rivet
on 3/14/16, 5:23 AM 434 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

--Axel Mendoza--
11831
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

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: 434 times
Last updated: 4/14/16, 8:14 AM