Browse Source

partner_ref_unique addon and change description icon

14.0
Antonio Espinosa 9 years ago
committed by Pedro M. Baeza
parent
commit
d27aa392f2
  1. 34
      partner_ref_unique/README.rst
  2. 5
      partner_ref_unique/__init__.py
  3. 30
      partner_ref_unique/__openerp__.py
  4. 6
      partner_ref_unique/models/__init__.py
  5. 16
      partner_ref_unique/models/res_company.py
  6. 31
      partner_ref_unique/models/res_partner.py
  7. BIN
      partner_ref_unique/static/description/icon.png
  8. 23
      partner_ref_unique/views/res_company_view.xml

34
partner_ref_unique/README.rst

@ -0,0 +1,34 @@
.. 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
========================
Partner unique reference
========================
Add an unique constraint to partner ref field
Credits
=======
Contributors
------------
* Antonio Espinosa <antonioea@antiun.com>
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.
Antiun Ingeniería S.L. is an IT consulting company especialized in Odoo
and provides Odoo development, install, maintenance and hosting
services.
To contribute to this module, please visit https://github.com/Antiun
or contact us at odoo@antiun.com

5
partner_ref_unique/__init__.py

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

30
partner_ref_unique/__openerp__.py

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

6
partner_ref_unique/models/__init__.py

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

16
partner_ref_unique/models/res_company.py

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields
class ResCompany(models.Model):
_inherit = "res.company"
partner_ref_unique = fields.Selection(
selection=[
('none', 'None'),
('companies', 'Only companies'),
('all', 'All partners'),
], string="Unique partner reference for", default="none")

31
partner_ref_unique/models/res_partner.py

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, api, _
from openerp.exceptions import ValidationError
class ResPartner(models.Model):
_inherit = "res.partner"
@api.multi
@api.constrains('ref', 'is_company', 'company_id')
def _check_ref(self):
for partner in self:
mode = partner.company_id.partner_ref_unique
if (partner.ref and (
mode == 'all' or
(mode == 'companies' and partner.is_company))):
domain = [
('id', '!=', partner.id),
('ref', '=', partner.ref),
('customer', '=', True),
]
if mode == 'companies':
domain.append(('is_company', '=', True))
other = self.search(domain)
if other:
raise ValidationError(
_("This reference is equal to partner '%s'") %
other[0].display_name)

BIN
partner_ref_unique/static/description/icon.png

After

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

23
partner_ref_unique/views/res_company_view.xml

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