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.

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