我必须在Odoo10中为我的模型创建层次结构视图。我做了以下事情。但我可以得到它。我希望这看起来像odoo8帐户视图。
pyhon文件:
class InconceExpenseDetails(models.Model):
_name = "income.expense.details"
parent_id = fields.Many2one("income.expense.details","Income ID")
child_ids = fields.One2many("income.expense.details","parent_id",string="Income IDS",select=True)
product_category = fields.Char("Category")
planned_amount = fields.Float('Planned Amount', digits=0)
actual_amount = fields.Float('Actual Amount', digits=0)
variance = fields.Float('Variance', digits=0)
currency_id = fields.Many2one('res.currency', string="Currency", default=lambda self: self.env.user.company_id.currency_id)
company_id = fields.Many2one("res.company",string="Company",default=lambda self: self.env.user.company_id)
type_seq = fields.Char("Sequence", select=1)
type = fields.Selection([
('revenue', 'Revenue'),
('income', 'Income'),
('expense', 'Expense'),
], string="Type")
查看文件:
<record id="view_budget_tree_view" model="ir.ui.view">
<field name="name">income.expense.details.tree</field>
<field name="model">income.expense.details</field>
<field name="field_parent">child_ids</field>
<field name="arch" type="xml">
<tree colors="blue:type == 'income'" string="Income and Expense Details" toolbar="1">
<field name="type_seq"/>
<field name="type"/>
<field name="product_category"/>
<field name="planned_amount"/>
<field name="actual_amount"/>
<field name="variance"/>
<field name="currency_id"/>
<field name="company_id"/>
<field name="parent_id" invisible="1"/>
</tree>
</field>
</record>
行动窗口:
<record id="action_budget_tree_view" model="ir.actions.act_window">
<field name="name">income.expense.details.tree</field>
<field name="res_model">income.expense.details</field>
<field name="view_type">tree</field>
<field name="domain">[('parent_id','=',False)]</field>
<field name="view_id" ref="view_budget_tree_view"/>
</record>
如果我将它作为普通树视图,它可以正常工作。但是我想把它作为Odoo8的帐户图表中的层次结构视图
答案 0 :(得分:1)
您需要计算字段级别:
account.financial.report
查看account
模块中的Sub Extract()
Dim x As Workbook
Dim y As Workbook
Dim Val As Variant
Dim filename As String
Dim LastCell As Range
Dim LastRow As Long
ThisWorkbook.Sheets("2").Range("A4:P1000").ClearContents
CopyCol = Split("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P", ",")
LR = Cells(Rows.Count, 1).End(xlUp).Row
LC = Cells(1, Columns.Count).End(xlToLeft).Column
LCell = Selection.SpecialCells(xlCellTypeLastCell).Address
LCC = Selection.SpecialCells(xlCellTypeLastCell).Column
LCR = Selection.SpecialCells(xlCellTypeLastCell).Row
Set y = ThisWorkbook ' set ThisWorkbook object (where this code lies)
Set x = Workbooks.Open("D:\Jenny\Raw data\Report.xlsx")
For Count = 0 To UBound(CopyCol)
Set temp = Range(CopyCol(Count) & "22:" & CopyCol(Count) & LCR)
If Count = 0 Then
Set CopyRange = temp
Else
Set CopyRange = Union(CopyRange, temp)
End If
Next
CopyRange.Copy
y.Sheets("2").Range("A4").PasteSpecial
x.Close
End Sub
。
答案 1 :(得分:1)
您需要创建一个Many2many字段child_id。 child_ids已经存在于One2many字段中,保持原样。创建另一个字段child_id(M2m - calculative)
@api.multi
def _get_child_ids(self):
for record in self:
result = []
if record.child_ids:
result = record.child_ids.ids
record.child_id = [(6,0,result)]
child_id = fields.Many2many(compute=_get_child_ids, comodel_name="income.expense.details", relation='self_rel_child', column1='child_type_id_1', column2='child_type_id_2',string="Income / Expense")
Xml看起来很好,只需用Many2many(child_id)替换One2many(child_ids)。
<record id="view_budget_tree_view" model="ir.ui.view">
<field name="name">income.expense.details.tree</field>
<field name="model">income.expense.details</field>
<field name="field_parent">child_id</field>
<field name="arch" type="xml">
<tree colors="blue:type == 'income'" string="Income and Expense Details" toolbar="1">
<field name="type_seq"/>
<field name="type"/>
<field name="product_category"/>
<field name="planned_amount"/>
<field name="actual_amount"/>
<field name="variance"/>
<field name="currency_id"/>
<field name="company_id"/>
<field name="parent_id" invisible="1"/>
</tree>
</field>
</record>
行动应该是,
<record id="action_chart_tree" model="ir.actions.act_window">
<field name="name">Chart of Income Expense</field>
<field name="res_model">income.expense.details</field>
<field name="view_type">tree</field>
<field name="view_id" ref="view_budget_tree_view"/>
<field name="domain">[('parent_id','=',False)]</field>
</record>