在会计odoo中过滤总帐报告中的日记帐项目 [英] Filter Journal Item in General Ledger report in accounting odoo
问题描述
所有银行帐户及其日记帐项目都显示在总帐中.我在日志项中有 branch_id 字段,当前登录用户也有 branch_id 字段.我只想显示他们的 branch_id 与当前用户 branch_id 相同的日记帐项目.如何过滤日记帐项目并在总帐报告中重新计算其借项和贷项以及余额?
All bank account and their journal items are shown in general ledger. I have branch_id field in journal item and current login user also has branch_id field. I want to only display journal item that their branch_id is same with current's user branch_id. How can I filter journal item and recalculate their debit and credit and balance in general ledger report?
@api.model
def _get_report_line_move_line(self, options, partner, aml, cumulated_init_balance, cumulated_balance):
if aml['payment_id']:
caret_type = 'account.payment'
elif aml['move_type'] in ('in_refund', 'in_invoice', 'in_receipt'):
caret_type = 'account.invoice.in'
elif aml['move_type'] in ('out_refund', 'out_invoice', 'out_receipt'):
caret_type = 'account.invoice.out'
else:
caret_type = 'account.move'
date_maturity = aml['date_maturity'] and format_date(self.env, fields.Date.from_string(aml['date_maturity']))
columns = [
{'name': aml['journal_code']},
{'name': aml['account_code']},
{'name': self._format_aml_name(aml['name'], aml['ref'], aml['move_name'])},
{'name': date_maturity or '', 'class': 'date'},
{'name': aml['full_rec_name'] or ''},
{'name': self.format_value(cumulated_init_balance), 'class': 'number'},
{'name': self.format_value(aml['debit'], blank_if_zero=True), 'class': 'number'},
{'name': self.format_value(aml['credit'], blank_if_zero=True), 'class': 'number'},
]
if self.user_has_groups('base.group_multi_currency'):
if aml['currency_id']:
currency = self.env['res.currency'].browse(aml['currency_id'])
formatted_amount = self.format_value(aml['amount_currency'], currency=currency, blank_if_zero=True)
columns.append({'name': formatted_amount, 'class': 'number'})
else:
columns.append({'name': ''})
columns.append({'name': self.format_value(cumulated_balance), 'class': 'number'})
return {
'id': aml['id'],
'parent_id': 'partner_%s' % partner.id,
'name': format_date(self.env, aml['date']),
'class': 'date',
'columns': columns,
'caret_options': caret_type,
'level': 4,
}
推荐答案
尝试更改 总帐 操作域.
您可以定义一个服务器操作来获取原始操作定义并在返回结果之前更改域,然后将其与 Accounting/Ledgers
下的 General Ledger
菜单项相关联.
You can define a server action that gets the original action definition and alter the domain before returning the result then associate it with the General Ledger
menu item under Accounting/Ledgers
.
示例:
<record model="ir.actions.server" id="action_account_moves_ledger_general">
<field name="name">General Ledger</field>
<field name="model_id" ref="account.model_account_move_line"/>
<field name="state">code</field>
<field name="code">
action = env.ref('account.action_account_moves_ledger_general').read()[0]
action['domain'] = "[('display_type', 'not in', ('line_section', 'line_note')), ('branch_id', '=', {})]".format( env.user.branch_id.id)
</field>
</record>
<record model="ir.ui.menu" id="account.menu_action_account_moves_ledger_general">
<field name="action" ref="action_account_moves_ledger_general"/>
</record>
这篇关于在会计odoo中过滤总帐报告中的日记帐项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!