forked from OCA/partner-contact
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][ADD] module partner_title_order
- Loading branch information
Showing
12 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import res_partner_title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The development of this module was financially supported by Camptocamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_partner_title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../partner_title_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |