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

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

Odoo 中文社区

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

关于生产进度的统计开发

已定时 已固定 已锁定 已移动 Odoo 开发与实施交流
6 帖子 3 发布者 6.5k 浏览 1 关注中
  • 从旧到新
  • 从新到旧
  • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • 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
            • 版块
            • 标签
            • 热门
            • 用户
            • 群组