0

現在、CentOS 6.4 マシンに OpenERP 7 をデプロイしています。システム全体をバックアップできるように、すべてを仮想化しています。

すべてがうまくいっているように見えます。モデルとビューを変更しましたが、一見不可能な問題に頭を悩ませていた 2 日間でした。

私の展開は書籍工場向けであるため、製品をカスタマイズする必要がありました (ページ数、製本タイプなど...)。

新しい製品ビューでは、フィールド x_colorpages と x_bwpages を合計して 3 番目のフィールド x_totalpages に入力できるものが必要です。簡単でしょ?

product.poduct オブジェクトに基づいた XML 、 product.normal.form ビューがあります

「x_paginecolori」または「xpagineBN」の値を変更すると、onchange 関数が自動的にトリガーされます。

そこで、製品モジュールのコードに入り、cal_change_event をコーディングしました。

/usr/lib/python2.6/site-packages/openerp-7.0_20130524_231019-py2.6.egg/openerp/addons/account/product.py にある Python ファイル product.py 内

def cal_change_event(self, cr, uid, ids, x_PagineColori, x_PagineBN):
      res = {}
      sum = 0
if not  x_PagineColori: 
    return {}
else if not x_PagineBN:
    return {}
else:
    sum = x_PagineColori + x_PagineBN
    res={'x_pagine':sum }
    return {'value':res} 

何をしても、onchange イベントは常に警告ポップアップをトリガーします。

ファイル "/usr/lib/python2.6/site-packages/openerp-7.0_20130524_231019-py2.6.egg/openerp/osv/osv.py"、185 行目、execute_cr で getattr(object, method)(cr, uid, *args, **kw) AttributeError: 'product.product' オブジェクトに属性 'cal_change_event' がありません

機能が見えないようですが、どこに置けばいいですか?product.py 内のクラスに配置した場合、Product.Product にこの属性を持たせないにはどうすればよいですか?

openerp の複数のインスタンスを検索するために、または product.py について何か見逃していないかどうかを確認するために、CENTOS インストール全体を grep しました。

product.py は正しいファイルではないようです。他の On_change 関数を消去しても、実際には何も問題はありません。ただし、エラー ログでデバッグ ポップアップ ウィンドウに同じ場所が表示されるため、ディレクトリは正しい必要があります。

これを機能させるには、最初からカスタム モジュールを作成する必要がありますか? 標準製品のモジュールを改変することはどういうわけか禁止されていますか?

洞察をお寄せいただきありがとうございます。私の脳はこれをデフォルトにしています。

ここに私のXmlがあります:

            <?xml version="1.0"?>
                <form string="Product" version="7.0">
                                        <sheet>    
            <div>
                             <label for="x_partner2" string="Cliente Referente del prodotto"/>
                                 <field name="x_partner2" />
                                    </div>
                                        <field name="image_medium" widget="image" class="oe_avatar oe_left"/>
                                        <div class="oe_title">
                                            <div class="oe_edit_only">
                                                <label for="name" string="Product Name"/>
                                            </div>
                                            <h1>
                                                <field name="name"/>
                                            </h1>
                                            <label for="categ_id" class="oe_edit_only"/>
                                            <h2><field name="categ_id"/></h2>
                                            <div name="options" groups="base.group_user">
                                                <field name="sale_ok"/>
                                                <label for="sale_ok"/>
                                            </div>
                                        </div>
                                        <div class="oe_right oe_button_box" name="buttons">
                                        </div>
                                        <notebook>
                  <page string="Information">
                                                <group>
                                                    <group>
                                                        <field name="type"/>
                                                        <field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)" groups="product.group_uom"/>
                                                        <field name="list_price"/>
                                                    </group>
                                                    <group>
                                                        <field name="default_code"/>
                                                        <label for="ean13"/>
                                                        <div name="ean">
                                                            <field name="ean13" placeholder="e.g. 5901234123457"/>
                                                        </div>
                                                    </group>
                                                    <group>
                                                        <field groups="product.group_product_variant" name="variants"/>
                                                        <field name="price_margin" groups="product.group_product_variant"/>
                                                        <field name="price_extra" groups="product.group_product_variant"/>
                                                    </group>
                                                </group>
                                                <field name="description" placeholder="describe the product characteristics..."/>
                            </page>
                  <page string="Dati del volume Universal Book">
                <group>
                <group>
                                            <field name="x_DataCreazione" />
                                                        <field name="x_DataUltimaModifica" />
                                        <field name="x_Autore" />
                                                        <field name="x_Larghezza"/>
                                         <field name="x_Altezza" />
                                         <field name="x_Dorso"/>
                                                 <field name="x_Rilegatura" />
                 <field name="x_volumiformati" />

                </group>
                </group>
                <group>
                                                 <field name="x_PagineColori"  on_change="cal_change_event(x_PagineColori,x_PagineBN)" />
                                                 <field name="x_PagineBN"  on_change="cal_change_event(x_PagineColori,x_PagineBN)" />
                                                 <field name="x_pagine" />
                </group>
                <group>
                                                 <field name="x_prezzo" />
                </group>
                </page>

                 <page string="Copertina">
                <group>
                <group>
                <field name="x_TipoCartaCopertina"/>
                <field name="x_TipoStampaCopertina"/>
                                      <field name="x_TipoFFR"/>
                                                 <field name="x_PlastificazioneCopertina" />
                                                 <field name="x_NumeroCopertinePerPagina" />
                </group>
                <group>
                <field name="x_TipoCartaSovracopertina"/>
                <field name="x_TipoStampaScopertina"/>
                 <field name="x_TipoFFRSovracopertina"/>
                 <field name="x_PlastificazioneSovracopertina"/>
                </group>
                </group>
                <label for="x_aletta" string="Libro con alette?"/>
                 <field name="x_aletta" />
                <label for="x_Note" string="Note"/>
                                                 <field name="x_Note" />
                                            </page>
                <page string="Margini">
                <group>
                 <field name="x_pagriferimento"/>
                 <field name="x_MargineDestro"/>
                 <field name="x_MargineDestro"/>
                <field name="x_MargineInferiore" />
                <field name="x_MargSinistro" />
                <field name="x_MargineSuperiore"/>
                <field name="x_RiferimentoLIFRE" />
                <field name="x_MergineSuperioreLIFRE" />
                <field name="x_MargineInferioreLIFRE" />
                </group>
                </page>
                                            <page string="Procurements" groups="base.group_user">
                                                <group name="procurement">
                                                    <group name="general">
                                                        <field name="cost_method" groups="product.group_costing_method"/>
                                                        <field name="standard_price" attrs="{'readonly':[('cost_method','=','average')]}"/>
                                                    </group>
                                                    <group name="procurement_uom" groups="product.group_uom" string="Purchase">
                                                        <field name="uom_po_id"/>
                                                    </group>
                                                </group>
                                                <separator string="Description for Suppliers"/>
                                                <field name="description_purchase" placeholder="This note will be displayed on requests for quotation..."/>
                                            </page>
                                            <page string="Inventory" groups="base.group_user">
                                                <group name="inventory">
                                                    <group name="status" string="Status">
                                                        <field name="state"/>
                                                        <field name="product_manager"/>
                                                    </group>
                                                    <group name="Weights" groups="product.group_stock_packaging" string="Weights">
                                                        <field digits="(14, 3)" name="volume" attrs="{'readonly':[('type','=','service')]}"/>
                                                        <field name="weight" attrs="{'readonly':[('type','=','service')]}"/>
                                                        <field name="weight_net" attrs="{'readonly':[('type','=','service')]}"/>
                                                    </group>
                                                </group>
                                            </page>
                                            <page string="Sales" attrs="{'invisible':[('sale_ok','=',False)]}">
                                                <group name="sale">
                                                    <group string="Sale Conditions">
                                                        <label for="warranty"/>
                                                        <div>
                                                            <field name="warranty" class="oe_inline"/> months
                                                        </div>
                                                    </group>
                                                    <group groups="product.group_uos" string="Unit of Measure">
                                                        <field name="uos_id"/>
                                                        <field name="uos_coeff"/>
                                                        <field name="mes_type"/>
                                                    </group>
                                                </group>
                                                <field name="packaging" groups="product.group_stock_packaging">
                                                    <form string="Packaging" version="7.0">
                                                        <group col="4">
                                                            <field name="ean"/>
                                                            <field name="sequence" invisible="1"/>
                                                            <newline/>
                                                            <field name="qty"/>
                                                            <field name="ul"/>
                                                            <field name="weight_ul"/>
                                                            <separator colspan="4" string="Palletization"/>
                                                            <field name="ul_qty"/>
                                                            <field name="rows"/>
                                                            <field name="weight"/>
                                                            <separator colspan="4" string="Pallet Dimension"/>
                                                            <field name="height"/>
                                                            <field name="width"/>
                                                            <field name="length"/>
                                                        </group>
                                                        <separator colspan="4" string="Description"/>
                                                        <field name="name"/>
                                                    </form>
                                                </field>
                                                <separator string="Description for Quotations"/>
                                                <field name="description_sale" placeholder="note to be displayed on quotations..."/>
                                            </page>
                                        </notebook>
                                    </sheet>
                                    <div class="oe_chatter">
                                        <field name="message_follower_ids" widget="mail_followers"/>
                                        <field name="message_ids" widget="mail_thread"/>
                                    </div>
                                </form>
4

2 に答える 2

0

標準モジュールの変更は禁止されていませんが、OpenERP を拡張する独自のモジュールを作成することをお勧めします。

あなたが OpenERP でどれだけの経験を積んでいるかわかりません (OpenERP を初めて使用する場合、問題は非常に単純な間違いによって引き起こされる可能性があります)。

  1. OpenERP を再起動し、製品モジュールを再インストールしましたか?
  2. _name = "product.product" のクラスで cal_change_event() メソッドが定義されていますか?
  3. XML コードを投稿していただけますか? この問題は、Python コードとは関係がない可能性があります。
于 2013-06-30T08:50:52.240 に答える