Odoo Help

0

0
3 Answers
1
Avatar

Niyas Raphy

--Niyas Raphy--
22544
| 7 7 11
Calicut, 印度
--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
2019/1/16 上午11:05

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
2019/1/23 上午8:52

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