Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Widget "many2many_tags" not loading list of items

By
Anders Wallenquist
on 9/8/15, 9:19 AM 592 views
class account_invoice_serial(models.Model):
_name = 'account.invoice.serial'
_description = "Product serial numbers"
_order = 'name'

name = fields.Char('Serial Number',track_visibility='always')
line_id = fields.Many2one('account.invoice.line',)
product_id = fields.Many2one('product.product', string='Product',)


class account_invoice_line(models.Model):
_inherit = 'account.invoice.line'
serial_number_ids = fields.One2many(comodel_name='account.invoice.serial', inverse_name='line_id', string='Serial numbers', readonly=False, copy=False)


<record id="invoice_form" model="ir.ui.view">

<field name="name">account.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form" />
<field name="arch" type="xml"> <xpath expr="//tree/field[@name='name']" position="after"> <field name="serial_number_ids" widget="One2many_list" options="{'no_create': True, 'no_create_edit': True }" />
</xpath>
</field>
</record>


I want to display a list of "names", instead I get a list of record ids. Are there a better widget to use?

This is my current work-a-round:

class account_invoice_line(models.Model):
_inherit = 'account.invoice.line'
serial_number_ids = fields.One2many(comodel_name='account.invoice.serial', inverse_name='line_id', string='Serial numbers', readonly=False, copy=False)
def _serial_numbers(self):
self.serial_numbers = ', '.join([s.name for s in self.serial_number_ids])
serial_numbers = fields.Char('Serial Numbers',compute="_serial_numbers",readonly=True)

This is my current solution: class account_invoice_line(models.Model): _inherit = 'account.invoice.line' serial_number_ids = fields.One2many(comodel_name='account.invoice.serial', inverse_name='line_id', string='Serial numbers', readonly=False, copy=False) def _serial_numbers(self): self.serial_numbers = ', '.join([s.name for s in self.serial_number_ids]) serial_numbers = fields.Char('Serial Numbers',compute="_serial_numbers",readonly=True)

Anders Wallenquist
on 9/8/15, 9:24 AM

in this xml attribute widget="One2many_list" 'O' must be small like this widget="one2many_list"

Hardikgiri Goswami
on 9/8/15, 9:26 AM

Based on little R&D, there is nothing like this widget in the tree view. There is one widget called "many2many_tags" can be used in the tree view but I am not sure it can be used for one2many field. You can give it a try.

Hardikgiri Goswami
on 9/8/15, 9:29 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 9/8/15, 9:19 AM
Seen: 592 times
Last updated: 9/8/15, 9:29 AM