Browse Source

[MIG] partner_coc: porting to V11 + tests

pull/645/head
Andrea 6 years ago
committed by tarteo
parent
commit
336d1cb8b1
  1. 68
      partner_coc/README.rst
  2. 2
      partner_coc/__init__.py
  3. 11
      partner_coc/__manifest__.py
  4. 2
      partner_coc/models/__init__.py
  5. 5
      partner_coc/models/res_partner.py
  6. 2
      partner_coc/readme/CONTRIBUTORS.rst
  7. 1
      partner_coc/readme/DESCRIPTION.rst
  8. 4
      partner_coc/readme/USAGE.rst
  9. 3
      partner_coc/tests/__init__.py
  10. 64
      partner_coc/tests/test_partner_coc.py
  11. 5
      partner_coc/views/res_partner_view.xml

68
partner_coc/README.rst

@ -1,12 +1,36 @@
.. 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 CoC
===========
Adds a field 'Chamber Of Commerce Registration Number' to partner.
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github
:target: https://github.com/OCA/partner-contact/tree/11.0/partner_coc
:alt: OCA/partner-contact
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/partner-contact-11-0/partner-contact-11-0-partner_coc
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/134/11.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
This module adds the field *Chamber Of Commerce Registration Number* to partners.
**Table of contents**
.. contents::
:local:
Usage
=====
@ -16,37 +40,43 @@ To use this module, you need to:
#. Go to the partner form;
#. make sure the partner is a company.
.. 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/10.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.
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 <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_coc%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* Onestein
Contributors
------------
~~~~~~~~~~~~
* Dennis Sluijk <d.sluijk@onestein.nl>
* Andrea Stirpe <a.stirpe@onestein.nl>
Maintainer
----------
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
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.
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/11.0/partner_coc>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

2
partner_coc/__init__.py

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

11
partner_coc/__manifest__.py

@ -1,11 +1,13 @@
# Copyright 2017-2018 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
'name': 'Partner CoC',
'summary': "Adds a field 'Chamber Of Commerce Registration Number' to "
"partner",
'version': '10.0.1.0.0',
'summary': "Adds field 'Chamber Of Commerce Registration Number'",
'version': '11.0.1.0.0',
'category': 'Web',
'author': 'Onestein,Odoo Community Association (OCA)',
'website': 'http://www.onestein.eu',
'website': 'https://github.com/OCA/partner-contact/',
'license': 'AGPL-3',
'depends': [
'partner_identification',
@ -15,5 +17,4 @@
'views/res_partner_view.xml'
],
'installable': True,
'application': False,
}

2
partner_coc/models/__init__.py

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

5
partner_coc/models/res_partner.py

@ -1,4 +1,7 @@
from odoo import models, fields
# Copyright 2017-2018 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResPartner(models.Model):

2
partner_coc/readme/CONTRIBUTORS.rst

@ -0,0 +1,2 @@
* Dennis Sluijk <d.sluijk@onestein.nl>
* Andrea Stirpe <a.stirpe@onestein.nl>

1
partner_coc/readme/DESCRIPTION.rst

@ -0,0 +1 @@
This module adds the field *Chamber Of Commerce Registration Number* to partners.

4
partner_coc/readme/USAGE.rst

@ -0,0 +1,4 @@
To use this module, you need to:
#. Go to the partner form;
#. make sure the partner is a company.

3
partner_coc/tests/__init__.py

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

64
partner_coc/tests/test_partner_coc.py

@ -0,0 +1,64 @@
# Copyright 2018 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp.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')
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_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')
def test_04_coc_registration_number_write(self):
self.main_partner.write({
'coc_registration_number': '56048785'
})
coc = self.main_partner.coc_registration_number
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')

5
partner_coc/views/res_partner_view.xml

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Add coc_registration_number to res partner view -->
<record model="ir.ui.view" id="view_partner_form">
<field name="name">view.partner.form</field>
<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="10"/>

Loading…
Cancel
Save