Skip to content

Commit afe09d5

Browse files
author
Maxime Chambreuil - http://www.savoirfairelinux.com
committed
Merge pull request OCA#193 from oihane/8.0-partner_handbill
[ADD] partner_prospect
2 parents 82f35d6 + d57047a commit afe09d5

File tree

11 files changed

+333
-0
lines changed

11 files changed

+333
-0
lines changed

partner_prospect/README.rst

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
2+
:alt: License: AGPL-3
3+
4+
================
5+
Partner prospect
6+
================
7+
8+
With this module you can easily distinguish if a partner is currently customer
9+
or prospect. A prospect partner will be those to which you still haven't sold
10+
anything, considering sales as non cancelled nor draft sale orders to that partner.
11+
12+
13+
Usage
14+
=====
15+
16+
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
17+
:alt: Try me on Runbot
18+
:target: https://runbot.odoo-community.org/runbot/167/8.0
19+
20+
For further information, please visit:
21+
22+
* https://www.odoo.com/forum/help-1
23+
24+
25+
Bug Tracker
26+
===========
27+
28+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
29+
In case of trouble, please check there if your issue has already been reported.
30+
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
31+
`here <https://github.com/OCA/sale-workflow/issues/new?body=module:%20partner_prospect%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
32+
33+
34+
Credits
35+
=======
36+
37+
Contributors
38+
------------
39+
* Esther Martín <esthermartin@avanzosc.es>
40+
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
41+
* Ana Juaristi <anajuaristi@avanzosc.es>
42+
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
43+
44+
Maintainer
45+
----------
46+
47+
.. image:: https://odoo-community.org/logo.png
48+
:alt: Odoo Community Association
49+
:target: https://odoo-community.org
50+
51+
This module is maintained by the OCA.
52+
53+
OCA, or the Odoo Community Association, is a nonprofit organization whose
54+
mission is to support the collaborative development of Odoo features and
55+
promote its widespread use.
56+
57+
To contribute to this module, please visit http://odoo-community.org.

partner_prospect/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# -*- coding: utf-8 -*-
2+
##############################################################################
3+
# For copyright and license notices, see __openerp__.py file in root directory
4+
##############################################################################
5+
6+
from . import models

partner_prospect/__openerp__.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# -*- coding: utf-8 -*-
2+
##############################################################################
3+
#
4+
# This program is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License as published by
6+
# the Free Software Foundation, either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
#
17+
##############################################################################
18+
19+
{
20+
"name": "Partner Prospect",
21+
"version": "1.0",
22+
"author": "AvanzOSC, "
23+
"Serv. Tecnol. Avanzados - Pedro M. Baeza,"
24+
"Odoo Community Association (OCA)",
25+
"website": "http://www.avanzosc.es",
26+
"category": "Sales Management",
27+
"contributors": [
28+
"Esther Martín <esthermartin@avanzosc.es>",
29+
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>",
30+
"Ana Juaristi <anajuaristi@avanzosc.es>",
31+
"Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>",
32+
],
33+
"depends": [
34+
"sale",
35+
],
36+
"data": [
37+
"views/res_partner_view.xml",
38+
],
39+
"installable": True
40+
}

partner_prospect/i18n/es.po

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * partner_prospect
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 8.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2015-08-12 12:31+0000\n"
10+
"PO-Revision-Date: 2015-08-12 12:31+0000\n"
11+
"Last-Translator: <>\n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: partner_prospect
19+
#: view:res.partner:partner_prospect.res_partner_prospect_search_view
20+
msgid "Group By"
21+
msgstr "Agrupar por"
22+
23+
#. module: partner_prospect
24+
#: view:res.partner:partner_prospect.res_partner_prospect_search_view
25+
msgid "Actual Customer"
26+
msgstr "Cliente real"
27+
28+
#. module: partner_prospect
29+
#: model:ir.model,name:partner_prospect.model_res_partner
30+
msgid "Partner"
31+
msgstr "Empresa"
32+
33+
#. module: partner_prospect
34+
#: view:res.partner:partner_prospect.res_partner_prospect_search_view
35+
#: field:res.partner,prospect:0
36+
msgid "Prospect"
37+
msgstr "Cliente eventual"
38+
39+
#. module: partner_prospect
40+
#: view:res.partner:partner_prospect.res_partner_prospect_search_view
41+
msgid "Suppliers"
42+
msgstr "Proveedores"
43+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * partner_prospect
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 8.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2015-08-12 12:31+0000\n"
10+
"PO-Revision-Date: 2015-08-12 12:31+0000\n"
11+
"Last-Translator: <>\n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: partner_prospect
19+
#: view:res.partner:partner_prospect.res_partner_prospect_search_view
20+
msgid "Group By"
21+
msgstr ""
22+
23+
#. module: partner_prospect
24+
#: view:res.partner:partner_prospect.res_partner_prospect_search_view
25+
msgid "Actual Customer"
26+
msgstr ""
27+
28+
#. module: partner_prospect
29+
#: model:ir.model,name:partner_prospect.model_res_partner
30+
msgid "Partner"
31+
msgstr ""
32+
33+
#. module: partner_prospect
34+
#: view:res.partner:partner_prospect.res_partner_prospect_search_view
35+
#: field:res.partner,prospect:0
36+
msgid "Prospect"
37+
msgstr ""
38+
39+
#. module: partner_prospect
40+
#: view:res.partner:partner_prospect.res_partner_prospect_search_view
41+
msgid "Suppliers"
42+
msgstr ""
43+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# -*- coding: utf-8 -*-
2+
##############################################################################
3+
# For copyright and license notices, see __openerp__.py file in root directory
4+
##############################################################################
5+
6+
from . import res_partner
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
##############################################################################
3+
# For copyright and license notices, see __openerp__.py file in root directory
4+
##############################################################################
5+
6+
from openerp import models, fields, api
7+
8+
9+
class ResPartner(models.Model):
10+
_inherit = 'res.partner'
11+
12+
@api.one
13+
@api.depends('commercial_partner_id',
14+
'commercial_partner_id.sale_order_ids',
15+
'commercial_partner_id.sale_order_ids.state',
16+
'commercial_partner_id.child_ids',
17+
'commercial_partner_id.child_ids.sale_order_ids',
18+
'commercial_partner_id.child_ids.sale_order_ids.state')
19+
def _compute_prospect(self):
20+
sale_ids = (
21+
self.commercial_partner_id.sale_order_ids +
22+
self.commercial_partner_id.mapped('child_ids.sale_order_ids'))
23+
self.prospect = not sale_ids.filtered(
24+
lambda r: r.state not in ('draft', 'sent', 'cancel'))
25+
26+
prospect = fields.Boolean(
27+
string='Prospect', compute='_compute_prospect', store=True)
9.23 KB
Loading

partner_prospect/tests/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# -*- coding: utf-8 -*-
2+
##############################################################################
3+
# For copyright and license notices, see __openerp__.py file in root directory
4+
##############################################################################
5+
6+
from . import test_partner_prospect
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# -*- coding: utf-8 -*-
2+
##############################################################################
3+
# For copyright and license notices, see __openerp__.py file in root directory
4+
##############################################################################
5+
6+
from openerp.tests.common import TransactionCase
7+
8+
9+
class TestPartnerProspect(TransactionCase):
10+
11+
def setUp(self):
12+
super(TestPartnerProspect, self).setUp()
13+
self.sale_order_model = self.env['sale.order']
14+
self.partner_model = self.env['res.partner']
15+
self.partner1 = self.partner_model.create({'name': 'Partner1'})
16+
self.partner2 = self.partner_model.create({
17+
'name': 'Partner2',
18+
'parent_id': self.partner1.id,
19+
})
20+
self.partner3 = self.partner_model.create({
21+
'name': 'Partner3',
22+
'parent_id': self.partner1.id,
23+
})
24+
self.partner4 = self.partner_model.create({'name': 'Partner4'})
25+
self.product = self.env.ref('product.product_product_4')
26+
self.sale_order1 = self.sale_order_model.create({
27+
'partner_id': self.partner1.id,
28+
'order_policy': 'manual',
29+
'order_line': [(0, 0, {'product_id': self.product.id, })],
30+
})
31+
self.sale_order2 = self.sale_order_model.create({
32+
'partner_id': self.partner2.id,
33+
'order_policy': 'manual',
34+
'order_line': [(0, 0, {'product_id': self.product.id, })],
35+
})
36+
self.sale_order3 = self.sale_order_model.create({
37+
'partner_id': self.partner4.id,
38+
'order_policy': 'manual',
39+
'order_line': [(0, 0, {'product_id': self.product.id, })],
40+
})
41+
42+
def test_partner_child_check(self):
43+
self.sale_order2.action_button_confirm()
44+
self.assertFalse(self.partner1.prospect, 'Partner1 is a prospect')
45+
self.assertFalse(self.partner2.prospect, 'Partner2 is a prospect')
46+
self.assertFalse(self.partner3.prospect, 'Partner3 is a prospect')
47+
48+
def test_partner_parent_check(self):
49+
self.sale_order1.action_button_confirm()
50+
self.assertFalse(self.partner1.prospect, 'Partner1 is a prospect')
51+
self.assertFalse(self.partner2.prospect, 'Partner2 is a prospect')
52+
self.assertFalse(self.partner3.prospect, 'Partner3 is a prospect')
53+
54+
def test_partner_prospect(self):
55+
self.assertTrue(self.partner4.prospect, 'Partner4 is not a prospect')
56+
self.sale_order3.action_button_confirm()
57+
self.assertFalse(self.partner4.prospect, 'Partner4 is a prospect')
58+
self.sale_order3.action_cancel()
59+
self.assertTrue(self.partner4.prospect, 'Partner4 is not a prospect')

0 commit comments

Comments
 (0)