Browse Source

[MIG] partner_multi_relation: Migration to 11.0

* Update README
* Python 2to3
* Move relation menus items under contacts
* Fix date comparison
* Fix cache invalidate on relation write
* Bump module version
* Remove test_relation_type_unlink_dberror

  This test is not required because it tests a standard behavior of SQL.
  If a foreign key column is not nullable, then the foreign row can not be deleted.

* Remove utf8 encoding comment
* Add missing dependency for partner_multi_relation
* Add missing active_test in view action
pull/654/head
David Dufresne 7 years ago
committed by Pedro M. Baeza
parent
commit
968561d5c2
  1. 25
      partner_multi_relation/README.rst
  2. 1
      partner_multi_relation/__init__.py
  3. 7
      partner_multi_relation/__manifest__.py
  4. 1
      partner_multi_relation/models/__init__.py
  5. 5
      partner_multi_relation/models/res_partner.py
  6. 1
      partner_multi_relation/models/res_partner_relation.py
  7. 3
      partner_multi_relation/models/res_partner_relation_all.py
  8. 4
      partner_multi_relation/models/res_partner_relation_type.py
  9. 1
      partner_multi_relation/models/res_partner_relation_type_selection.py
  10. 1
      partner_multi_relation/tests/__init__.py
  11. 34
      partner_multi_relation/tests/test_partner_relation.py
  12. 1
      partner_multi_relation/tests/test_partner_relation_all.py
  13. 1
      partner_multi_relation/tests/test_partner_relation_common.py
  14. 1
      partner_multi_relation/tests/test_partner_search.py
  15. 14
      partner_multi_relation/views/menu.xml
  16. 1
      partner_multi_relation/views/res_partner_relation_all.xml

25
partner_multi_relation/README.rst

@ -1,6 +1,8 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
=================
Partner Relations
=================
@ -57,9 +59,22 @@ For further information, please visit:
* https://www.odoo.com/forum/help-1
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/134/11.0
Known issues / Roadmap
======================
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/partner-contact/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.
Credits
=======
@ -76,9 +91,9 @@ Contributors
Maintainer
----------
.. image:: http://odoo-community.org/logo.png
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org
:target: https://odoo-community.org
This module is maintained by the OCA.
@ -86,4 +101,4 @@ 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 http://odoo-community.org.
To contribute to this module, please visit https://odoo-community.org.

1
partner_multi_relation/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2013-2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

7
partner_multi_relation/__manifest__.py

@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright 2013-2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Partner relations",
"version": "10.0.1.0.1",
"name": "Partner Relations",
"version": "1.0.0",
"author": "Therp BV,Camptocamp,Odoo Community Association (OCA)",
"complexity": "normal",
"category": "Customer Relationship Management",
"license": "AGPL-3",
"depends": [
'base',
'contacts',
'sales_team',
],
"demo": [

1
partner_multi_relation/models/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2013-2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import res_partner_relation_type

5
partner_multi_relation/models/res_partner.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2013-2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
"""Support connections between partners."""
@ -143,7 +142,7 @@ class ResPartner(models.Model):
# pylint: disable=no-value-for-parameter
date_args = []
for arg in args:
if (is_leaf(arg) and isinstance(arg[0], basestring) and
if (is_leaf(arg) and isinstance(arg[0], str) and
arg[0].startswith('search_relation')):
if arg[0] == 'search_relation_date':
date_args = []
@ -156,7 +155,7 @@ class ResPartner(models.Model):
active_args = []
if self.env.context.get('active_test', True):
for arg in args:
if (is_leaf(arg) and isinstance(arg[0], basestring) and
if (is_leaf(arg) and isinstance(arg[0], str) and
arg[0].startswith('search_relation')):
active_args = [('relation_all_ids.active', '=', True)]
break

1
partner_multi_relation/models/res_partner_relation.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2013-2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# pylint: disable=api-one-deprecated

3
partner_multi_relation/models/res_partner_relation_all.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2014-2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# pylint: disable=method-required-super
@ -430,7 +429,7 @@ CREATE OR REPLACE VIEW %%(table)s AS
rec.write_resource(base_resource, vals)
# Invalidate cache to make res.partner.relation.all reflect changes
# in underlying res.partner.relation:
self.env.invalidate_all()
self.env.clear()
return True
@api.model

4
partner_multi_relation/models/res_partner_relation_type.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2013-2018 Therp BV <https://therp.nl>.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
"""Define the type of relations that can exist between partners."""
@ -152,7 +151,8 @@ class ResPartnerRelationType(models.Model):
# already ended:
cutoff_date = fields.Date.today()
for relation in invalid_relations:
if relation.date_start >= cutoff_date:
if (relation.date_start and
relation.date_start >= cutoff_date):
relation.unlink()
elif (not relation.date_end or
relation.date_end > cutoff_date):

1
partner_multi_relation/models/res_partner_relation_type_selection.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2013-2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
"""

1
partner_multi_relation/tests/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Therp BV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_partner_relation_common

34
partner_multi_relation/tests/test_partner_relation.py

@ -1,9 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Therp BV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import date
from dateutil.relativedelta import relativedelta
from psycopg2 import IntegrityError
from openerp import fields
from openerp.exceptions import ValidationError
@ -235,38 +233,6 @@ class TestPartnerRelation(TestPartnerRelationCommon):
'contact_type_right': 'p'})
self.assertFalse(relation_bart2lisa.exists())
def test_relation_type_unlink_dberror(self):
"""Test deleting relation type when not possible.
This test will catch a DB Integrity error. Because of that the
cursor will be invalidated, and further tests using the objects
will not be possible.
"""
# First create a relation type having restrict particular conditions.
type_model = self.env['res.partner.relation.type']
relation_model = self.env['res.partner.relation']
partner_model = self.env['res.partner']
type_school2student = type_model.create({
'name': 'school has student',
'name_inverse': 'studies at school',
'handle_invalid_onchange': 'restrict'})
# Second create relation based on those conditions.
partner_school = partner_model.create({
'name': 'Test School',
'is_company': True,
'ref': 'TS'})
partner_bart = partner_model.create({
'name': 'Bart Simpson',
'is_company': False,
'ref': 'BS'})
relation_model.create({
'left_partner_id': partner_school.id,
'type_id': type_school2student.id,
'right_partner_id': partner_bart.id})
# Unlink should for the moment lead to error because of restrict:
with self.assertRaises(IntegrityError):
type_school2student.unlink()
def test_relation_type_unlink(self):
"""Test delete of relation type, including deleting relations."""
# First create a relation type having restrict particular conditions.

1
partner_multi_relation/tests/test_partner_relation_all.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Therp BV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.exceptions import ValidationError

1
partner_multi_relation/tests/test_partner_relation_common.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Therp BV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.tests import common

1
partner_multi_relation/tests/test_partner_search.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Camptocamp SA
# Copyright 2016 Therp BV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

14
partner_multi_relation/views/menu.xml

@ -2,9 +2,16 @@
<odoo>
<menuitem
id="menu_res_partner_relation_sales"
id="menu_res_partner_relation"
name="Relations"
sequence="3"
parent="sales_team.menu_sales"
parent="contacts.menu_contacts"
/>
<menuitem
id="menu_res_partner_relation_all"
sequence="3"
parent="menu_res_partner_relation"
action="action_res_partner_relation_all"
/>
@ -17,7 +24,8 @@
<menuitem
id="menu_res_partner_relation_type"
parent="sales_team.menu_config_address_book"
name="Relation Types"
parent="menu_res_partner_relation"
action="action_res_partner_relation_type"
/>

1
partner_multi_relation/views/res_partner_relation_all.xml

@ -82,6 +82,7 @@
name="search_view_id"
ref="search_res_partner_relation_all"
/>
<field name="context">{'active_test': 0}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Record and track your partners' relations. Relations may

Loading…
Cancel
Save