Skip to content

Commit

Permalink
[ADD] account_invoice_search_by_reference
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHForgeFlow committed May 2, 2017
1 parent 9517314 commit 3cc80c4
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 0 deletions.
49 changes: 49 additions & 0 deletions account_invoice_search_by_reference/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

==========================
Search by vendor reference
==========================

This module adds the ability of searching by vendor reference when searching
invoices from different views. This is useful for example, when receiving
supplier RMAs, where the user can search only by the internal invoice number.

Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/95/9.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/account-invoicing/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.

Credits
=======

Contributors
------------

* Eficent Business and IT Consulting Services S.L. <contact@eficent.com>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
5 changes: 5 additions & 0 deletions account_invoice_search_by_reference/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import model
17 changes: 17 additions & 0 deletions account_invoice_search_by_reference/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# © 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Account invoice search by reference",
"version": "9.0.1.0.0",
"author": "Eficent, Odoo Community Association (OCA)",
"category": "Invoicing",
"website": "http://www.eficent.com/",
"license": "AGPL-3",
"depends": [
"account"
],
"installable": True,
"auto_install": False,
}
5 changes: 5 additions & 0 deletions account_invoice_search_by_reference/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import account_invoice
35 changes: 35 additions & 0 deletions account_invoice_search_by_reference/model/account_invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# © 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from openerp import models, api


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

@api.model
def name_search(self, name, args=None, operator='ilike', limit=100):
args = args or []
domain = []
if name:
domain = ['|', ('reference', operator, name),
('number', operator, name)]
invoices = self.search(domain + args, limit=limit)
return invoices.name_get()

@api.multi
@api.depends('reference', 'number')
def name_get(self):
res = []
for rec in self:
for inv in rec:
if inv.reference and inv.number:
res.append((inv.id, "%s %s %s" % (
inv.number, inv.reference, inv.name or '')))
elif inv.reference and not inv.number:
res.append((inv.id, "%s %s" % (
inv.reference, inv.name or '')))
else:
return super(AccountInvoice, self).name_get()
return res

0 comments on commit 3cc80c4

Please sign in to comment.