From 4a5b8fedc5148a598e4f03496c01d8c7c8e1c210 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 21 Feb 2014 13:47:03 +0100 Subject: [PATCH 01/16] [REF] change the name of the module. --- web_widget_float_formula/__init__.py | 4 + web_widget_float_formula/__openerp__.py | 64 +++++++++ .../static/src/img/icon.png | Bin 0 -> 3262 bytes .../static/src/js/models.js | 132 ++++++++++++++++++ 4 files changed, 200 insertions(+) create mode 100644 web_widget_float_formula/__init__.py create mode 100644 web_widget_float_formula/__openerp__.py create mode 100644 web_widget_float_formula/static/src/img/icon.png create mode 100644 web_widget_float_formula/static/src/js/models.js diff --git a/web_widget_float_formula/__init__.py b/web_widget_float_formula/__init__.py new file mode 100644 index 00000000..97833ca3 --- /dev/null +++ b/web_widget_float_formula/__init__.py @@ -0,0 +1,4 @@ +# -*- encoding: utf-8 -*- +################################################################################ +# See __openerp__.py file for Copyright and Licence Informations. +################################################################################ diff --git a/web_widget_float_formula/__openerp__.py b/web_widget_float_formula/__openerp__.py new file mode 100644 index 00000000..8a34c04e --- /dev/null +++ b/web_widget_float_formula/__openerp__.py @@ -0,0 +1,64 @@ +# -*- encoding: utf-8 -*- +################################################################################ +# See Copyright and Licence Informations undermentioned. +################################################################################ +{ + 'name': 'Web Widget - Formulas in Float fields', + 'version': '1.0', + 'category': 'web', + 'description': """ +Allow to write simple mathematic formules in Integer / Float fields +=================================================================== + +Functionnalities : +------------------ + * Possibility to tip a text like "=45 + 4/3 - 5 * (2 +1)" ; + * if the formula is correct, The result will be computed and displayed ; + * if the formula is not correct, the initial text is displayed ; + +Documentations : +------------------ + * Video : http://www.youtube.com/watch?v=jQGdD34WYrA&hd=1 + +Technical informations : +------------------------ + * Overloads "instance.web.form.FieldFloat" ; (so works for fields.integer & fields.float) ; + * To compute, the module simply use the eval() javascript function ; + * Rounding computation is not done by this module (The module has the same behaviour if the user tips "=1/3" or if he tips "0.33[...]") ; + * avoid code injonction by regexpr test : "=alert('security')" is not valid ; + +Limits : +-------- + * Only supports the four operators : "+" "-" "*" "/" and parenthesis ; + +Copyright and Licence : +----------------------- + * 2013, Groupement Régional Alimentaire de Proximité (http://www.grap.coop/) + * Licence : AGPL-3 (http://www.gnu.org/licenses/) + +Contacts : +---------- + * Sylvain LE GAL (https://twitter.com/legalsylvain); + * for any help or question about this module. + """, + 'author': 'GRAP', + 'website': 'http://www.grap.coop', + 'license': 'AGPL-3', + 'depends': [ + 'web', + ], + 'init_xml': [], + 'update_xml': [], + 'demo_xml': [], + 'js': [ + 'static/src/js/models.js', + ], + 'css': [], + 'qweb': [], + 'images': [], + 'post_load': '', + 'application': False, + 'installable': True, + 'auto_install': False, + 'images': [], +} diff --git a/web_widget_float_formula/static/src/img/icon.png b/web_widget_float_formula/static/src/img/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..c0ad599b6986494c79525d0eedddabd87a343a86 GIT binary patch literal 3262 zcma)9X)qh?7EV525&IWvDWzJq)f%;nrKqZ1wW@ZNAc%cw?OLt9)J}<|gb+a}YAIjT zzNe_ImQ>n`wHkZl`tIDBJNMsxXP)z%^Uj=k-*bLEb54S}sR1j~B_;p>z-o9$&+?q3 z{{bWYxg}^i51rGW0k;gT7|%~Qqig(m4D!8W6953P_51^1)(tlP^Gm)!{fB|~eBgm0 z&i*ifj;oIg?24hcvm4A3=Ir{!ZvdtN0I;YV>gia8zS&%SVr6Ar)U~@Ec7MZMTlj^( zw49T+m6flzVoRVM-1t#mOOS@moU0waCD^OUBm|NwCQ1@P{z&dKMW>Lm%U|)C3{Q9| zczdz%=I~yzaMA0Dzawn4i`hDL?&+1}$a3+BLVc(S^XXV>+S*=$-+#<`D9>fPN336NY~Pz*FMLc|@!n*M{O<3#5;P$1#efc5K=6kmSvmlox;lO4%@vUlf7R~Yy*cQ@FvwT^hl#>Vwv@I)7`?>9N*5K!jSVYq7T!=r1Va4(Rrb$t63(D}>6GzCAaU zKwnwZ=2G|3s!%*cHJ2m!FGqWz6H^0N^?2qv`%|t(*K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r5mSW7Aavx!7p|Jb!o^jWkjO5?<)sH+ej2 zB#s!AwS4493gg2;F3jKIPah!dp+ty8T_gLcOzUT=SM$^6REf#g-(7}dS~m_E)ErkA z`MRoPHVV*_q{xcwC_kMw9KVAbeI=pNoM-fFHBK|)9#r9Th1WF)D}x*SoP^qa=$o2J zo~SBG}Ha*Ui?TfSC*#g<^l-L=f6z+(8+ zILmmAC%|o2Fk5p^Ntn01_`C>ZhANe?_wLBZX!*0M`mKMSz zz5J{aeK?c>1x;QmDy6e5B9C~J#83CH_8{K{fU3i1o>owu{oOsd`q8W_w#TO3dPgpeeq)%(XM2Gr1hkoTK Date: Fri, 21 Feb 2014 14:14:49 +0100 Subject: [PATCH 02/16] [FIX] remove company logo in the icon.png file. --- .../static/src/img/icon.png | Bin 3262 -> 3110 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/web_widget_float_formula/static/src/img/icon.png b/web_widget_float_formula/static/src/img/icon.png index c0ad599b6986494c79525d0eedddabd87a343a86..7f744399c89cd071ab9cb1033732941a9aee1c76 100644 GIT binary patch delta 3013 zcmb7`cQhN07RM7wNr~FTUPbH?BW6*vI;hmHQd?1K)JkI{iYjVrQK~gsHA|_z#U4ei zUudc*A!-y6ef_=j-g)nw_t(3BeE+!j+;i?JFrdg9;=9$jA zbaTpI+n|8x{;6K|n^|;o8OaH&1cieT(7nSg!IpMLBw~1Ak+8;h))ct2x470s2-|KQ zTXY8KLxeF{=0Ew*5J+Ad=<}|BUOw#&gVK7Cn7BoX%pti~X>+fBA6NVk;ZkomqRhj{ zPJhlo0yGY`)XbI8%5UzydrjpgQNHZpPgMNxL|L(2G?K~4&=^<}1L z{UTUHZSUQh?$SHWAYHB41sbRK^1bu8COBs5z`?J4F7}+H`qA~--yyMx;_&;btlQy0 zH(6h^AUFGGZQC%Oiq?m(F3{C}UwQweq+rPY7P3VVG({9;Nmr&D+8Y}G60vX{N;}Qc zlBW(zf5jeOkeAq7C198tJ+}bJeqad*GT)w$p5K>9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n&S6Q?N1xjx&li{UjR$tf#$V;a&@QWn*~b5-EF+4Vbw z+nc-QmpCgXZa8Egn&?yo!dWs0E|8gqe5C2QMcrY_t&ZhkDX{A8z8C*fK(aEYyNoH{)$?(zB>2;CT>xl{HYj&+m6=(bHGjnjRU&h@Be)m&o*}uaz*-%p_oiBvfErOWA znZ`tU_0U2;#o?CumUlZ^=Dk{W6hp#SB*P+T19-SXrtzK-825a!N&HuUx#g3GA zW;rP4^0VU%+$lhgnMZz^$0qe^%M20u`t|FQmZ4ku1SYJr)Mr~0K}xdUbn%xjNe>kC zwWs)MYHY=d1vkB`H(62BMy`oYS$swo*Cb=xIYY+L-(uL-VLCHi4dVDX0M5+_EG3qX)@Ua z?mUrh|3v3pPRfi9Iq||faU{NJZI4~ob$MQ-ynEK~ZpYtwuS1*e4cUJAd-c*hY0p$vqxjo&LRnm{X4fUuBCj?QfTz8hO z;)EVg#Xs;8ysBq&j$v=ZRzjijHG0Cb)s(6+8pAbVW1-XyPDIxmg!!8269xVD$qDal7}MeCi*v`wdB9?5 zfhgmD6I*I^)af&$&Ss?*$69a#!oPuXxaYr<7pu7cmR0?omCR(o3pme{S_M|sGP!2c zY*&^JyZ87gps@E<%t?@ z{RUFprxi)k(y3W1$r-n2j0CsvZea7yyL$>I86h|&=4yw_=ozR_!KVDqs1ve6gq zw+<#x>pNC)#F-aNy**u-qZMrj=Y&Od3H0^e+N2|=UboaC_(yyJl~{jK*oNaEHTLBe zDa7{yh(kgdJkZ~7i$bCDXW}(iM+;5f;&56UuT%p(Q~!gvIf&5|;|ff`wvPMRy#g9z z^BYD(Fd_EUD+n><#wF~Zu9$HE@Qy2iAP`7hQPH{hgam|)S0`6zL1SZ9QBl!jzmw5y z8{C5|L Date: Sat, 8 Mar 2014 00:37:39 +0100 Subject: [PATCH 03/16] [REF] change description in the __openerp__.py file. --- web_widget_float_formula/__openerp__.py | 39 ++++++++++++------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/web_widget_float_formula/__openerp__.py b/web_widget_float_formula/__openerp__.py index 8a34c04e..2cd5e8ab 100644 --- a/web_widget_float_formula/__openerp__.py +++ b/web_widget_float_formula/__openerp__.py @@ -7,38 +7,38 @@ 'version': '1.0', 'category': 'web', 'description': """ -Allow to write simple mathematic formules in Integer / Float fields +Allow to write simple mathematic formulas in Integer / Float fields =================================================================== -Functionnalities : +Functionnalities: ------------------ - * Possibility to tip a text like "=45 + 4/3 - 5 * (2 +1)" ; - * if the formula is correct, The result will be computed and displayed ; - * if the formula is not correct, the initial text is displayed ; + * Possibility to tip a text like "=45 + 4/3 - 5 * (2 +1)"; + * if the formula is correct, The result will be computed and displayed; + * if the formula is not correct, the initial text is displayed; -Documentations : +Documentations: ------------------ - * Video : http://www.youtube.com/watch?v=jQGdD34WYrA&hd=1 + * Video: http://www.youtube.com/watch?v=jQGdD34WYrA&hd=1 -Technical informations : +Technical informations: ------------------------ - * Overloads "instance.web.form.FieldFloat" ; (so works for fields.integer & fields.float) ; - * To compute, the module simply use the eval() javascript function ; - * Rounding computation is not done by this module (The module has the same behaviour if the user tips "=1/3" or if he tips "0.33[...]") ; - * avoid code injonction by regexpr test : "=alert('security')" is not valid ; + * Overloads "instance.web.form.FieldFloat"; (so works for fields.integer & fields.float); + * To compute, the module simply use the eval() javascript function; + * Rounding computation is not done by this module (The module has the same behaviour if the user tips "=1/3" or if he tips "0.33[...]"); + * avoid code injonction by regexpr test: "=alert('security')" is not valid; -Limits : +Limits: -------- - * Only supports the four operators : "+" "-" "*" "/" and parenthesis ; + * Only supports the four operators: "+" "-" "*" "/" and parenthesis; -Copyright and Licence : +Copyright and Licence: ----------------------- * 2013, Groupement Régional Alimentaire de Proximité (http://www.grap.coop/) - * Licence : AGPL-3 (http://www.gnu.org/licenses/) + * Licence: AGPL-3 (http://www.gnu.org/licenses/) Contacts : ---------- - * Sylvain LE GAL (https://twitter.com/legalsylvain); + * Sylvain LE GAL (https://twitter.com/legalsylvain); * for any help or question about this module. """, 'author': 'GRAP', @@ -47,9 +47,8 @@ Contacts : 'depends': [ 'web', ], - 'init_xml': [], - 'update_xml': [], - 'demo_xml': [], + 'data': [], + 'demo': [], 'js': [ 'static/src/js/models.js', ], From 35536443a172ec6d26e81555005f9ca023db06b4 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 7 Jul 2014 13:11:28 +0200 Subject: [PATCH 04/16] move all addons to __unported__, set all addons as not installable --- web_widget_float_formula/__init__.py | 4 - web_widget_float_formula/__openerp__.py | 63 --------- .../static/src/img/icon.png | Bin 3110 -> 0 bytes .../static/src/js/models.js | 132 ------------------ 4 files changed, 199 deletions(-) delete mode 100644 web_widget_float_formula/__init__.py delete mode 100644 web_widget_float_formula/__openerp__.py delete mode 100644 web_widget_float_formula/static/src/img/icon.png delete mode 100644 web_widget_float_formula/static/src/js/models.js diff --git a/web_widget_float_formula/__init__.py b/web_widget_float_formula/__init__.py deleted file mode 100644 index 97833ca3..00000000 --- a/web_widget_float_formula/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- encoding: utf-8 -*- -################################################################################ -# See __openerp__.py file for Copyright and Licence Informations. -################################################################################ diff --git a/web_widget_float_formula/__openerp__.py b/web_widget_float_formula/__openerp__.py deleted file mode 100644 index 2cd5e8ab..00000000 --- a/web_widget_float_formula/__openerp__.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- encoding: utf-8 -*- -################################################################################ -# See Copyright and Licence Informations undermentioned. -################################################################################ -{ - 'name': 'Web Widget - Formulas in Float fields', - 'version': '1.0', - 'category': 'web', - 'description': """ -Allow to write simple mathematic formulas in Integer / Float fields -=================================================================== - -Functionnalities: ------------------- - * Possibility to tip a text like "=45 + 4/3 - 5 * (2 +1)"; - * if the formula is correct, The result will be computed and displayed; - * if the formula is not correct, the initial text is displayed; - -Documentations: ------------------- - * Video: http://www.youtube.com/watch?v=jQGdD34WYrA&hd=1 - -Technical informations: ------------------------- - * Overloads "instance.web.form.FieldFloat"; (so works for fields.integer & fields.float); - * To compute, the module simply use the eval() javascript function; - * Rounding computation is not done by this module (The module has the same behaviour if the user tips "=1/3" or if he tips "0.33[...]"); - * avoid code injonction by regexpr test: "=alert('security')" is not valid; - -Limits: --------- - * Only supports the four operators: "+" "-" "*" "/" and parenthesis; - -Copyright and Licence: ------------------------ - * 2013, Groupement Régional Alimentaire de Proximité (http://www.grap.coop/) - * Licence: AGPL-3 (http://www.gnu.org/licenses/) - -Contacts : ----------- - * Sylvain LE GAL (https://twitter.com/legalsylvain); - * for any help or question about this module. - """, - 'author': 'GRAP', - 'website': 'http://www.grap.coop', - 'license': 'AGPL-3', - 'depends': [ - 'web', - ], - 'data': [], - 'demo': [], - 'js': [ - 'static/src/js/models.js', - ], - 'css': [], - 'qweb': [], - 'images': [], - 'post_load': '', - 'application': False, - 'installable': True, - 'auto_install': False, - 'images': [], -} diff --git a/web_widget_float_formula/static/src/img/icon.png b/web_widget_float_formula/static/src/img/icon.png deleted file mode 100644 index 7f744399c89cd071ab9cb1033732941a9aee1c76..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3110 zcmbuBc{tSn7RSG1CMHXE$-ab<-B`vNvZiF2?1}8M8@s8&jF6CBAySr-HA>d(lO;=$ z?Kd>ZI*cV@OkLgQ{+{1`p8MxL&vVZCoOAy9{PlXjlg!PGnCN-v0RUh!G1j*{>6kwW zr9G+L+Af194HBYff`pz#4Ad?0WIi2eY!?CmXL|l5C|l|b@5%BU%D@(772tsicL{a} zbln1OxeJ;2xp=x;y1TeV2I1W`0f3>@L|+#fQ9znUBa!X`bmT2Y@DSq`T+#Rf9CM!L zazZ1+Ax(=>gY@wEbotOXs>(J&!xQ%p+3X!8u4>d3R(NHy&09_cYUvjdJ>E5{d^3%0 zsUSIH6&Yb*IOFdAhG1(469PUoFh^MC`_&w>wL7=mOo-fU`#9$U=s|_CEPoe))a8Lb zpTbc?t13ba{cujT`<AN)+xyei zNM-76cCL$5+SJdV7AfIVLK@}VjaA5jxJa-r$~xQjlPRu6J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fmNTulv;s8=hf&b%V zcyv*bw|a{b^gS9Y8VOmUqAz+<_4@;}qfL46pp~>zy1`QBu)CTv0ESBUFoaH!dm2<5 z>fb&c?|mEnj`l51O%zg~bFuC22_)~u^b z#dfk&y2Y>g)oKZoKegB5GkMW)Ve+>-wfG5M?JSmvD8Vm1xW15I)*rd5Q2@1c02Els zj@V_D`=ihU&MOkGhA>a6Tgp7|%g;V#V_wDPFd?=iS^@@fy+6$mmyn>&LDTYt&iv(P z6nWlQn(I=Dxy~zV4P@#(NS>SVWOqfHOC#p!2Ua335uBh5%~7DCX^AzH{==wh@RB$YN&x+|15W#{o z5LHp(V(&Y}=%jmFMpiY?e0PkPCm@KcIN%t%NfFLs;sP*r)$|Xv6|r=v>~Eq;I?xH7 z&&~oBNJV}B4hDJE;}rW+R{OClnz9o0?47Vu9#SbXhGc9kOW5PJKj6o* zs*Bz@t^R>DWgZulwz&1dfSd{G&SeI|i6di;dHMNiZD--+tWmn5QS79DsTSPJ#aWx> z^olFms2L5xbTVgH@Y8iXKpe@Y5DA?%szc;#JgeJ_UgaB8E%Tpj!7?}Laaq*>|I&BB zwnP&DelCR{QNCqAvojd!Xn+t;-N(Uv#J{#)un4ZMqdpW6eQ~YOkoe`CG4v^Gr^N|* z{==$MyXg(mtnV{3SYv*vRmEsS9CF3pcWe@1Lo(RKUomb2rxvz7oR?x0>Q#O9EIR3X zytVriT3_ZpdYo#^1I!s!BJ1CKnKsy>x_tKiLf+uYE?5WF6yTT9AADp|6g=GDeV}gi z4k@XK*^fMB^Q^Cuxi>9V*cifod*a##F_dBY^;=_=J8OLVJtOQ@BT8OB3QkPZe2AQ8 z7Qkp6U7*#{lrI>d1t7P&(etyb{Slqq-UaLyBjrA Date: Fri, 17 Jul 2015 16:43:09 +0200 Subject: [PATCH 05/16] [PORT][WIP] move web_widget_float_formula from 'unported' folder; --- web_widget_float_formula/__init__.py | 4 + web_widget_float_formula/__openerp__.py | 63 +++++++++ .../static/src/img/icon.png | Bin 0 -> 3110 bytes .../static/src/js/models.js | 132 ++++++++++++++++++ 4 files changed, 199 insertions(+) create mode 100644 web_widget_float_formula/__init__.py create mode 100644 web_widget_float_formula/__openerp__.py create mode 100644 web_widget_float_formula/static/src/img/icon.png create mode 100644 web_widget_float_formula/static/src/js/models.js diff --git a/web_widget_float_formula/__init__.py b/web_widget_float_formula/__init__.py new file mode 100644 index 00000000..97833ca3 --- /dev/null +++ b/web_widget_float_formula/__init__.py @@ -0,0 +1,4 @@ +# -*- encoding: utf-8 -*- +################################################################################ +# See __openerp__.py file for Copyright and Licence Informations. +################################################################################ diff --git a/web_widget_float_formula/__openerp__.py b/web_widget_float_formula/__openerp__.py new file mode 100644 index 00000000..9f004bbd --- /dev/null +++ b/web_widget_float_formula/__openerp__.py @@ -0,0 +1,63 @@ +# -*- encoding: utf-8 -*- +################################################################################ +# See Copyright and Licence Informations undermentioned. +################################################################################ +{ + 'name': 'Web Widget - Formulas in Float fields', + 'version': '1.0', + 'category': 'web', + 'description': """ +Allow to write simple mathematic formulas in Integer / Float fields +=================================================================== + +Functionnalities: +------------------ + * Possibility to tip a text like "=45 + 4/3 - 5 * (2 +1)"; + * if the formula is correct, The result will be computed and displayed; + * if the formula is not correct, the initial text is displayed; + +Documentations: +------------------ + * Video: http://www.youtube.com/watch?v=jQGdD34WYrA&hd=1 + +Technical informations: +------------------------ + * Overloads "instance.web.form.FieldFloat"; (so works for fields.integer & fields.float); + * To compute, the module simply use the eval() javascript function; + * Rounding computation is not done by this module (The module has the same behaviour if the user tips "=1/3" or if he tips "0.33[...]"); + * avoid code injonction by regexpr test: "=alert('security')" is not valid; + +Limits: +-------- + * Only supports the four operators: "+" "-" "*" "/" and parenthesis; + +Copyright and Licence: +----------------------- + * 2013, Groupement Régional Alimentaire de Proximité (http://www.grap.coop/) + * Licence: AGPL-3 (http://www.gnu.org/licenses/) + +Contacts : +---------- + * Sylvain LE GAL (https://twitter.com/legalsylvain); + * for any help or question about this module. + """, + 'author': "GRAP,Odoo Community Association (OCA)", + 'website': 'http://www.grap.coop', + 'license': 'AGPL-3', + 'depends': [ + 'web', + ], + 'data': [], + 'demo': [], + 'js': [ + 'static/src/js/models.js', + ], + 'css': [], + 'qweb': [], + 'images': [], + 'post_load': '', + 'application': False, + 'installable': False, + 'auto_install': False, + 'images': [], +} diff --git a/web_widget_float_formula/static/src/img/icon.png b/web_widget_float_formula/static/src/img/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..7f744399c89cd071ab9cb1033732941a9aee1c76 GIT binary patch literal 3110 zcmbuBc{tSn7RSG1CMHXE$-ab<-B`vNvZiF2?1}8M8@s8&jF6CBAySr-HA>d(lO;=$ z?Kd>ZI*cV@OkLgQ{+{1`p8MxL&vVZCoOAy9{PlXjlg!PGnCN-v0RUh!G1j*{>6kwW zr9G+L+Af194HBYff`pz#4Ad?0WIi2eY!?CmXL|l5C|l|b@5%BU%D@(772tsicL{a} zbln1OxeJ;2xp=x;y1TeV2I1W`0f3>@L|+#fQ9znUBa!X`bmT2Y@DSq`T+#Rf9CM!L zazZ1+Ax(=>gY@wEbotOXs>(J&!xQ%p+3X!8u4>d3R(NHy&09_cYUvjdJ>E5{d^3%0 zsUSIH6&Yb*IOFdAhG1(469PUoFh^MC`_&w>wL7=mOo-fU`#9$U=s|_CEPoe))a8Lb zpTbc?t13ba{cujT`<AN)+xyei zNM-76cCL$5+SJdV7AfIVLK@}VjaA5jxJa-r$~xQjlPRu6Jo>ZzPaBuP z$c+If+|$YEy65B&4!=TN+5E=^{PAUOl7BC>7pmDdbB; za{+!SSp1spaJyeqsk0R)1p$93_Ph^%n6;d5Nw5=rN%^XfvvXi!O|W=g8G8e<=Nb0K zapY_6riZ5w)6fU*2CrnhupyG~_QNO-_Y{RPPtTCMgB9#qV29mq$Y8alGF^C$raan?OGi-doHx<%+0%255NaKw&7;-y zn^T9x*L?LIhRHQUR$n6^VSlyl2+`j+^yMDiGsQdrk+598VnJ2b?gv^|mbs?kLkJD@XH=ts85vjfvbWmQh7_d31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ua335uBh5%~7DCX^AzH{==wh@RB$YN&x+|15W#{o z5LHp(V(&Y}=%jmFMpiY?e0PkPCm@KcIN%t%NfFLs;sP*r)$|Xv6|r=v>~Eq;I?xH7 z&&~oBNJV}B4hDJE;}rW+R{OClnz9o0?47Vu9#SbXhGc9kOW5PJKj6o* zs*Bz@t^R>DWgZulwz&1dfSd{G&SeI|i6di;dHMNiZD--+tWmn5QS79DsTSPJ#aWx> z^olFms2L5xbTVgH@Y8iXKpe@Y5DA?%szc;#JgeJ_UgaB8E%Tpj!7?}Laaq*>|I&BB zwnP&DelCR{QNCqAvojd!Xn+t;-N(Uv#J{#)un4ZMqdpW6eQ~YOkoe`CG4v^Gr^N|* z{==$MyXg(mtnV{3SYv*vRmEsS9CF3pcWe@1Lo(RKUomb2rxvz7oR?x0>Q#O9EIR3X zytVriT3_ZpdYo#^1I!s!BJ1CKnKsy>x_tKiLf+uYE?5WF6yTT9AADp|6g=GDeV}gi z4k@XK*^fMB^Q^Cuxi>9V*cifod*a##F_dBY^;=_=J8OLVJtOQ@BT8OB3QkPZe2AQ8 z7Qkp6U7*#{lrI>d1t7P&(etyb{Slqq-UaLyBjrA Date: Fri, 17 Jul 2015 16:45:13 +0200 Subject: [PATCH 06/16] [PORT][WIP] 'web_widget_float_formula' : recover last changes from 7.0 branch; --- web_widget_float_formula/__init__.py | 4 ++-- web_widget_float_formula/__openerp__.py | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/web_widget_float_formula/__init__.py b/web_widget_float_formula/__init__.py index 97833ca3..41a41f91 100644 --- a/web_widget_float_formula/__init__.py +++ b/web_widget_float_formula/__init__.py @@ -1,4 +1,4 @@ # -*- encoding: utf-8 -*- -################################################################################ +############################################################################### # See __openerp__.py file for Copyright and Licence Informations. -################################################################################ +############################################################################### diff --git a/web_widget_float_formula/__openerp__.py b/web_widget_float_formula/__openerp__.py index 9f004bbd..ba90a4b5 100644 --- a/web_widget_float_formula/__openerp__.py +++ b/web_widget_float_formula/__openerp__.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- -################################################################################ +############################################################################### # See Copyright and Licence Informations undermentioned. -################################################################################ +############################################################################### { 'name': 'Web Widget - Formulas in Float fields', 'version': '1.0', @@ -22,9 +22,11 @@ Documentations: Technical informations: ------------------------ - * Overloads "instance.web.form.FieldFloat"; (so works for fields.integer & fields.float); + * Overloads "instance.web.form.FieldFloat"; (so works for fields.integer & + fields.float); * To compute, the module simply use the eval() javascript function; - * Rounding computation is not done by this module (The module has the same behaviour if the user tips "=1/3" or if he tips "0.33[...]"); + * Rounding computation is not done by this module (The module has the same + behaviour if the user tips "=1/3" or if he tips "0.33[...]"); * avoid code injonction by regexpr test: "=alert('security')" is not valid; Limits: @@ -33,7 +35,8 @@ Limits: Copyright and Licence: ----------------------- - * 2013, Groupement Régional Alimentaire de Proximité (http://www.grap.coop/) + * 2013, Groupement Régional Alimentaire de Proximité + (http://www.grap.coop/) * Licence: AGPL-3 (http://www.gnu.org/licenses/) Contacts : @@ -46,7 +49,7 @@ Contacts : 'license': 'AGPL-3', 'depends': [ 'web', - ], + ], 'data': [], 'demo': [], 'js': [ @@ -57,7 +60,7 @@ Contacts : 'images': [], 'post_load': '', 'application': False, - 'installable': False, + 'installable': True, 'auto_install': False, 'images': [], } From 72c538e263346a8b7b8a696a2d3fbc6241e2c3f9 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 17 Jul 2015 17:10:40 +0200 Subject: [PATCH 07/16] [PORT][REF] icon in description folder; move module description into readme file; use qweb file to include js file; --- web_widget_float_formula/README.rst | 55 ++++++++++++++++++ web_widget_float_formula/__openerp__.py | 54 +---------------- .../static/{src/img => description}/icon.png | Bin web_widget_float_formula/views/qweb.xml | 9 +++ 4 files changed, 67 insertions(+), 51 deletions(-) create mode 100644 web_widget_float_formula/README.rst rename web_widget_float_formula/static/{src/img => description}/icon.png (100%) create mode 100644 web_widget_float_formula/views/qweb.xml diff --git a/web_widget_float_formula/README.rst b/web_widget_float_formula/README.rst new file mode 100644 index 00000000..83b7c132 --- /dev/null +++ b/web_widget_float_formula/README.rst @@ -0,0 +1,55 @@ +Allow to write simple mathematic formulas in Integer / Float fields +=================================================================== + +* Possibility to tip a text like "=45 + 4/3 - 5 * (2 +1)"; +* if the formula is correct, The result will be computed and displayed; +* if the formula is not correct, the initial text is displayed; + +Technical informations +---------------------- + +* Overloads "instance.web.form.FieldFloat"; (so works for fields.integer & + fields.float); +* To compute, the module simply use the eval() javascript function; +* Rounding computation is not done by this module (The module has the same + behaviour if the user tips "=1/3" or if he tips "0.33[...]"); +* avoid code injonction by regexpr test: "=alert('security')" is not valid; + +Usage +===== + +See demo here Video: http://www.youtube.com/watch?v=jQGdD34WYrA&hd=1 + +Roadmap / Limit +=============== +* Only supports the four operators: "+" "-" "*" "/" and parenthesis; + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + +Credits +======= + +Contributors +------------ + +* Sylvain Le Gal (https://twitter.com/legalsylvain) + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. + diff --git a/web_widget_float_formula/__openerp__.py b/web_widget_float_formula/__openerp__.py index ba90a4b5..8009976e 100644 --- a/web_widget_float_formula/__openerp__.py +++ b/web_widget_float_formula/__openerp__.py @@ -6,61 +6,13 @@ 'name': 'Web Widget - Formulas in Float fields', 'version': '1.0', 'category': 'web', - 'description': """ -Allow to write simple mathematic formulas in Integer / Float fields -=================================================================== - -Functionnalities: ------------------- - * Possibility to tip a text like "=45 + 4/3 - 5 * (2 +1)"; - * if the formula is correct, The result will be computed and displayed; - * if the formula is not correct, the initial text is displayed; - -Documentations: ------------------- - * Video: http://www.youtube.com/watch?v=jQGdD34WYrA&hd=1 - -Technical informations: ------------------------- - * Overloads "instance.web.form.FieldFloat"; (so works for fields.integer & - fields.float); - * To compute, the module simply use the eval() javascript function; - * Rounding computation is not done by this module (The module has the same - behaviour if the user tips "=1/3" or if he tips "0.33[...]"); - * avoid code injonction by regexpr test: "=alert('security')" is not valid; - -Limits: --------- - * Only supports the four operators: "+" "-" "*" "/" and parenthesis; - -Copyright and Licence: ------------------------ - * 2013, Groupement Régional Alimentaire de Proximité - (http://www.grap.coop/) - * Licence: AGPL-3 (http://www.gnu.org/licenses/) - -Contacts : ----------- - * Sylvain LE GAL (https://twitter.com/legalsylvain); - * for any help or question about this module. - """, - 'author': "GRAP,Odoo Community Association (OCA)", + 'author': 'GRAP,Odoo Community Association (OCA)', 'website': 'http://www.grap.coop', 'license': 'AGPL-3', 'depends': [ 'web', ], - 'data': [], - 'demo': [], - 'js': [ - 'static/src/js/models.js', + 'data': [ + 'views/qweb.xml', ], - 'css': [], - 'qweb': [], - 'images': [], - 'post_load': '', - 'application': False, - 'installable': True, - 'auto_install': False, - 'images': [], } diff --git a/web_widget_float_formula/static/src/img/icon.png b/web_widget_float_formula/static/description/icon.png similarity index 100% rename from web_widget_float_formula/static/src/img/icon.png rename to web_widget_float_formula/static/description/icon.png diff --git a/web_widget_float_formula/views/qweb.xml b/web_widget_float_formula/views/qweb.xml new file mode 100644 index 00000000..b7467559 --- /dev/null +++ b/web_widget_float_formula/views/qweb.xml @@ -0,0 +1,9 @@ + + + + + From ed84fcfe8a16f69ec3bac2add8498144d368653f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Fri, 9 Oct 2015 10:03:39 +0200 Subject: [PATCH 08/16] [UPD] prefix versions with 8.0 --- web_widget_float_formula/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_widget_float_formula/__openerp__.py b/web_widget_float_formula/__openerp__.py index 8009976e..f84931c6 100644 --- a/web_widget_float_formula/__openerp__.py +++ b/web_widget_float_formula/__openerp__.py @@ -4,7 +4,7 @@ ############################################################################### { 'name': 'Web Widget - Formulas in Float fields', - 'version': '1.0', + 'version': '8.0.1.0.0', 'category': 'web', 'author': 'GRAP,Odoo Community Association (OCA)', 'website': 'http://www.grap.coop', From 8b704e00074ddc5071513db62bcc7d5bf9fef9e7 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 14 Oct 2015 02:57:05 +0200 Subject: [PATCH 09/16] [MIG] Make modules uninstallable --- web_widget_float_formula/__openerp__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/web_widget_float_formula/__openerp__.py b/web_widget_float_formula/__openerp__.py index f84931c6..4710a59c 100644 --- a/web_widget_float_formula/__openerp__.py +++ b/web_widget_float_formula/__openerp__.py @@ -15,4 +15,5 @@ 'data': [ 'views/qweb.xml', ], + 'installable': False, } From 2b935a60328e17f429ad8fe05bc16b7333bd4ac7 Mon Sep 17 00:00:00 2001 From: Oleg Bulkin Date: Mon, 12 Sep 2016 11:33:29 -0700 Subject: [PATCH 10/16] [MIG] web_widget_float_formula: v9 with i18n * Update JS to use v9 module system * Fix non-functioning logic for obtaining the value of an input element * Eliminate redundant calls (e.g. there were multiple calls to eval) * Modify formula cleanup to use localized decimal point and thousands separator characters * Add JS unit tests --- web_widget_float_formula/README.rst | 75 +++++--- web_widget_float_formula/__init__.py | 4 - web_widget_float_formula/__openerp__.py | 23 +-- .../static/src/js/models.js | 132 -------------- .../static/src/js/web_widget_float_formula.js | 103 +++++++++++ .../tests/js/test_web_widget_float_formula.js | 161 ++++++++++++++++++ web_widget_float_formula/tests/__init__.py | 5 + web_widget_float_formula/tests/test_js.py | 15 ++ web_widget_float_formula/views/qweb.xml | 9 - .../views/web_widget_float_formula.xml | 21 +++ 10 files changed, 369 insertions(+), 179 deletions(-) delete mode 100644 web_widget_float_formula/static/src/js/models.js create mode 100644 web_widget_float_formula/static/src/js/web_widget_float_formula.js create mode 100644 web_widget_float_formula/static/tests/js/test_web_widget_float_formula.js create mode 100644 web_widget_float_formula/tests/__init__.py create mode 100644 web_widget_float_formula/tests/test_js.py delete mode 100644 web_widget_float_formula/views/qweb.xml create mode 100644 web_widget_float_formula/views/web_widget_float_formula.xml diff --git a/web_widget_float_formula/README.rst b/web_widget_float_formula/README.rst index 83b7c132..092e8aed 100644 --- a/web_widget_float_formula/README.rst +++ b/web_widget_float_formula/README.rst @@ -1,36 +1,61 @@ -Allow to write simple mathematic formulas in Integer / Float fields -=================================================================== +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 -* Possibility to tip a text like "=45 + 4/3 - 5 * (2 +1)"; -* if the formula is correct, The result will be computed and displayed; -* if the formula is not correct, the initial text is displayed; +======================== +Formulas in Float Fields +======================== -Technical informations ----------------------- +This module allows the use of simple math formulas in integer/float fields +(e.g. "=45 + 4/3 - 5 * (2 + 1)"). -* Overloads "instance.web.form.FieldFloat"; (so works for fields.integer & - fields.float); -* To compute, the module simply use the eval() javascript function; -* Rounding computation is not done by this module (The module has the same - behaviour if the user tips "=1/3" or if he tips "0.33[...]"); -* avoid code injonction by regexpr test: "=alert('security')" is not valid; +* Only supports parentheses, decimal points, thousands separators, and the + operators "+", "-", "*", and "/" +* Will use the decimal point and thousands separator characters associated + with your language +* If the formula is valid, the result will be computed and displayed, and the + formula will be stored for editing +* If the formula is not valid, it's retained in the field as text + +**Technical Details** + +* Overloads web.form_widgets.FieldFloat (so it works for fields.integer & + fields.float) +* Uses the eval() JS function to evaluate the formula +* Does not do any rounding (this is handled elsewhere) +* Avoids code injection by applying strict regex to formula prior to eval() + (e.g. "=alert('security')" would not get evaluated) + +Installation +============ + +To install this module, simply follow the standard install process. + +Configuration +============= + +No configuration is needed or possible. Usage ===== -See demo here Video: http://www.youtube.com/watch?v=jQGdD34WYrA&hd=1 +Install and enjoy. A short demo video can be found at +http://www.youtube.com/watch?v=jQGdD34WYrA. -Roadmap / Limit -=============== -* Only supports the four operators: "+" "-" "*" "/" and parenthesis; +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/162/9.0 + +Known Issues / Roadmap +====================== Bug Tracker =========== Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed feedback -`here `_. +If you spotted it first, help us smash it by providing detailed and welcomed +feedback. Credits ======= @@ -39,17 +64,19 @@ Contributors ------------ * Sylvain Le Gal (https://twitter.com/legalsylvain) +* Oleg Bulkin Maintainer ---------- -.. image:: http://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: http://odoo-community.org +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org This module is maintained by the OCA. -OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. To contribute to this module, please visit http://odoo-community.org. - diff --git a/web_widget_float_formula/__init__.py b/web_widget_float_formula/__init__.py index 41a41f91..e69de29b 100644 --- a/web_widget_float_formula/__init__.py +++ b/web_widget_float_formula/__init__.py @@ -1,4 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################### -# See __openerp__.py file for Copyright and Licence Informations. -############################################################################### diff --git a/web_widget_float_formula/__openerp__.py b/web_widget_float_formula/__openerp__.py index 4710a59c..3b901505 100644 --- a/web_widget_float_formula/__openerp__.py +++ b/web_widget_float_formula/__openerp__.py @@ -1,19 +1,22 @@ -# -*- encoding: utf-8 -*- -############################################################################### -# See Copyright and Licence Informations undermentioned. -############################################################################### +# -*- coding: utf-8 -*- +# Copyright GRAP +# Copyright 2016 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + { - 'name': 'Web Widget - Formulas in Float fields', - 'version': '8.0.1.0.0', - 'category': 'web', - 'author': 'GRAP,Odoo Community Association (OCA)', + 'name': 'Web Widget - Formulas in Float Fields', + 'summary': 'Allow use of simple formulas in float fields', + 'version': '9.0.1.0.0', + 'category': 'Web', + 'author': 'GRAP, LasLabs, Odoo Community Association (OCA)', 'website': 'http://www.grap.coop', 'license': 'AGPL-3', 'depends': [ 'web', ], 'data': [ - 'views/qweb.xml', + 'views/web_widget_float_formula.xml', ], - 'installable': False, + 'installable': True, + 'application': False, } diff --git a/web_widget_float_formula/static/src/js/models.js b/web_widget_float_formula/static/src/js/models.js deleted file mode 100644 index 6a132251..00000000 --- a/web_widget_float_formula/static/src/js/models.js +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* -See __openerp__.py file for Copyright and Licence Informations. -*******************************************************************************/ - -openerp.web_widget_float_formula = function (instance) { - - instance.web.FormView = instance.web.FormView.extend({ - /*********************************************************************** - Overload section - ***********************************************************************/ - - /** - * Overload : '_process_save' function - 1: to force computation of formula if the user realize a keydown directly after the formula input in a tree view ; - 2: to clean up the '_formula_text' value in all case to avoid bugs in tree view ; - */ - _process_save: function(save_obj) { - for (var f in this.fields) { - if (!this.fields.hasOwnProperty(f)) { continue; } - f = this.fields[f]; - if (f.hasOwnProperty('_formula_text')){ - currentval = f.$('input').attr('value') - if (typeof currentval != 'undefined'){ - formula = f._get_valid_expression(currentval); - if (formula){ - f._compute_result(); - } - } - f._clean_formula_text(); - } - } - return this._super(save_obj); - }, - - }); - - instance.web.form.FieldFloat = instance.web.form.FieldFloat.extend({ - /*********************************************************************** - Overload section - ***********************************************************************/ - - /** - * Overload : 'start' function to catch 'blur' and 'focus' events. - */ - start: function() { - this.on("blurred", this, this._compute_result); - this.on("focused", this, this._display_formula); - return this._super(); - }, - - /** - * Overload : 'initialize_content' function to clean '_formula_text' value. - */ - initialize_content: function() { - this._clean_formula_text(); - return this._super(); - }, - - /*********************************************************************** - Custom section - ***********************************************************************/ - - /** - * keep in memory the formula to allow user to edit it again. - The formula has to be keeped in memory until a 'save' action. - */ - _formula_text: '', - - /** - * Clean '_formula_text' value. - */ - _clean_formula_text: function() { - this._formula_text = ''; - }, - - /** - * Return a valid formula from a val, if possible. - Otherwise, return false. - */ - _get_valid_expression: function(val) { - // Trim the value - currenttxt = val.toString().replace(/^\s+|\s+$/g, ''); - // Test if the value is a formula - if (currenttxt[0] == '=') { - // allowed chars : [0-9] .,+-/*() and spaces - myreg = RegExp('[0-9]|\\s|\\.|,|\\(|\\)|\\+|\\-|\\*|\\/','g') - // Test to avoid code injonction in eval function. - if (currenttxt.substring(1).replace(myreg, '') == ''){ - try { - // Try to compute - formula = currenttxt.substring(1).replace(/,/g,'.'); - var floatval = eval(formula); - }catch (e) {} - if (typeof (floatval) != 'undefined'){ - return formula; - } - } - } - return false; - }, - - /** - * test if the content of the field is a valid formula, - * compute the result, and replace the current value by the final result. - */ - _compute_result: function() { - var formula - // Erase old formula - this._formula_text = ''; - - formula = this._get_valid_expression(this.$el.find('input').attr('value')); - if (formula){ - // Store new formula - this._formula_text = "=" + formula; - // put the result in the field - this.set_value(eval(formula)); - // Force rendering anyway to avoid format loss if no change - this.render_value(); - } - }, - - /** - * Display the stored formula in the field, to allow modification. - */ - _display_formula: function() { - if (this._formula_text != ''){ - this.$el.find('input').val(this._formula_text); - } - }, - - }); -}; diff --git a/web_widget_float_formula/static/src/js/web_widget_float_formula.js b/web_widget_float_formula/static/src/js/web_widget_float_formula.js new file mode 100644 index 00000000..a64617f2 --- /dev/null +++ b/web_widget_float_formula/static/src/js/web_widget_float_formula.js @@ -0,0 +1,103 @@ +/** +* Copyright GRAP +* Copyright 2016 LasLabs Inc. +* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +**/ + +odoo.define('web_widget_float_formula', function(require) { + "use strict"; + + var form_view = require('web.FormView'); + form_view.include({ + // Ensure that formula is computed even if user saves right away and + // clean up '_formula_text' value to avoid bugs in tree view + _process_save: function(save_obj) { + for (var f in this.fields) { + if (!this.fields.hasOwnProperty(f)) { continue; } + f = this.fields[f]; + if (f.hasOwnProperty('_formula_text')) { + f._compute_result(); + f._clean_formula_text(); + } + } + + return this._super(save_obj); + }, + }); + + var core = require('web.core'); + core.bus.on('web_client_ready', null, function () { + // Import localization values used to eval formula + var translation_params = core._t.database.parameters; + var decimal_point = translation_params.decimal_point; + var thousands_sep = translation_params.thousands_sep; + + var field_float = require('web.form_widgets').FieldFloat; + field_float.include({ + start: function() { + this.on('blurred', this, this._compute_result); + this.on('focused', this, this._display_formula); + return this._super(); + }, + + initialize_content: function() { + this._clean_formula_text(); + return this._super(); + }, + + _formula_text: '', + + _clean_formula_text: function() { + this._formula_text = ''; + }, + + _process_formula: function(formula) { + var clean_formula = formula.toString().replace(/^\s+|\s+$/g, ''); + if (clean_formula[0] == '=') { + clean_formula = clean_formula.substring(1); + var myreg = RegExp('[0-9]|\\s|\\.|,|\\(|\\)|\\+|\\-|\\*|\\/','g'); + if (clean_formula.replace(myreg, '') === '') { + return clean_formula; + } + } + return false; + }, + + _eval_formula: function(formula) { + var value; + formula = formula.replace(thousands_sep, '').replace(decimal_point, '.'); + try { + value = eval(formula); + } + catch(e) {} + + if (typeof value != 'undefined') { + return value; + } + return false; + }, + + _compute_result: function() { + this._clean_formula_text(); + + var formula = this._process_formula(this.$el.find('input').val()); + if (formula !== false) { + var value = this._eval_formula(formula); + if (value !== false) { + this._formula_text = "=" + formula; + this.set_value(value); + // Force rendering to avoid format loss if there's no change + this.render_value(); + } + } + }, + + // Display the formula stored in the field to allow modification + _display_formula: function() { + if (this._formula_text !== '') { + this.$el.find('input').val(this._formula_text); + } + }, + }); + }); +}); diff --git a/web_widget_float_formula/static/tests/js/test_web_widget_float_formula.js b/web_widget_float_formula/static/tests/js/test_web_widget_float_formula.js new file mode 100644 index 00000000..808dd56e --- /dev/null +++ b/web_widget_float_formula/static/tests/js/test_web_widget_float_formula.js @@ -0,0 +1,161 @@ +/** +* Copyright 2016 LasLabs Inc. +* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +**/ + +odoo.define_section('web_widget_float_formula', ['web.form_common', 'web.form_widgets', 'web.core'], function(test) { + 'use strict'; + + window.test_setup = function(self, form_common, form_widgets, core) { + core.bus.trigger('web_client_ready'); + var field_manager = new form_common.DefaultFieldManager(null, {}); + var filler = {'attrs': {}}; // Needed to instantiate FieldFloat + self.field = new form_widgets.FieldFloat(field_manager, filler); + self.$element = $(''); + self.field.$el.append(self.$element); + }; + + test('Float fields should have a _formula_text property that defaults to an empty string', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + + assert.strictEqual(this.field._formula_text, ''); + }); + + test('.initialize_content() on float fields should clear the _formula_text property', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + this.field._formula_text = 'test'; + this.field.initialize_content(); + + assert.strictEqual(this.field._formula_text, ''); + }); + + test('._clean_formula_text() on float fields should clear the _formula_text property', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + this.field._formula_text = 'test'; + this.field._clean_formula_text(); + + assert.strictEqual(this.field._formula_text, ''); + }); + + test('._process_formula() on float fields should return false when given invalid formulas', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + + assert.strictEqual(this.field._process_formula('2*3'), false); + assert.strictEqual(this.field._process_formula('=2*3a'), false); + }); + + test('._process_formula() on float fields should properly process a valid formula', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + + assert.strictEqual(this.field._process_formula(' =2*3\n'), '2*3'); + }); + + test('._eval_formula() on float fields should properly evaluate a valid formula', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + + assert.equal(this.field._eval_formula('2*3'), 6); + }); + + test('._eval_formula() on float fields should properly handle alternative decimal points and thousands seps', + function(assert, form_common, form_widgets, core) { + var translation_params = core._t.database.parameters; + translation_params.decimal_point = ','; + translation_params.thousands_sep = '.'; + window.test_setup(this, form_common, form_widgets, core); + + assert.equal(this.field._eval_formula('2.000*3,5'), 7000); + }); + + test('._eval_formula() on float fields should return false when given an input that evals to undefined', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + + assert.equal(this.field._eval_formula(''), false); + }); + + test('._eval_formula() on float fields should return false when given an input that cannot be evaluated', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + + assert.equal(this.field._eval_formula('*/'), false); + }); + + test('._compute_result() on float fields should always clean up _formula_text', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + this.field._formula_text = 'test'; + this.field._compute_result(); + + assert.strictEqual(this.field._formula_text, ''); + }); + + test('._compute_result() should not change the value of the associated input when it is not a valid formula', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + this.$element.val('=2*3a'); + this.field._compute_result(); + + assert.strictEqual(this.$element.val(), '=2*3a'); + }); + + test('._compute_result() should not change the value of the associated input when it cannot be evaled', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + this.$element.val('=*/'); + this.field._compute_result(); + + assert.strictEqual(this.$element.val(), '=*/'); + }); + + test('._compute_result() should behave properly when the current value of the input element is a valid formula', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + this.$element.val('=2*3'); + this.field._compute_result(); + + assert.equal(this.$element.val(), '6'); + assert.strictEqual(this.field._formula_text, '=2*3'); + }); + + test('._display_formula() should update the value of the input element when there is a stored formula', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + this.field._formula_text = "test"; + this.field._display_formula(); + + assert.equal(this.$element.val(), 'test'); + }); + + test('.start() on float fields should add a handler that calls ._compute_result() when the field is blurred', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + this.field.called = false; + this.field._compute_result = function() { + this.called = true; + }; + this.field.start(); + this.field.trigger('blurred'); + + assert.strictEqual(this.field.called, true); + }); + + test('.start() on float fields should add a handler that calls ._display_formula() when the field is focused', + function(assert, form_common, form_widgets, core) { + window.test_setup(this, form_common, form_widgets, core); + this.field.called = false; + this.field._display_formula = function() { + this.called = true; + }; + this.field.start(); + this.field.trigger('focused'); + + assert.strictEqual(this.field.called, true); + }); + +}); diff --git a/web_widget_float_formula/tests/__init__.py b/web_widget_float_formula/tests/__init__.py new file mode 100644 index 00000000..9cf9e2d2 --- /dev/null +++ b/web_widget_float_formula/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_js diff --git a/web_widget_float_formula/tests/test_js.py b/web_widget_float_formula/tests/test_js.py new file mode 100644 index 00000000..4e6b155e --- /dev/null +++ b/web_widget_float_formula/tests/test_js.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 LasLabs Inc. +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from openerp.tests import HttpCase + + +class TestJS(HttpCase): + + def test_js(self): + self.phantom_js( + "/web/tests?module=web_widget_float_formula", + "", + login="admin", + ) diff --git a/web_widget_float_formula/views/qweb.xml b/web_widget_float_formula/views/qweb.xml deleted file mode 100644 index b7467559..00000000 --- a/web_widget_float_formula/views/qweb.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/web_widget_float_formula/views/web_widget_float_formula.xml b/web_widget_float_formula/views/web_widget_float_formula.xml new file mode 100644 index 00000000..63857f77 --- /dev/null +++ b/web_widget_float_formula/views/web_widget_float_formula.xml @@ -0,0 +1,21 @@ + + + + + +