我是Odoo的新手,我陷入了困境.我已经在自定义模块的后端添加了一些小部件.现在我想在我的网站前端添加一个小部件,但我没有让它工作.
我有以下几个片段:
frontend_views.xml
<openerp>
<data>
<!-- Templates -->
<template id="assets_frontend" name="test_module_asset_frontend" inherit_id="website.theme">
<xpath expr="." position="inside">
<!-- Custom JS and CSS -->
<link rel="stylesheet" href="/test_module/static/src/css/frontend.css" />
<script type="text/javascript" src="/test_module/static/src/js/frontend.js" />
</xpath>
</template>
</data>
</openerp>
Run Code Online (Sandbox Code Playgroud)
以及小部件的JavaScript代码:
static/src/js/frontend.js
openerp.test_module = function(instance, local) {
local.TestWidget = instance.Widget.extend({
start: function() {
console.log('Widget loaded!');
this._super();
},
});
instance.web.client_actions.add('example.action', 'instance.test_module.TestWidget');
}
Run Code Online (Sandbox Code Playgroud)
我怎么能在模板中调用小部件?我尝试了以下事项:
frontend_views.xml
<record model="ir.actions.client" id="action_client_example">
<field name="name">Example Client Action</field>
<field name="tag">example.action</field>
</record>
<template id="details">
<t t-call="website.layout">
<t t-set="title">Details</t>
<div class="oe_structure">
<div class="container">
<button id="test" name="action_client_example" sequence="0" …Run Code Online (Sandbox Code Playgroud) 如何将关系添加到枢轴模型?
我有以下表格:
users
-id
events
-id
user_event
-id
-user_id
-event_id
tickets
-price
-user_event_id
Run Code Online (Sandbox Code Playgroud)
所以一个用户可以访问多个事件,一个事件属于多个用户。现在我希望用户可以拥有一个特殊活动的许多不同门票。
我的模型如下:
class Event extends Eloquent{
// Joins
public function getUsers(){
return $this->belongsToMany('User', 'user_event', 'event_id', 'user_id')->withPivot('id', 'emailSent', 'info')->withTimestamps();
}
// Pivot
public function newPivot(Eloquent $parent, array $attributes, $table, $exists) {
if ($parent instanceof User) {
return new UserEvent($parent, $attributes, $table, $exists);
}
return parent::newPivot($parent, $attributes, $table, $exists);
}
Run Code Online (Sandbox Code Playgroud)
class User extends Eloquent implements UserInterface, RemindableInterface {
//Joins
public function getEvents(){
return $this->belongsToMany('Event', 'user_event', 'user_id', 'event_id')->withPivot('id', …Run Code Online (Sandbox Code Playgroud)