Skip to Content
मेन्यू
This question has been flagged

Hello everybody

I need to get the value date from account.payment and show it in payment_day field in sale.order.form, tried with Many2one but i need select a value.

I need that payment_date value have the same value as date for all registers

I appreciate your help.

Thanks a lot!!! 

#==============================model=================================
# -*- coding: utf-8 -*-

from odoo import models, fields, api

class SaleOrder(models.Model):
_inherit = 'sale.order'


payment_day = fields.Date(string='Fecha de Pago')

#==============================view=================================




sale.order.inherit
sale.order









Avatar
Discard
Best Answer

Hi Try this:

from odoo import models, fields, api


class SaleOrder(models.Model):

    _inherit = 'sale.order'


    payment_day = fields.Date(string='Fecha de Pago', compute='_compute_payment_day', store=True)


    @api.depends('payment_ids.payment_date')

    def _compute_payment_day(self):

        for order in self:

            if order.payment_ids:

                order.payment_day = order.payment_ids[0].payment_date

            else:

                order.payment_day = False

In "_compute_payment_day" method, we check if there are related payment records for each sale order ("payment_ids"). If there are any, we set the "payment_day" field to the date of the first payment record.


Hope it helps

Avatar
Discard
Related Posts Replies Views Activity
3
अप्रैल 19
3633
2
मार्च 15
6238
3
मई 25
2615
1
अप्रैल 25
1965
3
सित॰ 24
15282