Skip to Content
Menu
This question has been flagged

I have this module that allows to select the category of product that going to be used for this purchase, because we have a lot of products this a way to limit the search result,

but the problem is all the info related to order_id field are available after the product is selected, for example state, if we make state visible in the order line it value is there only after selecting a product, the same for my field category, is someone have an idea to fix this.

I am using odoo 11.0


from odoo import api, fields, models

class PurchaseOrder(models.Model):
_inherit = "purchase.order"

category = fields.Many2one('product.category',  )


class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"

category = fields.Many2one (related='order_id.category', string='Cat', readonly=True, store=True)

product_id = fields.Many2one('product.product', domain="['&', ('categ_id','=',category), ('purchase_ok', '=', True)]",
string='Product', change_default=True, required=True)

Avatar
Discard
Related Posts Replies Views Activity
1
Mar 21
1676
0
Mar 17
2835
0
Dec 24
29
1
Dec 24
40
0
Nov 24
29