Odoo 中文社区

    • 注册
    • 登录
    • 搜索
    • 版块
    • 标签
    • 热门
    • 用户
    • 群组

    Odoo中文社区可以通过以下两个域名访问:shine-it.net , odoo.net.cn

    由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

    本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

    开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

    如果您登录系统碰到问题,请在微信公众号留言:

    关于OpenERP里面的线程问题

    Odoo 开发与实施交流
    3
    5
    4165
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • Joshua
      Joshua 管理员 最后由 编辑

      今日研究OpenERP的mrp,想重写下这个方法,因为当我运行mrp的时候会自动生成PO,但是他们是一个个地通过make_po生成,如果我想一次过将这次运行mrp所有缺货的产品,不成功,因为里面调用make_po是逐个id调用的
      对于python的线程不是很了解,跟踪代码的时候发现id是一个个传过来,运行下图的代码是这个
      问题:如何可以一次过得到所有的Procurement Order

      <br />class procurement_compute_all(osv.osv_memory):<br />&nbsp; &nbsp; _name = &#039;procurement.order.compute.all&#039;<br />&nbsp; &nbsp; _description = &#039;Compute all schedulers&#039;<br /><br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;automatic&#039;: fields.boolean(&#039;Automatic orderpoint&#039;,help=&#039;Triggers an automatic procurement for all products that have a virtual stock under 0. You should probably not use this option, we suggest using a MTO configuration on products.&#039;),<br />&nbsp; &nbsp; }<br /><br />&nbsp; &nbsp; _defaults = {<br />&nbsp; &nbsp; &nbsp; &nbsp;  &#039;automatic&#039;: lambda *a: False,<br />&nbsp; &nbsp; }<br /><br />&nbsp; &nbsp; def _procure_calculation_all(self, cr, uid, ids, context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; @param self: The object pointer.<br />&nbsp; &nbsp; &nbsp; &nbsp; @param cr: A database cursor<br />&nbsp; &nbsp; &nbsp; &nbsp; @param uid: ID of the user currently logged in<br />&nbsp; &nbsp; &nbsp; &nbsp; @param ids: List of IDs selected<br />&nbsp; &nbsp; &nbsp; &nbsp; @param context: A standard dictionary<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; proc_obj = self.pool.get(&#039;procurement.order&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; for proc in self.browse(cr, uid, ids, context=context):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; proc_obj.run_scheduler(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname,\<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context=context)<br />&nbsp; &nbsp; &nbsp; &nbsp; return {}<br /><br />&nbsp; &nbsp; def procure_calculation(self, cr, uid, ids, context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; @param self: The object pointer.<br />&nbsp; &nbsp; &nbsp; &nbsp; @param cr: A database cursor<br />&nbsp; &nbsp; &nbsp; &nbsp; @param uid: ID of the user currently logged in<br />&nbsp; &nbsp; &nbsp; &nbsp; @param ids: List of IDs selected<br />&nbsp; &nbsp; &nbsp; &nbsp; @param context: A standard dictionary<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; threaded_calculation = threading.Thread(target=self._procure_calculation_all, args=(cr, uid, ids, context))<br />&nbsp; &nbsp; &nbsp; &nbsp; threaded_calculation.start()<br />&nbsp; &nbsp; &nbsp; &nbsp; return {&#039;type&#039;: &#039;ir.actions.act_window_close&#039;}<br /><br />procurement_compute_all()<br /><br /># vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:<br />
      


      [attachimg=1]

      【上海先安科技】(joshua AT openerp.cn),欢迎关注公众号:openerp_cn

      1 条回复 最后回复 回复 引用 0
      • mrshelly
        mrshelly 最后由 编辑

        应该与 python 线程无关...

        参考 
        addons\procurement\schedulers.py (OE server 6.0.2)

                    procurement_obj = self.pool.get('procurement.order')
                    if not ids:
                        ids = procurement_obj.search(cr, uid, [], order="date_planned")

        可以得到 需要处理的 procurement.order

        1 条回复 最后回复 回复 引用 0
        • digitalsatori
          digitalsatori 管理员 最后由 编辑

          的确与线程无关。make_po是procurement order的一个方法, 而每个procuement order只与一个产品相关,生成的PO必然是:一个产品一个PO

          一个简单的解决方法,也是给当前客户实施采用的方法是:重载run_scheduler, 在其中增加merge po的逻辑(可以调用purchase.order中的do_merge方法),将生成的单个产品的PO按照产品对应的供应商设置进行合并。

          【上海先安科技】(tony AT openerp.cn)

          1 条回复 最后回复 回复 引用 0
          • Joshua
            Joshua 管理员 最后由 编辑

            谢谢各位回复,确实与线程无关。 😞

            【上海先安科技】(joshua AT openerp.cn),欢迎关注公众号:openerp_cn

            1 条回复 最后回复 回复 引用 0
            • First post
              Last post