This repository hosts the code for the bases of the modules used in the official Odoo tutorials.
It has 3 branches for each Odoo version: one for the bases, one for the
Discover the JS framework
tutorial's solutions, and one for the
Master the Odoo web framework
tutorial's solutions. For example, 17.0
, 17.0-discover-js-framework-solutions
and
17.0-master-odoo-web-framework-solutions
.
花了一些时间学习了odoo的官方教程。 教程是没有问题的,指向的一些示例代码可能已经过时。 官方教程似乎没有完整的教程源码作为参考,所以我把学习过程的写的代码放出来做参考。 学习过程优先按官网教程来,实在找不到可以参考一下我的代码。
学完后可以看下这个odoo的编码指南 ,我觉得这个写得比较细致,对新人比较友好。
启动配置参考
odoo-bin -c dist/dev.conf.txt -u estate --dev xml
web教程是在它配好的demo上进行修改。已经默认配好了网页路由。 通过这个入口来访问
slot本质是基于props,需要在props 定义出slot参数。
服务中要注意生命周期的问题,使用useService可以放在setup里面,不能放在onWillStart里面 memoize, 将函数包装为缓存函数,只有在页面刷新时才会触发重新加载。页面切换不触发。
onWillStart 似乎必须放setup里面
响应式对象是一个对象,注意不能修改对象本身的应用,只能修改内部属性的值。 js中函数要注意当前绑定的this,可以手动来绑定。 可以用useState来接受一个reactive对象,注意不能直接改reactive的原始引用,只能修改其值。