Odoo Help

4

1
1 Answer
1
Avatar

Ray Carnes United States

--Ray Carnes--
21554
| 10 7 11
Greater Los Angeles, United States
--Ray Carnes--

Business Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0, 11.0 and 12.0.

Completed Odoo Functional and Technical Training.

Functional Areas:

  • CRM/Sales

  • Inventory

  • Manufacturing

  • Accounting

  • Purchasing

Major Skills:

  • Business Process Reengineering

  • Efficiency Consulting

  • User Needs and GAP Analysis;

  • Functional and Technical Design;

  • Prototyping and Proof of Concepts;

  • Requirements Specifications;

  • Agile Implementation;

  • Data Migration;

  • Configuration & Customization (UI and code);

  • Integration - Odoo and non Odoo Applications and Services;

  • Training and Knowledge Transfer;

  • Go Live Support;

  • Helpdesk;

  • Version Upgrades and Migration.

  • Accounting Expert.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

I am a skilled Communicator and I only take the serious things seriously!

Ray Carnes United States
10/18/13, 8:39 PM

I ended up writing a function:

    def onchange_supplier_invoice(self, cr, uid, ids, reference, context=None):

        msg = reference + 'has already been used!' 
        res = {'reference': reference, }

        if not reference:
            return res

        # Get all Supplier Invoices
        invoice_ids = self.search(cr, uid, [('type','=','in_invoice')], context)

        # Get all the references for all Supplier Invoices
        invoices = self.read(cr, uid, invoice_ids, fields=['reference'],context=context)

        # Check for duplicates
        for inv in invoices:
            if inv['reference'] == reference:
                raise osv.except_osv('Possible duplicate Invoice!',msg)

        return res

And triggering the function via on_change in the relevant field (in this case reference).

<field name="reference" string="Invoice Number" 
       attrs="{'required':[('state','!=','draft')]}"  
       on_change="onchange_supplier_invoice(reference)"/>
1 Comment
Ray Carnes United States
10/21/13, 3:18 AM

Depending on the use case, searching for Supplier Invoices matching the current supplier (if populated) may be better.

Ask a Question
Writer
Keep Informed
0 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now