Skip to content
  • Categories
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • 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

  • Default (Flatly)
  • No Skin
Collapse

Odoo 中文社区

  1. Home
  2. Categories
  3. Odoo 开发与实施交流
  4. 如何点击一个按钮,更改某个字段的值

如何点击一个按钮,更改某个字段的值

Scheduled Pinned Locked Moved Odoo 开发与实施交流
2 Posts 1 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 1 Offline
    1 Offline
    18684036
    wrote on last edited by
    #1

    今天在做采购单中,想加入一个功能,就是 采购员在递交 采购申请单给 领导签时,领导会想了解一下,这款材料,以往买是多少价钱
    于是我便将采购单进行更改,
    1.在notes下面加入了一个按钮
     为了效果更好看些,我模仿了Total  (update)的做法,即编辑可见,其他状态不可见
    2。按钮事件中,直接返回一个测试数据,如:最近三次报表分别为:80.00  98.67
     代码如下:
      return
      {values:{'notes':'最近三次报表分别为:80.00  98.67'}}
     发现该写法不起效果
    假如是在onchange下,该种写法是可以正常执行的

    于是请教了上海-Joshua 大神
    经大神指导,OE不能直接返回一个value值,需要Write进数据库

    故改成
        def buyprice_scrap(self, cr, uid, ids, context=None):
            vals={}
            vals['notes']='最近三次报表分别为:80.00  98.67'
            return super(purchase_order, self).write(cr, uid, ids,vals, context=context)
    测试成功




    1 Reply Last reply
    0

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Tags
    • Popular
    • Users
    • Groups