<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', '>', 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製品テンプレートを参照してオブジェクト]のですか?何か案は?
エラーの上のいくつかの行をログで確認します。そのメッセージには常に詳細情報があります。ところで、 'product.product'モデルのために同じフィールド(' product_package_item_ids')を2回作成しています: 'product.product'が委譲によって' product.template'を継承することを考慮してください。 'product.template'で作成したモデルは' product.product'でも自動的に生成されます。 – forvas
はい、product.productとproduct.templateフォームでboolean pack(product_package_item_ids)を作成したいので、product.product形式の値パックのみを入力します。 – Ftr