Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Artificial Intelligence
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Property Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all IndustriesInauguration Odoo Lyon
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Remove Empty Space Between Widget

Subscribe

Get notified when there's activity on this post

This question has been flagged
width
1 Reply
151 Views
Avatar
Ashilkrishna

Hi,

I added a custom widget field in the invoice_line_ids  view. The widget displays correctly, but it creates a  empty space between the widget , making the layout look uneven.

Screenshot attached.

How can I remove this extra space

<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<record id="inherit_invoice_line" model="ir.ui.view">
<field name="name">inherit.invoice.line</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='invoice_line_ids']/list/field[@name='quantity']" position="after">
<field name="current_on_hand_average_cost" optional="hide" groups="zl_account_base.groups_cost_group_manager"/>
<field name="cost" optional="hide" sum="Cost" groups="zl_account_base.groups_cost_group_manager"/>
<field name="product_type" column_invisible="1"/>
<!-- This button opens a wizard to update the cost of the invoice line -->
<button name="%(zl_product_report.action_update_cost_wizard)d"
type="action"
icon="fa-pencil"
aria-label="Update Cost"
title="Update Cost"
groups="zl_account_base.group_management"
invisible="not product_id"/>
<field name="is_cost_updated" column_invisible="1"/>
<field name="total_cost" optional="hide" sum="Total Cost" groups="zl_account_base.groups_cost_group_manager"/>
<field name="margin" optional="hide" sum="Margin" groups="zl_account_base.groups_cost_group_manager"/>
</xpath>

<!-- ONE XPATH - both icons together, right after product_id -->
<xpath expr="//field[@name='invoice_line_ids']/list/field[@name='product_id']" position="after">
<button data-hotkey="w"
name="action_open_product_transactions_wizard" type="object"
class="fa fa-info-circle btn-primary"
/>
<field name="company_stock_info" widget="company_stock_widget" nolabel="1" width="10px"/>
</xpath>
<xpath expr="//field[@name='invoice_line_ids']/list/field[@name='account_id']" position="attributes">
<attribute name="optional">hide</attribute>
</xpath>
<!-- <xpath expr="//field[@name='invoice_line_ids']/list/field[@name='tax_ids']" position="after">-->
<!-- <field name="line_tax_amount" optional="show" sum="Total Tax Amount"/>-->
<!-- </xpath>-->

</field>
</record>

<record id="view_move_form_margin_recompute" model="ir.ui.view">
<field name="name">account.move.form.margin.recompute</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<!-- Button for Customer Invoices -->
<button name="button_recompute_margins" type="object" string="Recompute Margins"
class="oe_highlight"
groups="zl_account_base.group_management" invisible="move_type not in ['out_invoice','out_refund']"/>

<!-- Button for Vendor Bills -->
<button name="recompute_margins_on_related_invoices" type="object" string="Update Sales Margins"
class="oe_highlight"
groups="zl_account_base.groups_cost_group_manager" invisible="move_type != 'in_invoice' or state != 'posted'"/>
help="Manually triggers the recalculation of margins on all sales invoices affected by this bill."/>
</xpath>
</field>
</record>

<!-- 2. Custom List View -->
<record id="view_invoice_line_analysis_tree" model="ir.ui.view">
<field name="name">account.move.line.analysis.tree</field>
<field name="model">account.move.line</field>
<field name="arch" type="xml">
<list string="Invoice Lines" create="false" edit="false" delete="false">
<field name="invoice_date" optional="show"/>
<field name="move_id"/>
<field name="partner_id" optional="show"/>
<field name="product_id"/>
<field name="quantity"/>
<field name="price_unit"/>
<field name="cost" optional="show"/>
<field name="margin" optional="show"/>
<field name="price_subtotal" sum="Total"/>
<field name="line_tax_amount" sum="Total Tax" optional="hide"/>
<button name="button_update_line_cost" type="object" icon="fa-refresh" help="Update Cost &amp; Margin for this line"/>
</list>
</field>
</record>


<!-- 1. Main Action Window -->
<record id="action_invoice_line_analysis" model="ir.actions.act_window">
<field name="name">Invoice Lines</field>
<field name="res_model">account.move.line</field>
<field name="view_mode">list,form</field>
<field name="view_id" ref="view_invoice_line_analysis_tree"/>
<field name="domain">[('display_type', '=', 'product'), ('move_id.state', '=', 'posted')]</field>
<field name="context">{
'search_default_sales_invoices': 1,
'create': False,
'edit': False,
'delete':False
}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
No invoice lines found. Let's create one!
</p>
</field>
</record>

<!-- 3. Custom Search View with Filters -->
<record id="view_invoice_line_analysis_search" model="ir.ui.view">
<field name="name">account.move.line.analysis.search</field>
<field name="model">account.move.line</field>
<field name="arch" type="xml">
<search string="Search Invoice Lines">
<field name="product_id"/>
<field name="partner_id"/>
<field name="move_id"/>
<separator/>
<filter string="Sales Invoices" name="sales_invoices" domain="[('move_id.move_type', '=', 'out_invoice')]"/>
<filter string="Purchase Bills" name="purchase_bills" domain="[('move_id.move_type', '=', 'in_invoice')]"/>
<filter string="Credit Notes" name="credit_notes" domain="[('move_id.move_type', '=', 'out_refund')]"/>
<filter string="Refunds" name="refunds" domain="[('move_id.move_type', '=', 'in_refund')]"/>
<group expand="0" string="Group By">
<filter string="Invoice/Bill" name="groupby_move" context="{'group_by': 'move_id'}"/>
<filter string="Product" name="groupby_product" context="{'group_by': 'product_id'}"/>
<filter string="Partner" name="groupby_partner" context="{'group_by': 'partner_id'}"/>
</group>
</search>
</field>
</record>

<!-- 4. Server Action for Mass Update -->
<record id="action_server_update_line_cost" model="ir.actions.server">
<field name="name">Update Cost &amp; Margin</field>
<field name="model_id" ref="account.model_account_move_line"/>
<field name="binding_model_id" ref="account.model_account_move_line"/>
<field name="binding_view_types">list</field>
<field name="state">code</field>
<field name="code">
if records:
records.button_update_line_cost()
</field>
</record>

<record id="account_move_list_view_inherited" model="ir.ui.view">
<field name="name">account.move.list.view</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_out_invoice_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='amount_total_in_currency_signed']" position="after">
<field name="total_margin" sum="Total Margin"/>
</xpath>
</field>
</record>

<!-- 5. Menu Item -->
<menuitem
id="menu_invoice_line_analysis"
name="Invoice Lines"
parent="account.menu_finance_reports"
groups="zl_account_base.groups_cost_group_manager"
action="action_invoice_line_analysis"
sequence="100"/>
</data>
</odoo>

Any guidance would be appreciated.

Thanks.

0
Avatar
Discard
Avatar
Muhammad Farooq Iqbal
Best Answer

Below is a clean updated version. The main change is: remove width="10px" from the XML and control the widget column using a CSS/SCSS class.

1. Updated XML

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <data>

        <record id="inherit_invoice_line" model="ir.ui.view">
            <field name="name">inherit.invoice.line</field>
            <field name="model">account.move</field>
            <field name="inherit_id" ref="account.view_move_form"/>
            <field name="arch" type="xml">

                <!-- Add icon button + custom widget after product -->
                <xpath expr="//field[@name='invoice_line_ids']/list/field[@name='product_id']" position="after">

                    <button data-hotkey="w"
                            name="action_open_product_transactions_wizard"
                            type="object"
                            icon="fa-info-circle"
                            title="Product Info"
                            class="btn-link o_invoice_line_icon_btn"/>

                    <field name="company_stock_info"
                           widget="company_stock_widget"
                           nolabel="1"
                           class="o_company_stock_widget_col"/>

                </xpath>

                <!-- Add cost/margin fields after quantity -->
                <xpath expr="//field[@name='invoice_line_ids']/list/field[@name='quantity']" position="after">

                    <field name="current_on_hand_average_cost"
                           optional="hide"
                           groups="zl_account_base.groups_cost_group_manager"/>

                    <field name="cost"
                           optional="hide"
                           sum="Cost"
                           groups="zl_account_base.groups_cost_group_manager"/>

                    <field name="product_type"
                           column_invisible="1"/>

                    <button name="%(zl_product_report.action_update_cost_wizard)d"
                            type="action"
                            icon="fa-pencil"
                            aria-label="Update Cost"
                            title="Update Cost"
                            class="btn-link o_invoice_line_icon_btn"
                            groups="zl_account_base.group_management"
                            invisible="not product_id"/>

                    <field name="is_cost_updated"
                           column_invisible="1"/>

                    <field name="total_cost"
                           optional="hide"
                           sum="Total Cost"
                           groups="zl_account_base.groups_cost_group_manager"/>

                    <field name="margin"
                           optional="hide"
                           sum="Margin"
                           groups="zl_account_base.groups_cost_group_manager"/>

                </xpath>

                <!-- Hide account field by default -->
                <xpath expr="//field[@name='invoice_line_ids']/list/field[@name='account_id']" position="attributes">
                    <attribute name="optional">hide</attribute>
                </xpath>

            </field>
        </record>

    </data>
</odoo>

2. Add SCSS/CSS file

Create this file:

your_module/static/src/scss/invoice_line_widget.scss

Add this:

/* Reduce spacing for custom invoice line icons/widgets */

.o_field_x2many_list_row_add,
.o_list_view {
    .o_invoice_line_icon_btn {
        padding-left: 2px !important;
        padding-right: 2px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        min-width: 24px !important;
        width: 24px !important;
        text-align: center;
    }

    .o_company_stock_widget_col {
        width: 28px !important;
        min-width: 28px !important;
        max-width: 28px !important;
        padding-left: 2px !important;
        padding-right: 2px !important;
        text-align: center;
        white-space: nowrap;
    }

    .o_company_stock_widget_col > * {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}
0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Increase the width of the product description
column width
Avatar
Avatar
2
May 24
3077
Fields [width & height]
width Height
Avatar
0
Jun 22
3594
How to register width and length of each item in a sale order? Solved
sale.order.line width
Avatar
Avatar
1
Mar 18
5047
Width of selection field Solved
selection width
Avatar
Avatar
Avatar
3
Aug 17
7532
Kanban cards on 2 columns
kanban width
Avatar
0
May 17
5888
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk Slovenščina Español (América Latina) Español Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now