我如何使用onchange从产品领域到购​​买订单行odoo的one2many领域

时间:2015-12-17 09:25:46

标签: openerp odoo-8 openerp-8

就像我在product.template中有一个字段名为squ_meter的字段,我需要在采购订单行的自定义字段中复制此值,使用相同的字段名称即squ_meter,我想在采购订单行字段中应用onchange

非常感谢任何形式的帮助。提前致谢

这是我的代码

class purchase_order_line(osv.osv):

<jaxws:client id="preProductionAanleveren" serviceClass="com.company.Service” address="${pre.production.url.delivery}">

    <jaxws:inInterceptors>
        <ref bean="preProductionSigningInterceptorIn"/>
        <ref bean="preProductionWsaSignaturePartsInterceptor"/>
    </jaxws:inInterceptors>

    <jaxws:outInterceptors>
        <ref bean="preProductionSigningInterceptorOut"/>
        <ref bean="preProductionWsaSignaturePartsInterceptor"/>
    </jaxws:outInterceptors>

    <jaxws:properties>
        <entry key="mtom-enabled" value="false"/> 
        <entry key="signatureParts" value="{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;
                    {Element}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
    </jaxws:properties>
</jaxws:client>

<!-- It will dynamically set the WSA signing parts if required, depending if they contain any value. See: http://davidvaleri.wordpress.com/2010/09/15/signing-ws-addressing-headers-in-apache-cxf/ -->
<bean id="preProductionWsaSignaturePartsInterceptor" class="com.company.StaxDynamicWsaSignaturePartsInterceptor"/>

<bean id="preProductionSigningInterceptorOut" class="org.apache.cxf.ws.security.wss4j.WSS4JStaxOutInterceptor">
    <constructor-arg>
        <map>
            <entry key="action" value="Timestamp Signature"/>
            <entry key="timeToLive" value="300" />
            <entry key="user" value="${pre.production.keystore.private.sign.key.alias}"/>
            <entry key="passwordCallbackRef" value-ref="preProductionPwdCallback"/> 
            <entry key="signatureKeyIdentifier" value="DirectReference" />

<bean id="preProductionSigningInterceptorIn" class="org.apache.cxf.ws.security.wss4j.WSS4JStaxInInterceptor">
    <constructor-arg>
        <map>
            <entry key="action" value="Timestamp Signature"/>
            <entry key="signaturePropRefId" value="cryptoProperties"/>
            <entry key="cryptoProperties" value-ref="preProductionCryptoProperties"/>
        </map>
    </constructor-arg>
</bean>

<bean id="preProductionPwdCallback" class="com.company.ClientKeystorePasswordCallback">
   <property name="passwords">
     <util:map key-type="java.lang.String" value-type="java.lang.String">
       <entry key="${pre.production.keystore.private.sign.key.alias}" value="${pre.production.keystore.private.sign.key.pwd}"/>
     </util:map>
   </property>
</bean>

<util:properties id="preProductionCryptoProperties">
    <prop key="org.apache.wss4j.crypto.merlin.keystore.file">${pre.production.keystore.private}</prop>
    <prop key="org.apache.wss4j.crypto.merlin.keystore.password">${pre.production.keystore.private.pwd}</prop>

    <prop key="org.apache.wss4j.crypto.merlin.truststore.file">${pre.production.keystore.trusted}</prop>
    <prop key="org.apache.wss4j.crypto.merlin.truststore.password">${pre.production.keystore.trusted.pwd}</prop>
</util:properties>

purchase_order_line.xml

_inherit = 'purchase.order.line'

_columns ={'squ_meter' : fields.float('Square Meter'),

    }

1 个答案:

答案 0 :(得分:1)

相关字段

当您想要保留除引用之外的任何关系字段的值时,相关字段非常有用,那么它将更容易实现。

<强> OLD API

notify_one()

<强>其中

  • 第一组参数是参考字段链 跟随,最后有所需的字段。
  • type是所需字段的类型。
  • 如果所需字段仍是某种引用,请使用关系。 relation是查找该引用的表。

<强> NEW API

不再有field.related字段。

相反,您只需设置与您的模型相关的名称参数:

_columns ={
        'squ_meter': fields.related('product_id','squ_meter', type='float',    relation='product.product', string='Square Meter', readonly=True),
    }

<强> purchase_order_line.xml

squ_meter = Fields.Float(string='Square Meter', related='product_id.squ_meter' , readonly=True)