form里面one2many字段怎么显示更多关联的字段?
-
@BraidTim 在 form里面one2many字段怎么显示更多关联的字段? 中说:
purchase.order
xml 文件里面:
<field name="order_line"> <tree string="Purchase Order Lines" editable="bottom"> <field name="product_id" context="{'partner_id': parent.partner_id}"/> <field name="name"/> <field name="date_planned"/> <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/> <field name="account_analytic_id" context="{'default_partner_id':parent.partner_id}" groups="purchase.group_analytic_accounting"/> <field name="product_qty"/> <field name="qty_received" invisible="not context.get('show_purchase', False)"/> <field name="qty_invoiced" invisible="not context.get('show_purchase', False)"/> <field name="product_uom" groups="product.group_uom"/> <field name="price_unit"/> <field name="taxes_id" widget="many2many_tags" domain="[('type_tax_use','=','purchase')]" context="{'default_type_tax_use': 'purchase'}"/> <field name="price_subtotal" widget="monetary"/> </tree>
-
@BraidTim 在 form里面one2many字段怎么显示更多关联的字段? 中说:
purchase.order
xml 文件里面:
<field name="order_line"> <tree string="Purchase Order Lines" editable="bottom"> <field name="product_id" context="{'partner_id': parent.partner_id}"/> <field name="name"/> <field name="date_planned"/> <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/> <field name="account_analytic_id" context="{'default_partner_id':parent.partner_id}" groups="purchase.group_analytic_accounting"/> <field name="product_qty"/> <field name="qty_received" invisible="not context.get('show_purchase', False)"/> <field name="qty_invoiced" invisible="not context.get('show_purchase', False)"/> <field name="product_uom" groups="product.group_uom"/> <field name="price_unit"/> <field name="taxes_id" widget="many2many_tags" domain="[('type_tax_use','=','purchase')]" context="{'default_type_tax_use': 'purchase'}"/> <field name="price_subtotal" widget="monetary"/> </tree>
-
@BraidTim 在 form里面one2many字段怎么显示更多关联的字段? 中说:
@Siyuan
这个我也找到位置了,但是没看到那一句写出了关联purchase.order.line这个模块啊
field name那儿写的是purchase.order模块里面字段吧?下面接tree分析的时候自动就是purchase.order.line的字段吗?我试了试好像还是说找不到字段,应该是还只是在purchase.order模块里面找我写的字段。首先要理解字段的定义:
class PurchaseOrder(models.Model): _name = "purchase.order" ... order_line = fields.One2many('purchase.order.line', 'order_id', string='Order Lines', states={'cancel': [('readonly', True)], 'done': [('readonly', True)]}, copy=True)这里就是
purchase.order的order_line字段,这里就声明了和purchase.order.line的关系。然后在视图里面,order_line字段包含的字段就是purchase.order.line的字段<field name="order_line"> <tree string="Purchase Order Lines" editable="bottom"> <!--这里面是purchase.order.line的字段--> <field name="product_id" context="{'partner_id': parent.partner_id}"/> <field name="price_subtotal" widget="monetary"/> </tree> -
@BraidTim 在 form里面one2many字段怎么显示更多关联的字段? 中说:
@Siyuan
这个我也找到位置了,但是没看到那一句写出了关联purchase.order.line这个模块啊
field name那儿写的是purchase.order模块里面字段吧?下面接tree分析的时候自动就是purchase.order.line的字段吗?我试了试好像还是说找不到字段,应该是还只是在purchase.order模块里面找我写的字段。首先要理解字段的定义:
class PurchaseOrder(models.Model): _name = "purchase.order" ... order_line = fields.One2many('purchase.order.line', 'order_id', string='Order Lines', states={'cancel': [('readonly', True)], 'done': [('readonly', True)]}, copy=True)这里就是
purchase.order的order_line字段,这里就声明了和purchase.order.line的关系。然后在视图里面,order_line字段包含的字段就是purchase.order.line的字段<field name="order_line"> <tree string="Purchase Order Lines" editable="bottom"> <!--这里面是purchase.order.line的字段--> <field name="product_id" context="{'partner_id': parent.partner_id}"/> <field name="price_subtotal" widget="monetary"/> </tree> -
@Joshua 在 form里面one2many字段怎么显示更多关联的字段? 中说:
string="Purchase Order Lines" editable="bottom"
谢谢大神解答,我仔细看了,原来之前写的 field XXX/ 直接关闭了标签才出错的
然后出现了一个奇怪的问题,我xml写的<record model="ir.ui.view" id="meeu_v1.action_window_purchase_material"> <field name="name">meeuV1 purchase material form</field> <field name="model">meeu_v1.purchase_material</field> <field name="arch" type="xml"> <form> <field name="supplier"/> <field name="purchase_material_list" > <tree> <field name="name"/> </tree> </field> </form> </field> </record> <record model="ir.ui.view" id="meeu_v1.action_window_purchase_material"> <field name="name">meeuV1 purchase material</field> <field name="model">meeu_v1.purchase_material</field> <field name="arch" type="xml"> <tree> <field name="supplier"/> <field name="purchase_material_list"> <tree> <field name="price"/> </tree> </field> </tree> </field> </record>然后结果

新建表单不是应该是form吗?怎么写在tree的字段反而出现在新建时候的视图里面?我在新建的时候点击开发者的编辑form视图也显示的

显示的也是tree
是不是有什么基础问题我没有注意到? -
我看了下你的代码,你一共定义了2个
meeu_v1.purchase_material的视图,一个是表单视图,一个是列表视图。但是列表视图里面是不能直接显示o2m对象里面的属性。所以你列表视图应该改为:<record model="ir.ui.view" id="meeu_v1.action_window_purchase_material"> <field name="name">meeuV1 purchase material</field> <field name="model">meeu_v1.purchase_material</field> <field name="arch" type="xml"> <tree> <field name="supplier"/> <field name="purchase_material_list"/> </tree> </field> </record>
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login

