Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
2138 Переглядів

i have a Payment view (model is account.payment) in which it displays the bill section in tree view by click on that it redirects to that bill view (model is account.move) and shows tree view for products in it.

i want to show this tree view of products in Payment view. how to do it?

Note: I'm using odoo 15 community  version.

Аватар
Відмінити
Найкраща відповідь

Hi,

Try this,

class AccountPayment(models.Model):
_inherit = 'account.payment'

move_ids = fields.One2many('account.move.line', 'payment_id', string='Bill lines')

class AccountMove(models.Model):
_inherit = 'account.move'

payment_id = fields.Many2one('account.payment', string='Payment')
XML
<record id="view_account_payment_form" model="ir.ui.view">
<field name="name">account.payment.form</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_form"/>
<field name="arch" type="xml">
        <xpath expr="//field[@name='ref']" position="after">

            <page name="payment_lines" string="Payment Lines">
                 <field name="move_ids" widget="one2many_list">
             
<tree string="Requisitions Lines" editable="bottom">
// add required fields here
</tree>
</field>
<page>
</xpath>
</field>
</record>




Thanks
Аватар
Відмінити
Найкраща відповідь

Hi,

To display the tree view of products from the bill (account.move) directly in the Payment view (account.payment) in Odoo 15 Community version, you can achieve this by adding a custom related field to the Payment model that fetches the related products from the bill.

* Inherit the model "account.payment" and add related_product_ids Many2many field.
In Python:
class AccountPayment(models.Model):
    _inherit = 'account.payment'

    related_product_ids = fields.Many2many(
        'product.product',
        string='Related Products',
        compute='_compute_related_products',
        help='Products from the related bills'
    )

    @api.depends('invoice_ids')
    def _compute_related_products(self):
        for payment in self:
            related_products = payment.invoice_ids.mapped('invoice_line_ids.product_id')
            payment.related_product_ids = [(6, 0, related_products.ids)]

In XML:

<odoo>
    <data>

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

<field name="name">account.payment.form.inherit</field>

<field name="model">account.payment</field>

<field name="inherit_id" ref="account.view_account_payment_form"/>

            <field name="arch" type="xml">

                <field name="amount" position="after">

                    <field name="related_product_ids" widget="many2many_tags"/>

                </field>

            </field>

        </record>

    </data>

</odoo>


Hope it helps

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
груд. 23
2357
1
груд. 23
3750
1
лип. 23
2713
0
трав. 23
2519
1
лют. 23
2401