diff --git a/attribute_set/README.rst b/attribute_set/README.rst index 61f3cd08b..ae7eb1439 100644 --- a/attribute_set/README.rst +++ b/attribute_set/README.rst @@ -93,6 +93,7 @@ Contributors * Akretion Raphaël VALYI * David Dufresne * Denis Roussel +* Mohamed Alkobrosli Maintainers ~~~~~~~~~~~ diff --git a/attribute_set/readme/CONTRIBUTORS.rst b/attribute_set/readme/CONTRIBUTORS.rst index 85d78a198..ea443d206 100644 --- a/attribute_set/readme/CONTRIBUTORS.rst +++ b/attribute_set/readme/CONTRIBUTORS.rst @@ -4,3 +4,4 @@ * Akretion Raphaël VALYI * David Dufresne * Denis Roussel +* Mohamed Alkobrosli diff --git a/attribute_set/static/description/index.html b/attribute_set/static/description/index.html index 1ff803f5b..b7ab25513 100644 --- a/attribute_set/static/description/index.html +++ b/attribute_set/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -436,12 +436,15 @@

Contributors

  • Akretion Raphaël VALYI <raphael.valyi@akretion.com>
  • David Dufresne <david.dufresne@savoirfairelinux.com>
  • Denis Roussel <denis.roussel@acsone.eu>
  • +
  • Mohamed Alkobrosli <malkobrosly@kencove.com>
  • Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +Odoo Community Association +

    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.

    diff --git a/attribute_set/tests/test_custom_attribute.py b/attribute_set/tests/test_custom_attribute.py index 3594553b1..9d6620eba 100644 --- a/attribute_set/tests/test_custom_attribute.py +++ b/attribute_set/tests/test_custom_attribute.py @@ -71,3 +71,40 @@ def test_create_attribute_company_dependent(self): self.assertTrue( self.env["res.partner"]._fields[attribute.name].company_dependent ) + + def test_wizard_validate(self): + model_id = self.env["ir.model"].search([("model", "=", "res.partner")]) + attribute = self._create_attribute( + { + "attribute_type": "select", + "option_ids": [ + (0, 0, {"name": "Value 1"}), + (0, 0, {"name": "Value 2"}), + ], + "relation_model_id": model_id.id, + } + ) + PartnerModel = self.env["res.partner"] + partner = PartnerModel.create({"name": "John Doe"}) + vals = { + "attribute_id": attribute.id, + "option_ids": [[[attribute.id], partner.name, [partner.id]]], + } + OptionWizard = self.env["attribute.option.wizard"] + # attribute has only two options + len_2 = len(attribute.option_ids) + self.assertTrue(len_2 == 2) + # a new option should be created + wizard1 = OptionWizard.create(vals) + len_3 = len(attribute.option_ids) + self.assertTrue(len_3 > 2) + self.assertIn(partner.name, attribute.option_ids.mapped("name")) + vals = { + "attribute_id": attribute.id, + } + # no option should be created + # as option_ids key is not passed in vals + wizard2 = OptionWizard.create(vals) + len_default = len(attribute.option_ids) + self.assertTrue(wizard1 != wizard2) + self.assertEqual(len_default, len_3) diff --git a/attribute_set/wizard/attribute_option_wizard.py b/attribute_set/wizard/attribute_option_wizard.py index 36b8a9108..2e0df2ed2 100644 --- a/attribute_set/wizard/attribute_option_wizard.py +++ b/attribute_set/wizard/attribute_option_wizard.py @@ -22,6 +22,10 @@ class AttributeOptionWizard(models.TransientModel): default=lambda self: self.env.context.get("attribute_id", False), ondelete="cascade", ) + option_ids = fields.Many2many( + "attribute.option", + string="Attribute Options", + ) def validate(self): return True @@ -37,6 +41,8 @@ def create(self, vals): model = attr.relation_model_id.model name = self.env[model].browse(op_id).name_get()[0][1] + vals["option_ids"][0][1] = name + vals["option_ids"][0][0] = [vals["attribute_id"]] opt_obj.create( { "attribute_id": vals["attribute_id"], @@ -82,7 +88,7 @@ def fields_view_get( ) eview = etree.fromstring(res["arch"]) - options = etree.Element("field", name="option_ids", nolabel="1") + options = etree.Element("field", name="option_ids", widget="many2many_tags") placeholder = eview.xpath("//separator[@string='options_placeholder']")[0] placeholder.getparent().replace(placeholder, options) res["arch"] = etree.tostring(eview, pretty_print=True)