diff --git a/partner_prospect/README.rst b/partner_prospect/README.rst index b5bac4aede1..64a6857c88c 100644 --- a/partner_prospect/README.rst +++ b/partner_prospect/README.rst @@ -15,7 +15,7 @@ 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/167/8.0 + :target: https://runbot.odoo-community.org/runbot/167/11.0 For further information, please visit: @@ -28,7 +28,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 -`here `_. +`here `_. Credits diff --git a/partner_prospect/__manifest__.py b/partner_prospect/__manifest__.py index f2dc1b2e1bb..ca24659cef7 100644 --- a/partner_prospect/__manifest__.py +++ b/partner_prospect/__manifest__.py @@ -18,7 +18,8 @@ { "name": "Partner Prospect", - "version": "8.0.1.0.0", + "version": "11.0.1.0.0", + "license": "AGPL-3", "author": "AvanzOSC, " "Serv. Tecnol. Avanzados - Pedro M. Baeza," "Odoo Community Association (OCA)", @@ -36,5 +37,5 @@ "data": [ "views/res_partner_view.xml", ], - 'installable': False + "installable": True, } diff --git a/partner_prospect/i18n/partner_prospect.pot b/partner_prospect/i18n/partner_prospect.pot deleted file mode 100644 index 3c47d85a418..00000000000 --- a/partner_prospect/i18n/partner_prospect.pot +++ /dev/null @@ -1,43 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * partner_prospect -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-08-12 12:31+0000\n" -"PO-Revision-Date: 2015-08-12 12:31+0000\n" -"Last-Translator: <>\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: partner_prospect -#: view:res.partner:partner_prospect.res_partner_prospect_search_view -msgid "Group By" -msgstr "" - -#. module: partner_prospect -#: view:res.partner:partner_prospect.res_partner_prospect_search_view -msgid "Actual Customer" -msgstr "" - -#. module: partner_prospect -#: model:ir.model,name:partner_prospect.model_res_partner -msgid "Partner" -msgstr "" - -#. module: partner_prospect -#: view:res.partner:partner_prospect.res_partner_prospect_search_view -#: field:res.partner,prospect:0 -msgid "Prospect" -msgstr "" - -#. module: partner_prospect -#: view:res.partner:partner_prospect.res_partner_prospect_search_view -msgid "Suppliers" -msgstr "" - diff --git a/partner_prospect/models/res_partner.py b/partner_prospect/models/res_partner.py index 4ae80f91964..a99b1d0becc 100644 --- a/partner_prospect/models/res_partner.py +++ b/partner_prospect/models/res_partner.py @@ -3,25 +3,38 @@ # For copyright and license notices, see __openerp__.py file in root directory ############################################################################## -from openerp import models, fields, api +from openerp import api, fields, models class ResPartner(models.Model): _inherit = 'res.partner' - @api.one + @api.multi @api.depends('commercial_partner_id', 'commercial_partner_id.sale_order_ids', 'commercial_partner_id.sale_order_ids.state', 'commercial_partner_id.child_ids', 'commercial_partner_id.child_ids.sale_order_ids', - 'commercial_partner_id.child_ids.sale_order_ids.state') + 'commercial_partner_id.child_ids.sale_order_ids.state', + 'commercial_partner_id.invoice_ids', + 'commercial_partner_id.child_ids.invoice_ids') def _compute_prospect(self): - sale_ids = ( - self.commercial_partner_id.sale_order_ids + - self.commercial_partner_id.mapped('child_ids.sale_order_ids')) - self.prospect = not sale_ids.filtered( - lambda r: r.state not in ('draft', 'sent', 'cancel')) + for partner in self: + sale_ids = ( + partner.commercial_partner_id.sale_order_ids + + partner.commercial_partner_id.mapped( + 'child_ids.sale_order_ids')) + invoice_ids = ( + partner.commercial_partner_id.invoice_ids + + partner.commercial_partner_id.mapped( + 'child_ids.invoice_ids')) + partner.prospect = ( + not sale_ids.filtered( + lambda r: r.state not in + ('draft', 'sent', 'cancel')) and + not invoice_ids.filtered( + lambda r: r.type in ('out_invoice', 'out_refund'))) prospect = fields.Boolean( - string='Prospect', compute='_compute_prospect', store=True) + string='Prospect', compute='_compute_prospect', default=False, + store=True) diff --git a/partner_prospect/tests/test_partner_prospect.py b/partner_prospect/tests/test_partner_prospect.py index 69a2e9a62c8..441b860acd4 100644 --- a/partner_prospect/tests/test_partner_prospect.py +++ b/partner_prospect/tests/test_partner_prospect.py @@ -12,7 +12,10 @@ def setUp(self): super(TestPartnerProspect, self).setUp() self.sale_order_model = self.env['sale.order'] self.partner_model = self.env['res.partner'] - self.partner1 = self.partner_model.create({'name': 'Partner1'}) + self.invoice_model = self.env['account.invoice'] + self.partner1 = self.partner_model.create({ + 'name': 'Partner1', + }) self.partner2 = self.partner_model.create({ 'name': 'Partner2', 'parent_id': self.partner1.id, @@ -21,39 +24,58 @@ def setUp(self): 'name': 'Partner3', 'parent_id': self.partner1.id, }) - self.partner4 = self.partner_model.create({'name': 'Partner4'}) + self.partner4 = self.partner_model.create({ + 'name': 'Partner4', + }) self.product = self.env.ref('product.product_product_4') self.sale_order1 = self.sale_order_model.create({ 'partner_id': self.partner1.id, - 'order_policy': 'manual', 'order_line': [(0, 0, {'product_id': self.product.id, })], }) self.sale_order2 = self.sale_order_model.create({ 'partner_id': self.partner2.id, - 'order_policy': 'manual', 'order_line': [(0, 0, {'product_id': self.product.id, })], }) self.sale_order3 = self.sale_order_model.create({ 'partner_id': self.partner4.id, - 'order_policy': 'manual', 'order_line': [(0, 0, {'product_id': self.product.id, })], }) def test_partner_child_check(self): - self.sale_order2.action_button_confirm() + self.sale_order2.action_confirm() self.assertFalse(self.partner1.prospect, 'Partner1 is a prospect') self.assertFalse(self.partner2.prospect, 'Partner2 is a prospect') self.assertFalse(self.partner3.prospect, 'Partner3 is a prospect') def test_partner_parent_check(self): - self.sale_order1.action_button_confirm() + self.sale_order1.action_confirm() self.assertFalse(self.partner1.prospect, 'Partner1 is a prospect') self.assertFalse(self.partner2.prospect, 'Partner2 is a prospect') self.assertFalse(self.partner3.prospect, 'Partner3 is a prospect') def test_partner_prospect(self): self.assertTrue(self.partner4.prospect, 'Partner4 is not a prospect') - self.sale_order3.action_button_confirm() + self.sale_order3.action_confirm() self.assertFalse(self.partner4.prospect, 'Partner4 is a prospect') self.sale_order3.action_cancel() self.assertTrue(self.partner4.prospect, 'Partner4 is not a prospect') + + def test_partner_child_check_invoice(self): + type = 'out_invoice' + self.invoice_model.create({ + 'partner_id': self.partner2.id, + 'type': type, + })._onchange_partner_id() + self.assertFalse(self.partner1.prospect, 'Partner1 is a prospect') + self.assertFalse(self.partner2.prospect, 'Partner2 is a prospect') + self.assertFalse(self.partner3.prospect, 'Partner3 is a prospect') + + def test_partner_parent_check_invoice(self): + type = 'out_refund' + self.invoice_model.create({ + 'partner_id': self.partner1.id, + 'type': type, + })._onchange_partner_id() + self.assertFalse(self.partner1.prospect, 'Partner1 is a prospect') + self.assertFalse(self.partner2.prospect, 'Partner2 is a prospect') + self.assertFalse(self.partner3.prospect, 'Partner3 is a prospect') diff --git a/partner_prospect/views/res_partner_view.xml b/partner_prospect/views/res_partner_view.xml index 042d0b359d1..8ef51422508 100644 --- a/partner_prospect/views/res_partner_view.xml +++ b/partner_prospect/views/res_partner_view.xml @@ -1,46 +1,50 @@ - - - - res.partner.prospect.form - res.partner - - - - - + + + + res.partner.prospect.form + res.partner + + + + + - - res.partner.prospect.tree - res.partner - - - - - + + res.partner.prospect.tree + res.partner + + + + - + + - - res.partner.prospect.search - res.partner - - - - - - - - - - - - + + res.partner.prospect.search + res.partner + + + + + + + + + + + + + + + {"search_default_customer": 1, "search_default_noprospect": 1} + - - {"search_default_customer": 1, "search_default_noprospect": 1} - - - + + {'default_customer':1, 'search_default_customer':1, 'search_default_noprospect': 1, 'default_company_type': 'company','default_is_company': 1} + + +