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

Override journal default on account_invoice

By
Mariano DAngelo
on 2/17/16, 1:09 PM 452 views

need to override account_invoice model default value of  journal_id field. I'm trying to do it like this:

class
account_invoice(models.Model):      _inherit = 'account.invoice'
    @api.model

    def _default_journal(self): 
        return None                   
    @api.model
    def _default_currency(self):
        inv_type = self._context.get('type', 'out_invoice')        

         inv_types = inv_type  if isinstance(inv_type, list) else [inv_type]         
        company_id = self._context.get('company_id', self.env.user.company_id.id)         
        domain = [ ('type', 'in', filter(None, map(TYPE2JOURNAL.get, inv_types))), ('company_id', '=', company_id), ]       

        journal = self.env['account.journal'].search(domain, limit=1) 

       return journal.currency or journal.company_id.currency_id.


But  def _default_currency is never override and its call from the odoo native model

Can you please try by defining journal_id field in account.invoice model again with that default function ?

Priyesh
on 2/17/16, 4:32 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

1 follower(s)

Stats

Asked: 2/17/16, 1:09 PM
Seen: 452 times
Last updated: 2/17/16, 1:18 PM