Browse Source

[REF] partner_company_type: Black python code

14.0
laurent.corron 5 years ago
committed by Kitti U
parent
commit
3b0fd0afe1
  1. 30
      partner_company_type/__manifest__.py
  2. 3
      partner_company_type/models/res_partner.py
  3. 20
      partner_company_type/models/res_partner_company_type.py
  4. 15
      partner_company_type/tests/test_res_partner_company_type.py

30
partner_company_type/__manifest__.py

@ -2,22 +2,18 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
'name': 'Partner Company Type',
'summary': 'Adds a company type to partner that are companies',
'version': '12.0.1.0.0',
'license': 'AGPL-3',
'author': 'ACSONE SA/NV,Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/partner-contact',
'depends': [
'base',
'contacts',
],
'data': [
'security/res_partner_company_type.xml',
'views/res_partner_company_type.xml',
'views/res_partner.xml',
],
'demo': [
'demo/res_partner_company_type.xml',
"name": "Partner Company Type",
"summary": "Adds a company type to partner that are companies",
"version": "12.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/partner-contact",
"depends": ["base", "contacts"],
"data": [
"security/res_partner_company_type.xml",
"views/res_partner_company_type.xml",
"views/res_partner.xml",
], ],
"demo": ["demo/res_partner_company_type.xml"],
"installable": True,
} }

3
partner_company_type/models/res_partner.py

@ -8,6 +8,5 @@ class ResPartner(models.Model):
_inherit = "res.partner" _inherit = "res.partner"
partner_company_type_id = fields.Many2one( partner_company_type_id = fields.Many2one(
comodel_name='res.partner.company.type',
string='Legal Form',
comodel_name="res.partner.company.type", string="Legal Form"
) )

20
partner_company_type/models/res_partner_company_type.py

@ -6,18 +6,12 @@ from odoo import fields, models
class ResPartnerCompanyType(models.Model): class ResPartnerCompanyType(models.Model):
_name = 'res.partner.company.type'
_description = 'Partner Company Type'
_name = "res.partner.company.type"
_description = "Partner Company Type"
name = fields.Char(
string='Title',
required=True,
translate=True,
)
shortcut = fields.Char(
string='Abbreviation',
translate=True,
)
name = fields.Char(string="Title", required=True, translate=True)
shortcut = fields.Char(string="Abbreviation", translate=True)
_sql_constraints = [('name_uniq', 'unique (name)',
"Partner Company Type already exists!")]
_sql_constraints = [
("name_uniq", "unique (name)", "Partner Company Type already exists!")
]

15
partner_company_type/tests/test_res_partner_company_type.py

@ -1,25 +1,22 @@
# Copyright 2017-2018 ACSONE SA/NV # Copyright 2017-2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import tools
from psycopg2 import IntegrityError
from odoo import tools
from odoo.tests import SavepointCase from odoo.tests import SavepointCase
from psycopg2 import IntegrityError
class TestResPartnerCompanyType(SavepointCase): class TestResPartnerCompanyType(SavepointCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(TestResPartnerCompanyType, cls).setUpClass() super(TestResPartnerCompanyType, cls).setUpClass()
cls.company_type = cls.env.ref( cls.company_type = cls.env.ref(
'partner_company_type.res_partner_company_type_sa')
"partner_company_type.res_partner_company_type_sa"
)
def test_00_duplicate(self): def test_00_duplicate(self):
# Test Duplicate Company type # Test Duplicate Company type
with self.assertRaises(IntegrityError), tools.mute_logger(
"odoo.sql_db"):
self.company_type.create(dict(
name=self.company_type.name,
))
with self.assertRaises(IntegrityError), tools.mute_logger("odoo.sql_db"):
self.company_type.create(dict(name=self.company_type.name))
Loading…
Cancel
Save