How to unlink record from Ony2Many relation?
One2Many Custom Model
_name = "purchase.shipment"
purchase_line_ids = fields.One2many('purchase.order.line', 'shipment_id', string='Shipment Lines')
Many2one Purchase Order Line
_inherit = "purchase.order.line"
shipment_id = fields.Many2one('purchase.shipment', string='Shipment', copy=False, ondelete='set null')
I have a wizard that add purchase lines to purchase.shipment table. purchase.shipment view has a page and inside I show lines in a tree and after tree there is Add Lines button that calls wizard to add lines and it works ok.
_name = 'purchase.shipment.lines'
_description = 'Adds/Links purchase order lines to shipment for all selected lines'
shipment_id = fields.Many2one('purchase.shipment', string="Shipment", required=True, default=_default_shipment)
purchase_order_lines = fields.Many2many('purchase.order.line', string="Purchase Order Lines")
self.shipment_id.purchase_line_ids |= self.purchase_order_lines
Now I want to remove/unlink line(s) from purchase.shipment line tree. By default there is delete icon on line item tree but it try to delete from purchase.order.line model. How to unlink purchase line from purchase.shipment. Odoo v12.