Odoo Help

0
3 Answers
1
Avatar

Niyas Raphy

--Niyas Raphy--
14510
| 6 6 9
Calicut, India
--Niyas Raphy--

Odoo Techno Functionalist

Feel free to connect :  niyasraphyk@gmail.com

Twitter:https://twitter.com/niyasraphy
LinkedIn: https://www.linkedin.com/in/niyasraphy/
FB:https://www.facebook.com/niyasraphy123

Happy to help :)

Niyas Raphy
1/16/19, 11:05 AM

Hi,

Compute fields will not work in search  method, if you want the computed field in search,  then give store attribute as True for the field and try.


See the sample,


journal_id = fields.Many2one('account.journal', string='Journal', compute="xyz", store=True)


Thanks

0
Blagoj
1/23/19, 8:52 AM

Hi , so store=True did work, but then the computation method was not called because i did not put api_depends. After all that it worked as a charm.

Here's the code now , Thank you so much


    journal_id = fields.Many2one('account.journal', string='Journal',
                                 required=True, readonly=True, store=True,states={'draft': [('readonly', False)]},
                                 default=_default_journal, compute='_get_order_journal',
                                 domain="[('type', 'in', {'out_invoice': ['sale'], 'out_refund': ['sale'], 'in_refund': ['purchase'], 'in_invoice': ['purchase']}.get(type, [])), ('company_id', '=', company_id)]")
   
    @api.depends('origin')
    def _get_order_journal(self):
        for res in self:
            journal_id = self.env['sale.order'].search([('name', '=', res.origin)], limit=1).warehouse_id.journal_id
            print(self.env['sale.order'].search([('name', '=', res.origin)], limit=1).warehouse_id)
            print(journal_id)
            if journal_id:
                res.journal_id = journal_id

Ask a Question
Writer
Keep Informed
1 follower(s)
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