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

[v9] How to hava a default depending on another field?

By
Anabela Damas
on 4/13/16, 1:29 PM 293 views

I have this code: 


class ResCompany(models.Model):
    _inherit = "res.company"
   code_default = fields.Many2one(comodel_name='info.code', string='Default code', help="Default to the documents")

And in my invoice I want to have the default defined in the company:

class AccountInvoice(models.Model):
_inherit = "account.invoice"
@api.depends('company_id')
@api.model
def default_code(self):
if self.company_id:
return self.company_id.cae_default.id
code = fields.Many2one('info.code', string='Code', default=default_code, help="Code to the documents",) 


But when the code enter the function default_code the self.company_id  is empty! I also done a onchange but I realy need a default funtion ... 


Any help ? 

Thanks

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: 4/13/16, 1:29 PM
Seen: 293 times
Last updated: 4/13/16, 1:29 PM