0
Odoo 10에서 폼 (stock.view_inventory_form)을 확장해야합니다.이 폼에는 다른 모델의 관련 레코드로 채워진 하위 트리가 있습니다. 여기 변경할 원형의 일부는 다음과 같습니다odoo 10 : 관련 레코드의 확장 폼보기 트리 (inventory.stock.line)
line_ids는 관련 모델 (stock.inventory.line)의 필드입니다<field name="line_ids" string="Inventory Details" context="{'default_location_id': location_id, 'default_product_id': product_id, 'default_prod_lot_id': lot_id, 'default_package_id': package_id, 'default_partner_id': partner_id}" mode="tree,kanban">
<tree string="Inventory Details" editable="bottom" decoration-info="product_qty != theoretical_qty" decoration-danger="theoretical_qty < 0">
<field name="product_id" domain="[('type','=','product')]"/>
<field name="product_uom_id" string="UoM" groups="product.group_uom"/>
<field name="location_id" domain="[('id', 'child_of', parent.location_id)]" groups="stock.group_stock_multi_locations"/>
<field name="prod_lot_id" domain="[('product_id', '=', product_id)]" context="{'default_product_id': product_id}" groups="stock.group_production_lot"/>
<field name="package_id" domain="['|', ('location_id','=', False), ('location_id', '=', location_id)]" groups="stock.group_tracking_lot"/>
<field name="partner_id" groups="stock.group_tracking_owner"/>
<field name="theoretical_qty" readonly="1"/>
<field name="product_qty" string="Real Quantity"/>
<field name="state" invisible="True"/>
</tree>
</field>
.
class stock_inventory_line(models.Model):
_inherit = 'stock.inventory.line'
x_container_details = fields.Char('Container details')
x_wagon_no = fields.Char('Wagon No')
x_seal_no = fields.Char('Seal No')
x_invoice_no = fields.Integer('Invoice No')
x_net_weight = fields.Integer('Net weight')
x_gross_weight = fields.Integer('Gross Weight')
그럼 내가 다음 코드를 사용하여 양식을 확장하려고 :
<record id="view_form_todo_task_inherited" model="ir.ui.view">
<field name="name">Test</field>
<field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock.view_inventory_form"/>
<field name="arch" type="xml">
<field name="line_ids">
<field name="x_container_details"/>
<field name="x_wagon_no"/>
</field>
</field>
</record>
Odoo가 오류를 반환하지 않습니다,하지만 내 필드가에 보여되지 않습니다 그래서 나는 다음과 모델을 확장 형태의 (하위) 트리 .. 내가 뭘 잘못하고 있니? 도움을받을 수있는 사람 덕분에!
감사합니다. Juan Salcedo! 그것은 작동합니다. 이전에 xpath없이 필자의 방식대로 비 관련 필드를 확장 했으므로 xpath가 없으면이를 수행 할 방법이 있다고 가정했습니다. – GiulioG
그걸 듣게되어 기쁩니다. 그렇습니다. 'xpath'를 사용할 수 없지만 위치를 지정해야합니다. 그러나 'xpath' 'field'보다 사용하기 쉽고, 'state'정의가 더 많은 경우에는 사용할 필드 (state)를 찾기 위해 문제를 겪을 수 있으므로 '// tree/field '경로. –