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.

838 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. var self = this;
  260. var fields = {};
  261. fields['weight'] = this.weight;
  262. fields.barcode = this.gui.get_current_screen_param('barcode') || false;
  263. fields.name = fields.name || _t('Container');
  264. this.pos.push_container(fields).then(
  265. this.pushed_container(fields["barcode"],fields)
  266. );
  267. },
  268. pushed_container: function(barcode,container){
  269. var self = this;
  270. var selected_order = this.pos.get_order();
  271. selected_order.add_container(container);
  272. self.gui.show_popup('confirm-pesee',{
  273. 'title': _t('Merci'),
  274. 'body': _t('La pesée est validée'),
  275. confirm: function(){
  276. self.gui.show_screen(self.next_screen);
  277. },
  278. });
  279. },
  280. close: function(){
  281. this._super();
  282. if (this.pos.config.iface_vkeyboard && this.chrome.widget.keyboard) {
  283. this.chrome.widget.keyboard.hide();
  284. }
  285. },
  286. });
  287. gui.define_screen({
  288. name:'balancecontainerscale',
  289. widget: BalanceContainerScaleScreenWidget,
  290. });
  291. screens.ScreenWidget.include({
  292. show: function(){
  293. var self = this;
  294. var queue = this.pos.proxy_queue;
  295. var scale_screen = this.gui.screen_instances['balancescale'];
  296. this.set_weight(0);
  297. // this.set_price(0);
  298. scale_screen.renderElement();
  299. queue.schedule(function () {
  300. return self.pos.proxy.reset_weight().then(function () {
  301. self.set_weight(0);
  302. // self.set_price(0);
  303. });
  304. }, {duration: 500});
  305. queue.schedule(function(){
  306. return self.pos.proxy.scale_read().then(function(scale_answer){
  307. self.set_weight(scale_answer.weight);
  308. if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) {
  309. self.set_weight(0);
  310. }
  311. });
  312. },{duration:500, repeat: true});
  313. this._super();
  314. },
  315. set_weight: function(weight){
  316. var scale_screen = this.gui.screen_instances['balancescale'];
  317. scale_screen.weight = weight;
  318. scale_screen.$('.weight').text(scale_screen.get_product_weight_string());
  319. scale_screen.$('.computed-price').text(scale_screen.format_currency(scale_screen.get_product_price() * 0));
  320. },
  321. set_price: function (price) {
  322. var scale_screen = this.gui.screen_instances['balancescale'];
  323. scale_screen.price = price;
  324. scale_screen.$('.computed-price').text(scale_screen.format_currency(0));
  325. },
  326. barcode_container_action: function(code){
  327. var self = this;
  328. if (self.pos.scan_container(code)) {
  329. // Vérfification: est-ce qu'un container vient d'être utilisé dans l'heure
  330. if (self.pos.scan_container_check(code)){
  331. var transaction = self.pos.scan_container_check(code);
  332. this.gui.show_popup('doublon-barcode',{
  333. title: _t('Contenu déjà enregistré récemment:'),
  334. transaction: transaction,
  335. confirm: function(){
  336. var transaction = self.pos.scan_container_check(code)
  337. self.delete_selected_transaction(transaction, code);
  338. self.gui.show_screen('products');
  339. },
  340. });
  341. } else {
  342. self.gui.show_screen('products');
  343. }
  344. } else {
  345. self.gui.show_screen('balancecontainerscale', {barcode: code.base_code});
  346. }
  347. },
  348. delete_selected_transaction: function(transaction, barcode){
  349. var self = this;
  350. if (!transaction.id){
  351. self.deleted_transaction(transaction.container_ean13)
  352. }
  353. else {
  354. rpc.query({
  355. model: 'pos.transaction',
  356. method: 'unlink',
  357. args: [transaction.id],
  358. }).then(function(){
  359. self.deleted_transaction(transaction.container_ean13);
  360. },function(err,ev){
  361. ev.preventDefault();
  362. var error_body = _t('Your Internet connection is probably down.');
  363. if (err.data) {
  364. var except = err.data;
  365. error_body = except.arguments && except.arguments[0] || except.message || error_body;
  366. }
  367. self.gui.show_popup('error',{
  368. 'title': _t('Error: Could not Save Changes'),
  369. 'body': error_body,
  370. });
  371. }
  372. );
  373. }
  374. },
  375. deleted_transaction: function(barcode){
  376. var self = this;
  377. this.pos.db.remove_transactions([barcode]);
  378. },
  379. close: function(){
  380. this._super();
  381. this.pos.proxy_queue.clear();
  382. },
  383. });
  384. var ConfirmPopupWidgetPesee = popups.extend({
  385. template: 'ConfirmPopupWidgetPesee',
  386. });
  387. gui.define_popup({name:'confirm-pesee', widget: ConfirmPopupWidgetPesee});
  388. // The initial screen that allows you to scan container
  389. var PresentationScreenWidget = screens.ScreenWidget.extend({
  390. template: 'PresentationScreenWidget',
  391. next_screen: 'products',
  392. // Ignore products, discounts, and client barcodes
  393. // barcode_product_action: function(code){},
  394. barcode_discount_action: function(code){},
  395. barcode_client_action: function(code){},
  396. init: function(parent, options) {
  397. this._super(parent, options);
  398. this.transactions = [];
  399. this.editing = false;
  400. },
  401. // this method shows the screen and sets up all the widget related to this screen. Extend this method
  402. // if you want to alter the behavior of the screen.
  403. show: function(){
  404. this._super();
  405. var self = this;
  406. this.set_weight(0);
  407. this.set_price(0);
  408. var scale_screen = this.gui.screen_instances['balancescale'];
  409. scale_screen.$el.removeClass('oe_hidden');
  410. var screen = this.gui.screen_instances['products'];
  411. screen.$el.removeClass('oe_hidden');
  412. $("#pos-header-text-selec").removeClass('oe_hidden');
  413. $("#pos-header-text-confirm").addClass('oe_hidden');
  414. },
  415. // this methods hides the screen. It's not a good place to put your cleanup stuff as it is called on the
  416. // POS initialization.
  417. hide: function(){
  418. this._super();
  419. var screen = this.gui.screen_instances['products'];
  420. screen.$el.addClass('oe_hidden');
  421. $("#pos-header-text-selec").addClass('oe_hidden');
  422. },
  423. });
  424. gui.define_screen({
  425. 'name': 'presentation',
  426. 'widget': PresentationScreenWidget,
  427. 'condition': function(){
  428. return this.pos.config.balance_id;
  429. },
  430. });
  431. // Screen confirmation de la pesée
  432. var ConfirmationScreen = screens.ScreenWidget.extend({
  433. template: 'ConfirmationScreen',
  434. next_screen: 'presentation',
  435. // previous_screen: 'presentation',
  436. show: function(){
  437. this._super();
  438. var self = this;
  439. this.renderElement();
  440. var scale_screen = this.gui.screen_instances['balancescale'];
  441. scale_screen.$el.removeClass('oe_hidden');
  442. this.$('.next,.back-presentation').click(function(){
  443. self.set_weight(0);
  444. self.set_price(0);
  445. self.gui.show_screen('presentation');
  446. });
  447. $("#pos-header-text-confirm").removeClass('oe_hidden');
  448. },
  449. set_weight: function(weight){
  450. var scale_screen = this.gui.screen_instances['balancescale'];
  451. var order = this.pos.get_order();
  452. var selected_orderline = order.get_selected_orderline();
  453. var container = selected_orderline.get_container();
  454. scale_screen.weight_container = container.weight;
  455. scale_screen.weight = weight;
  456. scale_screen.weight_brut = container.weight + scale_screen.weight;
  457. scale_screen.$('.weight').text(scale_screen.get_product_weight_string());
  458. scale_screen.$('.computed-price').text(scale_screen.get_computed_price_string());
  459. scale_screen.$('.weight-brut').text(scale_screen.get_product_weight_string_brut());
  460. if (container){
  461. var container_text = (container.weight || 0).toFixed(3) + ' kg';
  462. }
  463. else{
  464. var container_text = ''
  465. }
  466. scale_screen.$('.tare-container').text(container_text);
  467. },
  468. _get_active_pricelist: function(){
  469. var current_order = this.pos.get_order();
  470. var current_pricelist = this.pos.default_pricelist;
  471. if (current_order) {
  472. current_pricelist = current_order.pricelist;
  473. }
  474. return current_pricelist;
  475. },
  476. get_product_name: function(){
  477. var product = this.gui.get_current_screen_param('product');
  478. return (product ? product.display_name : undefined) || 'Unnamed Product';
  479. },
  480. get_product_price: function(){
  481. var product = this.gui.get_current_screen_param('product');
  482. var pricelist = this._get_active_pricelist();
  483. return (product ? product.get_price(pricelist, 1) : 0) || 0;
  484. },
  485. get_product_uom: function(){
  486. var product = this.gui.get_current_screen_param('product');
  487. if(product){
  488. return this.pos.units_by_id[product.uom_id[0]].name;
  489. }else{
  490. return '';
  491. }
  492. },
  493. });
  494. gui.define_screen({
  495. 'name': 'confirmation',
  496. 'widget': ConfirmationScreen,
  497. });
  498. // Add the Presentation to the GUI, and set it as the default screen
  499. chrome.Chrome.include({
  500. build_widgets: function(){
  501. this._super();
  502. if (this.pos.config.balance_id) {
  503. this.gui.set_startup_screen('presentation');
  504. }
  505. },
  506. });
  507. gui.Gui.include({
  508. show_saved_screen: function(order,options) {
  509. this._super();
  510. options = options || {};
  511. this.close_popup();
  512. this.show_screen(this.startup_screen);
  513. },
  514. });
  515. // We need to modify the OrderSelector to hide itself when we're on
  516. // the floor plan ?
  517. chrome.OrderSelectorWidget.include({
  518. hide: function(){
  519. this.$el.addClass('oe_invisible');
  520. },
  521. show: function(){
  522. this.$el.removeClass('oe_invisible');
  523. },
  524. renderElement: function(){
  525. var self = this;
  526. this._super();
  527. if (this.pos.config.balance_id) {
  528. if (this.pos.get_order()) {
  529. this.$el.removeClass('oe_invisible');
  530. } else {
  531. this.$el.addClass('oe_invisible');
  532. }
  533. }
  534. },
  535. });
  536. screens.ProductScreenWidget.include({
  537. previous_screen: 'presentation',
  538. show: function(){
  539. this._super();
  540. var self = this;
  541. var scale_screen = this.gui.screen_instances['balancescale'];
  542. scale_screen.$el.removeClass('oe_hidden');
  543. this.product_categories_widget.reset_category();
  544. this.numpad.state.reset();
  545. this.$('.back').click(function(){
  546. self.gui.show_screen('presentation');
  547. });
  548. $("#pos-header-text-prod").removeClass('oe_hidden');
  549. var container = this.gui.get_current_screen_param('container');
  550. if (container) {
  551. this.pos.proxy.reset_tare();
  552. }
  553. },
  554. hide: function(){
  555. this._super();
  556. $("#pos-header-text-prod").addClass('oe_hidden');
  557. var screen = this.gui.screen_instances['products'];
  558. },
  559. // Ajout fonction scale
  560. set_weight: function(weight){
  561. var scale_screen = this.gui.screen_instances['balancescale'];
  562. var order = this.pos.get_order();
  563. var selected_orderline = order.get_selected_orderline();
  564. var container = selected_orderline.get_container();
  565. scale_screen.weight_container = container.weight;
  566. scale_screen.weight = weight;
  567. scale_screen.weight_brut = container.weight + scale_screen.weight;
  568. scale_screen.$('.weight').text(scale_screen.get_product_weight_string());
  569. scale_screen.$('.computed-price').text(scale_screen.format_currency(scale_screen.get_product_price() * 0));
  570. scale_screen.$('.weight-brut').text(scale_screen.get_product_weight_string_brut());
  571. if (container){
  572. var container_text = (container.weight || 0).toFixed(3) + ' kg';
  573. }
  574. else{
  575. var container_text = ''
  576. }
  577. scale_screen.$('.tare-container').text(container_text);
  578. },
  579. click_product: function(product) {
  580. var scale_screen = this.gui.screen_instances['balancescale'];
  581. if (scale_screen.weight != 0) {
  582. this.create_transaction(product);
  583. }
  584. },
  585. create_transaction: function(product){
  586. var self = this;
  587. var fields = {};
  588. var order = this.pos.get_order();
  589. var selected_orderline = order.get_selected_orderline();
  590. var container = selected_orderline.get_container();
  591. var scale_screen = this.gui.screen_instances['balancescale'];
  592. // var product = this.get_product();
  593. var qrcode = '';
  594. var ean13 = '';
  595. var ean13_verif = '';
  596. fields['qrcode'] = qrcode.concat('https://qr.mayam.fr/', container.barcode);
  597. fields['container_ean13'] = container.barcode;
  598. fields['product_id'] = product.id;
  599. // var product_id = (this.get_product().id).toString();
  600. var product_id = ("00000" + product.default_code.toString()).slice(-5);
  601. var weight_str = (scale_screen.weight * 1000).toString();
  602. weight_str = ("00000" + weight_str).slice(-5);
  603. ean13 = ean13.concat(26,product_id,weight_str,4);
  604. var weight_brut_str = (scale_screen.weight_brut * 1000).toString();
  605. weight_brut_str = ("00000" + weight_brut_str).slice(-5);
  606. ean13_verif = ean13_verif.concat(26,'00999',weight_brut_str,4);
  607. var ean13_digit = this.pos.barcode_reader.barcode_parser.sanitize_ean(ean13);
  608. var ean13_verif_digit = this.pos.barcode_reader.barcode_parser.sanitize_ean(ean13_verif);
  609. fields['ean13'] = ean13_digit;
  610. fields['ean13_verif'] = ean13_verif_digit;
  611. fields['balance_id'] = this.pos.get_balance_id();
  612. var today = new Date();
  613. var date = today.getFullYear() + '-' + (today.getMonth()+1) + '-' + today.getDate();
  614. var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
  615. var date_time = date + ' ' + time;
  616. fields['write_date'] = date_time;
  617. fields['weight_net'] = scale_screen.weight;
  618. var pricelist = scale_screen._get_active_pricelist();
  619. fields['price_product'] = (product ? product.get_price(pricelist, scale_screen.weight) : 0) || 0;
  620. fields['price_net'] = fields['weight_net'] * fields['price_product'];
  621. fields.name = product.display_name;
  622. this.pos.push_transaction(fields).then(
  623. this.pushed_transaction(fields["ean13"], product)
  624. );
  625. },
  626. pushed_transaction: function(barcode, product){
  627. var self = this;
  628. this.gui.show_screen('confirmation',{product: product});
  629. },
  630. close: function(){
  631. this._super();
  632. this.pos.proxy_queue.clear();
  633. },
  634. });
  635. var CheckBarcodePopupDoublon = popups.extend({
  636. template:'CheckBarcodePopupDoublon',
  637. show: function(options){
  638. var self = this;
  639. options = options || {};
  640. this.name = options.transaction.name ;
  641. this.weight_net = options.transaction.weight_net ;
  642. this.price_product = options.transaction.price_product.toFixed(2); ;
  643. this.price_net = options.transaction.price_net.toFixed(2);
  644. this._super(options);
  645. this.renderElement();
  646. },
  647. });
  648. gui.define_popup({name:'doublon-barcode', widget: CheckBarcodePopupDoublon});
  649. return {
  650. BalanceContainerScaleScreenWidget: BalanceContainerScaleScreenWidget,
  651. PresentationScreenWidget: PresentationScreenWidget,
  652. BalanceScaleScreenWidget: BalanceScaleScreenWidget,
  653. CheckBarcodePopupDoublon: CheckBarcodePopupDoublon,
  654. ConfirmPopupWidgetPesee: ConfirmPopupWidgetPesee,
  655. ConfirmationScreen: ConfirmationScreen,
  656. };
  657. });