减少在odoo中的加载时间

问题描述

class valuation_report(models.Model):
  _inherit = "stock.valuation.layer"
      def _get_current_user(self):
          for r in self:
              r.user_id = self.env.user
      def _search_branch(self,operator,value):
          warehouse_id= self.env['stock.warehouse'].search([('branch_id','=',self.env.user.branch_id.id)])
          product_ids = self.env['product.product'].with_context(warehouse=warehouse_id.ids).search([]).filtered(lambda p:p.qty_available > 0)
          return [('product_id','in',product_ids.ids)]
      user = fields.Many2one('res.users',compute=_get_current_user,search=_search_branch)

我想减少以下代码中的加载时间。当我在ir.actions.act_window中使用domain时,我需要等待约7秒。我认为我的Warehouse_id和product_ids搜索时间很长,那么如何减少或如何替换搜索方法以获得更快的解决方案?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)