I have a button on purchase.order which does something I want to run the function of the button automatically when Purchase order is created form Sale Order which is done via Procurement.
I think this is also possible through javascript when the screen loads(do not know much js).
class Purchase_Order(models.Model):
_inherit = 'purchase.order'
@api.multi
def _unlink_imprint_charges(self):
self.env['purchase.order.line'].search(['&', ('order_id', '=', self.ids), ('is_charge', '=', True)]).unlink()
@api.multi
def charge_set_po(self):
self._unlink_imprint_charges()
for obj in self.order_line:
obj.env['purchase.order.line']._add_imprint_location(obj, self)
I want to call the charge_set_po function when urser clicks on the PO or when Procurement is done.