Edit: Abdullah thankyou we have almost the same code, it's doing the same thing; but I can't use the self in my python function as you do.
Hello I've made this js function that helps me to get the name of a field i'm clicking on:
odoo.define('app_catalogue_achat.index', function (require) {
"use strict";
var Model = require('web.Model')
var custom_model = new Model('app.history')
$(document).on('click', function() {
var domElement = $(event.target).val();
if (domElement)
// custom_model.call("write", [[55], {'product_id' : 1}])
custom_model.call('my_function', [[domElement]], {})
});
});
Plus this python function :
@api.model
def my_function(self, val, id):
print 'ok \n'
history_product_id = self.env['product.product'].search([('name', 'in', val)])
print history_product_id.id
# self.env['purchase.order'].create_history(history_product_id.id)
# self._get_month()
The python function translate the name i'm getting with js to my product id.
I get the good product id and i want to display it in a tree view (history) that is under my purchase order.
The main problem is that i can't use self in the pyhton function.
Self only working when I'm using an onchange function on the product id of the history tree view.
But when I try to add dynamicly the value that i get with js, I can't use self.
So I coudln't do self.product_id = my val
or any other solution using self.
Even in the purchase order.