-
-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] account_invoice_search_by_reference
- Loading branch information
1 parent
9517314
commit 3cc80c4
Showing
5 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
35
account_invoice_search_by_reference/model/account_invoice.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |