Browse Source

[MIG] partner_industry_secondary: Migration to 13.0

14.0
Stephan Keller 5 years ago
committed by Surachet Saejueng
parent
commit
f04264ae81
  1. 15
      partner_industry_secondary/README.rst
  2. 2
      partner_industry_secondary/__init__.py
  3. 6
      partner_industry_secondary/__manifest__.py
  4. 2
      partner_industry_secondary/migrations/13.0.1.0.0/post-migration.py
  5. 2
      partner_industry_secondary/models/__init__.py
  6. 2
      partner_industry_secondary/models/res_config_settings.py
  7. 2
      partner_industry_secondary/models/res_partner.py
  8. 21
      partner_industry_secondary/models/res_partner_industry.py
  9. 1
      partner_industry_secondary/readme/ROADMAP.rst
  10. 33
      partner_industry_secondary/static/description/index.html
  11. 2
      partner_industry_secondary/tests/__init__.py
  12. 22
      partner_industry_secondary/tests/test_res_partner_industry.py
  13. 28
      partner_industry_secondary/views/res_config_settings.xml
  14. 5
      partner_industry_secondary/views/res_partner_industry_view.xml

15
partner_industry_secondary/README.rst

@ -14,13 +14,13 @@ Partner Industry Secondary
: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/12.0/partner_industry_secondary
:target: https://github.com/OCA/partner-contact/tree/13.0/partner_industry_secondary
: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-12-0/partner-contact-12-0-partner_industry_secondary
:target: https://translation.odoo-community.org/projects/partner-contact-13-0/partner-contact-13-0-partner_industry_secondary
: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/12.0
:target: https://runbot.odoo-community.org/runbot/134/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -51,18 +51,13 @@ To use this module, you need to:
* Go to any partner's form.
Known issues / Roadmap
======================
* Add a unique constraint for name per parent industry.
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 <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_industry_secondary%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_industry_secondary%0Aversion:%2013.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.
@ -100,6 +95,6 @@ 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.
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/12.0/partner_industry_secondary>`_ project on GitHub.
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/13.0/partner_industry_secondary>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

2
partner_industry_secondary/__init__.py

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

6
partner_industry_secondary/__manifest__.py

@ -1,18 +1,18 @@
# Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016-2017 Tecnativa S.L. - Vicent Cubells
# Copyright 2019 Tecnativa S.L. - Cristina Martin R.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Partner Industry Secondary",
"summary": "Add secondary partner industries",
"version": "12.0.1.0.1",
"version": "13.0.1.0.0",
"category": "Sales",
"website": "https://github.com/OCA/partner-contact",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": ["base_setup", "contacts",],
"depends": ["base_setup", "contacts"],
"data": [
"security/ir.model.access.csv",
"security/partner_industry_security.xml",

2
partner_industry_secondary/migrations/12.0.1.0.0/post-migration.py → partner_industry_secondary/migrations/13.0.1.0.0/post-migration.py

@ -1,5 +1,5 @@
# Copyright 2019 Tecnativa - Cristina Martin R.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade

2
partner_industry_secondary/models/__init__.py

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

2
partner_industry_secondary/models/res_config_settings.py

@ -1,5 +1,5 @@
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models

2
partner_industry_secondary/models/res_partner.py

@ -1,7 +1,7 @@
# Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016 Tecnativa S.L. - Vicent Cubells
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import _, api, exceptions, fields, models

21
partner_industry_secondary/models/res_partner_industry.py

@ -3,7 +3,7 @@
# Copyright 2016 Tecnativa S.L. - Pedro M. Baeza
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# Copyright 2019 Tecnativa - Cristina Martin R.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import _, api, exceptions, fields, models
@ -23,7 +23,6 @@ class ResPartnerIndustry(models.Model):
)
parent_path = fields.Char(index=True)
@api.multi
def name_get(self):
def get_names(cat):
""" Return the list [cat.name, cat.parent_id.name, ...] """
@ -41,3 +40,21 @@ class ResPartnerIndustry(models.Model):
raise exceptions.ValidationError(
_("Error! You cannot create recursive industries.")
)
@api.constrains("name", "parent_id")
def _check_uniq_name(self):
if (
self.search_count(
[("name", "=", self.name), ("parent_id", "=", self.parent_id.id)]
)
> 1
):
raise exceptions.ValidationError(
_("Error! Industry with same name and parent already exists.")
)
def copy(self, default=None):
default = default or {}
if "name" not in default or default["name"] == self.name:
default["name"] = self.name + " 2"
return super(ResPartnerIndustry, self).copy(default=default)

1
partner_industry_secondary/readme/ROADMAP.rst

@ -1 +0,0 @@
* Add a unique constraint for name per parent industry.

33
partner_industry_secondary/static/description/index.html

@ -367,19 +367,18 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/partner-contact/tree/12.0/partner_industry_secondary"><img alt="OCA/partner-contact" src="https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/partner-contact-12-0/partner-contact-12-0-partner_industry_secondary"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/134/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/partner-contact/tree/13.0/partner_industry_secondary"><img alt="OCA/partner-contact" src="https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/partner-contact-13-0/partner-contact-13-0-partner_industry_secondary"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/134/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds secondary industries for partners.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id8">Maintainers</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
</ul>
</li>
</ul>
@ -403,30 +402,24 @@ you need to activate the following setting:</p>
<li>Go to any partner’s form.</li>
</ul>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id3">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Add a unique constraint for name per parent industry.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id4">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/partner-contact/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_industry_secondary%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_industry_secondary%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id5">Credits</a></h1>
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id6">Authors</a></h2>
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
<ul class="simple">
<li>Tecnativa</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id7">Contributors</a></h2>
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul class="simple">
<li>Rafael Blasco &lt;<a class="reference external" href="mailto:rafabn&#64;antiun.com">rafabn&#64;antiun.com</a>&gt;</li>
<li>Antonio Espinosa &lt;<a class="reference external" href="mailto:antonioea&#64;antiun.com">antonioea&#64;antiun.com</a>&gt;</li>
@ -440,13 +433,13 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/partner-contact/tree/12.0/partner_industry_secondary">OCA/partner-contact</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/partner-contact/tree/13.0/partner_industry_secondary">OCA/partner-contact</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

2
partner_industry_secondary/tests/__init__.py

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

22
partner_industry_secondary/tests/test_res_partner_industry.py

@ -1,9 +1,9 @@
# Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016 Tecnativa S.L. - Vicent Cubells
# Copyright 2016 Tecnativa S.L. - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.exceptions import ValidationError
from odoo.exceptions import UserError, ValidationError
from odoo.tests import common
@ -12,9 +12,9 @@ class TestResPartnerIndustry(common.SavepointCase):
def setUpClass(cls):
super(TestResPartnerIndustry, cls).setUpClass()
cls.industry_model = cls.env["res.partner.industry"]
cls.industry_main = cls.industry_model.create({"name": "Test",})
cls.industry_main = cls.industry_model.create({"name": "Test"})
cls.industry_child = cls.industry_model.create(
{"name": "Test child", "parent_id": cls.industry_main.id,}
{"name": "Test child", "parent_id": cls.industry_main.id}
)
def test_check_industries(self):
@ -27,11 +27,17 @@ class TestResPartnerIndustry(common.SavepointCase):
}
)
def test_check_recursion(self):
def test_check_copy(self):
industry_copy = self.industry_child.copy()
self.assertEqual(industry_copy.name, "Test child 2")
def test_check_uniq_name(self):
with self.assertRaises(ValidationError):
self.industry_model.create({"name": "Test"})
def test_check_recursion(self):
with self.assertRaises(UserError):
self.industry_main.parent_id = self.industry_child.id
def test_name(self):
self.assertEqual(
self.industry_child.name_get()[0][1], "Test / Test child",
)
self.assertEqual(self.industry_child.display_name, "Test / Test child")

28
partner_industry_secondary/views/res_config_settings.xml

@ -1,27 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2018 Eficent Business and IT Consulting Services, S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -->
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form</field>
<field
name="name"
>res.config.settings.view.form.inherit.partner_partner_industry_secondary</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form" />
<field name="inherit_id" ref="base.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@name='multi_company']" position="after">
<h2>Partner Industries</h2>
<div class="row mt16 o_settings_container" name="partner_industries">
<div class="col-xs-12 col-md-6 o_setting_box">
<div id="contacts_settings" position='inside'>
<div class="row mt16 o_settings_container">
<div class="col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="group_use_partner_industry_for_person" />
</div>
<div class="o_setting_right_pane">
<div
class="o_setting_right_pane"
id="partner_industry_secondary_show_form_settings"
>
<label
string="Industry for individual"
string="Enable industries for individuals"
for="group_use_partner_industry_for_person"
/>
<div class="text-muted">
Enable industries for individuals
</div>
Enable industries for individuals
</div>
<div class="content-group">
<div
class="mt16"
@ -39,7 +43,7 @@
</div>
</div>
</div>
</xpath>
</div>
</field>
</record>
</odoo>

5
partner_industry_secondary/views/res_partner_industry_view.xml

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
Copyright 2018 Eficent Business and IT Consulting Services, S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -->
<odoo>
<record id="res_partner_industry_view_form" model="ir.ui.view">
<field name="name">Industry</field>
@ -18,6 +18,9 @@
<field name="model">res.partner.industry</field>
<field name="inherit_id" ref="base.res_partner_industry_view_tree" />
<field name="arch" type="xml">
<tree position="attributes">
<attribute name="editable" />
</tree>
<field name="name" position="after">
<field name="parent_id" />
</field>

Loading…
Cancel
Save