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. [已解决]根据form数据 控制默认按钮(编辑/创建)

[已解决]根据form数据 控制默认按钮(编辑/创建)

Scheduled Pinned Locked Moved Odoo 新手求助
6 Posts 5 Posters 6.0k 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.
  • L Offline
    L Offline
    l315276651
    wrote on last edited by
    #1

    <record id="invoice_form_inherit" model="ir.ui.view">
        <field name="name">invoice.form.inherit</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="account.invoice_form"/>
        <field name="arch" type="xml">
            <xpath expt='//form[@string="Invoice"]' possition='attributes'>

                <!-- Frist intent : nothing happened -->
                <attribute name="edit" attrs="{'invisible:[('state','=','paid')]'}"/>

                <!-- Second intent : edit, always hide -->
                <attribute name="edit" attrs="{'invisible:[('state','=','paid')]'}">false</field>

                <!-- Thirds intent : edit, never hide -->
                <attribute name="edit" attrs="{'invisible:[('state','=','paid')]'}">true</field>
        </field>

    1 Reply Last reply
    0
    • D Offline
      D Offline
      digitalsatori
      管理员
      wrote on last edited by
      #2
      attrs=&quot;{&#039;invisible:[(&#039;state&#039;,&#039;=&#039;,&#039;paid&#039;)]&#039;
      

      is not needed

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mrshelly
        wrote on last edited by
        #3

        这个还是 py 文件中控制比较好... 默认只读, 某几个状态时 可写.

        G 1 Reply Last reply
        0
        • M mrshelly

          这个还是 py 文件中控制比较好... 默认只读, 某几个状态时 可写.

          G Offline
          G Offline
          guotao0609
          wrote on last edited by
          #4

          @mrshelly py里面没法控制吧?

          S 1 Reply Last reply
          0
          • G guotao0609

            @mrshelly py里面没法控制吧?

            S Offline
            S Offline
            Siyuan
            wrote on last edited by
            #5

            @guotao0609

            真要py文件修改xml还是有办法的,

            read 方法里面获取状态传进context

            field_view_get 方法里面从context 获得当前状态,更新对应的xml

            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