Skip to Content

Contributors

Re: Technical help on odoo cache framework

Indeed, self.invalidate_cache() is fixing the issue when added after super().

I tried self.invalidate_cache(['move_raw_ids']) to avoid the "RPG vs Bug" solution but the issue stay the same.
About @api.depends, I read that it was used to trigger computed fields update.

After some testing, I'm pretty sure that it is a framework issue because to reproduce it, you need this particular case:

- ProductA MTO - Manufacture (BoM A)
- ProductB MTO - Manufacture (BoM B)
- ProductC MTO - Buy
- ProductD MTO - Buy

BoM A Content:
- ProductB
- ProductC

BoM B Content:
- ProductD

When creating a new ProductA production, my inherited _generate_move() is correctly called for ProductB production but it fails for ProductA. If BoM content is switched, then it works fine...
The second clue that make me think that it is framework issue is the fact that the CacheMiss exception should not be raised in the UI and that the server does not report any issue on INFO/DEBUG handlers like if the exception had leaked to the UI unintentionally.




by Yann Papouin - 05:16 - 24 Apr 2020

Reference

  • Technical help on odoo cache framework
    Hi everyone,

    I'm working on extending the mrp module but I'm stuck on a technical issue that could come from a lack of knowledge of the 12.0 odoo framework since I'm coming from 6.1

    An Odoo server in raised on the UI with the message 'stock.move(311659,).product_type' when I create a new mrp.production record but no traceback is available neither in the UI or the server log/console.
    After some step-by-step debugging I finally found the culprit, an exception CacheMiss is raised when I try to access the `product_type` field of the mrp.production.move_raw_ids One2Many fields.
    Do you have some tips for me that would help me to understand what is failing in my code ?

    class MrpProduction(models.Model):
        _inherit = 'mrp.production'

        @api.multi
        def _generate_moves(self):
            super(MrpProduction, self)._generate_moves()
            for production in self:
                # Assign consumable immediatly
                consu_move_ids = production.move_raw_ids.filtered(
                    lambda r: r.product_type == 'consu'
                )
                consu_move_ids._action_assign()

    odoo-cachemiss.jpg
    Regards,
    Yann Papouin



    by Yann Papouin - 01:16 - 24 Apr 2020