Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1166 Vistas

I need to show only the related products on the order line. How??

from odoo import models, fields, api

class SaleOrder(models.Model):
    _inherit = 'sale.order'
    order_type_id = fields.Many2one('sales.order.type', string='Order Type')

    @api.depends('order_type_id')
    def _compute_product_domain(self):
        for order in self:
            if order.order_type_id:
                order.product_id_domain = order.order_type_id.product_ids.ids
            else:
                order.product_id_domain = []
 # Kosongkan jika tidak ada order type
from odoo import models, fields

class SalesOrderType(models.Model):
    _name = 'sales.order.type'
    _description = 'Sales Order Type'
    name = fields.Char(string='Type Name', required=True)
    product_ids = fields.Many2many('product.product', string='Related Products')
from odoo import models, fields

class ProductProduct(models.Model):
    _inherit = 'product.product'
    order_type_ids = fields.Many2many('sales.order.type', string='Order Types')
Avatar
Descartar
Mejor respuesta

Hi, you can inherit the sale order view and add a domain on the product field using XPath. Let me know if you need any further assistance.

Thank you

Avatar
Descartar
Autor

Im sorry, but is it possible to make all of the non-related products disappear?

Mejor respuesta

You need to apply a domain on the product field using XPath.

[('order_type_ids', '=', parent.order_type_id)]

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
sept 24
1198
3
jun 16
6183
1
sept 24
41
3
may 24
1856
1
ene 23
6708