跳至內容
選單
此問題已被標幟
3 回覆
10891 瀏覽次數

Hello community,

I've encountered this and I am not sure how it works. It's in the accounting module in the Journal entries form view

Its about that line:


<field name="account_id" domain="[('company_id', '=', parent.company_id), ('deprecated', '=', False)]"/>

What is parent standing for here? Is the notebook (or the widget one2many_list) considered as a child of the <sheet> of the form view. So parent.account_id refers to the account id of the record that's open on the form?

<record id="view_move_form" model="ir.ui.view">
<field name="name">account.move.form</field>
<field name="model">account.move</field>
<field name="arch" type="xml">
<form string="Account Entry">
<header>
<button name="post" states="draft" string="Post" type="object" class="oe_highlight" groups="account.group_account_invoice"/>
<button name="%(action_view_account_move_reversal)d" states="posted" string="Reverse Entry" type="action" groups="account.group_account_invoice"/>
<button name="button_cancel" states="posted" string="Cancel Entry" type="object" groups="account.group_account_invoice"/>
<field name="state" widget="statusbar"/>
</header>
<sheet>
<div class="oe_button_box">
<button name="open_reconcile_view"
class="oe_stat_button"
icon="fa-bars"
type="object"
string="Reconciled entries">
</button>
</div>
<label for="name" class="oe_edit_only" attrs="{'invisible':[('name','=','/')]}"/>
<h1>
<field name="name" readonly="True" attrs="{'invisible':[('name','=','/')]}"/>
</h1>
<group>
<group>
<field name="journal_id" options="{'no_open': True, 'no_create': True}"/>
<field name="date"/>
</group>
<group>
<field name="ref"/>
<field name="company_id" required="1" groups="base.group_multi_company"/>
<field name="amount" invisible="1"/>
<field name="currency_id" invisible="1"/>
</group>
</group>
<notebook>
<page string="Journal Items">
<field name="line_ids" widget="one2many_list"
context="{'line_ids': line_ids, 'journal_id': journal_id }">
<tree editable="bottom" string="Journal Items">
<field name="account_id" domain="[('company_id', '=', parent.company_id), ('deprecated', '=', False)]"/>
<field name="partner_id"
domain="['|', ('parent_id', '=', False), ('is_company', '=', True)]"/>
<field name="name"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
<field name="amount_currency" groups="base.group_multi_currency"/>
<field name="company_currency_id" invisible="1"/>
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency"/>
<field name="debit" sum="Total Debit"/>
<field name="credit" sum="Total Credit"/>
<field name="date_maturity" required="0"/>
</tree>
</field>
<field name="narration" colspan="4" placeholder="Add an internal note..." nolabel="1" height="50"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
頭像
捨棄
最佳答案

Hello Dimitar,

To understand the concept you should be firstly know all types of relational fields in odoo.

You can get to know all about this on : https://www.odoo.com/documentation/10.0/reference/orm.html#fields

I will be little concise.

This is the form view of existing model "account.move".

in which there is a relational(one2many) field for "account.move.line" named "line_ids".

There is a basic one2many relation between "account.move" and "account.move.line"[one account.move has many account.move.line].

To one2many field on form view we can write inline tree/form/kanban view of target model. Which is done in the above view for field "line_ids".


<field name="account_id" domain="[('company_id', '=', parent.company_id), ('deprecated', '=', False)]"/

in above code "parent" is a parent object(account.move).

So using parent you can use the current active account move object's any field value in tree/from/kanban of account.move.line.

I hope this explanation will helpful to you.

頭像
捨棄
最佳答案

Sorry, but I read that simply as a functional reference to the parent company in a hierarchical multi-company setup (parent company, child company).

頭像
捨棄
作者 最佳答案

Yes,

Thank you a lot. So basically a list view inside a form view displaying the one2many relations of the object that is displayed in the form view you can use parent on the related records to display a property of the single record.

I am wondering as I have never encountered this anywhere else. Where is this document is it part of this widget:

 <field name="line_ids" widget="one2many_list"

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
5月 18
3614
0
4月 23
1351
2
9月 22
4277
0
5月 19
3369
0
12月 24
849