[MERGE] Sync with website-al

bzr revid: tde@openerp.com-20140124120925-gyysjhkokizynsd8
This commit is contained in:
Thibault Delavallée 2014-01-24 13:09:25 +01:00
commit 43deedcdf6
23 changed files with 276 additions and 152 deletions

View File

@ -20,15 +20,11 @@
##############################################################################
import time
from openerp.addons import decimal_precision
from openerp.addons.sale.sale import sale_order as OriginalSaleOrder
from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp import SUPERUSER_ID
class sale_order_line(osv.osv):
class sale_order_line(osv.Model):
_inherit = 'sale.order.line'
_columns = {
@ -42,39 +38,10 @@ class sale_order_line(osv.osv):
class sale_order(osv.Model):
_inherit = 'sale.order'
def _amount_all_wrapper(self, cr, uid, ids, field_name, arg, context=None):
""" Wrapper because of direct method passing as parameter for function fields """
return self._amount_all(cr, uid, ids, field_name, arg, context=context)
def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
res = super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context=context)
Currency = self.pool.get('res.currency')
for order in self.browse(cr, uid, ids, context=context):
line_amount = sum([line.price_subtotal for line in order.order_line if line.is_delivery])
currency = order.pricelist_id.currency_id
res[order.id]['amount_delivery'] = Currency.round(cr, uid, currency, line_amount)
return res
def _get_order(self, cr, uid, ids, context=None):
result = {}
for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):
result[line.order_id.id] = True
return result.keys()
_columns = {
'carrier_id': fields.many2one(
"delivery.carrier", string="Delivery Method",
help="Complete this field if you plan to invoice the shipping based on picking."),
'amount_delivery': fields.function(
_amount_all_wrapper, type='float', digits_compute=decimal_precision.get_precision('Account'),
string='Delivery Amount',
store={
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
},
multi='sums', help="The amount without tax.", track_visibility='always'
),
}
def onchange_partner_id(self, cr, uid, ids, part, context=None):
@ -92,9 +59,9 @@ class sale_order(osv.Model):
return result
def _delivery_unset(self, cr, uid, order, context=None):
for line in order.order_line:
if line.is_delivery:
self.pool.get('sale.order.line').unlink(cr, uid, [line.id], context=context)
line_ids = [line.id for line in order.order_line if line.is_delivery]
self.pool['sale.order.line'].unlink(cr, uid, line_ids, context=context)
order.refresh()
return True
def delivery_set(self, cr, uid, ids, context=None):
@ -102,17 +69,17 @@ class sale_order(osv.Model):
grid_obj = self.pool.get('delivery.grid')
carrier_obj = self.pool.get('delivery.carrier')
acc_fp_obj = self.pool.get('account.fiscal.position')
for order in self.browse(cr, uid, ids, context=context):
self._delivery_unset(cr, uid, order, context=context)
for order in self.browse(cr, uid, ids, context=context):
grid_id = carrier_obj.grid_get(cr, uid, [order.carrier_id.id], order.partner_shipping_id.id)
if not grid_id:
raise osv.except_osv(_('No Grid Available!'), _('No grid matching for this carrier!'))
if not order.state in ('draft'):
if order.state != 'draft':
raise osv.except_osv(_('Order not in Draft State!'), _('The order state have to be draft to add delivery lines.'))
grid = grid_obj.browse(cr, SUPERUSER_ID, grid_id, context=context)
grid = grid_obj.browse(cr, uid, grid_id, context=context)
taxes = grid.carrier_id.product_id.taxes_id
fpos = order.fiscal_position or False
@ -129,6 +96,3 @@ class sale_order(osv.Model):
'type': 'make_to_stock',
'is_delivery': True
})
# remove the value of the carrier_id field on the sale order
# TDE NOTE: why removing it ?? seems weird
# return self.write(cr, uid, ids, {'carrier_id': False}, context=context)

View File

@ -55,7 +55,7 @@ class res_partner(osv.osv, EDIMixin):
res_partner_bank_type = self.pool.get('res.partner.bank.type')
try:
return self.pool.get('ir.model.data').get_object(cr, uid, 'base', 'bank_normal', context=context).code
except:
except ValueError:
pass
# second option: create a new custom type for EDI or use it if already created, as IBAN type is
# not always appropriate: we need a free-form bank type for max flexibility (users can correct

View File

@ -117,16 +117,16 @@ class event_event(osv.osv):
return result
def _get_tickets(self, cr, uid, context={}):
md = self.pool.get('ir.model.data')
imd = self.pool.get('ir.model.data')
try:
dummy, res_id = md.get_object_reference(cr, uid, 'event_sale', 'product_product_event')
product = imd.get_object(cr, uid, 'event_sale', 'product_product_event')
except ValueError:
return []
return [{
'name': _('Subscription'),
'product_id': res_id,
'price': 0,
}]
'name': _('Subscription'),
'product_id': product.id,
'price': 0,
}]
_columns = {
'event_ticket_ids': fields.one2many('event.event.ticket', "event_id", "Event Ticket"),
@ -196,13 +196,14 @@ class event_ticket(osv.osv):
'register_prospect': fields.function(_get_register, string='Unconfirmed Registrations', type='integer', multi='register_numbers'),
'register_attended': fields.function(_get_register, string='# of Participations', type='integer', multi='register_numbers'),
}
def _default_product_id(self, cr, uid, context={}):
md = self.pool.get('ir.model.data')
imd = self.pool.get('ir.model.data')
try:
dummy, res_id = md.get_object_reference(cr, uid, 'event_sale', 'product_product_event')
product = imd.get_object(cr, uid, 'event_sale', 'product_product_event')
except ValueError:
return False
return res_id
return product.id
_defaults = {
'product_id': _default_product_id

View File

@ -854,36 +854,29 @@ class product_product(osv.osv):
def copy(self, cr, uid, id, default=None, context=None):
if context is None:
context={}
context = {}
if not default:
default = {}
# Craft our own `<name> (copy)` in en_US (self.copy_translation()
# will do the other languages).
context_wo_lang = context.copy()
context_wo_lang = dict(context)
context_wo_lang.pop('lang', None)
product = self.read(cr, uid, id, ['name', 'list_price', 'standard_price', 'categ_id', 'variants', 'product_tmpl_id'], context=context_wo_lang)
default = default.copy()
if product['variants']:
default.update(variants=_("%s (copy)") % (product['variants']), product_tmpl_id=product['product_tmpl_id'][0])
else:
default.update(name=_("%s (copy)") % (product['name']), list_price=product['list_price'], standard_price=product['standard_price'], categ_id=product['categ_id'][0], product_tmpl_id=None)
product = self.read(cr, uid, id, ['name', 'variants', 'product_tmpl_id'], context=context_wo_lang)
default = dict(default)
if product['variants'] or context.get('variant'):
# if we copy a variant or create one, we keep the same template
name = default.pop('name', None)
variant = product['variants'] or name or product['name']
default.update({
'variants': _("%s (copy)") % (variant,),
'product_tmpl_id': product['product_tmpl_id'][0],
})
elif 'name' not in default:
default['name'] = _("%s (copy)") % (product['name'],)
if context.get('variant',False):
fields = ['product_tmpl_id', 'active', 'variants', 'default_code',
'price_margin', 'price_extra']
data = self.read(cr, uid, id, fields=fields, context=context)
for f in fields:
if f in default:
data[f] = default[f]
data['product_tmpl_id'] = data.get('product_tmpl_id', False) \
and data['product_tmpl_id'][0]
del data['id']
return self.create(cr, uid, data)
else:
return super(product_product, self).copy(cr, uid, id, default=default,
context=context)
return super(product_product, self).copy(cr, uid, id, default=default, context=context)
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
if context is None:
@ -988,7 +981,7 @@ class product_supplierinfo(osv.osv):
'product_uom': fields.related('product_tmpl_id', 'uom_po_id', type='many2one', relation='product.uom', string="Supplier Unit of Measure", readonly="1", help="This comes from the product form."),
'min_qty': fields.float('Minimal Quantity', required=True, help="The minimal quantity to purchase to this supplier, expressed in the supplier Product Unit of Measure if not empty, in the default unit of measure of the product otherwise."),
'qty': fields.function(_calc_qty, store=True, type='float', string='Quantity', multi="qty", help="This is a quantity which is converted into Default Unit of Measure."),
'product_tmpl_id' : fields.many2one('product.template', 'Product Template', required=True, ondelete='cascade', select=True),
'product_tmpl_id' : fields.many2one('product.template', 'Product Template', required=True, ondelete='cascade', select=True, oldname='product_id'),
'delay' : fields.integer('Delivery Lead Time', required=True, help="Lead time in days between the confirmation of the purchase order and the reception of the products in your warehouse. Used by the scheduler for automatic computation of the purchase order planning."),
'pricelist_ids': fields.one2many('pricelist.partnerinfo', 'suppinfo_id', 'Supplier Pricelist'),
'company_id':fields.many2one('res.company','Company',select=1),

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import logging
import re
import traceback
import werkzeug
@ -13,6 +14,10 @@ from openerp.osv import orm
logger = logging.getLogger(__name__)
class RequestUID(object):
def __init__(self, **kw):
self.__dict__.update(kw)
class ir_http(orm.AbstractModel):
_inherit = 'ir.http'
@ -79,6 +84,22 @@ class ir_http(orm.AbstractModel):
return self._dispatch()
def _postprocess_args(self, arguments):
url = request.httprequest.url
for arg in arguments.itervalues():
if isinstance(arg, orm.browse_record) and isinstance(arg._uid, RequestUID):
placeholder = arg._uid
arg._uid = request.uid
try:
good_slug = slug(arg)
if str(arg.id) != placeholder.value and placeholder.value != good_slug:
# TODO: properly recompose the url instead of using replace()
url = url.replace(placeholder.value, good_slug)
except KeyError:
return self._handle_exception(werkzeug.exceptions.NotFound())
if url != request.httprequest.url:
werkzeug.exceptions.abort(werkzeug.utils.redirect(url))
def _handle_exception(self, exception=None, code=500):
if isinstance(exception, werkzeug.exceptions.HTTPException) and exception.response:
return exception.response
@ -131,6 +152,12 @@ class ModelConverter(ir.ir_http.ModelConverter):
def to_url(self, value):
return slug(value)
def to_python(self, value):
m = re.match(self.regex, value)
_uid = RequestUID(value=value, match=m, converter=self)
return request.registry[self.model].browse(
request.cr, _uid, int(m.group(1)), context=request.context)
def generate(self, cr, uid, query=None, context=None):
return request.registry[self.model].name_search(
cr, uid, name=query or '', context=context)

View File

@ -1,3 +1,4 @@
@charset "utf-8";
/* THIS CSS FILE IS FOR WEBSITE THEMING CUSTOMIZATION ONLY
*
* css for editor buttons, openerp widget included in the website and other
@ -162,19 +163,29 @@ footer {
background-image: url("/website/static/src/img/drag_here.png");
}
.oe_structure.oe_empty:empty, [data-oe-type=html]:empty, .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child {
background-image: none;
background-repeat: no-repeat;
background-position: center;
height: 220px !important;
}
.oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child {
position: static;
}
.oe_structure.oe_editable.oe_empty:empty:before, .oe_editable[data-oe-type=html]:empty:before, .oe_structure.oe_editable.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before {
content: "Drag Building Blocks Here";
}
.oe_structure.oe_empty:empty:before, [data-oe-type=html]:empty:before, .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before {
content: " ";
text-align: center;
display: block;
padding-top: 160px;
padding-bottom: 30px;
color: grey;
font-size: 24px;
}
.oe_structure.oe_editable.oe_empty:empty:before, .oe_editable[data-oe-type=html]:empty:before, .oe_structure.oe_editable.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before {
content: "Drag Building Blocks Here";
}
.css_editable_display {

View File

@ -122,17 +122,27 @@ footer
.oe_structure.oe_editable.oe_empty:empty, .oe_editable[data-oe-type=html]:empty, .oe_structure.oe_editable.oe_empty > .oe_drop_zone.oe_insert:only-child, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child
background-image: url('/website/static/src/img/drag_here.png')
.oe_structure.oe_empty:empty, [data-oe-type=html]:empty, .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child
background-image: none /*url('/website/static/src/img/under_construction.png')*/
background-repeat: no-repeat
background-position: center
height: 220px !important
.oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child
position: static
.oe_structure.oe_empty:empty:before, [data-oe-type=html]:empty:before, .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before
content: ' '
text-align: center
display: block
padding-top: 160px
padding-bottom: 30px
color: grey
font-size: 24px
.oe_structure.oe_editable.oe_empty:empty:before, .oe_editable[data-oe-type=html]:empty:before, .oe_structure.oe_editable.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before
content: 'Drag Building Blocks Here'
.oe_structure.oe_empty:empty:before, [data-oe-type=html]:empty:before, .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before
content: ' '
display: block
padding-top: 160px
padding-bottom: 30px
.css_editable_display
display: none

View File

@ -420,9 +420,10 @@
});
// Adding Static Menus
menu.append('<li class="divider"></li>');
menu.append('<li><a data-action="ace" href="#">HTML Editor</a></li>');
menu.append('<li><a data-action="ace" href="#">HTML Editor</a></li>');
menu.append('<li class="js_change_theme"><a href="/page/website.themes">Change Theme</a></li>');
menu.append('<li><a href="/web#return_label=Website&action=website.action_module_website">Install Apps</a></li>');
menu.append('<li><a href="/web#return_label=Website&action=website.action_website_form">Website Settings</a></li>');
self.trigger('rte:customize_menu_ready');
}
);

View File

@ -375,7 +375,7 @@
});
},
stop: function(ev, ui){
if (action === 'insert' && ! dropped && $('.oe_drop_zone')) {
if (action === 'insert' && ! dropped && $('.oe_drop_zone') && ui.position.top > 50) {
var el = $('.oe_drop_zone').nearest({x: ui.position.left, y: ui.position.top}).first();
if (el.length) {
el.after($toInsert);

View File

@ -47,24 +47,6 @@
}
localStorage.setItem("website-reloads", JSON.stringify(stack));
};
} else if (step.trigger.url) {
step.triggers = function (callback) {
var stack = JSON.parse(localStorage.getItem("website-geturls")) || [];
var id = step.trigger.url.toString();
var index = stack.indexOf(id);
if (index !== -1) {
var url = new website.UrlParser(window.location.href);
var test = typeof step.trigger.url === "string" ?
step.trigger.url == url.pathname+url.search :
step.trigger.url.test(url.pathname+url.search);
if (!test) return;
stack.splice(index,1);
(callback || self.moveToNextStep).apply(self);
} else {
stack.push(id);
}
localStorage.setItem("website-geturls", JSON.stringify(stack));
};
} else if (step.trigger === 'drag') {
step.triggers = function (callback) {
self.onSnippetDragged(callback || self.moveToNextStep);
@ -86,8 +68,27 @@
});
};
}
} else if (step.trigger.modal) {
} else if (step.trigger.url) {
step.triggers = function (callback) {
var stack = JSON.parse(localStorage.getItem("website-geturls")) || [];
var id = step.trigger.url.toString();
var index = stack.indexOf(id);
if (index !== -1) {
var url = new website.UrlParser(window.location.href);
var test = typeof step.trigger.url === "string" ?
step.trigger.url == url.pathname+url.search :
step.trigger.url.test(url.pathname+url.search);
if (!test) return;
stack.splice(index,1);
(callback || self.moveToNextStep).apply(self);
} else {
stack.push(id);
}
localStorage.setItem("website-geturls", JSON.stringify(stack));
return index !== -1;
};
} else if (step.trigger.modal) {
step.triggers = function (callback, auto) {
var $doc = $(document);
function onStop () {
if (step.trigger.modal.stopOnClose) {
@ -98,7 +99,10 @@
$doc.one('shown.bs.modal', function () {
$('.modal button.btn-primary').one('click', function () {
$doc.off('hide.bs.modal', onStop);
(callback || self.moveToNextStep).apply(self, [step.trigger.modal.afterSubmit]);
console.log(callback);
if (!callback) {
self.moveToStep(step.trigger.modal.afterSubmit);
}
});
(callback || self.moveToNextStep).apply(self);
});
@ -199,16 +203,19 @@
},
onSnippetDragged: function (callback) {
var self = this;
function beginDrag () {
var selector = '#website-top-navbar [data-snippet-id].ui-draggable';
var beginDrag = function beginDrag () {
$('.popover.tour').remove();
function advance () {
var advance = function advance () {
if (_.isFunction(callback)) {
callback.apply(self);
}
}
$(selector).off('mouseup', advance);
};
$(document.body).one('mouseup', advance);
}
$('#website-top-navbar [data-snippet-id].ui-draggable').one('mousedown', beginDrag);
$(selector).off('mousedown', beginDrag);
};
$(selector).one('mousedown', beginDrag);
},
onSnippetDraggedAdvance: function () {
onSnippetDragged(self.moveToNextStep);
@ -280,7 +287,7 @@
function actualDragAndDrop ($thumbnail) {
var thumbnailPosition = $thumbnail.position();
$thumbnail.trigger($.Event("mousedown", { which: 1, pageX: thumbnailPosition.left, pageY: thumbnailPosition.top }));
$thumbnail.trigger($.Event("mousemove", { which: 1, pageX: thumbnailPosition.left, pageY: thumbnailPosition.top+500 }));
$thumbnail.trigger($.Event("mousemove", { which: 1, pageX: document.body.scrollWidth/2, pageY: document.body.scrollHeight/2 }));
var $dropZone = $(".oe_drop_zone").first();
var dropPosition = $dropZone.position();
$dropZone.trigger($.Event("mouseup", { which: 1, pageX: dropPosition.left, pageY: dropPosition.top }));
@ -327,7 +334,8 @@
var self = this;
var testId = 'test_'+tour.id+'_tour';
this.tours.push(tour);
var defaultDelay = 1000; //ms
var defaultDelay = 250; //ms
var defaultDelayReload = 1500; //ms
var overlapsCrash;
var test = {
id: tour.id,
@ -346,50 +354,67 @@
test.reset();
throw message;
}
function executeStep (step) {
// check if they are a cycle
function initReport () {
// set last time for report
if (!window.localStorage.getItem("test-last-time")) {
window.localStorage.setItem("test-last-time", new Date().getTime());
}
}
function setReport (step) {
var report = JSON.parse(window.localStorage.getItem("test-report")) || {};
report[step.stepId] = (new Date().getTime() - window.localStorage.getItem("test-last-time")) + " ms";
window.localStorage.setItem("test-report", JSON.stringify(report));
}
function testCycling (step) {
var lastStep = window.localStorage.getItem(testId);
var tryStep = lastStep != step.stepId ? 0 : (+(window.localStorage.getItem("test-last-"+testId) || 0) + 1);
window.localStorage.setItem("test-last-"+testId, tryStep);
if (tryStep > 2) {
throwError("Test: '" + testId + "' cycling step: '" + step.stepId + "'");
}
return tryStep;
}
function getDelay (step) {
return step.delay ||
((step.trigger === 'reload' || (step.trigger && step.trigger.url))
? defaultDelayReload
: defaultDelay);
}
function executeStep (step) {
if (testCycling(step) === 0) initReport();
var delay = getDelay (step);
overlapsCrash = setTimeout(function () {
throwError("Test: '" + testId + "' can't resolve step: '" + step.stepId + "'");
}, delay + 1000);
// set last time for report
if (tryStep == 0 || !window.localStorage.getItem("test-last-time")) {
window.localStorage.setItem("test-last-time", new Date().getTime());
}
var _next = false;
window.localStorage.setItem(testId, step.stepId);
function next () {
_next = true;
clearTimeout(overlapsCrash);
// set report
var report = JSON.parse(window.localStorage.getItem("test-report")) || {};
report[step.stepId] = (new Date().getTime() - window.localStorage.getItem("test-last-time")) + " ms";
window.localStorage.setItem("test-report", JSON.stringify(report));
setReport(step);
var nextStep = actionSteps.shift();
if (nextStep) {
setTimeout(function () {
executeStep(nextStep);
}, step.delay || defaultDelay);
}, delay);
} else {
clearTimeout(overlapsCrash);
window.localStorage.removeItem(testId);
}
}
setTimeout(function () {
clearTimeout(overlapsCrash);
overlapsCrash = setTimeout(function () {
throwError("Test: '" + testId + "' can't resolve step: '" + step.stepId + "'");
}, (step.delay || defaultDelay) + 1000);
setTimeout(function () {
var $element = $(step.element);
if (step.triggers) {
var flag = step.triggers && (!step.trigger || !step.trigger.modal);
if (flag) {
try {
step.triggers(next);
step.triggers(next, true);
} catch (e) {
throwError(e);
}
@ -414,7 +439,7 @@
$element.trigger($.Event("mouseup", { srcElement: $element }));
}
}
if (!step.triggers) next();
if (!flag) next();
},0);
}
var url = new website.UrlParser(window.location.href);

View File

@ -942,6 +942,7 @@
<li data-class="oe_img_bg" data-src="/website/static/src/img/parallax/quote.png"><a>Quote</a></li>
</ul>
</li>
<li data-class=""><a>None</a></li>
<li><a style="background: none; padding: 5px; border-top: 1px solid #ddd;"></a></li>
<li class="oe_custom_bg" data-class="oe_img_bg"><a><b>Choose an image...</b></a></li>
</ul>

View File

@ -16,9 +16,16 @@ class contactus(http.Controller):
return url
@http.route(['/crm/contactus'], type='http', auth="public", website=True, multilang=True)
def contactus(self, *arg, **post):
def contactus(self, description=None, partner_name=None, phone=None, contact_name=None, email_from=None, name=None):
post = {}
post['description'] = description
post['partner_name'] = partner_name
post['phone'] = phone
post['contact_name'] = contact_name
post['email_from'] = email_from
post['name'] = name
required_fields = ['contact_name', 'email_from', 'description']
post['user_id'] = False
error = set()
values = dict((key, post.get(key)) for key in post)
values['error'] = error
@ -34,6 +41,13 @@ class contactus(http.Controller):
if not post.get('name'):
post['name'] = post.get('contact_name')
section_ids = request.registry["crm.case.section"].search(
request.cr, SUPERUSER_ID, [("code", "=", "Website")], context=request.context)
if section_ids:
post['section_id'] = section_ids[0]
post['user_id'] = False
request.registry['crm.lead'].create(request.cr, SUPERUSER_ID, post, request.context)
company = request.website.company_id
values = {

View File

@ -12,5 +12,13 @@
<field name="state">open</field>
</record>
<record model="crm.case.section" id="website.section_sales_department">
<field name="name">Website</field>
<field name="code">Website</field>
<field name="use_leads">True</field>
<field name="alias_name">Website</field>
<field name="member_ids" eval="[(4, ref('base.user_root'))]"/>
</record>
</data>
</openerp>

View File

@ -43,7 +43,7 @@
modal: {
stopOnClose: true,
afterSubmit: 'event-page',
}
},
},
},
{
@ -60,8 +60,8 @@
placement: 'right',
title: "Create Event",
content: "Click <em>Continue</em> to create the event.",
trigger: {
url: /event\/[0-9]+\/register/
trigger: {
url: /event\/[0-9]+\/register/
},
},
{
@ -148,11 +148,10 @@
title: "Publish your event",
content: "Click to publish your event.",
trigger: 'click',
delay: 5000,
},
{
stepId: 'customize-event',
element: '.js_publish_management button#dopprod-8',
element: '.js_publish_management button[data-toggle="dropdown"]',
placement: 'left',
title: "Customize your event",
content: "Click here to customize your event further.",
@ -160,7 +159,7 @@
},
{
stepId: 'edit-event-backend',
element: '.js_publish_management ul>li>a',
element: '.js_publish_management ul>li>a:last',
placement: 'left',
title: "Customize your event",
content: "Click here to edit your event in the backend.",

View File

@ -13,6 +13,7 @@
],
'data': [
'views/website_payment_templates.xml',
'views/website_settings_payment.xml',
],
'auto_install': False,
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="website_settings_payment" model="ir.ui.view">
<field name="name">website.form</field>
<field name="model">website</field>
<field name="inherit_id" ref="website.view_website_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='other']" position='before'>
<div name="shop">
<separator string="E-Commerce"/>
<group name="shop">
<button type="action"
name="%(payment_acquirer.action_payment_acquirer)d"
string="Configure payment acquirers" class="oe_link"/>
</group>
</div>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -517,9 +517,8 @@ class Ecommerce(http.Controller):
'partner_invoice_id': partner_id,
'partner_shipping_id': shipping_id or partner_id
}
print order_info
order_info.update(registry.get('sale.order').onchange_partner_id(cr, SUPERUSER_ID, [], partner_id, context=context)['value'])
print order_info
order_info.pop('user_id')
order_line_obj.write(cr, SUPERUSER_ID, [order.id], order_info, context=context)

View File

@ -32,5 +32,12 @@
<field name="html_class">oe_image_full</field>
</record>
<record model="crm.case.section" id="website.section_sales_department">
<field name="name">Website</field>
<field name="code">Website</field>
<field name="alias_name">Website</field>
<field name="member_ids" eval="[(4, ref('base.user_root'))]"/>
</record>
</data>
</openerp>

View File

@ -145,6 +145,14 @@ class Website(orm.Model):
""" Create a new quotation used in the ecommerce (event, sale) """
SaleOrder = self.pool.get('sale.order')
quotation_values = self._ecommerce_get_quotation_values(cr, uid, context=context)
section_ids = request.registry["crm.case.section"].search(
request.cr, SUPERUSER_ID, [("code", "=", "Website")], context=context)
if section_ids:
quotation_values['section_id'] = section_ids[0]
quotation_values['user_id'] = False
return SaleOrder.create(cr, SUPERUSER_ID, quotation_values, context=context)
def ecommerce_get_new_order(self, cr, uid, context=None):

View File

@ -6,8 +6,9 @@
website.EditorBar.include({
start: function () {
this.registerTour(new website.EditorShopTour(this));
var res = this._super();
this.registerTour(new website.EditorShopTest(this));
return this._super();
return res;
},
});

View File

@ -7,6 +7,6 @@ $(document).ready(function () {
$("div.oe_sale_acquirer_button[data-id]", $payment).addClass("hidden");
$("div.oe_sale_acquirer_button[data-id='"+payment_id+"']", $payment).removeClass("hidden");
})
.find("#payment_method input[name='acquirer']:checked").click();
.find("input[name='acquirer']:checked").click();
});

View File

@ -2,6 +2,7 @@
from openerp.osv import orm, fields
from openerp import SUPERUSER_ID
from openerp.addons import decimal_precision
class delivery_carrier(orm.Model):
@ -18,7 +19,35 @@ class delivery_carrier(orm.Model):
class SaleOrder(orm.Model):
_inherit = 'sale.order'
def _amount_all_wrapper(self, cr, uid, ids, field_name, arg, context=None):
""" Wrapper because of direct method passing as parameter for function fields """
return self._amount_all(cr, uid, ids, field_name, arg, context=context)
def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
res = super(SaleOrder, self)._amount_all(cr, uid, ids, field_name, arg, context=context)
Currency = self.pool.get('res.currency')
for order in self.browse(cr, uid, ids, context=context):
line_amount = sum([line.price_subtotal for line in order.order_line if line.is_delivery])
currency = order.pricelist_id.currency_id
res[order.id]['amount_delivery'] = Currency.round(cr, uid, currency, line_amount)
return res
def _get_order(self, cr, uid, ids, context=None):
result = {}
for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):
result[line.order_id.id] = True
return result.keys()
_columns = {
'amount_delivery': fields.function(
_amount_all_wrapper, type='float', digits_compute=decimal_precision.get_precision('Account'),
string='Delivery Amount',
store={
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
},
multi='sums', help="The amount without tax.", track_visibility='always'
),
'website_order_line': fields.one2many(
'sale.order.line', 'order_id',
string='Order Lines displayed on Website', readonly=True,

View File

@ -18,7 +18,7 @@ class Website(orm.Model):
context=context)
order = self.ecommerce_get_current_order(cr, uid, context=context)
return self._check_carrier_quotation(cr, uid, order, context=context) and quantity or None
def _check_carrier_quotation(self, cr, uid, order, context=None):
# check to add or remove carrier_id
carrier_id = False
@ -30,11 +30,14 @@ class Website(orm.Model):
if not carrier_id:
order.write({'carrier_id': None}, context=context)
self.pool['sale.order']._delivery_unset(cr, SUPERUSER_ID, order, context=context)
return None
return True
elif not order.carrier_id:
carrier_ids = self.pool.get('delivery.carrier').search(cr, uid, [], context=context)
order.write({'carrier_id': carrier_ids[0]}, context=context)
order.delivery_set(context=context)
return None
carrier_id = carrier_ids and carrier_ids[0]
order.write({'carrier_id': carrier_id}, context=context)
if carrier_id:
order.delivery_set(context=context)
else:
self.pool['sale.order']._delivery_unset(cr, SUPERUSER_ID, order, context=context)
return carrier_id
return bool(carrier_id)