跳到主要内容

报价单界面报价金额显示数字大写

报价单界面报价金额显示为大写:

客户需求:

今天群里头有个人说需要在销售报价的报价金额汇总,需要显示为大写:

思考过程:

1, 首先这个是在标准的Doctye 上做定制。 因此要用到的工具为 客户端脚本 或者 服务端脚本。

2, 执行了一下业务执行的动作, 发现这个 报价的界面本来就有 in_words 字段用来显示大写金额的, 只是初期是错误的。

3, 并且执行的触发界面为 before save.

实现过程:

1, 先不更改大写, 先在这个金额前面加一串字符:

def quotation_before_save(doc, method):
doc.in_words = '12345' + doc.in_words

2, 如上操作之后确认没有问题, 则只要做转换即可。 查了一下网页, 最终实现的方法为: 采用 Money 包做转换。 则在服务器端安装这个包:

frappe@fa76ab175188:~/frappe-bench$ bench pip install Money
Looking in indexes: https://pypi.org/simple/
Collecting Money
Downloading money-1.3.0.tar.gz (18 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: Money
Building wheel for Money (setup.py) ... done
Created wheel for Money: filename=money-1.3.0-py3-none-any.whl size=6643 sha256=006215f5640573446bcfa86623e49c3ccfe8e0aaedae55cbcff9ab29f9a28b67
Stored in directory: /home/frappe/.cache/pip/wheels/68/fc/45/897e30f344f9d89c93c2bd8f556ac5ac3fc48411646057a033
Successfully built Money
Installing collected packages: Money
Successfully installed Money-1.3.0

3, 到这个地方卡壳了, 发现这个包没法在sever script里头调用。 思考的逻辑是需要在服务端建立 whitelist 方法来读取。 并且在客户端或者服务端调用 frappe.call 方法来操作。