Browse Source

[11.0][ADD] partner_certificate_of_conduct

pull/699/head
Nikos Tsirintanis 6 years ago
parent
commit
3fc48569a6
  1. 3
      partner_certificate_of_conduct/__init__.py
  2. 21
      partner_certificate_of_conduct/__manifest__.py
  3. 7
      partner_certificate_of_conduct/data/res_partner_id_category_data.xml
  4. 3
      partner_certificate_of_conduct/models/__init__.py
  5. 22
      partner_certificate_of_conduct/models/res_partner.py
  6. 3
      partner_certificate_of_conduct/readme/CONTRIBUTORS.rst
  7. 1
      partner_certificate_of_conduct/readme/DESCRIPTION.rst
  8. 8
      partner_certificate_of_conduct/readme/USAGE.rst
  9. 3
      partner_certificate_of_conduct/tests/__init__.py
  10. 67
      partner_certificate_of_conduct/tests/test_partner_certificate_of_conduct.py
  11. 14
      partner_certificate_of_conduct/views/res_partner_view.xml

3
partner_certificate_of_conduct/__init__.py

@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models

21
partner_certificate_of_conduct/__manifest__.py

@ -0,0 +1,21 @@
# Copyright 2017-2018 Onestein (<https://www.onestein.eu>)
# Copyright 2018 Therp BV (<https://www.therp.nl>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
'name': 'Partner Certificate of Conduct',
'summary': "Adds field 'Certificate of Conduct'",
'version': '11.0.1.0.0',
'category': 'CRM',
'author': 'Therp BV,Onestein,Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/partner-contact/',
'license': 'AGPL-3',
'depends': [
'partner_identification',
],
'data': [
'data/res_partner_id_category_data.xml',
'views/res_partner_view.xml'
],
'installable': True,
}

7
partner_certificate_of_conduct/data/res_partner_id_category_data.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_partner_id_category_certificate_of_conduct" model="res.partner.id_category">
<field name="code">co_conduct</field>
<field name="name">Certificate of Conduct</field>
</record>
</odoo>

3
partner_certificate_of_conduct/models/__init__.py

@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import res_partner

22
partner_certificate_of_conduct/models/res_partner.py

@ -0,0 +1,22 @@
# Copyright 2017-2018 Onestein (<https://www.onestein.eu>)
# Copyright 2018 Therp BV (<https://www.therp.nl>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
coc_certificate_of_conduct = fields.Char(
string='Certificate of Conduct',
compute=lambda s: s._compute_identification(
'coc_certificate_of_conduct', 'co_conduct',
),
inverse=lambda s: s._inverse_identification(
'coc_certificate_of_conduct', 'co_conduct',
),
search=lambda s, *a: s._search_identification(
'coc_certificate_of_conduct', 'co_conduct', *a
),
)

3
partner_certificate_of_conduct/readme/CONTRIBUTORS.rst

@ -0,0 +1,3 @@
* Dennis Sluijk <d.sluijk@onestein.nl>
* Andrea Stirpe <a.stirpe@onestein.nl>
* Nikos Tsirintanis <ntsirintanis@therp.nl>

1
partner_certificate_of_conduct/readme/DESCRIPTION.rst

@ -0,0 +1 @@
This module adds the field *Certificate of Conduct* to partners. Refer to https://www.justis.nl/producten/vog/certificate-of-conduct/ for what a Certificate of Conduct is.

8
partner_certificate_of_conduct/readme/USAGE.rst

@ -0,0 +1,8 @@
To use this module, you need to:
#. Go to the partner form;
#. make sure the partner is not a company.
#. Go to ID numbers tab and create a new record with Certificate of Conduct as category, and an ID number.
#. Save the record and form, and observe that there is a new field called Certificate of Conduct with your ID number.
#. OR
#. Assign a value to the new field directly, and observe ID numbers right after saving the form

3
partner_certificate_of_conduct/tests/__init__.py

@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import test_partner_certificate_of_conduct

67
partner_certificate_of_conduct/tests/test_partner_certificate_of_conduct.py

@ -0,0 +1,67 @@
# Copyright 2018 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp.tests.common import TransactionCase
class TestPartnerCertificateOfConduct(TransactionCase):
def setUp(self):
super(TestPartnerCertificateOfConduct, self).setUp()
self.main_partner = self.env.ref('base.main_partner')
self.partner_id_category = self.env.ref(
'partner_certificate_of_conduct.'
'res_partner_id_category_certificate_of_conduct'
)
def test_01_id_number_new(self):
# Good CoC
vals = {
'name': '56048785',
'category_id': self.partner_id_category.id,
}
self.main_partner.write({'id_numbers': [(0, 0, vals)]})
id_number = self.main_partner.id_numbers[0]
self.assertEqual(id_number.name, '56048785')
def test_02_id_number_duplicate(self):
# Duplicate CoC
vals = {
'name': '56048785',
'category_id': self.partner_id_category.id,
}
self.main_partner.write({'id_numbers': [(0, 0, vals)]})
id_number_name = self.main_partner.id_numbers[0].name
self.assertEqual(id_number_name, '56048785')
new_partner = self.env['res.partner'].create({'name': 'Test Partner'})
new_partner.write({'id_numbers': [(0, 0, vals)]})
id_number_name = new_partner.id_numbers[0].name
self.assertEqual(id_number_name, '56048785')
def test_03_coc_registration_number_create(self):
new_partner = self.env['res.partner'].create({
'name': 'Test Partner',
'coc_certificate_of_conduct': '56048785',
})
self.assertEqual(new_partner.coc_certificate_of_conduct, '56048785')
id_numbers = new_partner.id_numbers
self.assertTrue(id_numbers)
self.assertEqual(len(id_numbers), 1)
self.assertEqual(id_numbers.name, '56048785')
def test_04_coc_registration_number_write(self):
self.main_partner.write({
'coc_certificate_of_conduct': '56048786'
})
coc = self.main_partner.coc_certificate_of_conduct
self.assertEqual(coc, '56048786')
id_numbers = self.main_partner.id_numbers
self.assertTrue(id_numbers)
self.assertEqual(len(id_numbers), 1)
self.assertEqual(id_numbers.name, '56048786')

14
partner_certificate_of_conduct/views/res_partner_view.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Add coc_certificate_of_conduct to res partner view -->
<record id="view_partner_form" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="priority" eval="11"/>
<field name="arch" type="xml">
<field name="lang" position="after">
<field name="coc_certificate_of_conduct" attrs="{'invisible': [('company_type','=','company')]}"/>
</field>
</field>
</record>
</odoo>
Loading…
Cancel
Save