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

Create a new invoice sequence

Subscribe

Get notified when there's activity on this post

This question has been flagged
pythoninvoicexmlsequence
3 Replies
8356 Views
Avatar
Mostafa Mohamed Abdel Monaem

Hi there i'm creating a module to make 2 kinds of invoice with 2 different sequence ...first one with tax and the other with out 

i create a Boolean field to check the kind of invoice and when i press Validate i got that error 


ValueError: "invoice_validate() takes at least 4 arguments (4 given)" while evaluating
u'invoice_validate()'


here is my module code 

the .py file 

from openerp import models, fields, api

class invoice_edits(models.Model):

_inherit = 'account.invoice'
state_bool = fields.Boolean(string='Active Tax', default=True)



def invoice_validate(self, cr, uid, vals, context=None):
if context is None:
context = {}
if vals.get('state_bool') == True:
vals['number'] = self.pool.get('ir.sequence').get(cr, uid, 'sequence_sale_tax') or '/'
if vals.get('state_bool') == False:
vals['number'] = self.pool.get('ir.sequence').get(cr, uid, 'sequence_sale_without_tax') or '/'
res = super(invoice_edits, self).invoice_validate(cr, uid, vals, context=context)
return res



invoice_edits()

and here is my view xml file 



<openerp>
<data>

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

<field name="name">account.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='account_id']" position="after">
<field name="state_bool" attrs="{'readonly': [('state', '=', 'open')]}"/>
</xpath>
</data>
</field>
</record>
</data>
</openerp>

and here is my sequence file 



<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">

<record id="sequence_sale_tax" model="ir.sequence">
<field name="name">Account Tax</field>
<field eval="1" name="padding"/>
<field name="prefix">SAJ/%(year)s/</field>
</record>

<record id="sequence_sale_without_tax" model="ir.sequence">
<field name="name">Account Default Sales Journal</field>
<field eval="1" name="padding"/>
<field name="prefix">JAS/%(year)s/</field>
</record>
</data>
</openerp>

may i have some help please ?

0
Avatar
Discard
Avatar
Estudios, Procesos y Sistemas
Best Answer

Try this

This code works for us :)

def invoice_validate(self, cr, uid, ids, context=None):
    for invoice in self.browse(cr, uid, ids, context=context):
        try:
            if not invoice.custom_field:
                raise openerp.exceptions.Warning("Custom error")
        except ValueError:
            raise openerp.exceptions.Warning("Custom")
    super(account_invoice,self).invoice_validate(cr, uid, ids, context=context)

0
Avatar
Discard
Avatar
Bole
Best Answer

1. You declared different class, invoice_edits, so calling super to invoice_validate makes no sense.. 
declare account_invoice class ( and _inherit = 'account.invoice') 

2. overriding invoice_validate method does nothing, since the original method only writes state=open and has nothing to do with selecting sequence for invoice...

Maybe the easiest way to achieve what you want.. is to define 2 different journals, and assign different number sequences to each journal... that way, you can easily add more sequences/journals, and define the sequence simply by selecting appropriate journal before validating invoice... no coding needed at all for it.. or, if you want you can code come check on selected journal.. 

0
Avatar
Discard
Avatar
Sander Kruger
Best Answer

The invoice_validate function of account.invoice takes only 1 arguments (self). This function is called from account_invoice_workflow.xml with only 1 argument.

You override the function with a different signature, just like the purchase and portal_sale modules do. But I think you also need to rework the workflow XML document.

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
How to Customize Reporting > Invoices Analysis > Dashboard in odoo v8?
python invoice xml dashboard
Avatar
0
Oct 15
4289
How to change Invoice sequence via xml in Odoo 15 or newer?
invoice sequence
Avatar
0
Sep 24
2085
Odoo 17.1 - How to never reset invoice number
invoice sequence
Avatar
Avatar
2
Mar 24
3988
2 sequence combing for multiple company Solved
purchase python xml sequence v14
Avatar
Avatar
Avatar
2
Oct 23
3809
How to select manually a sequence for an invoice? Solved
invoice sequence
Avatar
Avatar
2
Feb 23
4618
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