Skip to Content
Menu
This question has been flagged
2 Replies
4908 Views

Im trying to convert the numeric total/subtotal to words in the POS module so that it is printed out on the receipt.  Im working on these files:

\addons\point_of_sale\static\src\js\ models.js

\addons\point_of_sale\static\src\xml\ pos.xml

Model.js

I've added the function get_letras() so far like so in models.js and added it to the pos_ticket_view.xml:


but it doesnt show up on the ticket.  So far Im passing order.get_letras(widget.format_currency(order.get_change())) but even if I pass it a fixed value like order.get_letras(510) I still get num as being UNDEFINED:


Any help would be appreciated:



Avatar
Discard
Best Answer

Hi Santiago,

You can use python code to convert number to words.

install num2words python package in your system

          from num2words import num2words
          num2words(Subtotal, lang='es') //here es for Spanish
Or you can refer

https://stackoverflow.com/questions/13913165/python-script-to-convert-from-numbers-to-words-for-printing-cheques/13932483
      
Write below code in your .js file

      var _super_order = models.Order.prototype;
      models.Order = models.Order.extend({
      export_for_printing: function() {
          var json =
      _super_order.export_for_printing.apply(this,arguments);
          json.subtotal_in_words = this.get_subtotal_in_words();
          return json;
          },
      get_subtotal_in_words:function(){
          var subtotal = this.get_total_without_tax();
          //here call your python code to convert subtotal to words and return it OR you can use js code to convert subototal into words
 },
      });

now to print this in receipt write below code in xml:


      <t t-esc="widget.format_currency(order.get_subtotal_in_words())"/>

Hope this will help you!

Thanks.

Avatar
Discard
Best Answer

I have a problem that looks like this but I would like to display the exchange of a currency in pos receipt, for example:

 total (CDF)                   4000fc

 total (USD)                    2$

I dont want to use two currences but just add that line in pos receipt.  thank you

Avatar
Discard
Related Posts Replies Views Activity
0
Dec 24
42
1
Dec 24
162
0
Nov 24
81
1
Nov 24
151
1
Nov 24
187