Add support for scanning code
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Support scanning code
|
||||
* Reset search offset when domain has changed
|
||||
* Add a canonicalize function for domains
|
||||
* Add menu to copy selected record from tree view to clipboard
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 96 960 960" width="48"><path d="M40 936V754h60v122h122v60H40Zm697 0v-60h122V754h60v182H737ZM153 825V326h80v499h-80Zm121 0V326h42v499h-42Zm122 0V326h83v499h-83Zm125 0V326h121v499H521Zm163 0V326h42v499h-42Zm83 0V326h38v499h-38ZM40 398V216h182v60H100v122H40Zm819 0V276H737v-60h182v182h-60Z"/></svg>
|
||||
|
After Width: | Height: | Size: 358 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="m611-323-43-43 114-113-114-113 43-43 113 114 113-114 43 43-114 113 114 113-43 43-113-114-113 114Zm-491-37v-240h160l200-200v640L280-360H120Zm300-288L307-540H180v120h127l113 109v-337ZM311-481Z"/></svg>
|
||||
|
After Width: | Height: | Size: 296 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M655-452v-60h145v60H655Zm33 292-119-88 34-47 119 88-34 47Zm-85-505-34-47 119-88 34 47-119 88ZM120-361v-240h160l200-200v640L280-361H120Zm300-288L307-541H180v120h127l113 109v-337Zm-94 168Z"/></svg>
|
||||
|
After Width: | Height: | Size: 292 B |
@@ -25,6 +25,7 @@
|
||||
"bower.json",
|
||||
"dist",
|
||||
"images",
|
||||
"sounds",
|
||||
"index.html",
|
||||
"locale",
|
||||
"package.json",
|
||||
|
||||
@@ -0,0 +1,395 @@
|
||||
Attribution 4.0 International
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
||||
does not provide legal services or legal advice. Distribution of
|
||||
Creative Commons public licenses does not create a lawyer-client or
|
||||
other relationship. Creative Commons makes its licenses and related
|
||||
information available on an "as-is" basis. Creative Commons gives no
|
||||
warranties regarding its licenses, any material licensed under their
|
||||
terms and conditions, or any related information. Creative Commons
|
||||
disclaims all liability for damages resulting from their use to the
|
||||
fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and
|
||||
conditions that creators and other rights holders may use to share
|
||||
original works of authorship and other material subject to copyright
|
||||
and certain other rights specified in the public license below. The
|
||||
following considerations are for informational purposes only, are not
|
||||
exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are
|
||||
intended for use by those authorized to give the public
|
||||
permission to use material in ways otherwise restricted by
|
||||
copyright and certain other rights. Our licenses are
|
||||
irrevocable. Licensors should read and understand the terms
|
||||
and conditions of the license they choose before applying it.
|
||||
Licensors should also secure all rights necessary before
|
||||
applying our licenses so that the public can reuse the
|
||||
material as expected. Licensors should clearly mark any
|
||||
material not subject to the license. This includes other CC-
|
||||
licensed material, or material used under an exception or
|
||||
limitation to copyright. More considerations for licensors:
|
||||
wiki.creativecommons.org/Considerations_for_licensors
|
||||
|
||||
Considerations for the public: By using one of our public
|
||||
licenses, a licensor grants the public permission to use the
|
||||
licensed material under specified terms and conditions. If
|
||||
the licensor's permission is not necessary for any reason--for
|
||||
example, because of any applicable exception or limitation to
|
||||
copyright--then that use is not regulated by the license. Our
|
||||
licenses grant only permissions under copyright and certain
|
||||
other rights that a licensor has authority to grant. Use of
|
||||
the licensed material may still be restricted for other
|
||||
reasons, including because others have copyright or other
|
||||
rights in the material. A licensor may make special requests,
|
||||
such as asking that all changes be marked or described.
|
||||
Although not required by our licenses, you are encouraged to
|
||||
respect those requests where reasonable. More considerations
|
||||
for the public:
|
||||
wiki.creativecommons.org/Considerations_for_licensees
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Attribution 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution 4.0 International Public License ("Public License"). To the
|
||||
extent this Public License may be interpreted as a contract, You are
|
||||
granted the Licensed Rights in consideration of Your acceptance of
|
||||
these terms and conditions, and the Licensor grants You such rights in
|
||||
consideration of benefits the Licensor receives from making the
|
||||
Licensed Material available under these terms and conditions.
|
||||
|
||||
|
||||
Section 1 -- Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright
|
||||
and Similar Rights in Your contributions to Adapted Material in
|
||||
accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
d. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
e. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
f. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
g. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
h. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
i. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
j. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
k. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part; and
|
||||
|
||||
b. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified
|
||||
form), You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
4. If You Share Adapted Material You produce, the Adapter's
|
||||
License You apply must not prevent recipients of the Adapted
|
||||
Material from complying with this Public License.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material; and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons is not a party to its public
|
||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
||||
its public licenses to material it publishes and in those instances
|
||||
will be considered the “Licensor.” The text of the Creative Commons
|
||||
public licenses is dedicated to the public domain under the CC0 Public
|
||||
Domain Dedication. Except for the limited purpose of indicating that
|
||||
material is shared under a Creative Commons public license or as
|
||||
otherwise permitted by the Creative Commons policies published at
|
||||
creativecommons.org/policies, Creative Commons does not authorize the
|
||||
use of the trademark "Creative Commons" or any other trademark or logo
|
||||
of Creative Commons without its prior written consent including,
|
||||
without limitation, in connection with any unauthorized modifications
|
||||
to any of its public licenses or any other arrangements,
|
||||
understandings, or agreements concerning use of licensed material. For
|
||||
the avoidance of doubt, this paragraph does not form part of the
|
||||
public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
||||
Binary file not shown.
Binary file not shown.
@@ -4344,4 +4344,10 @@
|
||||
return window.URL.createObjectURL(blob);
|
||||
};
|
||||
|
||||
Sao.common.play_sound = function(sound='success') {
|
||||
var snd = new Audio('sounds/' + sound + '.wav');
|
||||
snd.volume = localStorage.getItem('sao_sound_volume') || 0.5;
|
||||
snd.play();
|
||||
};
|
||||
|
||||
}());
|
||||
|
||||
@@ -1227,6 +1227,17 @@
|
||||
}
|
||||
this.autocompletion[fieldname] = result;
|
||||
},
|
||||
on_scan_code: function(code, depends) {
|
||||
depends = this.expr_eval(depends);
|
||||
var values = this._get_on_change_args(depends);
|
||||
return this.model.execute(
|
||||
'on_scan_code', [values, code], this.get_context(),
|
||||
true, false).then((changes) => {
|
||||
this.set_on_change(changes);
|
||||
this.set_modified();
|
||||
return !jQuery.isEmptyObject(changes);
|
||||
});
|
||||
},
|
||||
reset: function(value) {
|
||||
this.cancel();
|
||||
this.set(value, true);
|
||||
|
||||
@@ -269,6 +269,8 @@ html.accesskey {
|
||||
}
|
||||
|
||||
.tab-form, .tab-board {
|
||||
padding-bottom: 20px;
|
||||
|
||||
nav.toolbar {
|
||||
position: -webkit-sticky;
|
||||
position: sticky;
|
||||
@@ -1062,6 +1064,20 @@ input.column-boolean {
|
||||
}
|
||||
}
|
||||
|
||||
.btn-code-scanner {
|
||||
bottom: 0;
|
||||
margin: 20px;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
text-align: right;
|
||||
z-index: 1030;
|
||||
}
|
||||
|
||||
.modal .btn-code-scanner {
|
||||
margin: 5px;
|
||||
position: sticky;
|
||||
}
|
||||
|
||||
.infobar {
|
||||
line-height: @line-height-computed;
|
||||
position: fixed;
|
||||
|
||||
@@ -290,6 +290,22 @@ function eval_pyson(value){
|
||||
if (this.attributes.creatable) {
|
||||
this.creatable = Boolean(parseInt(this.attributes.creatable, 10));
|
||||
}
|
||||
if (this.attributes.scan_code) {
|
||||
this.scan_code_btn = new Sao.common.Button({
|
||||
'string': Sao.i18n.gettext("Scan"),
|
||||
'icon': 'tryton-barcode-scanner',
|
||||
'states': this.attributes.scan_code_states,
|
||||
}, null, 'lg', 'btn-primary');
|
||||
this.scan_code_btn.el.click(() => {
|
||||
new Sao.Window.CodeScanner(
|
||||
this.on_scan_code.bind(this),
|
||||
this.attributes.scan_code == 'loop');
|
||||
});
|
||||
this.el.append(jQuery('<div/>', {
|
||||
'class': 'btn-code-scanner',
|
||||
}).append(this.scan_code_btn.el));
|
||||
this.state_widgets.push(this.scan_code_btn);
|
||||
}
|
||||
},
|
||||
get_fields: function() {
|
||||
return Object.keys(this.widgets);
|
||||
@@ -309,6 +325,9 @@ function eval_pyson(value){
|
||||
var field;
|
||||
var depends;
|
||||
var promesses = [];
|
||||
if (this.scan_code_btn) {
|
||||
this.scan_code_btn.el.toggle(Boolean(record));
|
||||
}
|
||||
if (record) {
|
||||
// Force to set fields in record
|
||||
// Get first the lazy one from the view to reduce number of requests
|
||||
@@ -392,6 +411,17 @@ function eval_pyson(value){
|
||||
button.el.prop('disabled', true); // state will be reset at display
|
||||
this.screen.button(button.attributes);
|
||||
},
|
||||
on_scan_code: function(code) {
|
||||
var record = this.record;
|
||||
if (record) {
|
||||
return record.on_scan_code(
|
||||
code, this.attributes.scan_code_depends || []).done(() => {
|
||||
this.el.parents('form').submit();
|
||||
});
|
||||
} else {
|
||||
return jQuery.when();
|
||||
}
|
||||
},
|
||||
get selected_records() {
|
||||
if (this.record) {
|
||||
return [this.record];
|
||||
|
||||
@@ -2577,4 +2577,137 @@
|
||||
},
|
||||
});
|
||||
|
||||
Sao.Window.CodeScanner = Sao.class_(Object, {
|
||||
init: function(callback, loop=false) {
|
||||
this.callback = callback;
|
||||
this.loop = loop;
|
||||
this.submitting = false;
|
||||
this.dialog = new Sao.Dialog(
|
||||
Sao.i18n.gettext("Code Scanner"), 'code-scanner', 'md');
|
||||
this.el = this.dialog.modal;
|
||||
this.input = jQuery('<input/>', {
|
||||
'type': 'text',
|
||||
'class': 'form-control input-sm mousetrap',
|
||||
'aria-label': Sao.i18n.gettext("Code"),
|
||||
'placeholder': Sao.i18n.gettext("Code"),
|
||||
}).appendTo(jQuery('<div/>', {
|
||||
'class': 'col-sm-12',
|
||||
}).appendTo(this.dialog.body));
|
||||
|
||||
var sound_btn = jQuery('<button/>', {
|
||||
'class': 'btn btn-default pull-right',
|
||||
'type': 'button',
|
||||
'title': Sao.i18n.gettext("Toggle Sound"),
|
||||
}).prependTo(this.dialog.header);
|
||||
var sound_icon = jQuery('<img/>', {
|
||||
'class': 'icon',
|
||||
}).appendTo(sound_btn);
|
||||
|
||||
var sound_set_state = function(state) {
|
||||
var prm;
|
||||
if (state) {
|
||||
sound_btn.addClass('active');
|
||||
sound_btn.attr('aria-pressed', state);
|
||||
prm = Sao.common.ICONFACTORY.get_icon_url('tryton-sound-on')
|
||||
.done(url => {
|
||||
sound_icon.attr('src', url);
|
||||
});
|
||||
} else {
|
||||
sound_btn.removeClass('active');
|
||||
sound_btn.attr('aria-pressed', state);
|
||||
prm = Sao.common.ICONFACTORY.get_icon_url('tryton-sound-off')
|
||||
.done(url => {
|
||||
sound_icon.attr('src', url);
|
||||
});
|
||||
}
|
||||
localStorage.setItem('sao_code_scanner_sound', state);
|
||||
return prm;
|
||||
};
|
||||
var sound_state = JSON.parse(
|
||||
localStorage.getItem('sao_code_scanner_sound'));
|
||||
if (sound_state === null) {
|
||||
sound_state = true;
|
||||
}
|
||||
var sound_prm = sound_set_state(sound_state);
|
||||
sound_btn.click(
|
||||
() => sound_set_state(!sound_btn.hasClass('active')));
|
||||
|
||||
jQuery('<button/>', {
|
||||
'class': 'btn btn-link',
|
||||
'type': 'button',
|
||||
'title': Sao.i18n.gettext("Close"),
|
||||
}).text(' ' + Sao.i18n.gettext("Close")).prepend(
|
||||
Sao.common.ICONFACTORY.get_icon_img('tryton-close')
|
||||
).click(() => {
|
||||
this.response('RESPONSE_CLOSE');
|
||||
}).appendTo(this.dialog.footer);
|
||||
|
||||
jQuery('<button/>', {
|
||||
'class': 'btn btn-primary',
|
||||
'type': 'submit',
|
||||
'title': Sao.i18n.gettext("OK"),
|
||||
}).text(' ' + Sao.i18n.gettext("OK")).prepend(
|
||||
Sao.common.ICONFACTORY.get_icon_img('tryton-ok')
|
||||
).appendTo(this.dialog.footer);
|
||||
this.dialog.content.submit(e => {
|
||||
e.preventDefault();
|
||||
this.response('RESPONSE_OK');
|
||||
});
|
||||
|
||||
this.el.on('shown.bs.modal', () => {
|
||||
this.input.on('blur', this._keep_focus);
|
||||
this.input.focus();
|
||||
});
|
||||
this.el.on('hidden.bs.modal', function() {
|
||||
jQuery(this).remove();
|
||||
});
|
||||
// show modal after sound icons have been set
|
||||
// because they can trigger a renew session modal
|
||||
sound_prm.then(() => this.el.modal('show'));
|
||||
},
|
||||
_play_sound: function(sound) {
|
||||
if (JSON.parse(localStorage.getItem('sao_code_scanner_sound'))) {
|
||||
Sao.common.play_sound(sound);
|
||||
}
|
||||
},
|
||||
_keep_focus: function() {
|
||||
setTimeout(() => this.focus(), 1);
|
||||
},
|
||||
response: function(response_id) {
|
||||
if (this.submitting) return;
|
||||
if (response_id == 'RESPONSE_OK') {
|
||||
var code = this.input.val();
|
||||
this.input.val(''); // clear input to prevent multiple calls
|
||||
if (code) {
|
||||
this.submitting = true;
|
||||
this.input.off('blur');
|
||||
return this.callback(code)
|
||||
.always(() => this.submitting = false)
|
||||
.then((modified) => {
|
||||
this._play_sound('success');
|
||||
if (!this.loop || !modified) {
|
||||
this.destroy();
|
||||
}
|
||||
this.input.on('blur', this._keep_focus);
|
||||
this.input.focus();
|
||||
}, (error) => {
|
||||
this._play_sound('danger');
|
||||
if (error[0] == 'UserError') {
|
||||
Sao.common.warning.run(error[1][1], error[1][0]);
|
||||
} else {
|
||||
Sao.common.error.run(error[0], error[1]);
|
||||
}
|
||||
this.destroy();
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!this.loop || response_id != 'RESPONSE_OK') {
|
||||
this.destroy();
|
||||
}
|
||||
},
|
||||
destroy: function() {
|
||||
this.el.modal('hide');
|
||||
},
|
||||
});
|
||||
|
||||
}());
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
* Support scanning code
|
||||
* Reset search offset when domain has changed
|
||||
* Add a canonicalize function for domains
|
||||
* Support PYSON comparison of timedelta
|
||||
|
||||
@@ -11,4 +11,5 @@ include setup-freeze.py
|
||||
include make-*-installer.sh
|
||||
include */gtk-3.0/*
|
||||
include tryton/data/pixmaps/tryton/LICENSE
|
||||
include tryton/data/sounds/LICENSE
|
||||
graft doc
|
||||
|
||||
@@ -189,6 +189,9 @@ Form:
|
||||
* Spell Checking:
|
||||
Check box to enable spell checking in fields.
|
||||
|
||||
* Play Sound for Code Scanner:
|
||||
Check box to enable sound on success or failure of code scan.
|
||||
|
||||
.. _Menu-Options-PDA-Mode:
|
||||
|
||||
PDA Mode:
|
||||
|
||||
@@ -50,6 +50,7 @@ except ImportError:
|
||||
package_data = {
|
||||
'tryton': ['data/pixmaps/tryton/*.png',
|
||||
'data/pixmaps/tryton/*.svg',
|
||||
'data/sounds/*.wav',
|
||||
'data/locale/*/LC_MESSAGES/*.mo',
|
||||
'data/locale/*/LC_MESSAGES/*.po',
|
||||
]
|
||||
@@ -139,6 +140,7 @@ dist = setup(name=name,
|
||||
],
|
||||
extras_require={
|
||||
'calendar': ['GooCalendar>=0.7'],
|
||||
'sound': 'playsound',
|
||||
},
|
||||
zip_safe=False,
|
||||
**args
|
||||
|
||||
@@ -9,7 +9,7 @@ from .common import (
|
||||
error, file_open, file_selection, file_write, filter_domain,
|
||||
generateColorscheme, get_align, get_credentials, get_hostname, get_port,
|
||||
get_sensible_widget, get_toplevel_window, hex2rgb, highlight_rgb, humanize,
|
||||
idle_add, mailto, message, node_attributes, open_documentation,
|
||||
idle_add, mailto, message, node_attributes, open_documentation, play_sound,
|
||||
process_exception, resize_pixbuf, selection, setup_window, slugify, sur,
|
||||
sur_3b, timezoned_date, to_xml, untimezoned_date, url_open, userwarning,
|
||||
warning)
|
||||
@@ -70,6 +70,7 @@ __all__ = [
|
||||
message,
|
||||
node_attributes,
|
||||
open_documentation,
|
||||
play_sound,
|
||||
prepare_reference_domain,
|
||||
process_exception,
|
||||
resize_pixbuf,
|
||||
|
||||
@@ -36,7 +36,7 @@ from string import Template
|
||||
from threading import Lock, Thread
|
||||
|
||||
import tryton.rpc as rpc
|
||||
from tryton.config import CONFIG, PIXMAPS_DIR, TRYTON_ICON
|
||||
from tryton.config import CONFIG, PIXMAPS_DIR, SOUNDS_DIR, TRYTON_ICON
|
||||
|
||||
try:
|
||||
import ssl
|
||||
@@ -1482,3 +1482,11 @@ def idle_add(func):
|
||||
def setup_window(window):
|
||||
if sys.platform == 'darwin':
|
||||
window.set_mnemonic_modifier(Gdk.ModifierType.CONTROL_MASK)
|
||||
|
||||
|
||||
def play_sound(self, sound='success'):
|
||||
try:
|
||||
from playsound import playsound
|
||||
playsound(os.path.join(SOUNDS_DIR, f'{sound}.wav'))
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -87,6 +87,7 @@ class ConfigManager(object):
|
||||
'client.save_tree_width': True,
|
||||
'client.save_tree_state': True,
|
||||
'client.spellcheck': False,
|
||||
'client.code_scanner_sound': True,
|
||||
'client.lang': locale.getdefaultlocale()[0],
|
||||
'client.language_direction': 'ltr',
|
||||
'client.email': '',
|
||||
@@ -230,6 +231,10 @@ if not os.path.isdir(PIXMAPS_DIR):
|
||||
import pkg_resources
|
||||
PIXMAPS_DIR = pkg_resources.resource_filename(
|
||||
'tryton', 'data/pixmaps/tryton')
|
||||
SOUNDS_DIR = os.path.join(CURRENT_DIR, 'data', 'sounds')
|
||||
if not os.path.isdir(SOUNDS_DIR):
|
||||
import pkg_resources
|
||||
SOUNDS_DIR = pkg_resources.resource_filename('tryton', 'data/sounds')
|
||||
|
||||
TRYTON_ICON = GdkPixbuf.Pixbuf.new_from_file(
|
||||
os.path.join(PIXMAPS_DIR, 'tryton-icon.png'))
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 96 960 960" width="48"><path d="M40 936V754h60v122h122v60H40Zm697 0v-60h122V754h60v182H737ZM153 825V326h80v499h-80Zm121 0V326h42v499h-42Zm122 0V326h83v499h-83Zm125 0V326h121v499H521Zm163 0V326h42v499h-42Zm83 0V326h38v499h-38ZM40 398V216h182v60H100v122H40Zm819 0V276H737v-60h182v182h-60Z"/></svg>
|
||||
|
After Width: | Height: | Size: 358 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="m611-323-43-43 114-113-114-113 43-43 113 114 113-114 43 43-114 113 114 113-43 43-113-114-113 114Zm-491-37v-240h160l200-200v640L280-360H120Zm300-288L307-540H180v120h127l113 109v-337ZM311-481Z"/></svg>
|
||||
|
After Width: | Height: | Size: 296 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M655-452v-60h145v60H655Zm33 292-119-88 34-47 119 88-34 47Zm-85-505-34-47 119-88 34 47-119 88ZM120-361v-240h160l200-200v640L280-361H120Zm300-288L307-541H180v120h127l113 109v-337Zm-94 168Z"/></svg>
|
||||
|
After Width: | Height: | Size: 292 B |
@@ -0,0 +1,395 @@
|
||||
Attribution 4.0 International
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
||||
does not provide legal services or legal advice. Distribution of
|
||||
Creative Commons public licenses does not create a lawyer-client or
|
||||
other relationship. Creative Commons makes its licenses and related
|
||||
information available on an "as-is" basis. Creative Commons gives no
|
||||
warranties regarding its licenses, any material licensed under their
|
||||
terms and conditions, or any related information. Creative Commons
|
||||
disclaims all liability for damages resulting from their use to the
|
||||
fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and
|
||||
conditions that creators and other rights holders may use to share
|
||||
original works of authorship and other material subject to copyright
|
||||
and certain other rights specified in the public license below. The
|
||||
following considerations are for informational purposes only, are not
|
||||
exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are
|
||||
intended for use by those authorized to give the public
|
||||
permission to use material in ways otherwise restricted by
|
||||
copyright and certain other rights. Our licenses are
|
||||
irrevocable. Licensors should read and understand the terms
|
||||
and conditions of the license they choose before applying it.
|
||||
Licensors should also secure all rights necessary before
|
||||
applying our licenses so that the public can reuse the
|
||||
material as expected. Licensors should clearly mark any
|
||||
material not subject to the license. This includes other CC-
|
||||
licensed material, or material used under an exception or
|
||||
limitation to copyright. More considerations for licensors:
|
||||
wiki.creativecommons.org/Considerations_for_licensors
|
||||
|
||||
Considerations for the public: By using one of our public
|
||||
licenses, a licensor grants the public permission to use the
|
||||
licensed material under specified terms and conditions. If
|
||||
the licensor's permission is not necessary for any reason--for
|
||||
example, because of any applicable exception or limitation to
|
||||
copyright--then that use is not regulated by the license. Our
|
||||
licenses grant only permissions under copyright and certain
|
||||
other rights that a licensor has authority to grant. Use of
|
||||
the licensed material may still be restricted for other
|
||||
reasons, including because others have copyright or other
|
||||
rights in the material. A licensor may make special requests,
|
||||
such as asking that all changes be marked or described.
|
||||
Although not required by our licenses, you are encouraged to
|
||||
respect those requests where reasonable. More considerations
|
||||
for the public:
|
||||
wiki.creativecommons.org/Considerations_for_licensees
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Attribution 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution 4.0 International Public License ("Public License"). To the
|
||||
extent this Public License may be interpreted as a contract, You are
|
||||
granted the Licensed Rights in consideration of Your acceptance of
|
||||
these terms and conditions, and the Licensor grants You such rights in
|
||||
consideration of benefits the Licensor receives from making the
|
||||
Licensed Material available under these terms and conditions.
|
||||
|
||||
|
||||
Section 1 -- Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright
|
||||
and Similar Rights in Your contributions to Adapted Material in
|
||||
accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
d. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
e. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
f. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
g. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
h. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
i. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
j. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
k. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part; and
|
||||
|
||||
b. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified
|
||||
form), You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
4. If You Share Adapted Material You produce, the Adapter's
|
||||
License You apply must not prevent recipients of the Adapted
|
||||
Material from complying with this Public License.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material; and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons is not a party to its public
|
||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
||||
its public licenses to material it publishes and in those instances
|
||||
will be considered the “Licensor.” The text of the Creative Commons
|
||||
public licenses is dedicated to the public domain under the CC0 Public
|
||||
Domain Dedication. Except for the limited purpose of indicating that
|
||||
material is shared under a Creative Commons public license or as
|
||||
otherwise permitted by the Creative Commons policies published at
|
||||
creativecommons.org/policies, Creative Commons does not authorize the
|
||||
use of the trademark "Creative Commons" or any other trademark or logo
|
||||
of Creative Commons without its prior written consent including,
|
||||
without limitation, in connection with any unauthorized modifications
|
||||
to any of its public licenses or any other arrangements,
|
||||
understandings, or agreements concerning use of licensed material. For
|
||||
the avoidance of doubt, this paragraph does not form part of the
|
||||
public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
||||
Binary file not shown.
Binary file not shown.
@@ -79,6 +79,7 @@ class Main(Gtk.Application):
|
||||
('mode-pda', 'client.modepda'),
|
||||
('save-tree-width', 'client.save_tree_width'),
|
||||
('save-tree-state', 'client.save_tree_state'),
|
||||
('code-scanner-sound', 'client.code_scanner_sound'),
|
||||
('spell-checking', 'client.spellcheck'),
|
||||
('check-version', 'client.check_version'),
|
||||
]:
|
||||
@@ -307,6 +308,7 @@ class Main(Gtk.Application):
|
||||
form.append(_("Save Column Width"), 'app.save-tree-width')
|
||||
form.append(_("Save Tree State"), 'app.save-tree-state')
|
||||
form.append(_("Spell Checking"), 'app.spell-checking')
|
||||
form.append(_("Play Sound for Code Scanner"), 'app.code-scanner-sound')
|
||||
|
||||
section.append(_("PDA Mode"), 'app.mode-pda')
|
||||
section.append(_("Search Limit..."), 'app.search-limit')
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
import gettext
|
||||
|
||||
try:
|
||||
from http import HTTPStatus
|
||||
except ImportError:
|
||||
from http import client as HTTPStatus
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
from tryton.common import (
|
||||
IconFactory, RPCException, play_sound, process_exception)
|
||||
from tryton.common.underline import set_underline
|
||||
from tryton.config import CONFIG, TRYTON_ICON
|
||||
from tryton.exceptions import TrytonServerError
|
||||
from tryton.gui import Main
|
||||
from tryton.gui.window.nomodal import NoModal
|
||||
|
||||
_ = gettext.gettext
|
||||
|
||||
|
||||
class CodeScanner(NoModal):
|
||||
|
||||
def __init__(self, callback, loop=False):
|
||||
super().__init__()
|
||||
self.callback = callback
|
||||
self.loop = loop
|
||||
self.dialog = Gtk.MessageDialog(
|
||||
transient_for=self.parent, destroy_with_parent=True,
|
||||
text=_("Code Scanner"))
|
||||
Main().add_window(self.dialog)
|
||||
self.dialog.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
|
||||
self.dialog.set_icon(TRYTON_ICON)
|
||||
self.dialog.connect('response', self.response)
|
||||
|
||||
self.dialog.set_title(_("Code Scanner"))
|
||||
|
||||
self.entry = Gtk.Entry()
|
||||
self.entry.set_activates_default(True)
|
||||
self.entry.set_placeholder_text(_("Code"))
|
||||
self.dialog.get_message_area().pack_start(
|
||||
self.entry, expand=False, fill=False, padding=9)
|
||||
|
||||
button_close = self.dialog.add_button(
|
||||
set_underline(_("Close")), Gtk.ResponseType.CLOSE)
|
||||
button_close.set_image(IconFactory.get_image(
|
||||
'tryton-close', Gtk.IconSize.BUTTON))
|
||||
|
||||
button_ok = self.dialog.add_button(
|
||||
set_underline(_("OK")), Gtk.ResponseType.OK)
|
||||
button_ok.set_image(IconFactory.get_image(
|
||||
'tryton-ok', Gtk.IconSize.BUTTON))
|
||||
self.dialog.set_default_response(Gtk.ResponseType.OK)
|
||||
|
||||
self.dialog.show_all()
|
||||
self.register()
|
||||
self.entry.grab_focus()
|
||||
|
||||
def _play(self, sound):
|
||||
if CONFIG['client.code_scanner_sound']:
|
||||
play_sound(sound)
|
||||
|
||||
def response(self, dialog, response):
|
||||
if response == Gtk.ResponseType.OK:
|
||||
code = self.entry.get_text()
|
||||
self.entry.set_text('')
|
||||
if code:
|
||||
while True:
|
||||
try:
|
||||
modified = self.callback(code)
|
||||
self._play('success')
|
||||
if not self.loop or not modified:
|
||||
self.destroy()
|
||||
except Exception as exception:
|
||||
unauthorized = (
|
||||
isinstance(exception, TrytonServerError)
|
||||
and exception.faultCode == str(
|
||||
int(HTTPStatus.UNAUTHORIZED)))
|
||||
if not unauthorized:
|
||||
self._play('danger')
|
||||
try:
|
||||
process_exception(exception)
|
||||
except RPCException:
|
||||
pass
|
||||
if unauthorized:
|
||||
continue
|
||||
self.destroy()
|
||||
return
|
||||
if not self.loop or response != Gtk.ResponseType.OK:
|
||||
self.destroy()
|
||||
|
||||
def destroy(self):
|
||||
super().destroy()
|
||||
self.dialog.destroy()
|
||||
|
||||
def show(self):
|
||||
self.dialog.show()
|
||||
|
||||
def hide(self):
|
||||
self.dialog.hide()
|
||||
@@ -676,6 +676,16 @@ class Record:
|
||||
res = []
|
||||
self.autocompletion[fieldname] = res
|
||||
|
||||
def on_scan_code(self, code, depends):
|
||||
depends = self.expr_eval(depends)
|
||||
values = self._get_on_change_args(depends)
|
||||
changes = RPCExecute(
|
||||
'model', self.model_name, 'on_scan_code', values, code,
|
||||
context=self.get_context(), process_exception=False)
|
||||
self.set_on_change(changes)
|
||||
self.set_modified()
|
||||
return bool(changes)
|
||||
|
||||
def set_field_context(self):
|
||||
from .group import Group
|
||||
for name, field in self.group.fields.items():
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import gettext
|
||||
import operator
|
||||
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GLib, Gtk
|
||||
|
||||
from tryton.common import IconFactory, Tooltips, get_align, node_attributes
|
||||
from tryton.common.button import Button
|
||||
@@ -12,6 +12,7 @@ from tryton.common.focus import (
|
||||
get_invisible_ancestor, next_focus_widget)
|
||||
from tryton.common.underline import set_underline
|
||||
from tryton.config import CONFIG
|
||||
from tryton.gui.window.code_scanner import CodeScanner
|
||||
|
||||
from . import View, XMLViewParser
|
||||
from .form_gtk.binary import Binary
|
||||
@@ -471,6 +472,23 @@ class ViewForm(View):
|
||||
|
||||
self.creatable = bool(int(self.attributes.get('creatable', 1)))
|
||||
|
||||
if self.attributes.get('scan_code'):
|
||||
code_scanner_btn = Button({
|
||||
'string': _("Scan"),
|
||||
'icon': 'tryton-barcode-scanner',
|
||||
'states': self.attributes.get('scan_code_states', {}),
|
||||
})
|
||||
code_scanner_btn.set_image(IconFactory.get_image(
|
||||
'tryton-barcode-scanner', Gtk.IconSize.BUTTON))
|
||||
code_scanner_btn.set_always_show_image(True)
|
||||
code_scanner_btn.set_receives_default(False)
|
||||
vbox.pack_start(
|
||||
code_scanner_btn, expand=False, fill=True, padding=2)
|
||||
code_scanner_btn.connect(
|
||||
'clicked', lambda *a: CodeScanner(
|
||||
self.on_scan_code,
|
||||
self.attributes['scan_code'] == 'loop'))
|
||||
|
||||
def get_fields(self):
|
||||
return list(self.widgets.keys())
|
||||
|
||||
@@ -598,3 +616,13 @@ class ViewForm(View):
|
||||
self.screen.button(widget.attrs)
|
||||
finally:
|
||||
widget.handler_unblock_by_func(self.button_clicked)
|
||||
|
||||
def on_scan_code(self, code):
|
||||
if self.record:
|
||||
modified = self.record.on_scan_code(
|
||||
code, self.attributes.get('scan_code_depends', []))
|
||||
if self.attributes['scan_code'] == 'submit':
|
||||
window = self.widget.get_toplevel()
|
||||
if window and isinstance(window, Gtk.Window):
|
||||
GLib.idle_add(lambda: window and window.activate_default())
|
||||
return modified
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
* Add on_scan_code method on Model
|
||||
* Support add/update/remove/delete for on_change_with of xxx2Many
|
||||
* Add decorator on RPC
|
||||
* Remove translations with empty source
|
||||
|
||||
@@ -230,6 +230,15 @@ Instance methods:
|
||||
To be called by the client, this method must be decorated
|
||||
by :meth:`~trytond.model.fields.depends` with the fields needed.
|
||||
|
||||
.. method:: ModelView.on_scan_code(code)
|
||||
|
||||
Modify the instance when ``code`` is scanned.
|
||||
If the instance is not modified the scan loop ends.
|
||||
|
||||
.. note::
|
||||
When extended, this method must be decorated by
|
||||
:meth:`~trytond.model.fields.depends` with the fields used.
|
||||
|
||||
ModelStorage
|
||||
============
|
||||
|
||||
|
||||
@@ -258,6 +258,15 @@ Each form view must start with this tag with those attributes:
|
||||
``cursor``
|
||||
The name of the field that must have the cursor by default.
|
||||
|
||||
.. _form-attributes-scan_code:
|
||||
|
||||
``scan_code``
|
||||
Active the scan of code using :meth:`trytond.model.ModelView.on_scan_code`.
|
||||
If the value is ``one``, only one code is requested.
|
||||
If the value is ``submit``, the form is submitted after one code.
|
||||
If the value is ``loop``, codes are requested until the user stops.
|
||||
The default value is empty.
|
||||
|
||||
:ref:`col <common-attributes-col>`.
|
||||
|
||||
.. _form-label:
|
||||
|
||||
@@ -20,6 +20,9 @@ attlist.form &=
|
||||
[ a:defaultValue = "1" ] attribute creatable { "0" | "1" }?
|
||||
attlist.form &= [ a:defaultValue = "4" ] attribute col { text }?
|
||||
attlist.form &= attribute cursor { text }?
|
||||
attlist.form &= attribute scan_code { "one" | "submit" | "loop" }?
|
||||
attlist.form &= attribute scan_code_depends { text }?
|
||||
attlist.form &= attribute scan_code_states { text }?
|
||||
|
||||
label = element label { attlist.label, empty }
|
||||
attlist.label &= [ a:defaultValue = "" ] attribute string { text }?
|
||||
|
||||
@@ -57,6 +57,34 @@
|
||||
</attribute>
|
||||
</optional>
|
||||
</define>
|
||||
<define name="attlist.form" combine="interleave">
|
||||
<optional>
|
||||
<attribute>
|
||||
<name ns="">scan_code</name>
|
||||
<choice>
|
||||
<value>one</value>
|
||||
<value>submit</value>
|
||||
<value>loop</value>
|
||||
</choice>
|
||||
</attribute>
|
||||
</optional>
|
||||
</define>
|
||||
<define name="attlist.form" combine="interleave">
|
||||
<optional>
|
||||
<attribute>
|
||||
<name ns="">scan_code_depends</name>
|
||||
<text/>
|
||||
</attribute>
|
||||
</optional>
|
||||
</define>
|
||||
<define name="attlist.form" combine="interleave">
|
||||
<optional>
|
||||
<attribute>
|
||||
<name ns="">scan_code_states</name>
|
||||
<text/>
|
||||
</attribute>
|
||||
</optional>
|
||||
</define>
|
||||
<define name="label">
|
||||
<element>
|
||||
<name ns="">label</name>
|
||||
|
||||
@@ -25,6 +25,7 @@ CLIENT_ICONS = [(x, x) for x in [
|
||||
'tryton-archive',
|
||||
'tryton-attach',
|
||||
'tryton-back',
|
||||
'tryton-barcode-scanner',
|
||||
'tryton-bookmark-border',
|
||||
'tryton-bookmark',
|
||||
'tryton-bookmarks',
|
||||
@@ -65,6 +66,8 @@ CLIENT_ICONS = [(x, x) for x in [
|
||||
'tryton-remove',
|
||||
'tryton-save',
|
||||
'tryton-search',
|
||||
'tryton-sound-off',
|
||||
'tryton-sound-on',
|
||||
'tryton-star-border',
|
||||
'tryton-star',
|
||||
'tryton-switch',
|
||||
|
||||
@@ -72,6 +72,8 @@ class ModelView(Model):
|
||||
cls.__rpc__['on_change_with'] = RPC(
|
||||
instantiate=0, result=on_change_result)
|
||||
cls.__rpc__['on_change_notify'] = RPC(instantiate=0)
|
||||
cls.__rpc__['on_scan_code'] = RPC(
|
||||
instantiate=0, result=on_change_result)
|
||||
cls._buttons = {}
|
||||
|
||||
fields_ = {}
|
||||
@@ -187,9 +189,13 @@ class ModelView(Model):
|
||||
methods['depend_methods'][meth_name] - meth_done)
|
||||
meth_done.add(meth_name)
|
||||
|
||||
set_methods('on_change_notify')
|
||||
cls._on_change_notify_depends = methods['depends']['on_change_notify']
|
||||
meth_names = list(methods['depend_methods']['on_change_notify'])
|
||||
for func_name, depends_attr in [
|
||||
('on_change_notify', '_on_change_notify_depends'),
|
||||
('on_scan_code', '_on_scan_code_depends'),
|
||||
]:
|
||||
set_methods(func_name)
|
||||
setattr(cls, depends_attr, methods['depends'][func_name])
|
||||
meth_names = list(methods['depend_methods'][func_name])
|
||||
meth_done = set()
|
||||
while meth_names:
|
||||
meth_name = meth_names.pop()
|
||||
@@ -197,11 +203,15 @@ class ModelView(Model):
|
||||
assert callable(method) or isinstance(method, property), \
|
||||
"%s.%s not callable or property" % (cls, meth_name)
|
||||
set_methods(meth_name)
|
||||
cls._on_change_notify_depends |= methods['depends'][meth_name]
|
||||
setattr(
|
||||
cls, depends_attr,
|
||||
getattr(cls, depends_attr) | methods['depends'][meth_name])
|
||||
meth_names += list(
|
||||
methods['depend_methods'][meth_name] - meth_done)
|
||||
meth_done.add(meth_name)
|
||||
|
||||
cls.on_scan_code = on_change(cls.on_scan_code)
|
||||
|
||||
@classmethod
|
||||
def fields_view_get(cls, view_id=None, view_type='form', level=None):
|
||||
'''
|
||||
@@ -650,6 +660,10 @@ class ModelView(Model):
|
||||
else:
|
||||
element.attrib['id'] = str(action.action.id)
|
||||
|
||||
if element.tag == 'form' and element.get('scan_code'):
|
||||
element.set('scan_code_depends', encoder.encode(
|
||||
list(cls._on_scan_code_depends)))
|
||||
|
||||
if element.tag == 'tree' and element.get('sequence'):
|
||||
fields_attrs.setdefault(element.get('sequence'), {})
|
||||
|
||||
@@ -779,6 +793,9 @@ class ModelView(Model):
|
||||
"""
|
||||
return []
|
||||
|
||||
def on_scan_code(self, code):
|
||||
pass
|
||||
|
||||
@property
|
||||
def _changed_values(self):
|
||||
"""Return the values changed since the instantiation.
|
||||
|
||||
Reference in New Issue
Block a user