Browse Source

[MIG] base_partner_sequence: Migration to 13.0

14.0
Kevin Khao 5 years ago
committed by mostafaala2
parent
commit
959a3c80ba
  1. 11
      base_partner_sequence/README.rst
  2. 2
      base_partner_sequence/__init__.py
  3. 10
      base_partner_sequence/__manifest__.py
  4. 2
      base_partner_sequence/data/partner_sequence.xml
  5. 2
      base_partner_sequence/models/__init__.py
  6. 22
      base_partner_sequence/models/partner.py
  7. 1
      base_partner_sequence/readme/CONTRIBUTORS.rst
  8. 7
      base_partner_sequence/static/description/index.html
  9. 2
      base_partner_sequence/tests/__init__.py
  10. 12
      base_partner_sequence/tests/test_base_partner_sequence.py

11
base_partner_sequence/README.rst

@ -14,13 +14,13 @@ Add a sequence on customers' code
: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/base_partner_sequence
:target: https://github.com/OCA/partner-contact/tree/13.0/base_partner_sequence
: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-base_partner_sequence
:target: https://translation.odoo-community.org/projects/partner-contact-13-0/partner-contact-13-0-base_partner_sequence
: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|
@ -48,7 +48,7 @@ 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:%20base_partner_sequence%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:%20base_partner_sequence%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.
@ -77,6 +77,7 @@ Contributors
* Akim Juillerat <akim.juillerat@camptocamp.com>
* Cas Vissers <c.vissers@brahoo.nl>
* Quentin Groulard <quentin.groulard@acsone.eu>
* Kevin Khao <kevinkhao@gmail.com>
Maintainers
~~~~~~~~~~~
@ -91,6 +92,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/base_partner_sequence>`_ project on GitHub.
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/13.0/base_partner_sequence>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

2
base_partner_sequence/__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 models
from . import tests

10
base_partner_sequence/__manifest__.py

@ -1,8 +1,8 @@
# Copyright 2004-2009 Tiny SPRL (<http://tiny.be>).
# Copyright 2013 initOS GmbH & Co. KG (<http://www.initos.com>).
# Copyright 2004-2009 Tiny SPRL (<https://tiny.be>).
# Copyright 2013 initOS GmbH & Co. KG (<https://www.initos.com>).
# Copyright 2016 Tecnativa - Vicent Cubells
# Copyright 2016 Camptocamp - Akim Juillerat (<http://www.camptocamp.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Copyright 2016 Camptocamp - Akim Juillerat (<https://www.camptocamp.com>).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"author": (
"Tiny/initOS GmbH & Co. KG,"
@ -12,7 +12,7 @@
"Odoo Community Association (OCA)"
),
"name": "Add a sequence on customers' code",
"version": "12.0.1.0.0",
"version": "13.0.1.0.0",
"development_status": "Production/Stable",
"category": "Generic Modules/Base",
"website": "https://github.com/OCA/partner-contact",

2
base_partner_sequence/data/partner_sequence.xml

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<odoo noupdate="1">
<record model="ir.sequence" id="seq_res_partner">
<record id="seq_res_partner" model="ir.sequence">
<field name="name">Partner code</field>
<field name="code">res.partner</field>
<field name="prefix">P/</field>

2
base_partner_sequence/models/__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 partner

22
base_partner_sequence/models/partner.py

@ -1,8 +1,8 @@
# Copyright 2004-2009 Tiny SPRL (<http://tiny.be>).
# Copyright 2013 initOS GmbH & Co. KG (<http://www.initos.com>).
# Copyright 2004-2009 Tiny SPRL (<https://tiny.be>).
# Copyright 2013 initOS GmbH & Co. KG (<https://www.initos.com>).
# Copyright 2016 Tecnativa - Vicent Cubells
# Copyright 2016 Camptocamp - Akim Juillerat (<http://www.camptocamp.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Copyright 2016 Camptocamp - Akim Juillerat (<https://www.camptocamp.com>).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import _, api, exceptions, models
@ -12,38 +12,34 @@ class ResPartner(models.Model):
_inherit = "res.partner"
@api.multi
def _get_next_ref(self, vals=None):
return self.env["ir.sequence"].next_by_code("res.partner")
@api.model
def create(self, vals):
if not vals.get("ref") and self._needsRef(vals=vals):
if not vals.get("ref") and self._needs_ref(vals=vals):
vals["ref"] = self._get_next_ref(vals=vals)
return super(ResPartner, self).create(vals)
@api.multi
def copy(self, default=None):
default = default or {}
if self._needsRef():
if self._needs_ref():
default["ref"] = self._get_next_ref()
return super(ResPartner, self).copy(default)
return super(ResPartner, self).copy(default=default)
@api.multi
def write(self, vals):
for partner in self:
partner_vals = vals.copy()
if (
not partner_vals.get("ref")
and partner._needsRef(partner_vals)
and partner._needs_ref(vals=partner_vals)
and not partner.ref
):
partner_vals["ref"] = partner._get_next_ref(vals=partner_vals)
super(ResPartner, partner).write(partner_vals)
return True
@api.multi
def _needsRef(self, vals=None):
def _needs_ref(self, vals=None):
"""
Checks whether a sequence value should be assigned to a partner's 'ref'

1
base_partner_sequence/readme/CONTRIBUTORS.rst

@ -9,3 +9,4 @@
* Akim Juillerat <akim.juillerat@camptocamp.com>
* Cas Vissers <c.vissers@brahoo.nl>
* Quentin Groulard <quentin.groulard@acsone.eu>
* Kevin Khao <kevinkhao@gmail.com>

7
base_partner_sequence/static/description/index.html

@ -367,7 +367,7 @@ 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="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/base_partner_sequence"><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-base_partner_sequence"><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="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/base_partner_sequence"><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-base_partner_sequence"><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 the possibility to define a sequence for
the partner’s reference. This reference is then set as default
when you create a new partner, using the defined sequence.</p>
@ -394,7 +394,7 @@ invoice addresses.</p>
<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:%20base_partner_sequence%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:%20base_partner_sequence%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">
@ -422,6 +422,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Akim Juillerat &lt;<a class="reference external" href="mailto:akim.juillerat&#64;camptocamp.com">akim.juillerat&#64;camptocamp.com</a>&gt;</li>
<li>Cas Vissers &lt;<a class="reference external" href="mailto:c.vissers&#64;brahoo.nl">c.vissers&#64;brahoo.nl</a>&gt;</li>
<li>Quentin Groulard &lt;<a class="reference external" href="mailto:quentin.groulard&#64;acsone.eu">quentin.groulard&#64;acsone.eu</a>&gt;</li>
<li>Kevin Khao &lt;<a class="reference external" href="mailto:kevinkhao&#64;gmail.com">kevinkhao&#64;gmail.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
@ -431,7 +432,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<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/base_partner_sequence">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/base_partner_sequence">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
base_partner_sequence/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_base_partner_sequence

12
base_partner_sequence/tests/test_base_partner_sequence.py

@ -1,6 +1,6 @@
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>).
# Copyright 2015 ACSONE SA/NV (<https://acsone.eu>).
# Copyright 2016 Tecnativa - Vicent Cubells
# 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).
import odoo.tests.common as common
@ -20,7 +20,7 @@ class TestBasePartnerSequence(common.TransactionCase):
copy = self.partner.copy()
self.assertTrue(
copy.ref, "A partner with ref created by copy " "has a ref by default."
copy.ref, "A partner with ref created by copy has a ref by default."
)
def test_ref_sequence_on_contact(self):
@ -33,13 +33,11 @@ class TestBasePartnerSequence(common.TransactionCase):
}
)
self.assertEqual(
self.partner.ref,
contact.ref,
"All it's ok as sequence doesn't " "increase.",
self.partner.ref, contact.ref, "All it's ok as sequence doesn't increase."
)
def test_unique_ref_on_write(self):
"""Assert that create and write gives a different refs if we """
"""Assert that on create or on write, a different ref is assigned"""
vals = [
{"name": "test1", "email": "test@test.com"},
{"name": "test2", "email": "test@test.com"},

Loading…
Cancel
Save