Skip to content

Commit cbfb7b2

Browse files
schhatbar-initosfshah-initos
authored andcommitted
[14.0][MIG] chained_swapper
1 parent e472897 commit cbfb7b2

File tree

6 files changed

+38
-31
lines changed

6 files changed

+38
-31
lines changed

chained_swapper/README.rst

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ Chained Swapper
1414
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1515
:alt: License: AGPL-3
1616
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github
17-
:target: https://github.com/OCA/server-ux/tree/13.0/chained_swapper
17+
:target: https://github.com/OCA/server-ux/tree/14.0/chained_swapper
1818
:alt: OCA/server-ux
1919
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20-
:target: https://translation.odoo-community.org/projects/server-ux-13-0/server-ux-13-0-chained_swapper
20+
:target: https://translation.odoo-community.org/projects/server-ux-14-0/server-ux-14-0-chained_swapper
2121
:alt: Translate me on Weblate
2222
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23-
:target: https://runbot.odoo-community.org/runbot/250/13.0
23+
:target: https://runbot.odoo-community.org/runbot/250/14.0
2424
:alt: Try me on Runbot
2525

2626
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -119,6 +119,8 @@ Contributors
119119

120120
* Ernesto Tejeda
121121
* Pedro M. Baeza
122+
123+
* Sunanda Chhatbar <sunanda.chhatbar@initos.com>
122124

123125
Maintainers
124126
~~~~~~~~~~~
@@ -133,6 +135,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
133135
mission is to support the collaborative development of Odoo features and
134136
promote its widespread use.
135137

136-
This module is part of the `OCA/server-ux <https://github.com/OCA/server-ux/tree/13.0/chained_swapper>`_ project on GitHub.
138+
This module is part of the `OCA/server-ux <https://github.com/OCA/server-ux/tree/14.0/chained_swapper>`_ project on GitHub.
137139

138140
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

chained_swapper/demo/chained_swapper_demo.xml

+14-9
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@
1919
<field name="expression">bool(records.mapped('parent_id'))</field>
2020
</record>
2121
<!--Add an action-->
22-
<act_window
23-
id="partner_chained_swap_lang_action_demo"
24-
name="Chained swap: Language"
25-
res_model="chained.swapper.wizard"
26-
binding_model="res.partner"
27-
view_mode="form"
28-
context="{'chained_swapper_id': ref('chained_swapper_demo')}"
29-
target="new"
30-
/>
22+
<record id="partner_chained_swap_lang_action_demo" model="ir.actions.act_window">
23+
<field name="name">Chained swap: Language</field>
24+
<field name="res_model">chained.swapper.wizard</field>
25+
<field name="view_mode">form</field>
26+
<field name="target">new</field>
27+
<field name="binding_model_id" ref="base.model_res_partner" />
28+
<field name="binding_view_types">form</field>
29+
<field
30+
name="context"
31+
eval="{
32+
'chained_swapper_id': ref('chained_swapper_demo'),
33+
}"
34+
/>
35+
</record>
3136
<!-- pylint:disable=duplicate-xml-record-id -->
3237
<record id="chained_swapper_demo" model="chained.swapper">
3338
<field

chained_swapper/models/chained_swapper.py

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class ChainedSwapper(models.Model):
1414
model_id = fields.Many2one(
1515
comodel_name="ir.model",
1616
required=True,
17+
ondelete="cascade",
1718
help="Model is used for Selecting Field. This is editable "
1819
"until Contextual Action is not created.",
1920
)
@@ -23,6 +24,7 @@ class ChainedSwapper(models.Model):
2324
field_id = fields.Many2one(
2425
comodel_name="ir.model.fields",
2526
required=True,
27+
ondelete="cascade",
2628
domain="[('id', 'in', allowed_field_ids)]",
2729
)
2830
sub_field_ids = fields.One2many(

chained_swapper/readme/CONTRIBUTORS.rst

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
* Ernesto Tejeda
44
* Pedro M. Baeza
5+
6+
* Sunanda Chhatbar <sunanda.chhatbar@initos.com>

chained_swapper/security/ir.model.access.csv

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ access_chained_swapper_sub_field_user,chained.swapper.sub.field.user,model_chain
55
access_chained_swapper_sub_field_erp_manager,chained.swapper.sub.field.erp_manager,model_chained_swapper_sub_field,base.group_erp_manager,1,1,1,1
66
access_chained_swapper_constraint_user,chained.swapper.constraint.user,model_chained_swapper_constraint,base.group_user,1,0,0,0
77
access_chained_swapper_constraint_erp_manager,chained.swapper.constraint.erp_manager,model_chained_swapper_constraint,base.group_erp_manager,1,1,1,1
8+
access_chained_swapper_wizard,chained.swapper.wizard.constraint.erp_manager,model_chained_swapper_wizard,base.group_user,1,1,1,1

chained_swapper/tests/test_chained_swapper.py

+13-18
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from odoo import exceptions
66
from odoo.modules import registry
77
from odoo.tests import common
8+
from odoo.tests.common import Form
89

910
from ..hooks import uninstall_hook
1011

@@ -28,24 +29,18 @@ def setUpClass(cls):
2829
record = cls.env.ref("chained_swapper.chained_swapper_demo", False)
2930
if record:
3031
record.unlink()
31-
cls.chained_swapper = cls.env["chained.swapper"].create(
32-
{
33-
"name": "Language",
34-
"model_id": cls.env.ref("base.model_res_partner").id,
35-
"field_id": cls.env.ref("base.field_res_partner__lang").id,
36-
"sub_field_ids": [(0, 0, {"sub_field_chain": "child_ids.lang"})],
37-
"constraint_ids": [
38-
(
39-
0,
40-
0,
41-
{
42-
"name": "Only parent company",
43-
"expression": "bool(records.mapped('parent_id'))",
44-
},
45-
)
46-
],
47-
}
48-
)
32+
33+
chained_swapper_form = Form(cls.env["chained.swapper"])
34+
chained_swapper_form.name = "Language"
35+
chained_swapper_form.model_id = cls.env.ref("base.model_res_partner")
36+
chained_swapper_form.field_id = cls.env.ref("base.field_res_partner__lang")
37+
with chained_swapper_form.sub_field_ids.new() as sub_field_form:
38+
sub_field_form.sub_field_chain = "child_ids.lang"
39+
with chained_swapper_form.constraint_ids.new() as constraint_form:
40+
constraint_form.name = "Only parent company"
41+
constraint_form.expression = "bool(records.mapped('parent_id'))"
42+
43+
cls.chained_swapper = chained_swapper_form.save()
4944
cls.chained_swapper.add_action()
5045

5146
def test_create_unlink_action(self):

0 commit comments

Comments
 (0)