Customizing Accounting and finance module in odoo?

故事扮演 提交于 2019-11-30 16:21:04

问题


I am working on Accounting and Finance module, I want to do some modifications like hiding fields and hiding Chart of Taxes. Can you anybody help me out?

Please tell me the procedure to hide left side menu item (Chart of taxes).

Also I want to know view_id to hide taxes from invoice sheet and at bottom Tax (update).

Please just let me know the external ids to hide them I am unable to find them as they were linked to some other models.

Invoice/Taxes field:

field_id:tax_id

object:

type:many2many
relation:account.tax

回答1:


First of all activate Odoo developer Mode, so you can easily get the external ids of any objects.

Activate Odoo Developer Mode

How to know External ID of any object

Open that form and you can see one drop down field on top of the page only if the developer mode is active.

And select option "Edit Form View" from the drop down and you can see the details of that form view like model name, external id of that view and many more.

In your case to inherit this form use "account.invoice_supplier_form" external id of this form, see this image.

To know the External Id of Menu Items,

Go to Settinsgs => Technical => User Interface => Menu Items

Search menu name that you want, open that record and select View Metadata from the debug mode drop down.

How to hide Menu Items:

To hide menu items there is one easiest way is to do this by creating new group (in which only specified user can have access) and assign that group to the menu item while you re-define that menu.

Create one group using xml file this must be first added in __openerp__.py.

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data noupdate="1">
    <record id="new_group_id" model="res.groups">
      <field name="name">New Group Name</field>
      <field name="category_id" ref="base.module_category_hidden"/>
      <field name="users" eval="[(4, ref('base.user_root'))]"/>
    </record>
  </data>
</openerp>

And create another xml file in which is update that menu item with that xml code.

<record id="account.menu_action_tax_code_tree" model="ir.ui.menu">
  <field name="groups_id" eval="[(6, 0, [ref('new_group_id')] )]"/>
</record>

Another way is to do this from UI, directly assign that newly created group to menu items Go to Settings => Technical => User Interface => Menu Items (it's rollback while module will be upgrade in which that menu item defines).

How to hide fields in existing view

TO hide/add any fields in the existing form you must be inherit that view first and find that field using xpath or direct field and assign attributes to hide that field.

Example:

<record id="new_id" model="ir.ui.view">
  <field name="name">New.name</field>
  <field name="inherit_id" ref="account.invoice_supplier_form" />
  <field name="model">account.invoice</field>
  <field name="arch" type="xml">
    <data>
    <!-- path according to the fields that you want to hide from tree -->
      <xpath expr="/form/sheet/notebook/page/field[@name='line_cr_ids']/tree/field[@name='account_id']" position="attributes">
        <attribute name="invisible">True/1</attribute>
      </xpath>

      <field name="tax_line" position="attributes">
        <attribute name="invisible">True/1</attribute>
      </field>
    </data>
  </field>
</record>


来源:https://stackoverflow.com/questions/33448098/customizing-accounting-and-finance-module-in-odoo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!