You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

841 lines
29 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. /*
  2. © 2020 Le Filament (<http://www.le-filament.com>)
  3. License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. */
  5. odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) {
  6. "use strict";
  7. var chrome = require('point_of_sale.chrome');
  8. var gui = require('point_of_sale.gui');
  9. var models = require('point_of_sale.models');
  10. var screens = require('point_of_sale.screens');
  11. var popups = require('point_of_sale.popups');
  12. var container = require('pos_container.container');
  13. var models_and_db = require('pos_container.models_and_db');
  14. var core = require('web.core');
  15. var rpc = require('web.rpc');
  16. var utils = require('web.utils');
  17. var QWeb = core.qweb;
  18. var _t = core._t;
  19. var round_pr = utils.round_precision;
  20. var BalanceScaleScreenWidget = screens.ScaleScreenWidget.extend({
  21. template: 'BalanceScaleScreenWidget',
  22. next_screen: 'confirmation',
  23. previous_screen: 'products',
  24. init: function(parent, options){
  25. this._super(parent, options);
  26. this.weight_container = 0;
  27. this.weight_brut = 0;
  28. this.weight = 0;
  29. },
  30. set_weight: function(weight){
  31. var container = this.get_container();
  32. this.weight = weight;
  33. this.weight_container = container.weight;
  34. this.weight_brut = container.weight + this.weight;
  35. this.$('.weight').text(this.get_product_weight_string());
  36. this.$('.computed-price').text(this.get_computed_price_string());
  37. this.$('.weight-brut').text(this.get_product_weight_string_brut());
  38. },
  39. show: function(){
  40. var self = this;
  41. var queue = this.pos.proxy_queue;
  42. this.set_weight(0);
  43. this.renderElement();
  44. var container = this.gui.get_current_screen_param('container');
  45. queue.schedule(function () {
  46. return self.pos.proxy.reset_weight().then(function () {
  47. self.set_weight(0);
  48. self.set_price(0);
  49. });
  50. }, {duration: 500});
  51. // format price
  52. var price = this.format_price(this.get_product_price());
  53. if (container) {
  54. // format tare
  55. var tare = this.format_tare(container);
  56. queue.schedule(function () {
  57. return self.pos.proxy.scale_read_data_price_tare(price, tare).then(function (scale_answer) {
  58. self.set_weight(scale_answer.weight);
  59. self.set_price(scale_answer.price);
  60. if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) {
  61. self.gui.show_screen(self.next_screen);
  62. // add product *after* switching screen to scroll properly
  63. self.order_product();
  64. self.pos.proxy.reset_tare();
  65. }
  66. });
  67. }, {duration: 500, repeat: true});
  68. } else {
  69. queue.schedule(function () {
  70. return self.pos.proxy.scale_read_data_price(price).then(function (scale_answer) {
  71. self.set_weight(scale_answer.weight);
  72. self.set_price(scale_answer.price);
  73. if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) {
  74. self.gui.show_screen(self.next_screen);
  75. self.create_transaction();
  76. self.order_product();
  77. }
  78. });
  79. }, {duration: 500, repeat: true});
  80. }
  81. // this._super();
  82. var self = this;
  83. this.$('.next,.add-transaction').click(function(){
  84. self.create_transaction();
  85. });
  86. $("#pos-header-text-peser").removeClass('oe_hidden');
  87. },
  88. get_container: function(){
  89. return this.gui.get_current_screen_param('container');
  90. },
  91. //////////////////////////////
  92. // Ajout fonction Toledo?
  93. set_price: function (price) {
  94. if (!price) {
  95. this.$('.computed-price').text(this.get_computed_price_string());
  96. } else {
  97. this.price = price;
  98. //this.$('.price').text(this.format_currency(price));
  99. this.$('.computed-price').text(this.format_currency(price));
  100. }
  101. },
  102. get_price: function () {
  103. return this.price;
  104. },
  105. format_tare: function (container) {
  106. var tare = (Math.abs(container.weight) * 1000).toString();
  107. tare = ("0000" + tare).slice(-4);
  108. return tare;
  109. },
  110. format_price: function (product_price) {
  111. var price = (product_price * 1000).toString();
  112. price = ("000000" + price).slice(-6);
  113. return price;
  114. },
  115. // FIN
  116. //////////////////////////////
  117. get_current_container_weight: function(){
  118. var container = this.get_container();
  119. if (container){
  120. return (this.weight_container || 0).toFixed(3) + ' kg';
  121. }
  122. else{
  123. ''
  124. }
  125. },
  126. get_current_container_name: function(){
  127. var container = this.get_container();
  128. if (container){
  129. return container.name;
  130. }
  131. else{
  132. ''
  133. }
  134. },
  135. get_product_weight_string_brut: function(){
  136. var product = this.get_product();
  137. var defaultstr = (this.weight + this.weight_container || 0).toFixed(3) + ' Kg';
  138. if(!product || !this.pos){
  139. return defaultstr;
  140. }
  141. var unit_id = product.uom_id;
  142. if(!unit_id){
  143. return defaultstr;
  144. }
  145. var unit = this.pos.units_by_id[unit_id[0]];
  146. var weight = round_pr(this.weight + this.weight_container || 0, unit.rounding);
  147. var weightstr = weight.toFixed(Math.ceil(Math.log(1.0/unit.rounding) / Math.log(10) ));
  148. weightstr += ' ' + unit.name;
  149. return weightstr;
  150. },
  151. hide: function(){
  152. this._super();
  153. $("#pos-header-text-peser").addClass('oe_hidden');
  154. },
  155. create_transaction: function(){
  156. var self = this;
  157. var fields = {};
  158. var container = this.get_container();
  159. var product = this.get_product();
  160. var qrcode = '';
  161. var ean13 = '';
  162. var ean13_verif = '';
  163. fields['qrcode'] = qrcode.concat('https://qr.mayam.fr/', container.barcode);
  164. fields['container_ean13'] = container.barcode;
  165. fields['product_id'] = this.get_product().id;
  166. // var product_id = (this.get_product().id).toString();
  167. var product_id = ("00000" + product.default_code.toString()).slice(-5);
  168. var weight_str = (this.weight * 1000).toString();
  169. weight_str = ("00000" + weight_str).slice(-5);
  170. ean13 = ean13.concat(26,product_id,weight_str,4);
  171. var weight_brut_str = (this.weight_brut * 1000).toString();
  172. weight_brut_str = ("00000" + weight_brut_str).slice(-5);
  173. ean13_verif = ean13_verif.concat(26,'00999',weight_brut_str,4);
  174. var ean13_digit = this.pos.barcode_reader.barcode_parser.sanitize_ean(ean13);
  175. var ean13_verif_digit = this.pos.barcode_reader.barcode_parser.sanitize_ean(ean13_verif);
  176. fields['ean13'] = ean13_digit;
  177. fields['ean13_verif'] = ean13_verif_digit;
  178. fields['balance_id'] = this.pos.get_balance_id();
  179. var today = new Date();
  180. var date = today.getFullYear() + '-' + (today.getMonth()+1) + '-' + today.getDate();
  181. var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
  182. var date_time = date + ' ' + time;
  183. fields['write_date'] = date_time;
  184. fields['weight_net'] = this.weight;
  185. var pricelist = this._get_active_pricelist();
  186. fields['price_product'] = (product ? product.get_price(pricelist, this.weight) : 0) || 0;
  187. fields['price_net'] = fields['weight_net'] * fields['price_product'];
  188. fields.name = product.display_name;
  189. this.pos.push_transaction(fields).then(
  190. this.pushed_transaction(fields["ean13"])
  191. );
  192. },
  193. pushed_transaction: function(barcode){
  194. var self = this;
  195. // Remise à zero du poids à l'écran
  196. // this.set_weight(0);
  197. // this.renderElement();
  198. var product = this.get_product();
  199. this.gui.show_screen('confirmation',{product: product});
  200. },
  201. });
  202. gui.define_screen({
  203. name:'balancescale',
  204. widget: BalanceScaleScreenWidget,
  205. });
  206. /*--------------------------------------*\
  207. | THE SCALE SCREEN FREE |
  208. | BALANCE CONTAINER |
  209. \*======================================*/
  210. // The free balance container scale screen
  211. // displays the weight of
  212. // a new container on the electronic scale.
  213. var BalanceContainerScaleScreenWidget = screens.ScaleScreenWidget.extend({
  214. template: 'BalanceContainerScaleScreenWidget',
  215. next_screen: 'presentation',
  216. previous_screen: 'presentation',
  217. init: function(parent, options){
  218. this._super(parent, options);
  219. },
  220. show: function(){
  221. var self = this;
  222. var queue = this.pos.proxy_queue;
  223. var priceStr = '001000'; // bizerba doesn't accept '000000' as unit price
  224. this.renderElement();
  225. queue.schedule(function () {
  226. return self.pos.proxy.reset_weight().then(function () {
  227. self.set_weight(0);
  228. });
  229. }, {duration: 500});
  230. queue.schedule(function () {
  231. return self.pos.proxy.scale_read_data_price(priceStr).then(function (scale_answer) {
  232. self.set_weight(scale_answer.weight);
  233. if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) {
  234. self.gui.show_screen(self.next_screen);
  235. self.create_container();
  236. }
  237. });
  238. }, {duration: 500, repeat: true});
  239. this._super();
  240. var self = this;
  241. this.$('.next,.add-container').click(function(){
  242. self.create_container();
  243. });
  244. if(this.pos.config.iface_vkeyboard && this.chrome.widget.keyboard){
  245. this.chrome.widget.keyboard.connect($(this.el.querySelector('.container-name input')));
  246. }
  247. $("#pos-header-text-peser").removeClass('oe_hidden');
  248. $("#pos-topheader-scale-cont").removeClass('oe_hidden');
  249. },
  250. hide: function(){
  251. this._super();
  252. $("#pos-header-text-peser").addClass('oe_hidden');
  253. $("#pos-topheader-scale-cont").addClass('oe_hidden');
  254. },
  255. get_product: function(){
  256. return this.pos.get_container_product();
  257. },
  258. create_container: function(){
  259. if (this.weight != 0) {
  260. var self = this;
  261. var fields = {};
  262. fields['weight'] = this.weight;
  263. fields.barcode = this.gui.get_current_screen_param('barcode') || false;
  264. fields.name = fields.name || _t('Container');
  265. this.pos.push_container(fields).then(
  266. this.pushed_container(fields["barcode"],fields)
  267. );
  268. }
  269. },
  270. pushed_container: function(barcode,container){
  271. var self = this;
  272. var selected_order = this.pos.get_order();
  273. selected_order.add_container(container);
  274. self.gui.show_popup('confirm-pesee',{
  275. 'title': _t('Merci'),
  276. 'body': _t('La pesée est validée'),
  277. confirm: function(){
  278. self.gui.show_screen(self.next_screen);
  279. },
  280. });
  281. },
  282. close: function(){
  283. this._super();
  284. if (this.pos.config.iface_vkeyboard && this.chrome.widget.keyboard) {
  285. this.chrome.widget.keyboard.hide();
  286. }
  287. },
  288. });
  289. gui.define_screen({
  290. name:'balancecontainerscale',
  291. widget: BalanceContainerScaleScreenWidget,
  292. });
  293. screens.ScreenWidget.include({
  294. show: function(){
  295. var self = this;
  296. var queue = this.pos.proxy_queue;
  297. var scale_screen = this.gui.screen_instances['balancescale'];
  298. this.set_weight(0);
  299. // this.set_price(0);
  300. scale_screen.renderElement();
  301. // queue.schedule(function () {
  302. // return self.pos.proxy.reset_weight().then(function () {
  303. // self.set_weight(0);
  304. // // self.set_price(0);
  305. // });
  306. // }, {duration: 500});
  307. queue.schedule(function(){
  308. return self.pos.proxy.scale_read().then(function(scale_answer){
  309. self.set_weight(scale_answer.weight);
  310. if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) {
  311. self.set_weight(0);
  312. }
  313. });
  314. },{duration:500, repeat: true});
  315. this._super();
  316. },
  317. set_weight: function(weight){
  318. var scale_screen = this.gui.screen_instances['balancescale'];
  319. scale_screen.weight = weight;
  320. scale_screen.$('.weight').text(scale_screen.get_product_weight_string());
  321. scale_screen.$('.computed-price').text(scale_screen.format_currency(scale_screen.get_product_price() * 0));
  322. },
  323. set_price: function (price) {
  324. var scale_screen = this.gui.screen_instances['balancescale'];
  325. scale_screen.price = price;
  326. scale_screen.$('.computed-price').text(scale_screen.format_currency(0));
  327. },
  328. barcode_container_action: function(code){
  329. var self = this;
  330. if (self.pos.scan_container(code)) {
  331. // Vérfification: est-ce qu'un container vient d'être utilisé dans l'heure
  332. if (self.pos.scan_container_check(code)){
  333. var transaction = self.pos.scan_container_check(code);
  334. this.gui.show_popup('doublon-barcode',{
  335. title: _t('Contenu déjà enregistré récemment:'),
  336. transaction: transaction,
  337. confirm: function(){
  338. var transaction = self.pos.scan_container_check(code)
  339. self.delete_selected_transaction(transaction, code);
  340. self.gui.show_screen('products');
  341. },
  342. });
  343. } else {
  344. self.gui.show_screen('products');
  345. }
  346. } else {
  347. self.gui.show_screen('balancecontainerscale', {barcode: code.base_code});
  348. }
  349. },
  350. delete_selected_transaction: function(transaction, barcode){
  351. var self = this;
  352. if (!transaction.id){
  353. self.deleted_transaction(transaction.container_ean13)
  354. }
  355. else {
  356. rpc.query({
  357. model: 'pos.transaction',
  358. method: 'unlink',
  359. args: [transaction.id],
  360. }).then(function(){
  361. self.deleted_transaction(transaction.container_ean13);
  362. },function(err,ev){
  363. ev.preventDefault();
  364. var error_body = _t('Your Internet connection is probably down.');
  365. if (err.data) {
  366. var except = err.data;
  367. error_body = except.arguments && except.arguments[0] || except.message || error_body;
  368. }
  369. self.gui.show_popup('error',{
  370. 'title': _t('Error: Could not Save Changes'),
  371. 'body': error_body,
  372. });
  373. }
  374. );
  375. }
  376. },
  377. deleted_transaction: function(barcode){
  378. var self = this;
  379. this.pos.db.remove_transactions([barcode]);
  380. },
  381. close: function(){
  382. this._super();
  383. this.pos.proxy_queue.clear();
  384. },
  385. });
  386. var ConfirmPopupWidgetPesee = popups.extend({
  387. template: 'ConfirmPopupWidgetPesee',
  388. });
  389. gui.define_popup({name:'confirm-pesee', widget: ConfirmPopupWidgetPesee});
  390. // The initial screen that allows you to scan container
  391. var PresentationScreenWidget = screens.ScreenWidget.extend({
  392. template: 'PresentationScreenWidget',
  393. next_screen: 'products',
  394. // Ignore products, discounts, and client barcodes
  395. // barcode_product_action: function(code){},
  396. barcode_discount_action: function(code){},
  397. barcode_client_action: function(code){},
  398. init: function(parent, options) {
  399. this._super(parent, options);
  400. this.transactions = [];
  401. this.editing = false;
  402. },
  403. // this method shows the screen and sets up all the widget related to this screen. Extend this method
  404. // if you want to alter the behavior of the screen.
  405. show: function(){
  406. this._super();
  407. var self = this;
  408. this.set_weight(0);
  409. this.set_price(0);
  410. var scale_screen = this.gui.screen_instances['balancescale'];
  411. scale_screen.$el.removeClass('oe_hidden');
  412. var screen = this.gui.screen_instances['products'];
  413. screen.$el.removeClass('oe_hidden');
  414. $("#pos-header-text-selec").removeClass('oe_hidden');
  415. $("#pos-header-text-confirm").addClass('oe_hidden');
  416. },
  417. // this methods hides the screen. It's not a good place to put your cleanup stuff as it is called on the
  418. // POS initialization.
  419. hide: function(){
  420. this._super();
  421. var screen = this.gui.screen_instances['products'];
  422. screen.$el.addClass('oe_hidden');
  423. $("#pos-header-text-selec").addClass('oe_hidden');
  424. },
  425. });
  426. gui.define_screen({
  427. 'name': 'presentation',
  428. 'widget': PresentationScreenWidget,
  429. 'condition': function(){
  430. return this.pos.config.balance_id;
  431. },
  432. });
  433. // Screen confirmation de la pesée
  434. var ConfirmationScreen = screens.ScreenWidget.extend({
  435. template: 'ConfirmationScreen',
  436. next_screen: 'presentation',
  437. // previous_screen: 'presentation',
  438. show: function(){
  439. this._super();
  440. var self = this;
  441. this.renderElement();
  442. var scale_screen = this.gui.screen_instances['balancescale'];
  443. scale_screen.$el.removeClass('oe_hidden');
  444. this.$('.next,.back-presentation').click(function(){
  445. self.set_weight(0);
  446. self.set_price(0);
  447. self.gui.show_screen('presentation');
  448. });
  449. $("#pos-header-text-confirm").removeClass('oe_hidden');
  450. },
  451. set_weight: function(weight){
  452. var scale_screen = this.gui.screen_instances['balancescale'];
  453. var order = this.pos.get_order();
  454. var selected_orderline = order.get_selected_orderline();
  455. var container = selected_orderline.get_container();
  456. scale_screen.weight_container = container.weight;
  457. scale_screen.weight = weight;
  458. scale_screen.weight_brut = container.weight + scale_screen.weight;
  459. scale_screen.$('.weight').text(scale_screen.get_product_weight_string());
  460. scale_screen.$('.computed-price').text(scale_screen.get_computed_price_string());
  461. scale_screen.$('.weight-brut').text(scale_screen.get_product_weight_string_brut());
  462. if (container){
  463. var container_text = (container.weight || 0).toFixed(3) + ' kg';
  464. }
  465. else{
  466. var container_text = ''
  467. }
  468. scale_screen.$('.tare-container').text(container_text);
  469. },
  470. _get_active_pricelist: function(){
  471. var current_order = this.pos.get_order();
  472. var current_pricelist = this.pos.default_pricelist;
  473. if (current_order) {
  474. current_pricelist = current_order.pricelist;
  475. }
  476. return current_pricelist;
  477. },
  478. get_product_name: function(){
  479. var product = this.gui.get_current_screen_param('product');
  480. return (product ? product.display_name : undefined) || 'Unnamed Product';
  481. },
  482. get_product_price: function(){
  483. var product = this.gui.get_current_screen_param('product');
  484. var pricelist = this._get_active_pricelist();
  485. return (product ? product.get_price(pricelist, 1) : 0) || 0;
  486. },
  487. get_product_uom: function(){
  488. var product = this.gui.get_current_screen_param('product');
  489. if(product){
  490. return this.pos.units_by_id[product.uom_id[0]].name;
  491. }else{
  492. return '';
  493. }
  494. },
  495. });
  496. gui.define_screen({
  497. 'name': 'confirmation',
  498. 'widget': ConfirmationScreen,
  499. });
  500. // Add the Presentation to the GUI, and set it as the default screen
  501. chrome.Chrome.include({
  502. build_widgets: function(){
  503. this._super();
  504. if (this.pos.config.balance_id) {
  505. this.gui.set_startup_screen('presentation');
  506. }
  507. },
  508. });
  509. gui.Gui.include({
  510. show_saved_screen: function(order,options) {
  511. this._super();
  512. options = options || {};
  513. this.close_popup();
  514. this.show_screen(this.startup_screen);
  515. },
  516. });
  517. // We need to modify the OrderSelector to hide itself when we're on
  518. // the floor plan ?
  519. chrome.OrderSelectorWidget.include({
  520. hide: function(){
  521. this.$el.addClass('oe_invisible');
  522. },
  523. show: function(){
  524. this.$el.removeClass('oe_invisible');
  525. },
  526. renderElement: function(){
  527. var self = this;
  528. this._super();
  529. if (this.pos.config.balance_id) {
  530. if (this.pos.get_order()) {
  531. this.$el.removeClass('oe_invisible');
  532. } else {
  533. this.$el.addClass('oe_invisible');
  534. }
  535. }
  536. },
  537. });
  538. screens.ProductScreenWidget.include({
  539. previous_screen: 'presentation',
  540. show: function(){
  541. this._super();
  542. var self = this;
  543. var scale_screen = this.gui.screen_instances['balancescale'];
  544. scale_screen.$el.removeClass('oe_hidden');
  545. this.product_categories_widget.reset_category();
  546. this.numpad.state.reset();
  547. this.$('.back').click(function(){
  548. self.gui.show_screen('presentation');
  549. });
  550. $("#pos-header-text-prod").removeClass('oe_hidden');
  551. var container = this.gui.get_current_screen_param('container');
  552. if (container) {
  553. this.pos.proxy.reset_tare();
  554. }
  555. },
  556. hide: function(){
  557. this._super();
  558. $("#pos-header-text-prod").addClass('oe_hidden');
  559. var screen = this.gui.screen_instances['products'];
  560. },
  561. // Ajout fonction scale
  562. set_weight: function(weight){
  563. var scale_screen = this.gui.screen_instances['balancescale'];
  564. var order = this.pos.get_order();
  565. var selected_orderline = order.get_selected_orderline();
  566. var container = selected_orderline.get_container();
  567. scale_screen.weight_container = container.weight;
  568. scale_screen.weight = weight;
  569. scale_screen.weight_brut = container.weight + scale_screen.weight;
  570. scale_screen.$('.weight').text(scale_screen.get_product_weight_string());
  571. scale_screen.$('.computed-price').text(scale_screen.format_currency(scale_screen.get_product_price() * 0));
  572. scale_screen.$('.weight-brut').text(scale_screen.get_product_weight_string_brut());
  573. if (container){
  574. var container_text = (container.weight || 0).toFixed(3) + ' kg';
  575. }
  576. else{
  577. var container_text = ''
  578. }
  579. scale_screen.$('.tare-container').text(container_text);
  580. },
  581. click_product: function(product) {
  582. var scale_screen = this.gui.screen_instances['balancescale'];
  583. if (scale_screen.weight != 0) {
  584. this.create_transaction(product);
  585. }
  586. },
  587. create_transaction: function(product){
  588. var self = this;
  589. var fields = {};
  590. var order = this.pos.get_order();
  591. var selected_orderline = order.get_selected_orderline();
  592. var container = selected_orderline.get_container();
  593. var scale_screen = this.gui.screen_instances['balancescale'];
  594. // var product = this.get_product();
  595. var qrcode = '';
  596. var ean13 = '';
  597. var ean13_verif = '';
  598. fields['qrcode'] = qrcode.concat('https://qr.mayam.fr/', container.barcode);
  599. fields['container_ean13'] = container.barcode;
  600. fields['product_id'] = product.id;
  601. // var product_id = (this.get_product().id).toString();
  602. var product_id = ("00000" + product.default_code.toString()).slice(-5);
  603. var weight_str = (scale_screen.weight * 1000).toString();
  604. weight_str = ("00000" + weight_str).slice(-5);
  605. ean13 = ean13.concat(26,product_id,weight_str,4);
  606. var weight_brut_str = (scale_screen.weight_brut * 1000).toString();
  607. weight_brut_str = ("00000" + weight_brut_str).slice(-5);
  608. ean13_verif = ean13_verif.concat(26,'00999',weight_brut_str,4);
  609. var ean13_digit = this.pos.barcode_reader.barcode_parser.sanitize_ean(ean13);
  610. var ean13_verif_digit = this.pos.barcode_reader.barcode_parser.sanitize_ean(ean13_verif);
  611. fields['ean13'] = ean13_digit;
  612. fields['ean13_verif'] = ean13_verif_digit;
  613. fields['balance_id'] = this.pos.get_balance_id();
  614. var today = new Date();
  615. var date = today.getFullYear() + '-' + (today.getMonth()+1) + '-' + today.getDate();
  616. var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
  617. var date_time = date + ' ' + time;
  618. fields['write_date'] = date_time;
  619. fields['weight_net'] = scale_screen.weight;
  620. var pricelist = scale_screen._get_active_pricelist();
  621. fields['price_product'] = (product ? product.get_price(pricelist, scale_screen.weight) : 0) || 0;
  622. fields['price_net'] = fields['weight_net'] * fields['price_product'];
  623. fields.name = product.display_name;
  624. this.pos.push_transaction(fields).then(
  625. this.pushed_transaction(fields["ean13"], product)
  626. );
  627. },
  628. pushed_transaction: function(barcode, product){
  629. var self = this;
  630. this.gui.show_screen('confirmation',{product: product});
  631. },
  632. close: function(){
  633. this._super();
  634. this.pos.proxy_queue.clear();
  635. },
  636. });
  637. var CheckBarcodePopupDoublon = popups.extend({
  638. template:'CheckBarcodePopupDoublon',
  639. show: function(options){
  640. var self = this;
  641. options = options || {};
  642. this.name = options.transaction.name ;
  643. this.weight_net = options.transaction.weight_net ;
  644. this.price_product = options.transaction.price_product.toFixed(2); ;
  645. this.price_net = options.transaction.price_net.toFixed(2);
  646. this._super(options);
  647. this.renderElement();
  648. },
  649. });
  650. gui.define_popup({name:'doublon-barcode', widget: CheckBarcodePopupDoublon});
  651. return {
  652. BalanceContainerScaleScreenWidget: BalanceContainerScaleScreenWidget,
  653. PresentationScreenWidget: PresentationScreenWidget,
  654. BalanceScaleScreenWidget: BalanceScaleScreenWidget,
  655. CheckBarcodePopupDoublon: CheckBarcodePopupDoublon,
  656. ConfirmPopupWidgetPesee: ConfirmPopupWidgetPesee,
  657. ConfirmationScreen: ConfirmationScreen,
  658. };
  659. });