跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(Flatly)
  • 不使用皮肤
折叠

Odoo 中文社区

  1. 主页
  2. 版块
  3. Odoo 开发与实施交流
  4. 关于生产进度的统计开发

关于生产进度的统计开发

已定时 已固定 已锁定 已移动 Odoo 开发与实施交流
6 帖子 3 发布者 5.0k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • L 离线
    L 离线
    linyaohui
    写于 最后由 编辑
    #1

    大家好,因为实际需要,例如一个生产订单要生产a产品10000,今天完成1000,明天完成1000,这样我每天需要记录当天完成数,因此我做了一个form专门来记录生产订单的进度,我有个问题,就是记录进度的功能已经实现了,但是怎样实现我所记录的进度统计呢(当我选了某个生产单,可以知道它已完成了2000)?该如何开发?

    附件是我的代码,请大家帮帮忙

    1 条回复 最后回复
    0
    • JoshuaJ 离线
      JoshuaJ 离线
      Joshua 管理员
      写于 最后由 编辑
      #2

      这样

      <br />class mrp_production(osv.osv):<br />&nbsp; &nbsp; _name=&quot;mrp.production&quot;<br />&nbsp; &nbsp; _inherit = &quot;mrp.production&quot;	<br />&nbsp; &nbsp; def&nbsp; _compute(self, cr, uid, ids, name, arg, context):<br />&nbsp; &nbsp; &nbsp; &nbsp; res = {}<br />&nbsp; &nbsp; &nbsp; &nbsp; for po in self.browse(cr, uid, ids):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cr.execute(&quot;select mo.order, sum(mo.allqty) from mrp_extend as mo&nbsp; where mo.order=%s group by mo.order &quot;,(po.name,))&nbsp; &nbsp; &nbsp;  <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; record = cr.fetchone()<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if record:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res[mo.id] = record[1]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res[mo.id] = False<br />&nbsp; &nbsp; &nbsp; &nbsp; return res<br />		<br />&nbsp; &nbsp; _columns = {&nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;x_finished&#039; : fields.function(_compute, type=&#039;float&#039;, method=True, string=&#039;已完成 &#039;),&nbsp; &nbsp; <br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; def process(self, cr, uid, ids, context={}):<br />&nbsp; &nbsp; &nbsp; &nbsp; self._compute(cr, uid, ids, name, arg, context)<br />&nbsp; &nbsp; &nbsp; &nbsp; return True <br />		<br />mrp_production()<br />
      



      错误的地方有:
      1.

      cr.execute(&quot;select mo.order, sum(mo.allqty) from mrp_extend as mo&nbsp; where mo.order=%s group by mo.order &quot;,(po.name,))&nbsp; &nbsp; 
      

       

      many2one 存的是Id不是直接的值

      2.

      res[mo.id] = record[1]
      


      mo.id 不存在,改为po.id

      3.

       def process(self, cr, uid, ids, context={}):<br />&nbsp; &nbsp; &nbsp; &nbsp; self._compute(cr, uid, ids, name, arg, context)<br />&nbsp; &nbsp; &nbsp; &nbsp; return True 
      


      里面无需写方法,而且方法参数错了

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

      1 条回复 最后回复
      0
      • L 离线
        L 离线
        linyaohui
        写于 最后由 编辑
        #3

        谢谢josuhua,working了,但是那些方法的参数是如何来定的?

        1 条回复 最后回复
        0
        • L 离线
          L 离线
          liu198619
          写于 最后由 编辑
          #4

          同问,参数应该如何定义?

          1 条回复 最后回复
          0
          • JoshuaJ 离线
            JoshuaJ 离线
            Joshua 管理员
            写于 最后由 编辑
            #5

            参数除了基本参数外,其他你喜欢怎么定就怎么定,基本参数,可以参考addon里面

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

            1 条回复 最后回复
            0

            • 登录

            • 没有帐号? 注册

            • 登录或注册以进行搜索。
            • 第一个帖子
              最后一个帖子
            0
            • 版块
            • 标签
            • 热门
            • 用户
            • 群组