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
    • Approvals
    • 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
    • Estate 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 Industries
  • 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

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
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

disable the existing views buttons when inherit a account_move_views.xml

Subscribe

Get notified when there's activity on this post

This question has been flagged
accountinginheritstatesodoo18
3 Replies
2635 Views
Avatar
Kalana Piyumantha
 This is my model and form view, I want to inherit account_move_views.xml(accounting->customer->invoice form view) with these 3 buttons, But existing module buttons are there, i want to disable those existing buttons, and also new status 'waiting' status should be visible in draft, waiting and post status too, but except waiting status, these waiting status is not visible? i want to fix this too? how? how can i modify both files??

from odoo import models, fields, api, _
from odoo.exceptions import UserError


class AccountMove(models.Model):
_inherit = 'account.move'

state = fields.Selection(
selection=[
('draft', 'Draft'),
('waiting_approval', 'Waiting For Approval'),
('posted', 'Posted'),
('cancel', 'Cancelled'),
],
string='Status',
required=True,
readonly=True,
copy=False,
tracking=True,
default='draft',
)

def action_send_for_approval(self):
"""Send invoice for approval"""
for record in self:
if record.move_type not in ('out_invoice', 'out_refund'):
raise UserError(_("Only customer invoices can be sent for approval."))
if record.state != 'draft':
raise UserError(_("Only Draft Invoices can be sent for approval"))
record.state = 'waiting_approval'
return True

def action_approve_invoice(self):
"""Approve invoice and post it"""
# Check if user has permission to approve
if not self.env.user.has_group('account.group_account_manager'):
raise UserError(_('Only Accounting managers can Send this to approval Stage'))

for record in self:
if record.state != 'waiting_approval':
raise UserError(_('Only Invoices waiting for approval Can Be approved.'))

# Post the Invoice
# record.action_post()
record.state = 'posted'

if record.partner_id and record.partner_id.email:
record._send_approval_email()

return True

def _send_approval_email(self):
"""Send email notification to customer"""
template = self.env.ref('vkd_accounting_approval_process.email_template_invoice_approved',
raise_if_not_found=False)
if template:
template.send_mail(
self.id,
force_send=True,
email_layout_xmlid='mail.mail_notification_light'
)

def action_draft(self):
res = super().action_draft()
for record in self:
if record.state == 'waiting_approval':
record.state = 'draft'
return res

@api.model
def _get_mail_template(self):
return self.env.ref('vkd_accounting_approval_process.invoice_approval_email', raise_if_not_found=False),<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!-- _inherit_approval-->
<record id="view_move_form" model="ir.ui.view">
<field name="name">account.move.form.inherit.vkd_accounting_approval_process</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">

<xpath expr="//form/header" position="inside">

<button name="action_send_for_approval" string="Send For Approval" type="object" class="btn-primary"
invisible="state != 'draft'"/>
<button name="action_approve_invoice" string="Approve Invoice" type="object" class="btn-success"
groups="account.group_account_manager" invisible="state != 'waiting_approval'"/>
<button name="action_draft" string="Send to Draft" type="object" class="btn-secondary"
invisible="state != 'waiting_approval'"/>
</xpath>
</field>
<!-- Add approval information in form -->
</record>
</odoo>
0
Avatar
Discard
Avatar
D Enterprise
Best Answer

Hii,
Updated XML:
<?xml version="1.0" encoding="UTF-8"?>

<odoo>

    <record id="view_move_form_inherit_approval" model="ir.ui.view">

        <field name="name">account.move.form.inherit.vkd_accounting_approval_process</field>

        <field name="model">account.move</field>

        <field name="inherit_id" ref="account.view_move_form"/>

        <field name="arch" type="xml">


            <!-- Override the statusbar to include 'waiting_approval' -->

            <xpath expr="//field[@name='state']" position="attributes">

                <attribute name="widget">statusbar</attribute>

                <attribute name="statusbar_visible">draft,waiting_approval,posted</attribute>

                <attribute name="readonly">1</attribute>

            </xpath>


            <!-- Remove default buttons -->

            <xpath expr="//form/header/button[@name='action_post']" position="attributes">

                <attribute name="invisible">1</attribute>

            </xpath>

            <xpath expr="//form/header/button[@name='button_draft']" position="attributes">

                <attribute name="invisible">1</attribute>

            </xpath>

            <xpath expr="//form/header/button[@name='button_cancel']" position="attributes">

                <attribute name="invisible">1</attribute>

            </xpath>


            <!-- Add custom buttons -->

            <xpath expr="//form/header" position="inside">

                <button name="action_send_for_approval"

                        string="Send for Approval"

                        type="object"

                        class="btn-primary"

                        attrs="{'invisible': [('state', '!=', 'draft')]}"/>

               

                <button name="action_approve_invoice"

                        string="Approve Invoice"

                        type="object"

                        class="btn-success"

                        groups="account.group_account_manager"

                        attrs="{'invisible': [('state', '!=', 'waiting_approval')]}"/>

               

                <button name="action_draft"

                        string="Send to Draft"

                        type="object"

                        class="btn-secondary"

                        attrs="{'invisible': [('state', '!=', 'waiting_approval')]}"/>

            </xpath>


        </field>

    </record>

</odoo>

 i hope it is use full

0
Avatar
Discard
Avatar
Kalana Piyumantha
Author Best Answer
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!-- _inherit_approval-->
<record id="view_move_form" model="ir.ui.view">
<field name="name">account.move.form.inherit.vkd_accounting_approval_process</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='action_post']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//form/header" position="inside">
<button name="action_send_for_approval" string="Send For Approval" type="object" class="btn-primary"
invisible="state != 'draft'"/>
<button name="action_approve_invoice" string="Approve Invoice" type="object" class="btn-success"
groups="account.group_account_manager" invisible="state != 'waiting_approval'"/>
<button name="action_draft" string="Send to Draft" type="object" class="btn-secondary"
invisible="state != 'waiting_approval'"/>
</xpath>
</field>
</record>

</odoo> Updated view, this part is also i have, please look at my code, Nothing happen, same issue( I am a beginner)
0
Avatar
Discard
Cybrosys Techno Solutions Pvt.Ltd

Try the following code.

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!-- _inherit_approval-->
<record id="view_move_form" model="ir.ui.view">
<field name="name">account.move.form.inherit.vkd_accounting_approval_process</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='action_post']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='action_post']" position="after">
<button name="action_send_for_approval" string="Send For Approval" type="object" class="btn-primary"
invisible="state != 'draft'"/>
<button name="action_approve_invoice" string="Approve Invoice" type="object" class="btn-success"
groups="account.group_account_manager" invisible="state != 'waiting_approval'"/>
<button name="action_draft" string="Send to Draft" type="object" class="btn-secondary"
invisible="state != 'waiting_approval'"/>
</xpath>
</field>
</record>
</odoo>

Please ensure that the path of the file is correctly added in the manifest file.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,


1- To disable the existing button in 'account.move', try the following.

<record id="view_move_view_form" model="ir.ui.view">
<field name="name">account.move.view.form.inherit</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='button_name']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>


2- To add 'waiting' state.

class AccountMove(models.Model):
"""The model account move is inherited for adding new state"""
_inherit = 'account.move'

state = fields.Selection(
selection_add=[
('draft', 'Draft'),
('waiting', 'Waiting'),
('posted', 'Posted')
],
default='draft',
)

Upgrade the module after making the changes.


Hope it helps

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
Issue with the "Pay" Button Visibility After Full Invoice Payment in Odoo
accounting odoo18
Avatar
Avatar
Avatar
2
Aug 25
2360
Inherit the menu item or action act window in odoo 18
menuitem inherit odoo18
Avatar
Avatar
1
Nov 25
233
Issue with CybroSys Modules Showing as Uninstallable in Odoo 18
accounting Cybrosys odoo18
Avatar
Avatar
1
Mar 25
2787
Field create_asset is not specified, but when doing so, it says the field is invalid
accounting localization schema odoo18
Avatar
Avatar
1
Jun 25
1596
How to add a new column in the General ledger?
accounting reporting generalledger odoo18
Avatar
0
Jun 25
136
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 ภาษาไทย 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