Category: Odoo

Odoo 10 Could not execute command lessc

这个问题出现的十分突然,早上打开项目,直接抛出“Could not execute command lessc”这个Error,导致界面加载异常。

现将处理过程做一次分析整理。

再看系统环境变量

启动程序,问题依旧。。

跟进代码

发现 os.environ 这个变量中的PATH里面被覆盖了。

调整启动配置

再次跟进代码
Over...

Odoo Javascript & Widget

定义一个OdooClass

odoo.define('addon_name.service', function (require) {
    "use strict";
    var utils = require('web.utils');
    var Model = require('web.Model');

    // do things with utils and Model
    var something_useful = 15;
    return  {
        something_useful: something_useful,
    };
});

重写记录打开方式

odoo.define('combined_statements.working_papers', function(require) {
	"use strict";
	var core = require('web.core');
	var ListView = require('web.ListView');
	var utils = require('web.utils');
	var web_client = require('web.web_client');
	var Model = require('web.Model');

	var QWeb = core.qweb;
	var _t = core._t;

	/**
	 * 打开工作底稿创建向导页面
	 */
	function open_wording_papers_wizard_action() {
		web_client.action_manager.do_action({
			name: "底稿定义",
			type: "ir.actions.act_window",
			res_model: "working.papers.define.wizard",
			target: 'new',
			xml_id: 'combined_statements.working_papers_define_wizard_form',
			views: [[false, 'form']]
		});
	}

	ListView.include({
                // 为增加按钮绑定点击事件
		render_buttons: function($node) {
			let add_button = false;
			if (!this.$buttons) {
				add_button = true;
			}

			this._super.apply(this, arguments);

			if (add_button) {
				this.$buttons.on('click', '.o_button_open', open_wording_papers_wizard_action.bind(this));
			}
		},

		// 重写Tree视图点击行打开记录的方式
		do_activate_record: function(index, id, dataset, view) {
			if (this.model === 'combined.statements.working.paper') {
				let record = this.records.get(id);
				this.do_action({
					type: "ir.actions.client",
					tag: 'working.papers',
					params: record,
				});
			}else {
				this._super.apply(this, arguments);
			}
		}
	});

});

Odoo开发之开发者模式

--dev <feature,feature,...,feature>

  • all  以下功能全部激活
  • xml  直接从xml文件中读取模板。而不是从数据库。
  • reload  更新python文件时重新启动服务器(需要watchdog包)
  • qweb: break in the evaluation of qweb template when a node contains t-debug='debugger'
  • (i)p(u)db: start the chosen python debugger in the code when an unexpected error is raised before logging and returning the error.

官方帮助:https://www.odoo.com/documentation/10.0/reference/cmdline.html

pip install watchdog
python odoo-bin -c dev.conf --dev all

Odoo 12 企业版开发环境搭建

基础环境请参阅:Odoo 10.0 64位 绿色版

目录结构

创建适用于odoo12的配置文件

python source\odoo-bin --save --stop-after-init

创建数据库及用户

-- 创建用户
CREATE USER xxx WITH PASSWORD 'xxxxxx';
-- 创建数据库yyy并指定所有者为xxx
CREATE DATABASE yyy OWNER xxx;
-- 对数据库yyy的全部操作权限赋给用户xxx,否则xxx仅仅能登录控制台,没有不论什么数据库的操作权限
GRANT ALL PRIVILEGES ON DATABASE yyy to xxx;
-- 删除数据库yyy
DROP DATABASE yyy;
-- 删除用户xxx
DROP USER XXX;

PyCharm启动设置

Odoo Widget 颜色的使用

Tree视图定义行的颜色

<record id="purchase_order_tree" model="ir.ui.view">
	<field name="name">purchase.order.tree</field>
	<field name="model">purchase.order</field>
	<field name="arch" type="xml">
		<tree decoration-bf="message_unread==True" decoration-muted="state=='cancel'" decoration-info="state in ('wait','confirmed')" string="Purchase Order">
			<field name="message_unread" invisible="1"/>
			<field name="name" string="Reference"/>
			<field name="date_order" />
			<field name="partner_id"/>
			<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
			<field name="date_planned" invisible="context.get('quotation_only', False)"/>
			<field name="origin"/>
			<field name="amount_untaxed" sum="Total Untaxed amount" string="Untaxed" widget="monetary"/>
			<field name="amount_total" sum="Total amount" widget="monetary"/>
			<field name="currency_id" invisible="1"/>
			<field name="state"/>
			<field name="invoice_status" invisible="not context.get('show_purchase', True)"/>
		</tree>
	</field>
</record>

Kanban组件

color值为0~9

<li><ul class="oe_kanban_colorpicker" data-field="color"/></li>

示例:

<record id="view_forum_post_kanban" model="ir.ui.view">
	<field name="name">forum.post.kanban</field>
	<field name="model">forum.post</field>
	<field name="arch" type="xml">
		<kanban default_group_by="documentation_stage_id" >
			<field name="documentation_stage_id"/>
			<field name="create_uid"/>
			<field name="color"/>
			<templates>
			<t t-name="kanban-box">
				<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_global_click">
					<div class="o_dropdown_kanban dropdown" groups="base.group_user">
						<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
							<li t-if="widget.editable"><a type="edit">Edit Post</a></li>
							<li t-if="widget.deletable"><a type="delete">Delete</a></li>
							<li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
						</ul>
					</div>
				</div>
			</t>
			</templates>
		</kanban>
	</field>
</record>

Many2many_tag widget

值范围:1~12

<field name="about_place_route" widget="many2many_tags" options="{'color_field': 'color', 'no_open':True,'no_create':1,'no_create_edit':1}" />


啊啊