猜测你应该可以给供应商发货的部分建个仓库,每次从这个仓库发货并告诉供应商。不知道行不行。自己没做过。
Ying Liu
-
[求助]网店发货:自己发货与供应商代发货,如何设置流程及仓库 -
Odoo 8.0 product, product variant 产品和产品系列 的实现,实施和操作如果这个记录不能删除,就设置其active = False, 参见下面product.py的源代码:
# unlink or inactive product
for variant_id in map(int,variants_inactive):
try:
with cr.savepoint():
product_obj.unlink(cr, uid, [variant_id], context=ctx)
except (psycopg2.Error, osv.except_osv):
product_obj.write(cr, uid, [variant_id], {'active': False}, context=ctx)
pass -
Odoo 8.0 product, product variant 产品和产品系列 的实现,实施和操作Odoo 8.0 的产品 product 支持 product variant (产品系列)。 可是实施操作起来有很多容易出错的地方。下面是从源代码总结出来的正确实施操作办法。欢迎指正。
1. 实现原理
在Odoo 8.0 里面,有很多Model用来实现产品管理功能。 “product_template” 是基本的产品model, 一个“product_template”可以有多个“product_attribute_line” 属性系列。 一个属性系列是一个产品属性(product_attribute)和其中的多个属性值(product_attribute_value)。比如,一个帽子的产品有尺寸属性,尺寸属性值可以有大中小三个。 在产品(product_template)里面这是一个属性系列。一个产品可以有多个系列,比如还可以有颜色和颜色属性值比如红和白。 对一个产品的不同属性值(product_attribute_value)可以有附加的价格比如帽子的大号价钱要加十块钱。这个是存在 “product_attribute_price" model 里面。 Odoo为一个产品的suoy属性值组合自动产生所有个产品系列product variant, 实际的实现是 “product_product” model. 上面帽子产品有六个系列(大中小 )× (红白)。
问题的关键是这六个product variant是Odoo自动产生的,而且会在两种情况下重置:1)你修改产品的属性列表 2)产品的Active设为True时。此时所有在product variant的列表里面增删都会被重置。 技术细节参考这里( [检测到链接无效,已移除] )。 删除不掉的产品系列其Active设为“False”。
2. 实施操作建议
实施时候要规划好,一个产品到底有什么属性,这个最重要。加一个或减一个属性,Odoo会删除所有的产品系列来产生新的。 相比之下,具体的属性值比如加减一个颜色不是大问题。 有个关键细节: 每个属性最少有二个值,要不然会被忽略。比如,系统初始化时候如果帽子颜色只有一个白色,Odoo会忽略颜色这个属性系列, 只为尺寸产生三个产品系列。 如果后来再加一个红色,系统就会删除旧的产品系列,重新生成六个产品系列。 如果再加一个颜色比如黄色,系统会为大中小生成三个黄色的产品系列,旧的保留。 同理, 如果只有红白二个颜色时候,不要删除一个。因为系统认为没有必要为单值的产品属性系列生成产品系列,因而会删除六个产品系列而重新生成大中小三个产品系列。
操作是正确的做法是在Product 的 attribute 里面 定义好所有的产品属性系列 (attribute 和product attribute value),每个属性定义至少二个值。 在 variant prices里,可以为某个属性增加减少附加价格。[color=red][b]每次点击List Variants 的时候[/b][/color],Odoo系统会自动验证和产生所有的产品系列(product variants)并删除多余的产品系列。
在Product variants 可以看到所有的产品系列,不要在这里增删任何产品系列。 -
如何存取模块的配置信息开发一个新模块通常需要一些配置测试。本来以为这个很容易,结果还是费力才找到一个不完美的方法。 有必要分享一下让大家少走弯路。
Odoo有一个View(openerp/addons/base/res/res_config.xml) 和一个Python (openerp/addons/base/res/res_config.py)文件定义了基本的模块配置功能.分析了这两个文件之后我还是没有找到好的办法。主要原因是其定义的几个model都是基于TransientModel (或旧版本的osv.osv_memory)。 而模块配置参数需要长久保存。
试着不用这种配置却发现很难定义一个普通的Model,只创建一条记录用于修改。 大家有什么好办法可以分享一下。
最后发现可以基于 'res.config.settings' model 来很简单定义新的配置参数。 只要表里列的名符合"default_xxx" 的模式就可以自动存取。这些列的值存在系统的'ir_value' 表里可供存取。 详细的描述和例子可以看 [检测到链接无效,已移除] -
Ubuntu下用PyCharm 运行调试 Odoo 8.0又花了一天时间在Ubuntu下用PyCharm运行 Odoo 8.0. 好看的格式在我的博客网站 [检测到链接无效,已移除]
我试了各种功能都正常。 希望能帮助大家少走点弯路。
[b]Run and Debug Odoo using PyCharm in Ubuntu[/b]
11 Sep 2014
As a beginner, being able to debug through the Odoo source code is a great learning experience. PyCharm Professional Edition is a wonderful tool to develop/debug Python applications. The following are steps to run/debug Odoo using PyCharm in Ubuntu. Though not officially stated, running Odoo in Windows is not a good idea. I started with a freshly installed Ubuntu 14.04.1 LTS desktop.
[b]1. Update server and install tools[/b]
Check that the Ubuntu /etc/default/locale is set to LANG="en_US.UTF-8". Then run the following to update the Ubuntu and install tools.
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y vim git python-pip
[b]2. Install PostgreSQL and required packages[/b]
sudo apt-get install -y postgresql python-dateutil python-feedparser python-ldap python-libxslt1 python-lxml python-mako python-openid python-psycopg2 python-pybabel python-pychart python-pydot python-pyparsing python-reportlab python-simplejson python-tz python-vatnumber python-vobject python-webdav python-werkzeug python-xlwt python-yaml python-zsi python-docutils python-psutil python-mock python-unittest2 python-jinja2 python-pypdf python-decorator python-passlib
sudo pip install gdata
[b] 3. Start PostgreSQL and create a new role for Odoo[/b]
In my case, I create a superuser "odoo" and set its password as "odoo".
```python
# Add PostgreSQL role
sudo -u postgres /etc/init.d/postgresql start
sudo -u postgres psql -e --command "CREATE USER odoo WITH SUPERUSER PASSWORD 'odoo'"
[b]4. Get Odoo 8.0 source code[/b]
# in the directory that you want put odoo source code
git clone -b 8.0 https://github.com/odoo/odoo.git br />
[b]5. Create Odoo configuration file[/b]
In Odoo project root, copy debian/openerp-server.conf to another folder. In my case, it is copied as /home/ying/dev/projects/odoo-config/openerp-server.conf , edit the file to have the following configurations:
[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = localhost
db_port = 5432
db_user = odoo
db_password = odoo
addons_path = /home/ying/dev/projects/odoo/addons,/home/ying/dev/projects/odoo-connector
In the addons_path option, set it to the addons directory in the Odoo project root. The second part is a path of a custom addon.
[b]6. Install Java SDK[/b]
PyCharm needs Java SDK. Download Java SDK .rpm file from Oracle's website.
We need alien to covert RPM package to Ubuntu package. Type:
sudo apt-get install -y alien
To install Java SDK, type: sudo alien -i -c <path to the Java SDK RPM file>
The installation takes a while. Once it is done, test the installation with: java -version
[b]7. Install PyCharm Professional[/b]
Downalod PyCharm PRofessional from JetBrains web site to the desired installation location.
Unpack the pycharm-.tar.gz using the following command: tar xfz pycharm-.tar.gz
Remove the pycharm-*.tar.gz to save disk space (optional).
Run pycharm.sh from the bin subdirectory
[b]8. Config PyCharm to run Odoo[/b]
Then in PyCharm menu Run --> Edit Configurations, click "+" on the top left to create a new configuration with the following settings:
Name: odoo8
Single instance checkbox: checked
Script: Python 2.7.6 (usr/bin/python2.7)
Script parameters: --config=--config=/home/ying/dev/projects/odoo-config/openerp-server.conf
Congratulations, you should be able to run and debug Odoo !!!
[b]9. Issues and solutions[/b]
You may need to drop the newly created database if something is wrong when you run Odoo to create the initial database. There might be some garbage left in the database and you see an error message like "QWebTemplateNotFound: External ID not found in the system: web.login".
I had this error when Odoo couldn't find Python passlib package. I installed the package, deleted the newly created database, and restarted Odoo. -
Windows下 如何用PyCharm运行调试 Odoo 8.0作为新手,能够单步执行调试源代码是个很好的学习过程。 花了一天时间,终于成功用PyCharm运行最新的Odoo 8.0 版本。
***** 新手犯了一个低级的错误,发现[b]Odoo在Windows下不能正常运行[/b]。 建议大家不要尝试了。 留这个帖子引以为戒。 **********
原文在 [检测到链接无效,已移除]
Debug Odoo using PyCharm in Windows
08 Sep 2014
This blog describes how to setup PyCharm to run/debug Odoo in Windows environment. I use PyCharm Professional 3.4 in 64-bit Windows 8 to run/debug Odoo 8.0 branch. This blog has three parts. The first part describes how to install required packages. The second part shows how to configure PostgreSQL and Odoo. The third part gives problems and their solutions during my installation process.
I. Install packages and source code
1. Get Odoo source code and change branch to 8.0
git clone https://github.com/odoo/odoo.git br />git checkout 8.0
2. Install Visual Studio if you don't have one.
The free Visual Studio Express is enough to compile and install Python packages in later steps. To avoid "error: Unable to find vcvarsall.bat", I need to set the following environment variable in "cmd" command line:
If you have Visual Studio 2013 installed (Visual Studio Version 12), execute SET VS90COMNTOOLS=%VS120COMNTOOLS%.
For Visual Studio 2012 (Visual Studio Version 11), execute SET VS90COMNTOOLS=%VS110COMNTOOLS%.
For Visual Studio 2010, execute SET VS90COMNTOOLS=%VS100COMNTOOLS%.
3. Install required packages from a binary source
With 64-bit Python 2.7.8 installed, I had some compiling errors in installing some required packages for Odoo. Tired of fixing them, I just installed the following pre-compiled Windows 64-bit binary packages from http://www.lfd.uci.edu/~gohlke/pythonlibs br />
Pillow
lxml
psycopg2
python-ldap
pywin32
There are installable windows files for them. Carefully select each file that matches your 32-bit/64-bit and Python version, download and execute the file to install it.
4. Create a virtual environment
This is optional but it's a good idea to use a virtual environment.
In PyCharm, open the odoo folder to create a new project.
Then in File --> Setting --> Project Setting (top left panel) --> Project Interpreter, click the tool icon on the top right, then select "Create Virtual Environment". In the dialog, give the new environment a name such as "odoo8", remember the location, choose base interpreter, click both check-boxes (Inherit global site-packages, Make available to all projects). Finally click OK to create it.
You should see some packages such as pip, psycopg2, python-ldap, pywin32 and setuptools. It is a good idea to upgrade pip and setuptools.
Select pip, then the up-arrow icon on the right side to upgrade it. Do the same to upgrade setuptools.
5. Copy and edit requirments.txt
Copy requirements.txt from the root of Odoo source repository to the location of your virtual environment. With the above configuration, it isC:\Users\your-username\odoo8". Edit the file to remove the following lines<br /><br />Pillow==2.5.1<br /><br />lxml==3.3.5<br /><br />psycopg2==2.5.3<br /><br />python-ldap==2.4.15<br />6. Batch install packages from requirments.txt<br />In the "cmd" window that has the correct setting of VS90COMNTOOLS, go to the location of your virtual environment. By default, it is
C:\Users\username\odoo8". execute
.\Scripts\activate.bat
pip -r requirements.txt
The above commands activate the virtual environment and install all required packages for Odoo. Please pay attention to the output of any error message. The output is also stored in a pip log file C:\Users\your-username\pip\pip.log. You can ignore warning messages. pip stops when there is an error.
Restart your PyCharm and you should see all packages in the newly created environment. Make this environment the interpreter of your Odoo project. You are able to run openerp-server.py file.
However, you still need to install Postgresql and configure the Odoo to work with it.
II. Install PostgreSQL and configure Odoo
1. Download and install PostgreSQL for Windows.
2. Create a new role with superuser privilege for Odoo application.
In my case, I create a superuser "odoo" and set its password as "odoo".
3. Check PostgreSQL configuration
You do not need to change anything because default configuration works correctly as a local database. However, if there is any errors, you can check the the two configuration files of PostgreSQL . Both can be edited using Tools --> Server Configuration menu in pgAdmin.
In postgresql.conf, make sure that listen_addresses are enabled. It is checked by default.
In pg_hba.conf, enable the "host all all 127.0.0.1/32 md5". It means localhost can be connected with a role name and password. It is checked by default.
4. Config Odoo
In Odoo project root, copy debian/openerp-server.conf to another folder. In my case, it is D:\Dev\odooTest\openerp-server.conf , edit the file to have the following configurations:
[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = localhost
db_port = 5432
db_user = odoo
db_password = odoo
addons_path = D:\Dev\PyCharmProjects\odoo\addons
In the addons_path option, set it to the addons directory in your Odoo project root.
Then in PyCharm menu Run --> Edit Configurations, click "+" on the top left to create a new configuration with the following settings:
Name: Odoo8 Single instance checkbox: checked Script: D:\Dev\PyCharmProjects\odoo\openerp-server Script parameters: --config=D:\Dev\odooTest\openerp-server.conf
Congratulations, you should be able to run and debug Odoo !!!
III. Issues and solutions
When install packages from requirements.txt, there is an message "error: Unable to find vcvarsall.bat". Setting VS90COMNTOOLS to correct Visual Studio path fixed it.
Packages such as lxml, psycopg2, python-ldap had many compile errors. The solution is downloading and installing binary packages from [检测到链接无效,已移除] br />
The Pillow package did work correctly because of an error of 'decoder zip not available'. Again, installing binary package fixed it.
You may need to drop the newly created database if something is wrong when you run Odoo to create the initial database. There might be some garbage left in the database and you see an error message like "QWebTemplateNotFound: External ID not found in the system: web.login" -
Odoo Logging 的配置,使用和实现odoo 8.0 还是从 openerp-server 开始启动运行的。 这里有个以前发的不错的帖子 [检测到链接无效,已移除]
-
Odoo Logging 的配置,使用和实现Odoo Logging Configuration, Usage and Implementation
转自本人博客( [检测到链接无效,已移除]
Overview
Logging provides valuable runtime debugging/monitoring information when an application is on production. It is also a helpful tool in debugging application in development phase. This blog describes the logging configuration, usage and implementation in Odoo 8.0.
logging configuration
Odoo uses the Python standard logging library. However, it uses a special configuration syntax to configure logging levels for its modules. Following are a complete list of Odoo logging configuration options:
logfile: the log filename. If not set, use stdout.
logrotate: True/False. If True, create a daily log file and keep 30 files.
log_db: Ture/False. If Ture, also write log to 'ir_logging' table in database.
log_level: any value in the list of ['debug_rpc_answer', 'debug_rpc', 'debug', 'debug_sql', 'info', 'warn', 'error', 'critical']. Odoo changed the log_level meaning here because this level values are mapped to a set of predefined 'module:log_level' pairs. Even this option is not set, there is a set of predefined settings. See the following implementation section for details.
log_handler: can be a list of 'module:log_level' pairs. The default value is ':INFO' -- it means the default logging level is 'INFO' for all modules.
logging in your code
Using logging in an Odoo addon is simple. The following is an example with the recommended use of different logging levels:
import logging
_logger = logging.getLogger(name)
_logger.debug("debug message for debugging only")
_logger.info("information message to report important modular event")
_logger.warning("warning message to report minor issues")
_logger.error("error message to report failed operations")
_logger.critical("critical message -- so bad that the module cannot work")
Examples of logging configuration are listed below. Please pay attention to the syntax of log_handler -- not quotation or square bracket around the value.
log_level = debug_sql
log_handler = openerp.addons.my_addon1:DEBUG,openerp.addons.my_addon2:DEBUG
## Odoo logging implementation
Odoo logging functions are defined inopenerpr/netsvc.py
.
Logging initialization is defined in theinit_logger()
function.
After callingtools.translated.resetlocal()
, it sets a
logging format that consists of the following fields:
> time, process id, logging level, database name, module name,
> and logging message.
If alogfile
configuration option is provided, it uses a file
handler (one of TimedRotatingFileHandler, WatchedFileHandler,
and FileHandler) to log messages to a file.
If nologfile
is configured, it logs messages to stdout.
Iflog_db
is configured with a database name, it logs message
to their.logging
table in the specified database.
It readslog_level
configuration option that is pre-mapped as one of the
following:
```python
PSEUDOCONFIG_MAPPER = {
'debug_rpc_answer': ['openerp:DEBUG','openerp.http.rpc.request:DEBUG', 'openerp.http.rpc.response:DEBUG'],
'debug_rpc': ['openerp:DEBUG','openerp.http.rpc.request:DEBUG'],
'debug': ['openerp:DEBUG'],
'debug_sql': ['openerp.sql_db:DEBUG'],
'info': [],
'warn': ['openerp:WARNING', 'werkzeug:WARNING'],
'error': ['openerp:ERROR', 'werkzeug:ERROR'],
'critical': ['openerp:CRITICAL', 'werkzeug:CRITICAL'],
}
It reads log_handler configuration option that defines mappings of a module and its logging level. The default is :INFO. Then it combines the mapped value of log_level option, log_handler and the following default logging configuration:
DEFAULT_LOG_CONFIGURATION = [
'openerp.workflow.workitem:WARNING',
'openerp.http.rpc.request:INFO',
'openerp.http.rpc.response:INFO',
'openerp.addons.web.http:INFO',
'openerp.sql_db:INFO',
':INFO',
]
Finally, it set logging level for every module in the combined list of 'module:log_level' pairs.
The init_logger() is called by parse_config() method in openerp/tools/config.py that is called by the main() method in openerp/cli/server.py.
Note: it seems that the openerp/loglevels.py is not used by any module. -
Odoo 8.0 nightly build installation Docker image做这个的目的有二个:一是做个Docker的Image。 类似于VM的概念但是性能更好,管理更方便。运行一个Docker Container好像启动一个进程。所有一台计算机上面可以跑很多各种配置的Odoo。 二是从Dockerfile可以看到如果从一个最基本的操作系统(我用的是Ubuntu)怎么安装 Odoo 8.0 nightly build。 知道八月份,Odoo才有真正的nightly build, 以前只有孤零零个七月份的build。
如果不是因为Docker的bug, 只需要一条指令就可以运行配置好的Odoo 8.0了。所有东西,包括数据库用户都配置好了。 -
Odoo 8.0 nightly build installation Docker image我做了一个Odoo 8.0 nightly build 的 Docker Image [检测到链接无效,已移除]
在任何安装了Docker的操作系统上,一旦下载之后,几秒钟就可以有一个全新的的Odoo 8.0系统可以使用。一台计算机的可以运行多个。自己做的修改也可以存起来。
Docker现在是最热门的系统软件。在Digital Ocean上五个美金一个月,有现成的。非常适合开发调试。