Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • Hotel
    Real Estate
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    Consulting
    • Accounting Firm
    • Odoo पार्टनर
    • Marketing Agency
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

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

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

Delete (previously canceled) invoices

Subscribe

Get notified when there's activity on this post

This question has been flagged
modulespythoninvoicedeleteodooV8
3 Replies
6642 Views
Avatar
E.M.

Hi,

I am trying to write a module to delete invoices.

I have seen this post https://www.odoo.com/forum/help-1/question/how-to-delete-an-invoice-after-validation-20831 which explains what to do.

I have therefore created a new module delete_invoices with the following code:

/usr/lib/python2.7/dist-packages/openerp/addons/custom/delete_invoices# cat delete_invoices.py
# -*- coding: utf-8 -*-
from openerp import models, fields, api

# DESCRIPTION:
# Class DeleteInvoices allows invoice deletion
# NOTES:
# account_cancel / diary allow cancel entries required

class DeleteInvoices ( models.Model ):
_inherit = 'account.invoice'

@api.multi
def unlink(self):
for invoice in self:
if invoice.state not in ('draft', 'cancel'):
raise Warning(_('You cannot delete an invoice which is not draft or cancelled. You should refund it instead.'))
# elif invoice.internal_number:
# raise Warning(_('You cannot delete an invoice after it has been validated (and received a number). You can set it back to "Draft" state and modify its content, then re-confirm it.'))
return super(account_invoice, self).unlink()


Unfortunately when I try to delete a cancelled invoice I get the following message:

  File "/usr/lib/python2.7/dist-packages/openerp/addons/custom/delete_invoices/delete_invoices.py", line 20, in unlink
return super(account_invoice, self).unlink()
NameError: global name 'account_invoice' is not defined

Any tips or ideas? Thanks a lot.


For completition I also include __openerp__ and __init__ files:

# cat __init__.py
from . import delete_invoices
# cat __openerp__.py
{
'name': 'Allow delete invoice',
'description': 'This module allows to delete invoices once they have been cancelled',
'author': 'E.M.',
'depends': ['account_cancel'],
'data': [],
}

Thanks

0
Avatar
Discard
Mirco Strizzi

In the __openerp__.py you have to add account depends too. Account_cancel it's not enough

E.M.
Author

Thanks Mirco. 'account_cancel' depends on 'account' so at the end you will need to have installed both modules so 'account' might be redundant here. In any case issue is located on how I am replacing the method and not in dependencies.

Avatar
Axel Mendoza
Best Answer

The account_invoice error refers to the class name used on the super call. Just change to DeleteInvoices and you will be ok

0
Avatar
Discard
E.M.
Author

Still same error: File "/usr/lib/python2.7/dist-packages/openerp/addons/custom/delete_invoices/delete_invoices.py", line 20, in unlink return super(DeleteInvoices, self).unlink() NameError: global name 'account_invoice' is not defined

Axel Mendoza

That was an error you havd. You should have more. Post all the code because in that line I only saw one account_invoice variable usage on super call. It must be something that you are not posting

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
Adding a field to sale.order.line: which dependence should be specified in __openerp__.py?
modules python sale.order.line odooV8
Avatar
Avatar
1
जुल॰ 15
7002
TypeError: __init__() takes exactly 2 arguments (3 given) - Odoo v8 to Odoo v10 community Solved
python invoice migration odooV8 odoov10
Avatar
Avatar
1
मार्च 17
11399
Odoo module development with pycharm
modules python backend odooV8 Pycharm4
Avatar
Avatar
1
जून 16
9482
Odoo module development with eclipse Solved
modules python pydev eclipse odooV8
Avatar
Avatar
1
अक्तू॰ 15
7850
Error while trying to add a new combo to res.partner
modules python module res_partner odooV8
Avatar
Avatar
Avatar
3
सित॰ 15
6923
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

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