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.
You create a compute field for this purpose.
@api.one
def _foo(self):
print 'Foo'
action_compute = fields.Char(compute='_foo')
This function will work whenever you click a purchase order in tree view.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.