Browse Source

[9.0][ADD] partner_ref_unique module

- Added OCA icon
pull/626/head
cubells 8 years ago
committed by Cris Martín
parent
commit
1d603b18df
  1. 45
      partner_ref_unique/README.rst
  2. 2
      partner_ref_unique/__init__.py
  3. 18
      partner_ref_unique/__openerp__.py
  4. 2
      partner_ref_unique/models/__init__.py
  5. 2
      partner_ref_unique/models/res_company.py
  6. 2
      partner_ref_unique/models/res_partner.py
  7. BIN
      partner_ref_unique/static/description/icon.png
  8. 5
      partner_ref_unique/tests/__init__.py
  9. 43
      partner_ref_unique/tests/test_res_partner_ref.py
  10. 11
      partner_ref_unique/views/res_company_view.xml

45
partner_ref_unique/README.rst

@ -8,27 +8,52 @@ Partner unique reference
Add an unique constraint to partner ref field Add an unique constraint to partner ref field
Usage
=====
To use this module, you need to:
* Go to your company settings and choose an option on section *Partner* in tab
*Configuration*.
* Try to create two partners with the same ref.
.. 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/9.0
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 smashing it by providing a detailed and welcomed feedback.
Credits Credits
======= =======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors Contributors
------------ ------------
* Antonio Espinosa <antonioea@antiun.com> * Antonio Espinosa <antonioea@antiun.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
Maintainer Maintainer
---------- ----------
.. image:: http://www.antiun.com/images/logo-b.png
:alt: Antiun Ingeniería S.L.
:target: http://www.antiun.com
This module is maintained by Antiun Ingeniería S.L.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
Antiun Ingeniería S.L. is an IT consulting company especialized in Odoo
and provides Odoo development, install, maintenance and hosting
services.
This module is maintained by the OCA.
To contribute to this module, please visit https://github.com/Antiun
or contact us at odoo@antiun.com
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.

2
partner_ref_unique/__init__.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models from . import models

18
partner_ref_unique/__openerp__.py

@ -1,30 +1,24 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
"name": "Partner unique reference", "name": "Partner unique reference",
"summary": "Add an unique constraint to partner ref field", "summary": "Add an unique constraint to partner ref field",
"version": "8.0.1.0.0",
"version": "9.0.1.0.0",
"category": "Customer Relationship Management", "category": "Customer Relationship Management",
"website": "http://www.antiun.com", "website": "http://www.antiun.com",
"author": "Antiun Ingeniería S.L.",
"author": "Antiun Ingeniería S.L., "
"Tecnativa, "
"Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",
"application": False, "application": False,
"installable": True, "installable": True,
# 'auto_install':False,
"external_dependencies": {
"python": [],
"bin": [],
},
"depends": [ "depends": [
"base", "base",
], ],
"data": [ "data": [
"views/res_company_view.xml", "views/res_company_view.xml",
], ],
"demo": [
],
"qweb": [
]
} }

2
partner_ref_unique/models/__init__.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import res_company from . import res_company

2
partner_ref_unique/models/res_company.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields from openerp import models, fields

2
partner_ref_unique/models/res_partner.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, api, _ from openerp import models, api, _

BIN
partner_ref_unique/static/description/icon.png

Before

Width: 128  |  Height: 128  |  Size: 11 KiB

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

5
partner_ref_unique/tests/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_res_partner_ref

43
partner_ref_unique/tests/test_res_partner_ref.py

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.tests import common
from openerp.exceptions import ValidationError
class TestResPartnerRefUnique(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestResPartnerRefUnique, cls).setUpClass()
cls.company = cls.env.ref('base.main_company')
partner_obj = cls.env['res.partner']
cls.partner1 = partner_obj.create({
'name': 'Partner1',
})
cls.partner2 = partner_obj.create({
'name': 'Partner2',
})
def test_check_ref(self):
# Test can create/modify partners with same ref
self.company.partner_ref_unique = 'none'
self.partner1.ref = 'same_ref'
self.partner2.ref = 'same_ref'
self.assertEqual(self.partner1.ref, self.partner2.ref)
self.partner2.ref = False
# Test can't create/modify partner with same ref
self.company.partner_ref_unique = 'all'
with self.assertRaises(ValidationError):
self.partner2.ref = 'same_ref'
# Test can't create/modify companies with same ref
self.company.partner_ref_unique = 'companies'
self.partner2.ref = 'same_ref'
self.assertEqual(self.partner1.ref, self.partner2.ref)
self.partner2.ref = False
self.partner1.is_company = True
self.partner2.is_company = True
with self.assertRaises(ValidationError):
self.partner2.ref = 'same_ref'

11
partner_ref_unique/views/res_company_view.xml

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
<!-- Copyright 2016 Antiun Ingenieria S.L. - Antonio Espinosa
Copyright 2017 Tecnativa - Vicent Cubells
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). --> License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>
<odoo>
<record id="view_company_form" model="ir.ui.view"> <record id="view_company_form" model="ir.ui.view">
<field name="name">Add partner_ref_unique field</field> <field name="name">Add partner_ref_unique field</field>
<field name="model">res.company</field> <field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/> <field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<page string="Configuration" position="inside">
<page name="configuration" position="inside">
<group> <group>
<group name="partner" string="Partners"> <group name="partner" string="Partners">
<field name="partner_ref_unique"/> <field name="partner_ref_unique"/>
@ -19,5 +19,4 @@
</field> </field>
</record> </record>
</data>
</openerp>
</odoo>
Loading…
Cancel
Save