pythonxmlodoo

Customizing Accounting and finance module in odoo?


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

Solution

  • 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.

    Account Form View with Debug mode

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

    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. enter image description here

    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>