[REF] lunch: XML/LESS/JS

CSS to LESS
Adaptation to new webclient
This commit is contained in:
qsm-odoo
2015-09-11 16:22:19 +02:00
parent f5f0edaae1
commit 047dab7029
7 changed files with 102 additions and 153 deletions
-28
View File
@@ -1,28 +0,0 @@
.openerp .o_lunch .o_lunch_alert {
height: 22px;
}
.openerp .o_lunch .o_lunch_30pc {
width: 30%;
display: inline-block;
vertical-align: top;
}
.openerp .o_lunch .o_lunch_30pc:nth-child(3) {
padding-right: 0;
}
.openerp .o_lunch .o_lunch_30pc {
padding-right: 5%;
}
.openerp .o_lunch h2 {
color: #7c7bad;
}
.openerp .o_lunch .o_lunch_vignette {
border-bottom: 1px solid #dddddd;
padding-top: 5px;
padding-bottom: 5px;
}
.openerp .o_lunch .o_lunch_vignette:last-child {
border: none;
}
.openerp .o_lunch .oe_group_text_button {
margin-bottom: 3px;
}
-24
View File
@@ -1,24 +0,0 @@
@charset "utf-8"
.openerp
.o_lunch
.o_lunch_alert
height: 22px
.o_lunch_30pc
width: 30%
display: inline-block
vertical-align: top
.o_lunch_30pc:nth-child(3)
padding-right: 0
.o_lunch_30pc
padding-right: 5%
h2
color: #7C7BAD
.o_lunch_vignette
border-bottom: 1px solid #dddddd
padding-top: 5px
padding-bottom: 5px
.o_lunch_vignette:last-child
border: none
.oe_group_text_button
margin-bottom: 3px
+23 -21
View File
@@ -2,20 +2,18 @@ odoo.define('lunch.form_widgets', function (require) {
"use strict";
var core = require('web.core');
var Model = require('web.Model');
var form_common = require('web.form_common');
var form_widgets = require('web.form_widgets');
var form_relational = require('web.form_relational');
var _t = core._t;
var QWeb = core.qweb;
var lunch = {};
lunch.lunch_order_widget_previous_orders = form_relational.AbstractManyField.extend(form_common.ReinitializeWidgetMixin, {
template : 'lunch_order_widget_previous_orders',
var LunchPreviousOrdersWidget = form_relational.AbstractManyField.extend(form_common.ReinitializeWidgetMixin, {
className: 'row o_lunch_last_orders',
events: {
'click span.add_button': 'set_order_line',
'click .o_add_button': 'set_order_line',
},
init: function(field_manager, node){
init: function(field_manager, node) {
this._super.apply(this, arguments);
this.lunch_data = {};
this.fields_to_read = ['product_id', 'supplier', 'note', 'price', 'category_id', 'currency_id'];
@@ -25,13 +23,14 @@ lunch.lunch_order_widget_previous_orders = form_relational.AbstractManyField.ext
fetch_value: function(){
var self = this;
return this.dataset.read_ids(this.get('value'), this.fields_to_read)
.done(function(data){
_.each(data, function(order){
.then(function(data) {
_.each(data, function(order) {
self.lunch_data[order['id']] = order;
});
return data;
});
},
get_line_value: function (id) {
get_line_value: function(id) {
var data = _.clone(this.lunch_data[id]);
if (typeof this.lunch_data[id]['product_id'][0] != 'undefined'){
data['product_id'] = this.lunch_data[id]['product_id'][0];
@@ -44,30 +43,33 @@ lunch.lunch_order_widget_previous_orders = form_relational.AbstractManyField.ext
}
return data;
},
set_order_line: function(event){
var data = this.get_line_value( parseInt($(event.currentTarget).attr('id')) );
set_order_line: function(event) {
var data = this.get_line_value(parseInt($(event.currentTarget).data('id')));
var order_line_ids = this.field_manager.fields.order_line_ids;
order_line_ids.data_create(data);
order_line_ids.reload_current_view();
},
render_value: function() {
var self = this;
return this.fetch_value().done(function(data) {
return this.fetch_value().then(function(data) {
if (_.isEmpty(data)) {
return self.$el.html(QWeb.render("lunch_order_widget_no_previous_order"));
return self.$el.html(QWeb.render("lunch_order_widget_no_previous_order"));
}
var categories = _.groupBy(data,function(data1){return data1['supplier'][1];});
return self.$el.html(QWeb.render("lunch_order_widget_previous_orders_list", {'widget': self, 'categories': categories}
));
return self.$el.html(QWeb.render("lunch_order_widget_previous_orders_list", {'widget': self, 'categories': categories}));
});
},
destroy: function () {
this.monetary.destroy();
this._super();
}
destroy: function() {
this.monetary.destroy();
this._super();
},
is_false: function() {
return false;
},
});
core.form_widget_registry.add('previous_order', lunch.lunch_order_widget_previous_orders);
return lunch;
core.form_widget_registry.add('previous_order', LunchPreviousOrdersWidget);
return LunchPreviousOrdersWidget;
});
+15
View File
@@ -0,0 +1,15 @@
.o_web_client .o_lunch {
.o_lunch_last_orders {
width: 100%;
.o_lunch_vignette {
.clearfix();
padding: 5px 0;
+ .o_lunch_vignette {
border-top: 1px solid @odoo-brand-lightsecondary;
}
}
}
}
+21 -36
View File
@@ -1,42 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="lunch_order_widget_previous_orders">
<div>
<div class="previous_order_lines"></div>
</div>
</t>
<t t-name="lunch_order_widget_no_previous_order">
<div class="oe_inline o_lunch_intro">
<h3>This is the first time you order a meal</h3>
<p class="text-muted">Select a product and put your order comments on the note.</p>
<p class="text-muted">Your favorite meals will be created based on your last orders.</p>
<p class="text-muted">Don't forget the alerts displayed in the reddish area</p>
</div>
</t>
<div t-name="lunch_order_widget_no_previous_order" class="col-md-12">
<h3>This is the first time you order a meal</h3>
<p class="text-muted">Select a product and put your order comments on the note.</p>
<p class="text-muted">Your favorite meals will be created based on your last orders.</p>
<p class="text-muted">Don't forget the alerts displayed in the reddish area</p>
</div>
<t t-name="lunch_order_widget_previous_orders_list">
<t t-foreach="categories" t-as="product_category">
<div class="o_lunch_30pc">
<h2><t t-esc="product_category"/></h2>
<t t-foreach='categories[product_category]' t-as='product'>
<div class="o_lunch_vignette">
<span class="pull-right add_button oe_edit_only" t-att-id="product.id">
<button type="button" class="oe_button oe_link">
<span class="fa fa-plus-square"></span>
<span>Add</span>
</button>
</span>
<div class="oe_group_text_button">
<div class="o_lunch_text">
<t t-esc="product.product_id[1]"/>
<span class="badge">
<t t-esc="widget.monetary.format_value(product.price)"/> <t t-esc="product.currency_id[1]"/>
</span>
</div>
</div>
<div class="text-muted"><t t-if="product.note != false" t-esc="product.note"/></div>
</div>
</t>
<div t-foreach="categories" t-as="product_category" class="col-sm-4">
<h3><t t-esc="product_category"/></h3>
<div t-foreach='categories[product_category]' t-as='product' class="o_lunch_vignette">
<button type="button" class="pull-right o_add_button oe_edit_only oe_link" t-att-data-id="product.id">
<span class="fa fa-plus-square"></span>
<span>Add</span>
</button>
<div class="o_lunch_text">
<t t-esc="product.product_id[1]"/>
<span class="badge">
<t t-esc="widget.monetary.format_value(product.price)"/> <t t-esc="product.currency_id[1]"/>
</span>
</div>
<div class="text-muted"><t t-if="product.note != false" t-esc="product.note"/></div>
</div>
</t>
</div>
</t>
</templates>
+1 -1
View File
@@ -2,7 +2,7 @@
<odoo>
<template id="assets_backend" name="lunch assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/lunch/static/src/css/lunch.css"/>
<link rel="stylesheet" href="/lunch/static/src/less/lunch.less"/>
<script type="text/javascript" src="/lunch/static/src/js/lunch.js"></script>
</xpath>
</template>
+42 -43
View File
@@ -370,36 +370,39 @@
</header>
<sheet>
<field name="balance_visible" invisible="1"/>
<div class="alert alert-warning" role="alert" attrs="{'invisible': ['|',('cash_move_balance', '&gt;', 0),('balance_visible', '=', False)]}">
Warning : Your balance is insufficient.
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button"
attrs="{'invisible': [('balance_visible', '=', False)]}"
name="%(lunch_cashmove_action_account)d"
icon="fa-money"
type="action">
<div class="o_form_field o_stat_info">
<span class="o_stat_value"><field name="cash_move_balance" widget="monetary"/></span>
<span class="o_stat_text">Balance</span>
</div>
</button>
</div>
<group>
<group>
<field name='user_id'
context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'lunch.group_lunch_user']}"/>
<field name='user_id' context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'lunch.group_lunch_user']}"/>
<field name='date'/>
</group>
<group>
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button"
attrs="{'invisible': [('balance_visible', '=', False)]}"
name="%(lunch_cashmove_action_account)d"
icon="fa-money"
type="action">
<div class="o_form_field o_stat_info">
<span class="o_stat_value"><field name="cash_move_balance" widget="monetary"/></span>
<span class="o_stat_text">Balance</span>
</div>
</button>
<div>
<div class="alert alert-warning" role="alert" attrs="{'invisible': ['|',('cash_move_balance', '&gt;', 0),('balance_visible', '=', False)]}">
Warning : Your balance is insufficient.
</div>
</group>
<div attrs="{'invisible': ['|',('state','!=','new'),('alerts','=',False)]}" class="alert alert-danger oe_edit_only">
<field name='alerts'/>
</div>
</div>
</group>
<div attrs="{'invisible': ['|',('state','!=','new'),('alerts','=',False)]}" class="oe_inline alert alert-danger oe_edit_only">
<field name='alerts'/>
</div>
<field name='previous_order_ids' widget='previous_order' class="oe_edit_only"/>
<separator string='Select your order'/>
<field name='order_line_ids' nolabel='1'>
<field name='order_line_ids'>
<tree string='List' editable='bottom'>
<field name='product_id'/>
<field name='note' />
@@ -411,7 +414,6 @@
<group class='oe_subtotal_footer oe_right'>
<field name='total' widget='monetary' options="{'currency_field': 'currency_id'}"/>
</group>
<br/><br/>
</sheet>
</form>
</field>
@@ -460,7 +462,7 @@
<field name="name">lunch.alert.tree</field>
<field name="model">lunch.alert</field>
<field name="arch" type="xml">
<tree string="alert tree">
<tree>
<field name="message"/>
<field name="alert_type"/>
<field name='start_hour' widget='float_time'/>
@@ -473,35 +475,32 @@
<field name="name">lunch.alert.form</field>
<field name="model">lunch.alert</field>
<field name="arch" type="xml">
<form string="alert tree">
<group string="Schedule Date">
<group>
<field name="alert_type" class="oe_inline"/>
<form>
<group>
<group string="Schedule Date">
<field name="alert_type"/>
<field name="specific_day" attrs="{'invisible': [('alert_type','!=','specific')], 'required':[('alert_type','=','specific')]}"/>
</group>
</group>
<group attrs="{'invisible': [('alert_type','!=','week')]}">
<group>
<field name="monday"/>
<field name="tuesday"/>
<field name="wednesday"/>
<field name="thursday"/>
<group string="Schedule Hour">
<field name='start_hour' widget='float_time'/>
<field name='end_hour' widget='float_time'/>
</group>
<group>
<field name="friday"/>
<field name="saturday"/>
<field name="sunday"/>
<group attrs="{'invisible': [('alert_type','!=','week')]}">
<group col="4">
<field name="monday"/>
<field name="tuesday"/>
<field name="wednesday"/>
<field name="thursday"/>
<field name="friday"/>
<field name="saturday"/>
<field name="sunday"/>
</group>
</group>
</group>
<group string="Schedule Hour">
<field name='start_hour' widget='float_time'/>
<field name='end_hour' widget='float_time'/>
</group>
<group string='Message'>
<field name='message' nolabel='1' placeholder="Write the message you want to display during the defined period..."/>
</group>
</form>
</field>
</record>
</odoo>