Merge branch 'master-riddhi-05072018' into 'master-patch-july-2018'

Master riddhi 05072018

See merge request flectra-hq/flectra!106
This commit is contained in:
Parthiv Patel 2018-07-19 12:38:55 +00:00
commit 05250730da
4 changed files with 87 additions and 20 deletions

View File

@ -131,6 +131,9 @@ FormRenderer.include({
'click .oe_dashboard_link_change_layout': '_onChangeLayout', 'click .oe_dashboard_link_change_layout': '_onChangeLayout',
'click .oe_dashboard_column .oe_close': '_onCloseAction', 'click .oe_dashboard_column .oe_close': '_onCloseAction',
}), }),
custom_events: _.extend({}, FormRenderer.prototype.custom_events, {
switch_view: '_onSwitchView',
}),
/** /**
* @override * @override
@ -140,6 +143,7 @@ FormRenderer.include({
this.noContentHelp = params.noContentHelp; this.noContentHelp = params.noContentHelp;
this.actionsDescr = {}; this.actionsDescr = {};
this._boardSubcontrollers = []; // for board: controllers of subviews this._boardSubcontrollers = []; // for board: controllers of subviews
this._boardFormViewIDs = {}; // for board: mapping subview controller to form view id
}, },
/** /**
* Call `on_attach_callback` for each subview * Call `on_attach_callback` for each subview
@ -266,6 +270,11 @@ FormRenderer.include({
hasSelectors: false, hasSelectors: false,
}); });
return view.getController(self).then(function (controller) { return view.getController(self).then(function (controller) {
self._boardFormViewIDs[controller.handle] = _.first(
_.find(action.views, function (descr) {
return descr[1] === 'form';
})
);
self._boardSubcontrollers.push(controller); self._boardSubcontrollers.push(controller);
return controller.appendTo(params.$node); return controller.appendTo(params.$node);
}); });
@ -384,6 +393,16 @@ FormRenderer.include({
$action.find('.oe_content').toggle(); $action.find('.oe_content').toggle();
this.trigger_up('save_dashboard'); this.trigger_up('save_dashboard');
}, },
/**
* Let FormController know which form view it should display based on the
* window action of the sub controller that is switching view
*
* @private
* @param {OdooEvent} event
*/
_onSwitchView: function (event) {
event.data.formViewID = this._boardFormViewIDs[event.target.handle];
},
}); });
}); });

View File

@ -272,6 +272,51 @@ QUnit.test('can open a record', function (assert) {
form.destroy(); form.destroy();
}); });
QUnit.test('can open record using action form view', function (assert) {
assert.expect(1);
var form = createView({
View: FormView,
model: 'board',
data: this.data,
arch: '<form string="My Dashboard">' +
'<board style="2-1">' +
'<column>' +
'<action context="{}" view_mode="list" string="ABC" name="51" domain="[]"></action>' +
'</column>' +
'</board>' +
'</form>',
mockRPC: function (route) {
if (route === '/web/action/load') {
return $.when({
res_model: 'partner',
views: [[4, 'list'], [5, 'form']],
});
}
return this._super.apply(this, arguments);
},
archs: {
'partner,4,list':
'<tree string="Partner"><field name="foo"/></tree>',
'partner,5,form':
'<form string="Partner"><field name="display_name"/></form>',
},
intercepts: {
do_action: function (event) {
assert.deepEqual(event.data.action, {
res_id: 1,
res_model: 'partner',
type: 'ir.actions.act_window',
views: [[5, 'form']],
}, "should do a do_action with correct parameters");
},
},
});
form.$('tr.o_data_row td:contains(yop)').click();
form.destroy();
});
QUnit.test('can drag and drop a view', function (assert) { QUnit.test('can drag and drop a view', function (assert) {
assert.expect(4); assert.expect(4);

View File

@ -21,6 +21,8 @@ BANNED_DEVICES = {
"0424:9514", # Standard Microsystem Corp. Builtin Ethernet module "0424:9514", # Standard Microsystem Corp. Builtin Ethernet module
"1d6b:0002", # Linux Foundation 2.0 root hub "1d6b:0002", # Linux Foundation 2.0 root hub
"0424:ec00", # Standard Microsystem Corp. Other Builtin Ethernet module "0424:ec00", # Standard Microsystem Corp. Other Builtin Ethernet module
"0424:2514", # Standard Microsystems Corp. USB 2.0 Hub (rpi3b+)
"0424:7800", # Standard Microsystems Corp. (rpi3b+)
} }
@ -100,11 +102,12 @@ class Proxy(http.Controller):
""" """
if debug is None: if debug is None:
resp += """(<a href="/hw_proxy/status?debug">debug version</a>)""" resp += """(<a href="/hw_proxy/status?debug">debug version</a>)"""
devices = subprocess.check_output("lsusb").split('\n') devices = subprocess.check_output("lsusb").decode('utf-8').split('\n')
count = 0 count = 0
resp += "<div class='devices'>\n" resp += "<div class='devices'>\n"
for device in devices: for device in devices:
device_name = device[device.find('ID')+2:] device_name = device[device.find('ID')+2:]
if device_name: # to avoid last empty line
device_id = device_name.split()[0] device_id = device_name.split()[0]
if not (device_id in BANNED_DEVICES): if not (device_id in BANNED_DEVICES):
resp += "<div class='device' data-device='"+device+"'>"+device_name+"</div>\n" resp += "<div class='device' data-device='"+device+"'>"+device_name+"</div>\n"
@ -124,7 +127,7 @@ class Proxy(http.Controller):
%s %s
</pre> </pre>
""" % subprocess.check_output('lsusb -v', shell=True) """ % subprocess.check_output('lsusb -v', shell=True).decode('utf-8')
return request.make_response(resp,{ return request.make_response(resp,{
'Cache-Control': 'no-cache', 'Cache-Control': 'no-cache',

View File

@ -28,7 +28,7 @@ except ImportError:
def _toledo8217StatusParse(status): def _toledo8217StatusParse(status):
""" Parse a scale's status, returning a `(weight, weight_info)` pair. """ """ Parse a scale's status, returning a `(weight, weight_info)` pair. """
weight, weight_info = None, None weight, weight_info = None, None
stat = ord(status[status.index('?') + 1]) stat = status[status.index(b'?') + 1]
if stat == 0: if stat == 0:
weight_info = 'ok' weight_info = 'ok'
else: else:
@ -68,17 +68,17 @@ Toledo8217Protocol = ScaleProtocol(
parity=serial.PARITY_EVEN, parity=serial.PARITY_EVEN,
timeout=1, timeout=1,
writeTimeout=1, writeTimeout=1,
weightRegexp="\x02\\s*([0-9.]+)N?\\r", weightRegexp=b"\x02\\s*([0-9.]+)N?\\r",
statusRegexp="\x02\\s*(\\?.)\\r", statusRegexp=b"\x02\\s*(\\?.)\\r",
statusParse=_toledo8217StatusParse, statusParse=_toledo8217StatusParse,
commandDelay=0.2, commandDelay=0.2,
weightDelay=0.5, weightDelay=0.5,
newWeightDelay=0.2, newWeightDelay=0.2,
commandTerminator='', commandTerminator=b'',
weightCommand='W', weightCommand=b'W',
zeroCommand='Z', zeroCommand=b'Z',
tareCommand='T', tareCommand=b'T',
clearCommand='C', clearCommand=b'C',
emptyAnswerValid=False, emptyAnswerValid=False,
autoResetWeight=False, autoResetWeight=False,
) )
@ -98,15 +98,15 @@ ADAMEquipmentProtocol = ScaleProtocol(
weightRegexp=r"\s*([0-9.]+)kg", # LABEL format 3 + KG in the scale settings, but Label 1/2 should work weightRegexp=r"\s*([0-9.]+)kg", # LABEL format 3 + KG in the scale settings, but Label 1/2 should work
statusRegexp=None, statusRegexp=None,
statusParse=None, statusParse=None,
commandTerminator="\r\n", commandTerminator=b"\r\n",
commandDelay=0.2, commandDelay=0.2,
weightDelay=0.5, weightDelay=0.5,
newWeightDelay=5, # AZExtra beeps every time you ask for a weight that was previously returned! newWeightDelay=5, # AZExtra beeps every time you ask for a weight that was previously returned!
# Adding an extra delay gives the operator a chance to remove the products # Adding an extra delay gives the operator a chance to remove the products
# before the scale starts beeping. Could not find a way to disable the beeps. # before the scale starts beeping. Could not find a way to disable the beeps.
weightCommand='P', weightCommand=b'P',
zeroCommand='Z', zeroCommand=b'Z',
tareCommand='T', tareCommand=b'T',
clearCommand=None, # No clear command -> Tare again clearCommand=None, # No clear command -> Tare again
emptyAnswerValid=True, # AZExtra does not answer unless a new non-zero weight has been detected emptyAnswerValid=True, # AZExtra does not answer unless a new non-zero weight has been detected
autoResetWeight=True, # AZExtra will not return 0 after removing products autoResetWeight=True, # AZExtra will not return 0 after removing products
@ -165,8 +165,8 @@ class Scale(Thread):
if not char: if not char:
break break
else: else:
answer.append(char) answer.append(bytes(char))
return ''.join(answer) return b''.join(answer)
def _parse_weight_answer(self, protocol, answer): def _parse_weight_answer(self, protocol, answer):
""" Parse a scale's answer to a weighing request, returning """ Parse a scale's answer to a weighing request, returning