Skip to content

Commit

Permalink
[14.0][ADD] module partner_title_order
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoRubi authored and kv1612 committed Oct 20, 2021
1 parent 5a35489 commit 184453c
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 0 deletions.
5 changes: 5 additions & 0 deletions partner_title_order/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
===================
Partner title order
===================

Add sequence to partner title to be able to determine their order.
1 change: 1 addition & 0 deletions partner_title_order/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions partner_title_order/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Partner title order",
"summary": "Makes partner title sortable by sequence",
"version": "14.0.1.0.0",
"category": "Hidden",
"author": "Camptocamp",
"license": "AGPL-3",
"depends": [
"base",
],
"website": "https://github.com/OCA/partner-contact",
"data": [
# views
"views/res_partner_title_views.xml",
],
"installable": True,
}
1 change: 1 addition & 0 deletions partner_title_order/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_partner_title
11 changes: 11 additions & 0 deletions partner_title_order/models/res_partner_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import fields, models


class ResPartnerTitle(models.Model):
_inherit = "res.partner.title"
_order = 'sequence,name'

sequence = fields.Integer(default=10)
3 changes: 3 additions & 0 deletions partner_title_order/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Simone Orsi <[email protected]>
* `Trobz <https://trobz.com>`_:
* Khoi Vo <[email protected]>
1 change: 1 addition & 0 deletions partner_title_order/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The development of this module was financially supported by Camptocamp
1 change: 1 addition & 0 deletions partner_title_order/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_partner_title
35 changes: 35 additions & 0 deletions partner_title_order/tests/test_partner_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo.tests.common import SavepointCase


class TestPartnerTitle(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))

def test_default_order(self):
partner_titles = self.env["res.partner.title"].search([])
self.assertEqual(
partner_titles.mapped("name"),
partner_titles.sorted(lambda x: x.name).mapped("name"),
)

def test_sequence_order(self):
partner_titles = self.env["res.partner.title"].search([])
partner_first = partner_titles[0]
partner_first.sequence = 100
partner_last = partner_titles[-1]
partner_last.sequence = 0
partner_titles = self.env["res.partner.title"].search([])
self.assertEqual(
partner_titles.mapped("name"),
partner_titles.sorted(lambda x: (x.sequence, x.name)).mapped(
"name"
),
)
# last and first inverted
self.assertEqual(partner_titles[0], partner_last)
self.assertEqual(partner_titles[-1], partner_first)
26 changes: 26 additions & 0 deletions partner_title_order/views/res_partner_title_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 Camptocamp SA
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>

<record id="view_partner_title_tree" model="ir.ui.view">
<field name="model">res.partner.title</field>
<field name="inherit_id" ref="base.view_partner_title_tree"/>
<field name="arch" type="xml">
<field name="name" position="before">
<field name="sequence" widget="handle" />
</field>
</field>
</record>

<record id="view_partner_title_form" model="ir.ui.view">
<field name="model">res.partner.title</field>
<field name="inherit_id" ref="base.view_partner_title_form"/>
<field name="arch" type="xml">
<field name="name" position="before">
<field name="sequence" />
</field>
</field>
</record>

</odoo>
1 change: 1 addition & 0 deletions setup/partner_title_order/odoo/addons/partner_title_order
6 changes: 6 additions & 0 deletions setup/partner_title_order/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 184453c

Please sign in to comment.