master-sf1.0

This commit is contained in:
qihao.gong@jikimo.com
2023-05-06 16:03:00 +08:00
parent fcf0354a1e
commit 0077d97cfa
307 changed files with 20636 additions and 0 deletions

View 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;
}
}
}
}
}

View File

@@ -0,0 +1,5 @@
.o_button_iot {
min-width: 120px;
min-height: 40px;
margin-left: 50px;
}

View 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;
}
}
}
}

View 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);

View 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]}&amp;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>

View 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>

View 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>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
</templates>

View 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>-->
<!--&lt;!&ndash; <img src="/barcodes/static/img/barcode.png" alt="Barcode"/>&ndash;&gt;-->
<!-- <span class="o_barcode_laser"/>-->
<!-- </div>-->
</div>
</t>
</templates>

View 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>

View File

@@ -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>

View 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>

View 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>