Odoo 10 - 帐户移动行导入

Odoo 10 - Account move line import

在 Odoo 8 中,我们可以导入 "Account moves" 和 "Account move lines" 的 CSV 数据。

我正在迁移到 Odoo 10:我找到了如何导入 "Account moves" 但我可以在哪里导入我的移动线(帐户移动线视图上没有 "Import" 按钮) ?

谢谢。

克里斯托夫

account.move.line 中设置默认树视图 create='false'

如果在树视图中设置 create='false' 那么 odoo 将隐藏 CreateImport 按钮。

以下是odoo默认视图.

    <record id="view_move_line_tree" model="ir.ui.view">
        <field name="name">account.move.line.tree</field>
        <field name="model">account.move.line</field>
        <field eval="1" name="priority"/>
        <field name="arch" type="xml">
            <tree string="Journal Items" create="false">
                <field name="date"/>
                <field name="move_id" required="0"/>
                <field name="journal_id" options='{"no_open":True}'/>
                <field name="name"/>
                <field name="ref"/>
                <field name="statement_id" invisible="1"/>
                <field name="partner_id"/>
                <field name="account_id" options='{"no_open":True}' domain="[('company_id', '=', company_id)]"/>
                <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
                <field name="reconciled" invisible="1"/>
                <field name="full_reconcile_id"/>
                <field name="debit" sum="Total Debit"/>
                <field name="credit" sum="Total Credit"/>
                <field name="amount_currency" readonly="True" groups="base.group_multi_currency"/>
                <field name="currency_id" readonly="True" invisible="1" />
                <field name="date_maturity"/>
                <field name="company_currency_id" invisible="1"/>
                <field name="company_id" invisible="1"/>
            </tree>
        </field>
    </record>

您可以覆盖模块中的树视图上方并删除 create='false'.

    <record id="account.view_move_line_tree" model="ir.ui.view">
        <field name="name">account.move.line.tree</field>
        <field name="model">account.move.line</field>
        <field eval="1" name="priority"/>
        <field name="arch" type="xml">
            <tree string="Journal Items">
                <field name="date"/>
                <field name="move_id" required="0"/>
                <field name="journal_id" options='{"no_open":True}'/>
                <field name="name"/>
                <field name="ref"/>
                <field name="statement_id" invisible="1"/>
                <field name="partner_id"/>
                <field name="account_id" options='{"no_open":True}' domain="[('company_id', '=', company_id)]"/>
                <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
                <field name="reconciled" invisible="1"/>
                <field name="full_reconcile_id"/>
                <field name="debit" sum="Total Debit"/>
                <field name="credit" sum="Total Credit"/>
                <field name="amount_currency" readonly="True" groups="base.group_multi_currency"/>
                <field name="currency_id" readonly="True" invisible="1" />
                <field name="date_maturity"/>
                <field name="company_currency_id" invisible="1"/>
                <field name="company_id" invisible="1"/>
            </tree>
        </field>
    </record>

之后您可以导入 CSV 文件。

您可以在同一个文件中导入 account.move.line & account.move,我附上了导入格式。

您可以在树视图中导出任何现有帐户从操作中移动,并且 select 所有必需的 field.Just 导出它。

如果你想导入 account.move.line 和 account.move 使用不同的文件,那么你必须继承 account.move.line 创建方法并设置 check_move_validity 为 False。

    if self._context.get('check_move_validity', True):
        move.with_context(context)._post_validate()

以上条件是 odoo 基础模块 account.move.line 创建方法 condtion.When account.move.line 是在创建时系统正在检查 check_move_validity 是否为 False 然后系统将不会尝试协调单一移动线。

您需要继承自定义模块中的create和write方法,然后逐行导入工作。

@api.model
def create(self, vals):
    move_line = super(AccountMoveLine, self.with_context(check_move_validity=False)).create(vals)
    return move_line

@api.multi
def write(self, vals):
    move_line = super(AccountMoveLine, self.with_context(check_move_validity=False)).write(vals)
    return move_line

这可能对你有帮助。

有关我在 odoov11.0c 上的信息 全部基于 ids,当你导入数据时,请记住 account_account account_move 和 account_move_line 是链接的,并查看直接在模型 class

上使用的术语

从 xls 文件中,您可以从标准菜单导入 account_move 并使用这些第一行单元格名称移动帐户行: 杂志 日期 ID line_ids/partner_id 数字 参考 line_ids/debit line_ids/credit 旁白 line_ids/matching_number/Number line_ids/due日期
line_ids/counterpart
line_ids/account_id 状态

希望对您有所帮助