<t t-extend="template_name">
<t t-jquery="[div,span,button,etc].class_name" t-operation="[replace,after,before]">
<-- your code -->
</t>
</t>
for example :
<t t-extend="website_sale.products_item">
<t t-jquery="div.product_price" t-operation="replace">
<-- your code -->
</t>
</t>
Showing posts with label Jquery in odoo. Show all posts
Showing posts with label Jquery in odoo. Show all posts
Wednesday, 17 June 2020
Odoo10 - How to inherit t-if tag and extend it template.
Labels:
#docker,
#error,
#odoo,
#odoo11,
#odoo12,
#openerp,
#ubuntu,
erp,
Jquery in odoo,
js,
many2many,
map view,
model,
Odoo,
OpenERP,
OpenERP v8
Wednesday, 15 March 2017
ValueError Expected singleton in Odoo
Expected Singleton:
Class methods required single invoking object (Single Browsable Record) to invoke the method and suppose it will call by multiple invoking objects (Browsable Recordsets) then method is not able to identify for which object it should process, therefore it will raise an error Expected Singleton.
New API decorator is used to define method calling pattern whether methods allows only single object or multiple objects to invoke this method.
For Example:
if self.location_id: #face ValueError Expected singleton because self contains multiple recordset.
########
Need to change with following:
for warehouse in self:
if warehouse.location_id:
########
@api.one
This decorator loops automatically on Records of RecordSet for you. Self is redefined as current record
Note:
Caution: the returned value is put in a list. This is not always supported by the web client, e.g. on button action
methods. In that case, you should use @api.multi to decorate your method, and probably call self.ensure_one() in
the method definition.
@api.multi
Self will be the current RecordSet without iteration. It is the default behavior (multiple browsable objects). Methods which returns non premitive type data(list, dictionary, function) must be decorated with @api.multi
@api.model
This decorator will convert old API calls to decorated function to new API signature. It allows to be polite when
migrating code. Self does not contain any record/recordset in methods which are decorated by this decorator.
So simply call like this
self.env['model_name'].method_name(arguments)
Class methods required single invoking object (Single Browsable Record) to invoke the method and suppose it will call by multiple invoking objects (Browsable Recordsets) then method is not able to identify for which object it should process, therefore it will raise an error Expected Singleton.
New API decorator is used to define method calling pattern whether methods allows only single object or multiple objects to invoke this method.
For Example:
if self.location_id: #face ValueError Expected singleton because self contains multiple recordset.
########
Need to change with following:
for warehouse in self:
if warehouse.location_id:
########
@api.one
This decorator loops automatically on Records of RecordSet for you. Self is redefined as current record
Note:
Caution: the returned value is put in a list. This is not always supported by the web client, e.g. on button action
methods. In that case, you should use @api.multi to decorate your method, and probably call self.ensure_one() in
the method definition.
@api.multi
Self will be the current RecordSet without iteration. It is the default behavior (multiple browsable objects). Methods which returns non premitive type data(list, dictionary, function) must be decorated with @api.multi
@api.model
This decorator will convert old API calls to decorated function to new API signature. It allows to be polite when
migrating code. Self does not contain any record/recordset in methods which are decorated by this decorator.
So simply call like this
self.env['model_name'].method_name(arguments)
Labels:
create,
erp,
JavaScript for odoo v8,
Jquery in odoo,
JScript for odoo,
module,
Odoo,
odoo9,
open source,
OpenERP,
OpenERP v8,
Point Of Sale,
Procurement,
Ubuntu 12.04,
Ubuntu server
one2many, many2many, many2one field in openerp
In OpenERP/Odoo, we have one2many and many2many datatype field. For add, update, delete we have some trick to link with record, which are listed below.
1. (0, 0, { values }) link to a new record that needs to be created with the given values dictionary
2. (1, ID, { values }) update the linked record with id = ID (write *values* on it)
3. (2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
4. (3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
5. (4, ID) link to existing record with id = ID (adds a relationship)
6. (5) unlink all (like using (3,ID) for all linked records)
7. (6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)
1. (0, 0, { values }) link to a new record that needs to be created with the given values dictionary
2. (1, ID, { values }) update the linked record with id = ID (write *values* on it)
3. (2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
4. (3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
5. (4, ID) link to existing record with id = ID (adds a relationship)
6. (5) unlink all (like using (3,ID) for all linked records)
7. (6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)
Tuesday, 7 March 2017
How to call a wizard from js in odoo ?
this.do_action({
type: 'ir.actions.act_window',
res_model: 'Model name',
view_mode: 'form',
view_type: 'form',
views: [[false, 'form']],
target: 'new',
context:{}
});
type: 'ir.actions.act_window',
res_model: 'Model name',
view_mode: 'form',
view_type: 'form',
views: [[false, 'form']],
target: 'new',
context:{}
});
Monday, 6 March 2017
How to Store Image in binary field from system path in odoo ?
def get_file(self, cr, uid, ids, field_name=None, arg=None,context=None):result = dict.fromkeys(ids)for record_browse in self.browse(cr, uid, ids):addons_path = http.addons_manifest['web']['addons_path']f = open(os.path.join(addons_path,'modulename','static','src','img', 'image.png'), 'rb')result[record_browse.id] = base64.encodestring(f.read())f.close()return result_columns = {
'web_icon': fields.function(get_file, method=True,store=False,type='binary',string="Download File"),}
Tuesday, 21 February 2017
How to Make Custom Keyboard shortcuts for odoo ?
Here, i will show you some example to get custom shortcuts works in odoo. you can also override default shortcuts in odoo. as you can see for that we have to create one js file in out module. the path of the file is module / static / src / js / file_js.js
and put the below code into file .
//Edit the current object F2
with this user can save the record with F2 button.
so as simple way we can also create record, delete record, make tree view to unlimited , remove the filter , open calendar and so many things using key board key.
and put the below code into file .
$.shortcut = function(key, callback, args) {$(document).keydown(function(e) {if(!args) args=[]; // IE barks when args is nullconsole.log(e.keyCode)if((e.keyCode == key.charCodeAt(0) || e.keyCode == key)) {callback.apply(this, args);return false;}});};
//Edit the current object F2
$.shortcut('113', function() {$('.oe_form_button_edit').each(function() {if($(this).parents('div:hidden').length == 0){$(this).trigger('click');}});});
with this user can save the record with F2 button.
so as simple way we can also create record, delete record, make tree view to unlimited , remove the filter , open calendar and so many things using key board key.
Friday, 18 September 2015
How can we use JQ or JavaScript for a specific field in Odoo v8? | OpenERP
Add id for particular field in XML
than add js code in js file like below:
openerp.module_name = function(instance) {
var QWeb = openerp.web.qweb;
_t = instance.web._t;
instance.web.FormView.include({
load_form: function(data) {
var self = this;
this.$el.find('#field id').on('change', function() {
alert( this.value ); // or $(this).val()
// here put your logic for validation field.
});
return self._super(data);
},
});
};
Subscribe to:
Posts (Atom)