Browse Source

[IMP] partner_coc: black, isort

14.0
Nikos Tsirintanis 5 years ago
committed by bosd
parent
commit
37da8e6479
  1. 25
      partner_coc/__manifest__.py
  2. 16
      partner_coc/models/res_partner.py
  3. 47
      partner_coc/tests/test_partner_coc.py

25
partner_coc/__manifest__.py

@ -2,19 +2,14 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
'name': 'Partner CoC',
'summary': "Adds field 'Chamber Of Commerce Registration Number'",
'version': '13.0.1.0.0',
'category': 'Web',
'author': '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,
"name": "Partner CoC",
"summary": "Adds field 'Chamber Of Commerce Registration Number'",
"version": "13.0.1.0.0",
"category": "Web",
"author": "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,
}

16
partner_coc/models/res_partner.py

@ -5,17 +5,11 @@ from odoo import fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
_inherit = "res.partner"
coc_registration_number = fields.Char(
string='CoC Registration Number',
compute=lambda s: s._compute_identification(
'coc_registration_number', 'coc',
),
inverse=lambda s: s._inverse_identification(
'coc_registration_number', 'coc',
),
search=lambda s, *a: s._search_identification(
'coc', *a
),
string="CoC Registration Number",
compute=lambda s: s._compute_identification("coc_registration_number", "coc"),
inverse=lambda s: s._inverse_identification("coc_registration_number", "coc"),
search=lambda s, *a: s._search_identification("coc", *a),
)

47
partner_coc/tests/test_partner_coc.py

@ -7,58 +7,49 @@ from odoo.tests.common import TransactionCase
class TestPartnerCoC(TransactionCase):
def setUp(self):
super(TestPartnerCoC, self).setUp()
self.main_partner = self.env.ref('base.main_partner')
self.partner_id_category = self.env.ref('partner_coc.id_category_coc')
self.main_partner = self.env.ref("base.main_partner")
self.partner_id_category = self.env.ref("partner_coc.id_category_coc")
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)]})
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')
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,
}
vals = {"name": "56048785", "category_id": self.partner_id_category.id}
self.main_partner.write({'id_numbers': [(0, 0, vals)]})
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')
self.assertEqual(id_number_name, "56048785")
new_partner = self.env['res.partner'].create({'name': 'Test Partner'})
new_partner = self.env["res.partner"].create({"name": "Test Partner"})
new_partner.write({'id_numbers': [(0, 0, vals)]})
new_partner.write({"id_numbers": [(0, 0, vals)]})
id_number_name = new_partner.id_numbers[0].name
self.assertEqual(id_number_name, '56048785')
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_registration_number': '56048785',
})
new_partner = self.env["res.partner"].create(
{"name": "Test Partner", "coc_registration_number": "56048785"}
)
self.assertEqual(new_partner.coc_registration_number, '56048785')
self.assertEqual(new_partner.coc_registration_number, "56048785")
id_numbers = new_partner.id_numbers
self.assertTrue(id_numbers)
self.assertEqual(len(id_numbers), 1)
self.assertEqual(id_numbers.name, '56048785')
self.assertEqual(id_numbers.name, "56048785")
def test_04_coc_registration_number_write(self):
self.main_partner.write({
'coc_registration_number': '56048785'
})
self.main_partner.write({"coc_registration_number": "56048785"})
coc = self.main_partner.coc_registration_number
self.assertEqual(coc, '56048785')
self.assertEqual(coc, "56048785")
id_numbers = self.main_partner.id_numbers
self.assertTrue(id_numbers)
self.assertEqual(len(id_numbers), 1)
self.assertEqual(id_numbers.name, '56048785')
self.assertEqual(id_numbers.name, "56048785")
Loading…
Cancel
Save