Odoo Missing Dependencies: web.ControlPanelMixin - odoo

I'm trying to install some module In Odoo 13 Community. The dependency 'web.ControlPanelMixin' is missing, I'm trying to fing the problem, so far I got no succes.
The JavaScript Code:
odoo.define('crm_dashboard.dashboard', [
'web.core',
'web.framework',
'web.session',
'web.ajax',
'web.ActionManager',
'web.view_registry',
'web.Widget',
'web.AbstractAction',
'web.ControlPanelMixin'
], function (require) {
"use strict";
var core = require('web.core');
var framework = require('web.framework');
var session = require('web.session');
var ajax = require('web.ajax');
var ActionManager = require('web.ActionManager');
var view_registry = require('web.view_registry');
var Widget = require('web.Widget');
var AbstractAction = require('web.AbstractAction');
var ControlPanelMixin = require('web.ControlPanelMixin');
var QWeb = core.qweb;
...
});
I tried searching for where is 'web.ControlPanelMixin' declared:
[odoo-13.0]$ grep -rnw ./ -e 'ControlPanelMixin'
./doc/reference/javascript_reference.rst:2221: var ControlPanelMixin = require('web.ControlPanelMixin');
./doc/reference/javascript_reference.rst:2224: var ClientAction = AbstractAction.extend(ControlPanelMixin, {
./doc/reference/javascript_reference.rst:2262:- add ControlPanelMixin in the widget:
./doc/reference/javascript_reference.rst:2266: var ControlPanelMixin = require('web.ControlPanelMixin');
./doc/reference/javascript_reference.rst:2268: var MyClientAction = AbstractAction.extend(ControlPanelMixin, {
./doc/reference/javascript_reference.rst:2277: var SomeClientAction = Widget.extend(ControlPanelMixin, {
./mymodules/odoo_crm_dashboard/static/src/js/crm_dashboard.js:11: 'odoo.web.ControlPanelMixin'
./mymodules/odoo_crm_dashboard/static/src/js/crm_dashboard.js:25:var ControlPanelMixin = require('web.ControlPanelMixin');
./mymodules/odoo_crm_dashboard/static/src/js/crm_dashboard.js:31:var CRMDashboardView = AbstractAction.extend(ControlPanelMixin, {
Thank you!

I think there is a mistake:
odoo.define('crm_dashboard.dashboard', [
'web.core',
'web.framework',
'web.session',
'web.ajax',
'web.ActionManager',
'web.view_registry',
'web.Widget',
'web.AbstractAction',
'web.ControlPanelMixin'
]
It is web.ControlPanelMixin not odoo.web.ControlPanelMixin
You can review this documentation

ControlPanelMixin was removed in Odoo 13.0.
Instead of extending from it, objects can now use hasControlPanel: true. See the Odoo source code for an example.

Related

API integration using google app script calling methods on google sheets

I would like to add different API request on a spreadsheet where i already add some google app script code from here in oder to retrieve all orders from a woocommerce external source, however now i want to add another API calling request which allows me to list all products on my woocommerce source. So i type a new function below, modify the endpoint to /wp-json/wc/v3/products according to woocommerce API rest documentation here Woocommerce API rest doc. Here is the code i add to the Github code :
// Custom code to v2 Woocommerce API
function start_syncv2() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(Products);
fetch_products(sheet)
}
function fetch_products(sheet) {
var ck = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(OrderDetails).getRange("B4").getValue();
var cs = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(OrderDetails).getRange("B5").getValue();
var website = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(OrderDetails).getRange("B3").getValue();
var surl = website + "/wp-json/wc/v3/sheet?consumer_key=" + ck + "&consumer_secret=" + cs + "&after=" + "&per_page=100";
var url = surl
Logger.log(url)
var options =
{
"method": "GET",
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
"muteHttpExceptions": true,
};
var result = UrlFetchApp.fetch(url, options);
Logger.log(result.getResponseCode())
if (result.getResponseCode() == 200) {
var params = JSON.parse(result.getContentText());
Logger.log(result.getContentText());
}
var doc = SpreadsheetApp.getActiveSpreadsheet();
var temp = SpreadsheetApp.getSheetByName(sheet);
var consumption = {};
var arrayLength = params.length;
Logger.log(arrayLength)
for (var i = 0; i < arrayLength; i++) {
Logger.log("dfsfsdfsf")
var a;
var container = [];
a = container.push(params[i]["id"]);
Logger.log(a)
a = container.push(params[i]["name"]);
a = container.push(params[i]["sku"]);
a = container.push(params[i]["price"]);
a = container.push(params[i]["tax_status"]);
a = container.push(params[i]["stock_status"]);
a = container.push(params[i]["categories"]["name"]);
a = container.push(params[i]["images"]);
a = container.push(params[i]["attributes"]["options"]);
a = container.push(params[i]["_links"]["self"]["href"]);
var doc = SpreadsheetApp.getActiveSpreadsheet();
var temp = doc.getSheetByName(sheet);
temp.appendRow(container);
}
}
I have issue using google sheets calling method describe here. As i want my new API call request, i think my main problem is to select the right sheet into the spreadsheet.
Here is a copy of my spreadsheet : Woocommerce-google sheets integration

Mongoose require model in model

i want to use a static-method from another model in a model. But when i require the other model and call the function:
TypeError: Cannot read property 'isCalculated' of undefined
so.. is it not possible to require a model in another model? :(
The models are in the same folder, so I call
var Confirmation = require("./confirmation").Confirmation;
and export in confirmation:
module.exports = {
Confirmation: mongoose.model('Confirmation', confirmationSchema)
};
Thanks :)
Update: The code:invoice.js
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var autoIncrement = require('mongoose-auto-increment');
var Moment = 'Moment';
var moment = require('moment');
var Currency = mongoose.Types.Currency;
var Confirmation = require("./confirmation.js");
autoIncrement.initialize(mongoose.connection);
var invoiceSchema = new Schema({...}); //invoiceSchema
invoiceSchema.statics.insert= function(invoice, cb) {
....
Confirmation.isCalculated(..) //error here
....
}
module.exports = mongoose.model("Invoice", invoiceSchema);
And the code of: confirmation.js
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var Invoice = require("./invoice.js");
var confirmationSchema = new Schema({...});
confirmationSchema.statics.isCalculated = function(pid, aid, cb) {...};
module.exports = mongoose.model('Confirmation', confirmationSchema)
My guess would be that because of your circular imports (confirmation.js requires invoice.js which requires confirmation.js...), the Confirmation model in your invoice.js isn't materialized properly.
I think you should remove the circular imports altogether and dynamically get a reference to "the other" model using mongoose.model(), like so:
invoiceSchema.statics.insert = function(invoice, cb) {
....
mongoose.model('Confirmation').isCalculated(..)
....
}

function + module.exports

I have a problem with module.export on titanium. I tried following https://wiki.appcelerator.org/display/guides/CommonJS+Modules+in+Titanium but it doesn't work at all.
I have 2 little pieces of code. App.js:
var fenetreBase = Titanium.UI.createWindow({fullscreen:true,backgroundColor:"white",exitOnClose:true});
fenetreBase.open();
var vueimage = new (require('UI/viewimage'))();
vueimage.test();
fenetreBase.add(vueimage);
and viewimage.js in the folder UI.
function viewimage() {
var lavue = Ti.UI.createView({backgroundColor:'red' });
var item =...
lavue.add(item...);
return lavue;
}
viewimage.prototype.test = function() {
Ti.API.info("test");
};
module.exports = viewimage;
I have an error saying
Object #<view> has no method 'test' in app.js vueimage.test()
In my mind, I follow the example of "Instantiable Objects" in the wiki above but I may have not understand something. I expect I made a stupid mistake. I tried many other things, each uglier than other and it doesn't work anyway.
Can somebody tell me where the mistake is?
your mistake is assuming that you have an instance of viewimage when you run:
var vueimage = new (require('UI/viewimage'))();
you are getting an instance of
var lavue = Ti.UI.createView({backgroundColor:'red' });
which doesn't have a test property.
Perhaps you could use an object like this instead:
function viewimage() {
var result = {};
var lavue = Ti.UI.createView({backgroundColor:'red' });
var item =...
lavue.add(item...);
result.lavue = lavue;
result.test = function() {
Ti.API.info("test");
};
return result;
}
EDIT
In your App.js:
var vueimage = new (require('UI/viewimage'))();
vueimage.test();
fenetreBase.add(vueimage.lavue);

knockout mapping to be done only first time

I am generating the knockout mapping from server side view model using below
var bindData2ViewModel = function (data) {
var rdata = ko.toJSON(data);
ko.mapping.fromJSON(rdata, {}, vm.model());
ko.applyBindings(vm);
};
var CustomerViewModel = function () {
var self = this;
self.model = ko.observable({});
return { model: self.model };
};
var vm = new CustomerViewModel();
now there is another call which is giving me the data... i just want to bind that data to the client side viewmodel without changing the binding... how to do that?
var rebindData2ViewModel = function (data) {
var rdata = ko.toJSON(data);
vm.model.set(rdata);
ko.applyBindings(vm);
};
tried above but not working... what is the correct way to do this?
basically to rebind the data to the existing model.. you just need to set the data using the angular brackets.. no need of json etc... because data should itself return as jsonresult
var rebindData2ViewModel = function (data) {
vm.model(data);
};

Mootools variable scope issues

I have a problem getting my mind round variable scope and could do with some help :)
I'm setting up a module in joomla that will rotate images. I've a bit of code I've used on non Joomla sites that works fine. However I've ported it and I'm running into problems that I think are variable scope issues so any thoughts would be great.
Sorry for the long code but I included the whole function in case (when it works) it might help someone else.
function slideshow(container,containerCaption,previewCode,timer,classis,headerId,thumbOpacity,titlebar){
var showDuration = timer;
var container = $(container);
var images = $(container).getElements('span');
var currentIndex = 0;
var interval;
var preview = new Element('div',{
id: containerCaption,
styles: {
opacity: thumbOpacity
}
}).inject(container);
preview.set('html',previewCode);
images.each(function(img,i){
if(i > 0) {
img.set('opacity',0);
}
});
var show = function() {
images[currentIndex].fade('out');
images[currentIndex = currentIndex < images.length - 1 ? currentIndex+1 : 0].fade('in');
var title = '';
var captionText = '';
if(images[currentIndex].get('alt')) {
cap = images[currentIndex].get('alt').split('::');
title = cap[0];
captionText = cap[1];
urltoUse = cap[2];
preview.set('html','<span class="lctf1"><ahref="'+urltoUse+'">'
+ title + '</a></span>'
+ (captionText ? '<p>' + captionText + '</p>' : ''));
}
};
window.addEvent('domready',function(){
interval = show.periodical(showDuration);
});
}
window.addEvent('domready',function() {
container = "slideshow-container";
containerCaption ="slideshow-container-caption";
previewCode = '<span ><?php echo $itemtitle[0];?></span><p ><?php echo $itemdesc[0];?></p>';
timer = <?php echo $slidetime*1000;?>;
classis = 1;
headerId = "";
thumbOpacity =0.7;
titlebar = "<?php echo $showTitle;?>";
if($(container)){
slideshow(container,containerCaption,previewCode,timer,classis,headerId,thumbOpacity,titlebar);
}
});
The javascript error being thrown is that preview is undefined.
Your code seems to work, I made a jsfiddle here: http://jsfiddle.net/7E2MX/3/ which runs with no errors.
I did change one line though:
var images = $(container).getElements('span');
to
var images = $(container).getElements('img');