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

I have created a custom Char field my_field​ in my sales order model. I want to display that field's value in purchase order line. I can do it using .write()​ method but, I have to directly update it through the default function without using .write()​.

This is my current sales order model:

`

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

    my_field = fields.Char(string="My Field")
    def _prepare_purchase_order_line_data(self, so_line, date_order, company):
        res = super(InheritSaleOrder, self)._prepare_purchase_order_line_data(so_line, date_order, company)
        res.update({
            "my_field": so_line.order_id.my_field,
        })
        return res

    def _prepare_invoice(self):
        res = super(InheritSaleOrder, self)._prepare_invoice()
        res.update({
            "my_field": self.my_field,
        })
        return res
`

I got this predefined function _prepare_purchase_order_line_data​ but it doesn't seem to be working. It is not passing the value to purchase order line(I have created the same custom field in my purchase order line model).

For context, I've successfully used a similar approach with the _prepare_invoice​ method to pass the value to invoices.

Does any one knows a way to do this

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
серп. 22
1289
0
груд. 15
5642
1
лют. 24
1608
0
вер. 21
2411
4
січ. 20
5749