master-sf1.0
This commit is contained in:
30
sf_machine_connect/static/src/css/MyWidget.css
Normal file
30
sf_machine_connect/static/src/css/MyWidget.css
Normal file
@@ -0,0 +1,30 @@
|
||||
.o_int_colorpicker {
|
||||
.o_color_pill {
|
||||
display: inline-block;
|
||||
height: 25px;
|
||||
width: 25px;
|
||||
margin: 4px;
|
||||
border-radius: 25px;
|
||||
position: relative;
|
||||
@for $size from 1 through length($o-colors) {
|
||||
&.o_color_#{$size - 1} {
|
||||
background-color: nth($o-colors, $size);
|
||||
&:not(.readonly):hover {
|
||||
transform: scale(1.2);
|
||||
transition: 0.3s;
|
||||
cursor: pointer;
|
||||
}
|
||||
&.active:after{
|
||||
content: "\f00c";
|
||||
display: inline-block;
|
||||
font: normal normal normal 14px/1 FontAwesome;
|
||||
font-size: inherit;
|
||||
color: #fff;
|
||||
position: absolute;
|
||||
padding: 4px;
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
5
sf_machine_connect/static/src/css/iot.css
Normal file
5
sf_machine_connect/static/src/css/iot.css
Normal file
@@ -0,0 +1,5 @@
|
||||
.o_button_iot {
|
||||
min-width: 120px;
|
||||
min-height: 40px;
|
||||
margin-left: 50px;
|
||||
}
|
||||
13
sf_machine_connect/static/src/css/many2one_field.scss
Normal file
13
sf_machine_connect/static/src/css/many2one_field.scss
Normal file
@@ -0,0 +1,13 @@
|
||||
.o_form_view:not(.o_field_highlight) {
|
||||
.o_field_many2one_selection {
|
||||
.o_external_button, .o_dropdown_button {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
&:hover, &:focus-within {
|
||||
.o_external_button, .o_dropdown_button {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
82
sf_machine_connect/static/src/js/test.js
Normal file
82
sf_machine_connect/static/src/js/test.js
Normal file
@@ -0,0 +1,82 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { browser } from "@web/core/browser/browser";
|
||||
import { Dialog } from "@web/core/dialog/dialog";
|
||||
import { _lt } from "@web/core/l10n/translation";
|
||||
import { useChildRef, useOwnedDialogs, useService } from "@web/core/utils/hooks";
|
||||
import { sprintf } from "@web/core/utils/strings";
|
||||
import { isMobileOS } from "@web/core/browser/feature_detection";
|
||||
import * as BarcodeScanner from "@web/webclient/barcode/barcode_scanner";
|
||||
|
||||
const {xml, Component} = owl;
|
||||
import { standardFieldProps } from "@web/views/fields/standard_field_props";
|
||||
// Import the registry
|
||||
import {registry} from "@web/core/registry";
|
||||
|
||||
|
||||
export class CodeField extends Component {
|
||||
setup() {
|
||||
super.setup();
|
||||
}
|
||||
async onBarcodeBtnClick() {
|
||||
const barcode = await BarcodeScanner.scanBarcode();
|
||||
if (barcode) {
|
||||
await this.onBarcodeScanned(barcode);
|
||||
if ("vibrate" in browser.navigator) {
|
||||
browser.navigator.vibrate(100);
|
||||
}
|
||||
} else {
|
||||
this.notification.add(this.env._t("Please, scan again !"), {
|
||||
type: "warning",
|
||||
});
|
||||
}
|
||||
}
|
||||
async search(barcode) {
|
||||
const results = await this.orm.call("sf.tray", "name_search", [code], {
|
||||
name: barcode,
|
||||
args: this.getDomain(),
|
||||
operator: "ilike",
|
||||
limit: 2, // If one result we set directly and if more than one we use normal flow so no need to search more
|
||||
context: this.context,
|
||||
});
|
||||
return results.map((result) => {
|
||||
const [id, displayName] = result;
|
||||
return {
|
||||
id,
|
||||
name: displayName,
|
||||
};
|
||||
});
|
||||
}
|
||||
async onBarcodeScanned(barcode) {
|
||||
const results = await this.search(barcode);
|
||||
const records = results.filter((r) => !!r.id);
|
||||
if (records.length === 1) {
|
||||
this.update([{ id: records[0].id, name: records[0].name }]);
|
||||
} else {
|
||||
const searchInput = this.autocompleteContainerRef.el.querySelector("input");
|
||||
searchInput.value = barcode;
|
||||
searchInput.dispatchEvent(new Event("input"));
|
||||
if (this.env.isSmall) {
|
||||
searchInput.click();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CodeField.template = xml`
|
||||
<button
|
||||
t-on-click="onBarcodeBtnClick"
|
||||
type="button"
|
||||
class="btn ms-3 o_barcode"
|
||||
tabindex="-1"
|
||||
draggable="false"
|
||||
aria-label="Scan barcode"
|
||||
title="Scan barcode"
|
||||
data-tooltip="Scan barcode"
|
||||
/>
|
||||
`;
|
||||
// CodeField.template = 'sf_machine_connect.CodeField';
|
||||
CodeField.props = standardFieldProps;
|
||||
|
||||
// Add the field to the correct category
|
||||
registry.category("fields").add("code", CodeField);
|
||||
94
sf_machine_connect/static/src/xml/Barcode_Scan_template.xml
Normal file
94
sf_machine_connect/static/src/xml/Barcode_Scan_template.xml
Normal file
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="sf_machine_connect.Barcode_Scan_template" t-inherit="web.Legacy.ControlPanel" t-inherit-mode="extension" owl="1">
|
||||
<xpath expr="//div[hasclass('o_cp_pager')]" position="inside">
|
||||
<button
|
||||
style="float:left"
|
||||
t-on-click="onBarcodeScanned"
|
||||
type="button"
|
||||
class="btn ms-3 o_barcode"
|
||||
tabindex="-1"
|
||||
draggable="false"
|
||||
aria-label="Scan barcode"
|
||||
title="Scan barcode"
|
||||
data-tooltip="Scan barcode"
|
||||
>扫码</button>
|
||||
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
<!-- <t t-name="web.Many2OneField.CreateConfirmationDialog" owl="1">-->
|
||||
<!-- <Dialog title="title" size="'md'">-->
|
||||
<!-- <div>-->
|
||||
<!-- Create <strong t-esc="props.value"/> as a new <t t-esc="props.name"/>?-->
|
||||
<!-- </div>-->
|
||||
<!-- <t t-set-slot="footer">-->
|
||||
<!-- <button class="btn btn-primary" t-on-click="onCreate">Create</button>-->
|
||||
<!-- <button class="btn" t-on-click="() => props.close()">Discard</button>-->
|
||||
<!-- </t>-->
|
||||
<!-- </Dialog>-->
|
||||
<!-- </t>-->
|
||||
|
||||
<!-- <t t-name="web.Many2OneField" owl="1">-->
|
||||
<!-- <t t-if="props.readonly">-->
|
||||
<!-- <t t-if="!props.canOpen">-->
|
||||
<!-- <span>-->
|
||||
<!-- <span t-esc="displayName" />-->
|
||||
<!-- <t t-foreach="extraLines" t-as="extraLine" t-key="extraLine_index">-->
|
||||
<!-- <br />-->
|
||||
<!-- <span t-esc="extraLine" />-->
|
||||
<!-- </t>-->
|
||||
<!-- </span>-->
|
||||
<!-- </t>-->
|
||||
<!-- <t t-else="">-->
|
||||
<!-- <a-->
|
||||
<!-- t-if="props.value"-->
|
||||
<!-- class="o_form_uri"-->
|
||||
<!-- t-att-href="props.value ? `#id=${props.value[0]}&model=${relation}` : '#'"-->
|
||||
<!-- t-on-click.prevent="onClick"-->
|
||||
<!-- >-->
|
||||
<!-- <span t-esc="displayName" />-->
|
||||
<!-- <t t-foreach="extraLines" t-as="extraLine" t-key="extraLine_index">-->
|
||||
<!-- <br />-->
|
||||
<!-- <span t-esc="extraLine" />-->
|
||||
<!-- </t>-->
|
||||
<!-- </a>-->
|
||||
<!-- </t>-->
|
||||
<!-- </t>-->
|
||||
<!-- <t t-else="">-->
|
||||
<!-- <div class="o_field_many2one_selection">-->
|
||||
<!-- <Many2XAutocomplete t-props="Many2XAutocompleteProps"/>-->
|
||||
<!-- <t t-if="hasExternalButton">-->
|
||||
<!-- <button-->
|
||||
<!-- type="button"-->
|
||||
<!-- class="btn btn-secondary fa o_external_button"-->
|
||||
<!-- t-att-class="props.openTarget === 'current' ? 'fa-arrow-right' : 'fa-external-link'"-->
|
||||
<!-- tabindex="-1"-->
|
||||
<!-- draggable="false"-->
|
||||
<!-- aria-label="Internal link"-->
|
||||
<!-- data-tooltip="Internal link"-->
|
||||
<!-- t-on-click="onExternalBtnClick"-->
|
||||
<!-- />-->
|
||||
<!-- </t>-->
|
||||
<!-- <button-->
|
||||
<!-- t-if="hasBarcodeButton"-->
|
||||
<!-- t-on-click="onBarcodeBtnClick"-->
|
||||
<!-- type="button"-->
|
||||
<!-- class="btn ms-3 o_barcode"-->
|
||||
<!-- tabindex="-1"-->
|
||||
<!-- draggable="false"-->
|
||||
<!-- aria-label="Scan barcode"-->
|
||||
<!-- title="Scan barcode"-->
|
||||
<!-- data-tooltip="Scan barcode"-->
|
||||
<!-- />-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="o_field_many2one_extra">-->
|
||||
<!-- <t t-foreach="extraLines" t-as="extraLine" t-key="extraLine_index">-->
|
||||
<!-- <br t-if="!extraLine_first" />-->
|
||||
<!-- <span t-esc="extraLine" />-->
|
||||
<!-- </t>-->
|
||||
<!-- </div>-->
|
||||
<!-- </t>-->
|
||||
<!-- </t>-->
|
||||
|
||||
</templates>
|
||||
10
sf_machine_connect/static/src/xml/Flush.xml
Normal file
10
sf_machine_connect/static/src/xml/Flush.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="owl_demo.PartnerOrderSummary2" owl="1">
|
||||
<div class="row" style="padding-top: 20px;">
|
||||
<p>
|
||||
显示累加字符串:aaaaaabbb
|
||||
</p>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
27
sf_machine_connect/static/src/xml/MyComponent.xml
Normal file
27
sf_machine_connect/static/src/xml/MyComponent.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="owl_demo.MyComponent1" owl="1">
|
||||
<div class="container">
|
||||
<div class="jumbotron">
|
||||
<h1>欢迎登陆页面!</h1>
|
||||
<p>这是一个超大屏幕(Jumbotron)的实例。</p>
|
||||
<p><a class="btn btn-primary btn-lg" role="button">
|
||||
学习更多</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="bg-info text-center p-2">-->
|
||||
<!-- <i class="fa fa-arrow-left p-1 left"-->
|
||||
<!-- style="cursor: pointer;"-->
|
||||
<!-- t-on-click="onPrevious"> </i>-->
|
||||
<!-- <b t-esc="messageList[Math.abs(-->
|
||||
<!-- state.currentIndex%4)]"/>-->
|
||||
<!-- <i class="fa fa-arrow-right p-1 right"-->
|
||||
<!-- style="cursor: pointer;"-->
|
||||
<!-- t-on-click="onNext"> </i>-->
|
||||
<!-- <i class="fa fa-close p-1 float-right"-->
|
||||
<!-- style="cursor: pointer;"-->
|
||||
<!-- t-on-click="onRemove"> </i>-->
|
||||
<!-- </div>-->
|
||||
</t>
|
||||
</templates>
|
||||
4
sf_machine_connect/static/src/xml/MyWidget.xml
Normal file
4
sf_machine_connect/static/src/xml/MyWidget.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates>
|
||||
|
||||
</templates>
|
||||
32
sf_machine_connect/static/src/xml/PartnerOrderSummary2.xml
Normal file
32
sf_machine_connect/static/src/xml/PartnerOrderSummary2.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="sf_machine_connect.PartnerOrderSummary2" owl="1">
|
||||
<!-- <div class="row" style="padding-top: 20px;">-->
|
||||
<div style="padding-top: 20px;">
|
||||
|
||||
<button
|
||||
t-on-click="onBarcodeBtnClick"
|
||||
type="button"
|
||||
class="btn ms-3 o_barcode"
|
||||
tabindex="-1"
|
||||
draggable="false"
|
||||
aria-label="Scan barcode"
|
||||
title="Scan barcode"
|
||||
data-tooltip="Scan barcode"
|
||||
>扫码</button>
|
||||
|
||||
|
||||
<!-- <div class="o_barcode_mobile_container">-->
|
||||
<!-- <a role="button" class="btn btn-primary o_mobile_barcode">-->
|
||||
<!-- <i class="fa fa-camera fa-2x o_barcode_mobile_camera"/>-->
|
||||
<!-- Tap to scan-->
|
||||
<!-- </a>-->
|
||||
<!--<!– <img src="/barcodes/static/img/barcode.png" alt="Barcode"/>–>-->
|
||||
<!-- <span class="o_barcode_laser"/>-->
|
||||
<!-- </div>-->
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</t>
|
||||
</templates>
|
||||
15
sf_machine_connect/static/src/xml/barcodes.xml
Normal file
15
sf_machine_connect/static/src/xml/barcodes.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="mobile_barcode_template">
|
||||
<div class="o_barcode_mobile_container">
|
||||
<a role="button" class="btn btn-primary o_mobile_barcode">
|
||||
<i class="fa fa-camera fa-2x o_barcode_mobile_camera"/>
|
||||
Tap to scan
|
||||
</a>
|
||||
<img src="/barcodes/static/img/barcode.png" alt="Barcode"/>
|
||||
<span class="o_barcode_laser"/>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<templates>
|
||||
<div t-name="iot.scan_progress_template">
|
||||
<h4>Range(s) to scan</h4>
|
||||
<ul class="scan_ranges list-group mb-2"/>
|
||||
<div class="input-group mb-4">
|
||||
<input type="text" name="add_scan_range_ip" class="add_scan_range_ip form-control" placeholder="Scan another range, e.g.: 10.1.1.*"/>
|
||||
<a role="button" class="add_scan_range btn btn-primary" tabindex="-1">Add</a>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<h4 class="scan_network"></h4>
|
||||
<h4 class="iot_box_found"></h4>
|
||||
<ul class="found_devices list-group"/>
|
||||
</div>
|
||||
</div>
|
||||
</templates>
|
||||
20
sf_machine_connect/static/src/xml/many2one_field.xml
Normal file
20
sf_machine_connect/static/src/xml/many2one_field.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="sf_machine_connect.CodeField" owl="1">
|
||||
<div class="o_field_many2one_selection">
|
||||
<button
|
||||
t-on-click="onBarcodeBtnClick"
|
||||
type="button"
|
||||
class="btn ms-3 o_barcode"
|
||||
tabindex="-1"
|
||||
draggable="false"
|
||||
aria-label="Scan barcode"
|
||||
title="Scan barcode"
|
||||
data-tooltip="Scan barcode"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
17
sf_machine_connect/static/src/xml/stack.xml
Normal file
17
sf_machine_connect/static/src/xml/stack.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" >
|
||||
<t t-extend="stock_barcode_lines_template">
|
||||
<t t-jquery="div[class='o_barcode_line list-group-item d-flex flex-row flex-nowrap']"
|
||||
t-operation="append">
|
||||
<div class="o_barcode_pic position-relative text-center mt-2 mb-1">
|
||||
<i class="fa fa-5x mx-auto fa-exclamation-triangle text-white d-none"/>
|
||||
<img class="o_barcode_icon" src="/stock_barcode/static/img/barcode.svg" alt="Barcode" height="40px"/>
|
||||
<!-- <t t-if='widget.mobileMethods.scanBarcode'> -->
|
||||
|
||||
<div class="o_stock_mobile_barcode"/> <!-- Used to open the device scanner -->
|
||||
<span> Tap to scan</span>
|
||||
<!-- </t> -->
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
||||
Reference in New Issue
Block a user