Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
1774 Zobrazení

Hi Peeps.

Im making an app for odoo 15 and im facing an issue in the form view.

I have an one2many filed (lines) called chargable_lines. For a reason i cannot target why the lines do not show my fields whatsoever.

here is a video of the code and the view
https://videoserver.wcgdoc.com/index.php/s/bf69P4YsgE3AAxo

thanks in advance

               

               

               

               

               

           

       

   


Avatar
Zrušit
Nejlepší odpověď

Hi,


If your One2many field (chargable_lines) isn't showing any fields in the form view, it's likely because the view is missing a proper <tree> or <form> layout.


Please try with the following code.


<record id="view_wh_charges_form" model="ir.ui.view">
<field name="name">wh.charges.form</field>
<field name="model">wh.charges</field>
<field name="arch" type="xml">
<form string="Warehouse Charges">
<sheet>
<group>
<group>
<field name="name"/>
<field name="partner_id"/>
<field name="date"/>
<field name="related_invoice_id"/>
<field name="currency_id"/>
</group>
<group>
<field name="total_bill"/>
</group>
</group>
<notebook>
<page string="Charges">
<field name="chargable_lines">
<tree editable="bottom">
<field name="product_id"/>
<field name="price"/>
<field name="billed_qty"/>
<field name="total"/>
<field name="currency_id"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>




Hope it helps.

Avatar
Zrušit
Nejlepší odpověď

Hi,
Have a  look at this: Working Of One2Many Fields in Odoo

Thanks

Avatar
Zrušit
Nejlepší odpověď

Hello Pete Charalampopoulos,


I hope you're doing well.


I noticed that there is no relation field between the two models in the tree view. If you haven't already created a relationship between these tables, you'll need to do so. I've shared the code below for your reference:

Python:

class WhCharges(models.Model):

    _name = 'wh.charges'

    

    # Add a One2many field to create a relation with 'wh.charges.line'

    wh_changes_id = fields.One2many('wh.charges.line', 'wh_changes_id')


class WhChargesLine(models.Model):

    _name = 'wh.charges.line'

    

    # Add a Many2one field to create a relation with 'wh.charges'

    wh_changes_id = fields.Many2one('wh.charges')


This should establish the internal link between the two models.

Hope this helps!


Thanks & Regards,

Name : Yahoo Baba

Email:  yahoobaba077@gmail.com

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
4
kvě 25
695
1
lis 24
1113
2
kvě 25
495
1
úno 25
1003
1
úno 25
688