# Add \`scan\_code = "loop"\` via \`view\_attributes\`

**URL:** <https://discuss.tryton.org/t/add-scan-code-loop-via-view-attributes/8258>\
**Category:** Developer\
**Created:** [January 29, 2025, 2:08pm UTC](https://discuss.tryton.org/t/add-scan-code-loop-via-view-attributes/8258 "2025-01-29T14:08:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![udono](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/udono/32/2114_2.png) [@udono](https://discuss.tryton.org/u/udono)\
**Post date:** [January 29, 2025, 2:08pm UTC](https://discuss.tryton.org/t/add-scan-code-loop-via-view-attributes/8258/1 "2025-01-29T14:08:25Z")

</div>

I would like to add `scan_code = "loop"` via `view_attributes` into some views.

```auto
    @classmethod
    def view_attributes(cls):
        return super().view_attributes() + [
            ('/form', 'scan_code', 'loop')
            ]

```

The resulting view `arch`(-itechture) in [`trytond/model/modelview.py:parse_view`](https://foss.heptapod.net/tryton/tryton/-/blob/0f32ebc21be37821dd7113e68ced5fc6a4edd175/trytond/trytond/model/modelview.py#L537) creates the following form XML:

```auto
<form scan_code="&quot;loop&quot;" scan_code_depends="[&quot;lines&quot;]">
…

```

I would expect it creates this XML:

```auto
<form scan_code="loop" scan_code_depends="[lines]">
…

```

Is `view_attributes` not the right tool and it is better to use

> [@Use view\_attributes to change the string](https://discuss.tryton.org/t/use-view-attributes-to-change-the-string/1423/3):
>
> > [@Use view\_attributes to change the string](https://discuss.tryton.org/t/use-view-attributes-to-change-the-string/1423/1):
> >
> > I need to change the string of some fields. is it possible using view\_attributes?
> 
> Indeed you can use the view inheritance with the `replace_attributes` as position: [Extending View — Tryton server](http://docs.tryton.org/projects/server/en/latest/topics/views/extension.html?highlight=replace_attributes#extending-view)

WDYT?

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [January 29, 2025, 3:01pm UTC](https://discuss.tryton.org/t/add-scan-code-loop-via-view-attributes/8258/2 "2025-01-29T15:01:34Z")

</div>

No use [view extension](https://docs.tryton.org/latest/server/topics/views/extension.html#topics-extension).

---

<div class="post-metadata">

**Author:** ![udono](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/udono/32/2114_2.png) [@udono](https://discuss.tryton.org/u/udono)\
**Post date:** [February 3, 2025, 4:20pm UTC](https://discuss.tryton.org/t/add-scan-code-loop-via-view-attributes/8258/3 "2025-02-03T16:20:13Z")

</div>

Closed on February 3, 2025, 4:20pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
