Hii,
One2Many Custom Model
class PurchaseShipment(models.Model):
_name = "purchase.shipment"
purchase_line_ids = fields.One2many('purchase.order.line', 'shipment_id', string='Shipment Lines')
Many2one Purchase Order Line
class PurchaseOrderLine(models.Model):
_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.
class PurchaseShipmentLines(models.TransientModel):
_name = 'purchase.shipment.lines'
_description = 'Adds/Links purchase order lines to shipment for all selected lines'
def _default_shipment(self):
return self.env['purchase.shipment'].browse(self._context.get('active_id'))
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")
@api.multi
def add_to_shipment(self):
self.shipment_id.purchase_line_ids |= self.purchase_order_lines
return {}
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.
Thanks,