23.odoo入门——工作杂记
来源:互联网 发布:android 7.0源码 编辑:程序博客网 时间:2024/06/06 20:23
23————————
上午:
添加一个页面,里面有highcharts实现的图表,再画一个没有线的表格
再学习,测试git
下午:
问题1:odoo端实现一个需求:菜单中有2个项,往其中一项中输入数字,另外一项中根据一定的逻辑得到相应的数字
2个字段分别定义为onchange函数即可
实现代码如下:
#-----------------------装饰器函数,lwl----------------------------##onchange handler@api.onchange('each')def _onchange_each(self): product_id = int(self.product_id) total = 0 subscription_model = self.env['wens.investment.financing.subscription'] subscription_records = subscription_model.search([('product_id', '=', product_id)]) for item in subscription_records: total += item.money self.total = total * self.each@api.onchange('total')def _onchange_total(self): product_id = int(self.product_id) total = 0 subscription_model = self.env['wens.investment.financing.subscription'] subscription_records = subscription_model.search([('product_id', '=', product_id)]) for item in subscription_records: total += item.money if abs(total - 0) < 0.000001: self.each = 0 else: self.each = float(self.total) / total#-----------------------装饰器函数,lwl----------------------------#
关于装饰器,推荐博客:
https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014318435599930270c0381a3b44db991cd6d858064ac0000
问题2:实现了2个菜单数值的互相依赖,但是发现float类型的字段each只能显示2位小数,如何控制这个小数位数
请教了大佬,修改用法是:
each = fields.Float(string=u'每份分红',required=True, digits=(16, 5))
该字段其实在odoo/fields.py的源代码中有提到:
Some field attributes are automatically copied from the source field ifthey are not redefined: ``string``, ``help``, ``readonly``, ``required`` (onlyif all fields in the sequence are required), ``groups``, ``digits``, ``size``,``translate``, ``sanitize``, ``selection``, ``comodel_name``, ``domain``,``context``. All semantic-free attributes are copied from the sourcefield.
例如看代码:
class Float(Field): """ The precision digits are given by the attribute :param digits: a pair (total, decimal), or a function taking a database cursor and returning a pair (total, decimal) """……
有时候感叹当个伸手党真爽,这种东西要查起来也挺麻烦- - !
问题3:在形如下图的表的列名中,字段是数据库的列名,这能否修改呢?
请教大佬,可以的,只要在xml的field字段中加入string属性就可以修改了,代码如下:
<field name="confirmed" string = '认购是否有效'/>
阅读全文
0 0
- 23.odoo入门——工作杂记
- 22.odoo入门——工作杂记
- 24.odoo入门——工作杂记
- 26.odoo入门——工作杂记之many2one
- 10.11.12.odoo入门——杂记
- 20.odoo入门——杂记
- 21.odoo入门——杂记
- 25.odoo入门——工作杂记之many2many, git删除版本控制
- 13.odoo入门——杂记之git
- 9.odoo入门——杂记之views下的xml(一)
- 15.odoo入门——工作遇到的odoo的一些细节和javascript实现数据库操作后跳转页面
- 19.odoo入门——odoo的session
- 8.odoo入门——jinja2入门(一)
- 7.odoo入门——初探odoo后台启动过程(一)
- 8.odoo入门——初探odoo后台启动过程(二)
- 18.odoo入门——odoo权限控制(一)模型(数据表)级别权限控制
- 6.odoo入门——培训签到课程项目(三)
- 16.odoo入门——初探后台启动过程(三)
- HDU 6152-Friend-Graph(ccpc)
- 启用lumen的user token认证
- BZOJ[1367][Baltic2004]Sequence 可并堆
- Evaluate the value of an arithmetic expression in Reverse Polish Notation.
- 算法入门经典——果园里的树
- 23.odoo入门——工作杂记
- [12] LNMP架构
- A*算法浅析
- 并查集-总结
- [python]1.Django的基本用法
- HDU 6153-A Secret(kmp&&ccpc)
- ReentrantLock的原理和应用
- linux label
- Linux Centos6.8 安装配置Readis3.2.8