2017-11-13 1 views
0

は私です.pyコード:検証エラー:作成/更新:必須フィールドが正しく設定されていない「[参照を持つオブジェクト:製品テンプレート - product.template]」私は製品カテゴリを作成するが、ここで検証エラー</p> <p>を持ちたい

<record model="ir.ui.view" id="product_template_only_form_view"> 
     <field name="name">product.template.pack.form</field> 
     <field name="model">product.template</field> 
     <field name="inherit_id" ref="product.product_template_only_form_view" /> 
     <field name="arch" type="xml"> 
      <field name="type" position="after"> 
       <field name="pack"/> 
      </field> 
      <notebook position="inside"> 
       <page string="Pack" attrs="{'invisible': ['|', ('product_variant_count', '&gt;', 1), ('pack', '=', False)]}"> 
        <field name="product_package_item_ids"> 
         <tree editable="bottom"> 
          <field name="product_categ_id"/> 
          <field name="quantity"/> 
         </tree> 
        </field> 
       </page> 
      </notebook> 
     </field> 
    </record> 

    <record model="ir.ui.view" id="nan_product_pack_form"> 
     <field name="name">product.product.pack.form</field> 
     <field name="model">product.product</field> 
     <field name="inherit_id" ref="product.product_normal_form_view" /> 
     <field name="arch" type="xml"> 
      <field name="type" position="after"> 
       <field name="pack"/> 
      </field> 
      <notebook position="inside"> 
       <page string="Pack" attrs="{'invisible':[('pack', '=', False)]}"> 
       <!-- <page string="Pack" attrs="{'required': [('pack','=', True)]}"> --> 
        <field name="product_package_item_ids"> 
        <!-- <field name="product_package_item_ids" attrs="{'required': [('attribute_value_ids','=', True)]}"> --> 
        <!-- <field name="product_package_item_ids" attrs="{'required':[('pack', '=', 'attribute_value_ids')]}"> --> 
         <tree editable="bottom"> 
          <field name="product_categ_id"/> 
          <field name="quantity"/> 
         </tree> 
        </field> 
       </page> 
      </notebook> 
     </field> 
    </record> 

この:ここ

class product_product(models.Model): 
    _inherit = 'product.product' 

    product_package_item_ids = fields.One2many("product.package.item", "parent_product_id", "Product Package Item") 


class product_template(models.Model): 
    _inherit = 'product.template' 

    pack = fields.Boolean(
     'Pack?', 
     help='Product Pack?', 
     ) 
    product_package_item_ids = fields.One2many("product.package.item", "parent_product_id", "Product Package Item") 

は私のXMLコードです

どのようにそれを修正するために - :エラーが

The operation cannot be completed, probably due to the following: - deletion: you may be trying to delete a record while other records still reference it - creation/update: a mandatory field is not correctly set

[product.template製品テンプレートを参照してオブジェクト]のですか?何か案は?

+0

エラーの上のいくつかの行をログで確認します。そのメッセージには常に詳細情報があります。ところで、 'product.product'モデルのために同じフィールド(' product_package_item_ids')を2回作成しています: 'product.product'が委譲によって' product.template'を継承することを考慮してください。 'product.template'で作成したモデルは' product.product'でも自動的に生成されます。 – forvas

+0

はい、product.productとproduct.templateフォームでboolean pack(product_package_item_ids)を作成したいので、product.product形式の値パックのみを入力します。 – Ftr

答えて

0

あなたはproduct.templateproduct.productの両方でproduct_package_item_idsを作成する必要はありません。 product.productproduct.templateモデルを継承しているためです。 product.productモデルからproduct_package_item_idsを削除します。そしてさらに試みる。

+0

私はすでにそれを修正しました。 @KbiRあなたの答えに感謝 – Ftr

関連する問題