[MERGE] forward port branch saas-11 up to bde7f88
This commit is contained in:
@@ -101,7 +101,7 @@ class AccountBankStatement(models.Model):
|
||||
journals = self.env['account.journal'].search([('type', '=', journal_type), ('company_id', '=', company_id)])
|
||||
if journals:
|
||||
return journals[0]
|
||||
return False
|
||||
return self.env['account.journal']
|
||||
|
||||
@api.multi
|
||||
def _get_opening_balance(self, journal_id):
|
||||
|
||||
@@ -526,7 +526,7 @@ class AccountInvoice(models.Model):
|
||||
report_invoice = self.env['report']._get_report_from_name('account.report_invoice')
|
||||
except IndexError:
|
||||
report_invoice = False
|
||||
if report_invoice:
|
||||
if report_invoice and report_invoice.attachment:
|
||||
for invoice in self:
|
||||
with invoice.env.do_in_draft():
|
||||
invoice.number, invoice.state = invoice.move_name, 'open'
|
||||
|
||||
@@ -119,8 +119,6 @@ class OAuthLogin(Home):
|
||||
@http.route()
|
||||
def web_auth_reset_password(self, *args, **kw):
|
||||
providers = self.list_providers()
|
||||
if len(providers) == 1:
|
||||
werkzeug.exceptions.abort(werkzeug.utils.redirect(providers[0]['auth_link'], 303))
|
||||
response = super(OAuthLogin, self).web_auth_reset_password(*args, **kw)
|
||||
response.qcontext.update(providers=providers)
|
||||
return response
|
||||
|
||||
@@ -316,8 +316,10 @@ class xml_decl(osv.TransientModel):
|
||||
|
||||
numlgn = 0
|
||||
for linekey in entries:
|
||||
numlgn += 1
|
||||
amounts = entries[linekey]
|
||||
if round(amounts[0], 0) == 0:
|
||||
continue
|
||||
numlgn += 1
|
||||
item = ET.SubElement(datas, 'Item')
|
||||
self._set_Dim(item, 'EXSEQCODE', unicode(numlgn))
|
||||
self._set_Dim(item, 'EXTRF', unicode(linekey.EXTRF))
|
||||
|
||||
@@ -294,7 +294,10 @@ class Task(models.Model):
|
||||
|
||||
def _get_default_stage_id(self):
|
||||
""" Gives default stage_id """
|
||||
return self.stage_find(self.env.context.get('default_project_id'), [('fold', '=', False)])
|
||||
project_id = self.env.context.get('default_project_id')
|
||||
if not project_id:
|
||||
return False
|
||||
return self.stage_find(project_id, [('fold', '=', False)])
|
||||
|
||||
@api.multi
|
||||
def _read_group_stage_ids(self, domain, read_group_order=None, access_rights_uid=None):
|
||||
@@ -390,6 +393,10 @@ class Task(models.Model):
|
||||
def _onchange_project(self):
|
||||
if self.project_id:
|
||||
self.partner_id = self.project_id.partner_id
|
||||
self.stage_id = self.stage_find(self.project_id.id, [('fold', '=', False)])
|
||||
else:
|
||||
self.partner_id = False
|
||||
self.stage_id = False
|
||||
|
||||
@api.onchange('user_id')
|
||||
def _onchange_user(self):
|
||||
|
||||
@@ -15,7 +15,10 @@ class ProjectIssue(models.Model):
|
||||
|
||||
@api.model
|
||||
def _get_default_stage_id(self):
|
||||
return self.stage_find(self.env.context.get('default_project_id'), [('fold', '=', False)])
|
||||
project_id = self.env.context.get('default_project_id')
|
||||
if not project_id:
|
||||
return False
|
||||
return self.stage_find(project_id, [('fold', '=', False)])
|
||||
|
||||
name = fields.Char(string='Issue', required=True)
|
||||
active = fields.Boolean(default=True)
|
||||
@@ -150,6 +153,11 @@ class ProjectIssue(models.Model):
|
||||
if self.project_id:
|
||||
self.partner_id = self.project_id.partner_id.id
|
||||
self.email_from = self.project_id.partner_id.email
|
||||
self.stage_id = self.stage_find(self.project_id.id, [('fold', '=', False)])
|
||||
else:
|
||||
self.partner_id = False
|
||||
self.email_from = False
|
||||
self.stage_id = False
|
||||
|
||||
@api.onchange('task_id')
|
||||
def _onchange_task_id(self):
|
||||
|
||||
@@ -160,13 +160,14 @@ class AccountInvoice(models.Model):
|
||||
#line['tax_ids'] is like [(4, tax_id, None), (4, tax_id2, None)...]
|
||||
taxes = self.env['account.tax'].browse([x[1] for x in line['tax_ids']])
|
||||
price_unit = taxes.compute_all(price_unit, currency=inv.currency_id, quantity=1.0)['total_excluded']
|
||||
price_before = line.get('price', 0.0)
|
||||
line.update({'price': round(valuation_price_unit * line['quantity'], account_prec)})
|
||||
diff_res.append({
|
||||
'type': 'src',
|
||||
'name': i_line.name[:64],
|
||||
'price_unit': round(price_unit - valuation_price_unit, account_prec),
|
||||
'quantity': line['quantity'],
|
||||
'price': round((price_unit - valuation_price_unit) * line['quantity'], account_prec),
|
||||
'price': round(price_before - line.get('price', 0.0), account_prec),
|
||||
'account_id': acc,
|
||||
'product_id': line['product_id'],
|
||||
'uom_id': line['uom_id'],
|
||||
|
||||
@@ -74,12 +74,15 @@ class PurchaseOrder(models.Model):
|
||||
types = type_obj.search([('code', '=', 'incoming'), ('warehouse_id', '=', False)])
|
||||
return types[:1]
|
||||
|
||||
@api.depends('order_line.move_ids.picking_id')
|
||||
@api.depends('order_line.move_ids')
|
||||
def _compute_picking(self):
|
||||
for order in self:
|
||||
pickings = self.env['stock.picking']
|
||||
for line in order.order_line:
|
||||
moves = line.move_ids.filtered(lambda r: r.state != 'cancel')
|
||||
# We keep a limited scope on purpose. Ideally, we should also use move_orig_ids and
|
||||
# do some recursive search, but that could be prohibitive if not done correctly.
|
||||
moves = line.move_ids | line.move_ids.mapped('returned_move_ids')
|
||||
moves = moves.filtered(lambda r: r.state != 'cancel')
|
||||
pickings |= moves.mapped('picking_id')
|
||||
order.picking_ids = pickings
|
||||
order.picking_count = len(pickings)
|
||||
|
||||
@@ -29,6 +29,16 @@ class procurement_order(osv.osv):
|
||||
def _run(self, cr, uid, ids, context=None):
|
||||
procurement = self.browse(cr, uid, ids[0], context=context)
|
||||
if procurement._is_procurement_task() and not procurement.task_id:
|
||||
# If the SO was confirmed, cancelled, set to draft then confirmed, avoid creating a new
|
||||
# task.
|
||||
if procurement.sale_line_id:
|
||||
existing_task = self.pool['project.task'].search(
|
||||
cr, uid, [('sale_line_id', '=', procurement.sale_line_id.id)],
|
||||
context=context
|
||||
)
|
||||
if existing_task:
|
||||
return existing_task
|
||||
|
||||
#create a task for the procurement
|
||||
return self._create_service_task(cr, uid, procurement, context=context)
|
||||
return super(procurement_order, self)._run(cr, uid, ids, context=context)
|
||||
|
||||
@@ -77,9 +77,9 @@ class PackOperation(models.Model):
|
||||
def _set_is_done(self):
|
||||
# TDE FIXME: whuuuut ???
|
||||
if not self.product_id:
|
||||
if self.processed_boolean and self.qty_done == 0:
|
||||
if self.is_done and self.qty_done == 0:
|
||||
self.qty_done = 1.0
|
||||
if not self.processed_boolean and self.qty_done != 0:
|
||||
if not self.is_done and self.qty_done != 0:
|
||||
self.qty_done = 0.0
|
||||
|
||||
def _get_remaining_prod_quantities(self):
|
||||
|
||||
@@ -177,11 +177,13 @@ class Quant(models.Model):
|
||||
|
||||
quants_reconcile_sudo = self.env['stock.quant'].sudo()
|
||||
quants_move_sudo = self.env['stock.quant'].sudo()
|
||||
check_lot = False
|
||||
for quant, qty in quants:
|
||||
if not quant:
|
||||
#If quant is None, we will create a quant to move (and potentially a negative counterpart too)
|
||||
quant = self._quant_create_from_move(
|
||||
qty, move, lot_id=lot_id, owner_id=owner_id, src_package_id=src_package_id, dest_package_id=dest_package_id, force_location_from=location_from, force_location_to=location_to)
|
||||
check_lot = True
|
||||
else:
|
||||
quant._quant_split(qty)
|
||||
quants_move_sudo |= quant
|
||||
@@ -201,6 +203,24 @@ class Quant(models.Model):
|
||||
if self._cr.fetchone():
|
||||
quants_reconcile_sudo._quant_reconcile_negative(move)
|
||||
|
||||
# In case of serial tracking, check if the product does not exist somewhere internally already
|
||||
# Checking that a positive quant already exists in an internal location is too restrictive.
|
||||
# Indeed, if a warehouse is configured with several steps (e.g. "Pick + Pack + Ship") and
|
||||
# one step is forced (creates a quant of qty = -1.0), it is not possible afterwards to
|
||||
# correct the inventory unless the product leaves the stock.
|
||||
picking_type = move.picking_id and move.picking_id.picking_type_id or False
|
||||
if check_lot and lot_id and move.product_id.tracking == 'serial' and (not picking_type or (picking_type.use_create_lots or picking_type.use_existing_lots)):
|
||||
other_quants = self.search([('product_id', '=', move.product_id.id), ('lot_id', '=', lot_id),
|
||||
('qty', '>', 0.0), ('location_id.usage', '=', 'internal')])
|
||||
if other_quants:
|
||||
# We raise an error if:
|
||||
# - the total quantity is strictly larger than 1.0
|
||||
# - there are more than one negative quant, to avoid situations where the user would
|
||||
# force the quantity at several steps of the process
|
||||
if sum(other_quants.mapped('qty')) > 1.0 or len([q for q in other_quants.mapped('qty') if q < 0]) > 1:
|
||||
lot_name = self.env['stock.production.lot'].browse(lot_id).name
|
||||
raise UserError(_('The serial number %s is already in stock.') % lot_name + _("Otherwise make sure the right stock/owner is set."))
|
||||
|
||||
@api.model
|
||||
def _quant_create_from_move(self, qty, move, lot_id=False, owner_id=False,
|
||||
src_package_id=False, dest_package_id=False,
|
||||
@@ -234,16 +254,10 @@ class Quant(models.Model):
|
||||
negative_quant_id = self.sudo().create(negative_vals)
|
||||
vals.update({'propagated_from_id': negative_quant_id.id})
|
||||
|
||||
# In case of serial tracking, check if the product does not exist somewhere internally already
|
||||
picking_type = move.picking_id and move.picking_id.picking_type_id or False
|
||||
if lot_id and move.product_id.tracking == 'serial' and (not picking_type or (picking_type.use_create_lots or picking_type.use_existing_lots)):
|
||||
if qty != 1.0:
|
||||
raise UserError(_('You should only receive by the piece with the same serial number'))
|
||||
other_quants = self.search([('product_id', '=', move.product_id.id), ('lot_id', '=', lot_id),
|
||||
('qty', '>', 0.0), ('location_id.usage', '=', 'internal')])
|
||||
if other_quants:
|
||||
lot_name = self.env['stock.production.lot'].browse(lot_id).name
|
||||
raise UserError(_('The serial number %s is already in stock.') % lot_name + _("Otherwise make sure the right stock/owner is set."))
|
||||
|
||||
# create the quant as superuser, because we want to restrict the creation of quant manually: we should always use this method to create quants
|
||||
return self.sudo().create(vals)
|
||||
@@ -423,7 +437,9 @@ class Quant(models.Model):
|
||||
|
||||
if pack_operation_id:
|
||||
pack_operation = self.env['stock.pack.operation'].browse(pack_operation_id)
|
||||
domain += [('owner_id', '=', pack_operation.owner_id.id), ('location_id', '=', pack_operation.location_id.id)]
|
||||
domain += [('location_id', '=', pack_operation.location_id.id)]
|
||||
if pack_operation.owner_id:
|
||||
domain += [('owner_id', '=', pack_operation.owner_id.id)]
|
||||
if pack_operation.package_id and not pack_operation.product_id:
|
||||
domain += [('package_id', 'child_of', pack_operation.package_id.id)]
|
||||
elif pack_operation.package_id and pack_operation.product_id:
|
||||
@@ -431,7 +447,9 @@ class Quant(models.Model):
|
||||
else:
|
||||
domain += [('package_id', '=', False)]
|
||||
else:
|
||||
domain += [('owner_id', '=', move.restrict_partner_id.id), ('location_id', 'child_of', move.location_id.id)]
|
||||
domain += [('location_id', 'child_of', move.location_id.id)]
|
||||
if move.restrict_partner_id:
|
||||
domain += [('owner_id', '=', move.restrict_partner_id.id)]
|
||||
|
||||
if company_id:
|
||||
domain += [('company_id', '=', company_id)]
|
||||
|
||||
@@ -80,13 +80,14 @@
|
||||
<br/>
|
||||
<br/>
|
||||
<table class="table table-condensed" t-if="o.pack_operation_ids">
|
||||
<t t-set="has_barcode" t-value="any([pack_operation.product_id and pack_operation.product_id.barcode or pack_operation.package_id for pack_operation in o.pack_operation_ids])"/>
|
||||
<t t-set="has_serial_number" t-value="o.pack_operation_ids.filtered('pack_lot_ids')" groups="stock.group_production_lot"/>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Product</strong></th>
|
||||
<th class="text-right"><strong>Quantity</strong></th>
|
||||
<t t-if="o.picking_type_id.code != 'incoming'"><th><strong>Source</strong></th></t>
|
||||
<th t-if="any([pack_operation.product_id and pack_operation.product_id.barcode or pack_operation.package_id for pack_operation in o.pack_operation_ids])" class="text-center">
|
||||
<th t-if="has_barcode" class="text-center">
|
||||
<strong>Barcode</strong>
|
||||
</th>
|
||||
<th t-if="has_serial_number">
|
||||
@@ -108,7 +109,7 @@
|
||||
<span t-field="pack_operation.package_id"/>
|
||||
</td>
|
||||
</t>
|
||||
<td>
|
||||
<td t-if="has_barcode">
|
||||
<span t-if="pack_operation.product_id and pack_operation.product_id.barcode">
|
||||
<img t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('Code128', pack_operation.product_id.barcode, 600, 100)" style="width:300px;height:50px"/>
|
||||
</span>
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
import models # noqa
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import stock_dropshipping # noqa
|
||||
@@ -0,0 +1,19 @@
|
||||
# coding: utf-8
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from openerp import models, api
|
||||
|
||||
class AccountInvoice(models.Model):
|
||||
_inherit = 'account.invoice'
|
||||
|
||||
@api.model
|
||||
def _anglo_saxon_sale_move_lines(self, i_line):
|
||||
for sale_line in i_line.sale_line_ids:
|
||||
for proc in sale_line.procurement_ids:
|
||||
if proc.purchase_line_id:
|
||||
# if the invoice line is related to sale order lines having one of its
|
||||
# procurement_ids with a purchase_line_id set, it means that it is a
|
||||
# confirmed dropship and in that case we mustn't create the cost of
|
||||
# sale line (because the product won't enter the stock)
|
||||
return []
|
||||
return super(AccountInvoice, self)._anglo_saxon_sale_move_lines(i_line)
|
||||
@@ -74,13 +74,17 @@ class Subscription(models.Model):
|
||||
'nextcall': subscription.date_init,
|
||||
'model': self._name,
|
||||
'args': repr([[subscription.id]]),
|
||||
'function': 'model_copy',
|
||||
'function': '_cron_model_copy',
|
||||
'priority': 6,
|
||||
'user_id': subscription.user_id.id
|
||||
}
|
||||
cron = self.env['ir.cron'].create(cron_data)
|
||||
subscription.write({'cron_id': cron.id, 'state': 'running'})
|
||||
|
||||
@api.model
|
||||
def _cron_model_copy(self, ids):
|
||||
self.browse(ids).model_copy()
|
||||
|
||||
@api.multi
|
||||
def model_copy(self):
|
||||
for subscription in self.filtered(lambda sub: sub.cron_id):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
'name': 'Bootswatch Theme',
|
||||
'summary': 'Support for Bootswatch themes in master',
|
||||
'description': 'This theme module is exclusively for master to keep the support of Bootswatch themes which were previously part of the website module in 8.0.',
|
||||
'category': 'Website',
|
||||
'category': 'Theme',
|
||||
'sequence': 900,
|
||||
'version': '1.0',
|
||||
'depends': ['website'],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
'name': 'Default Theme',
|
||||
'description': 'Default website theme to showcase customization possibilities.',
|
||||
'category': 'Hidden',
|
||||
'category': 'Theme/Hidden',
|
||||
'sequence': 1000,
|
||||
'version': '1.0',
|
||||
'depends': ['website'],
|
||||
|
||||
@@ -631,8 +631,8 @@ class Database(http.Controller):
|
||||
try:
|
||||
# country code could be = "False" which is actually True in python
|
||||
country_code = post.get('country_code') or False
|
||||
request.session.proxy("db").create_database(master_pwd, name, bool(post.get('demo')), lang, password, post.get('login'), country_code)
|
||||
request.session.authenticate(name, 'admin', password)
|
||||
request.session.proxy("db").create_database(master_pwd, name, bool(post.get('demo')), lang, password, post['login'], country_code)
|
||||
request.session.authenticate(name, post['login'], password)
|
||||
return http.local_redirect('/web/')
|
||||
except Exception, e:
|
||||
error = "Database creation error: %s" % e
|
||||
|
||||
@@ -1435,7 +1435,7 @@ var FieldStatus = common.AbstractField.extend({
|
||||
});
|
||||
}
|
||||
}
|
||||
}, 300),
|
||||
}, 300, true),
|
||||
});
|
||||
|
||||
var FieldMonetary = FieldFloat.extend({
|
||||
|
||||
@@ -692,7 +692,6 @@ var PivotView = View.extend({
|
||||
if (width > 1) {
|
||||
var total_cell = {width:nbr_measures, height: depth, title:""};
|
||||
if (nbr_measures === 1) {
|
||||
total_cell.title = this.measures[this.active_measures[0]].string;
|
||||
total_cell.total = true;
|
||||
}
|
||||
result[0].push(total_cell);
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<label for="login" class="control-label">Email</label>
|
||||
<input id="login" type="text" name="login" class="form-control" autocomplete="off"/>
|
||||
<input id="login" type="text" name="login" class="form-control" required="required" autocomplete="off"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -244,7 +244,8 @@ body .modal {
|
||||
font-weight: bold;
|
||||
}
|
||||
.o_bg_img_opt_object {
|
||||
width: 100%;
|
||||
display: inline-block;
|
||||
max-width: 100%;
|
||||
background: white;
|
||||
min-height: 10px;
|
||||
position: relative;
|
||||
|
||||
@@ -667,6 +667,9 @@ class res_partner(osv.osv):
|
||||
'zoom': zoom,
|
||||
'sensor': 'false',
|
||||
}
|
||||
google_maps_api_key = self.pool['ir.config_parameter'].get_param(cr, openerp.SUPERUSER_ID, 'google_maps_api_key', context=context)
|
||||
if google_maps_api_key:
|
||||
params['key'] = google_maps_api_key
|
||||
return urlplus('//maps.googleapis.com/maps/api/staticmap' , params)
|
||||
|
||||
def google_map_link(self, cr, uid, ids, zoom=10, context=None):
|
||||
|
||||
@@ -250,7 +250,7 @@ body .modal {
|
||||
}
|
||||
|
||||
// LOGIN FORM
|
||||
.oe_login_form {
|
||||
.oe_login_form, .oe_signup_form {
|
||||
max-width: 300px;
|
||||
position: relative;
|
||||
margin: 50px auto;
|
||||
|
||||
@@ -914,7 +914,14 @@ Sitemap: <t t-esc="url_root"/>sitemap.xml
|
||||
"fields": ["name", "address", "phone", "mobile", "fax", "email"]}'/>
|
||||
</address>
|
||||
<!-- FORWARD-PORT UP TO SAAS-12 -->
|
||||
<a t-att-href="res_company.google_map_link()" target="_BLANK">Visualize on Google Maps</a>
|
||||
<t t-if="'key=' in res_company.google_map_img()">
|
||||
<a t-att-href="res_company.google_map_link()" target="_BLANK">
|
||||
<img class="thumbnail img-responsive" t-att-src="res_company.google_map_img()" />
|
||||
</a>
|
||||
</t>
|
||||
<t t-if="'key=' not in res_company.google_map_img()">
|
||||
<a t-att-href="res_company.google_map_link()" target="_BLANK">Visualize on Google Maps</a>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="contactus" name="Contact us" page="True">
|
||||
|
||||
@@ -253,6 +253,7 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
|
||||
partners = partners[pager['offset']:pager['offset'] + self._references_per_page]
|
||||
|
||||
google_map_partner_ids = ','.join(map(str, [p.id for p in partners]))
|
||||
google_maps_api_key = request.env['ir.config_parameter'].sudo().get_param('google_maps_api_key')
|
||||
|
||||
values = {
|
||||
'countries': countries,
|
||||
@@ -264,6 +265,7 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
|
||||
'pager': pager,
|
||||
'searches': post,
|
||||
'search_path': "%s" % werkzeug.url_encode(post),
|
||||
'google_maps_api_key': google_maps_api_key,
|
||||
}
|
||||
return request.render("website_crm_partner_assign.index", values, status=partners and 200 or 404)
|
||||
|
||||
|
||||
@@ -118,25 +118,27 @@
|
||||
|
||||
<template id="ref_country" inherit_id="website_crm_partner_assign.index" customize_show="True" name="Left World Map">
|
||||
<xpath expr="//ul[@id='reseller_countries']" position="after">
|
||||
<!-- modal for large map -->
|
||||
<div class="modal fade partner_map_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">World Map</h4>
|
||||
<t t-if="google_maps_api_key">
|
||||
<!-- modal for large map -->
|
||||
<div class="modal fade partner_map_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">World Map</h4>
|
||||
</div>
|
||||
<iframe t-attf-src="/google_map/?width=898&height=485&partner_ids=#{ google_map_partner_ids }&partner_url=/partners/"
|
||||
style="width:898px; height:485px; border:0; padding:0; margin:0;"></iframe>
|
||||
</div>
|
||||
<iframe t-attf-src="/google_map/?width=898&height=485&partner_ids=#{ google_map_partner_ids }&partner_url=/partners/"
|
||||
style="width:898px; height:485px; border:0; padding:0; margin:0;"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- modal end -->
|
||||
<h3>World Map<button class="btn btn-link" data-toggle="modal" data-target=".partner_map_modal"><span class="fa fa-external-link" /></button></h3>
|
||||
<ul class="nav">
|
||||
<iframe t-attf-src="/google_map?width=260&height=240&partner_ids=#{ google_map_partner_ids }&partner_url=/partners/"
|
||||
style="width:260px; height:240px; border:0; padding:0; margin:0;" scrolling="no"></iframe>
|
||||
</ul>
|
||||
<!-- modal end -->
|
||||
<h3>World Map<button class="btn btn-link" data-toggle="modal" data-target=".partner_map_modal"><span class="fa fa-external-link" /></button></h3>
|
||||
<ul class="nav">
|
||||
<iframe t-attf-src="/google_map?width=260&height=240&partner_ids=#{ google_map_partner_ids }&partner_url=/partners/"
|
||||
style="width:260px; height:240px; border:0; padding:0; margin:0;" scrolling="no"></iframe>
|
||||
</ul>
|
||||
</t>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ class WebsiteCustomer(http.Controller):
|
||||
context=request.context)
|
||||
google_map_partner_ids = ','.join(map(str, partner_ids))
|
||||
partners = partner_obj.browse(request.cr, openerp.SUPERUSER_ID, partner_ids, request.context)
|
||||
google_maps_api_key = request.env['ir.config_parameter'].sudo().get_param('google_maps_api_key')
|
||||
|
||||
tag_obj = request.registry['res.partner.tag']
|
||||
tag_ids = tag_obj.search(cr, uid, [('website_published', '=', True), ('partner_ids', 'in', partner_ids)],
|
||||
@@ -103,6 +104,7 @@ class WebsiteCustomer(http.Controller):
|
||||
'search_path': "?%s" % werkzeug.url_encode(post),
|
||||
'tag': tag,
|
||||
'tags': tags,
|
||||
'google_maps_api_key': google_maps_api_key,
|
||||
}
|
||||
return request.website.render("website_customer.index", values)
|
||||
|
||||
|
||||
@@ -68,25 +68,27 @@
|
||||
<!-- Option: left column: World Map -->
|
||||
<template id="opt_country" inherit_id="website_customer.index" customize_show="True" name="Show Map">
|
||||
<xpath expr="//div[@id='ref_left_column']" position="inside">
|
||||
<!-- modal for large map -->
|
||||
<div class="modal fade customer_map_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">World Map</h4>
|
||||
<t t-if="google_maps_api_key">
|
||||
<!-- modal for large map -->
|
||||
<div class="modal fade customer_map_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">World Map</h4>
|
||||
</div>
|
||||
<iframe t-attf-src="/google_map/?width=898&height=485&partner_ids=#{ google_map_partner_ids }&partner_url=/customers/"
|
||||
style="width:898px; height:485px; border:0; padding:0; margin:0;"></iframe>
|
||||
</div>
|
||||
<iframe t-attf-src="/google_map/?width=898&height=485&partner_ids=#{ google_map_partner_ids }&partner_url=/customers/"
|
||||
style="width:898px; height:485px; border:0; padding:0; margin:0;"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- modal end -->
|
||||
<h3>World Map<button class="btn btn-link" data-toggle="modal" data-target=".customer_map_modal"><span class="fa fa-external-link" /></button></h3>
|
||||
<ul class="nav">
|
||||
<iframe t-attf-src="/google_map?width=260&height=240&partner_ids=#{ google_map_partner_ids }&partner_url=/customers/"
|
||||
style="width:260px; height:240px; border:0; padding:0; margin:0;" scrolling="no"></iframe>
|
||||
</ul>
|
||||
<!-- modal end -->
|
||||
<h3>World Map<button class="btn btn-link" data-toggle="modal" data-target=".customer_map_modal"><span class="fa fa-external-link" /></button></h3>
|
||||
<ul class="nav">
|
||||
<iframe t-attf-src="/google_map?width=260&height=240&partner_ids=#{ google_map_partner_ids }&partner_url=/customers/"
|
||||
style="width:260px; height:240px; border:0; padding:0; margin:0;" scrolling="no"></iframe>
|
||||
</ul>
|
||||
</t>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -335,7 +335,14 @@
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<!-- FORWARD-PORT UP TO SAAS-12 -->
|
||||
<a t-att-href="event.google_map_link()" target="_BLANK">Visualize on Google Maps</a>
|
||||
<t t-if="'key=' in event.google_map_img()">
|
||||
<a t-att-href="event.google_map_link()" target="_BLANK">
|
||||
<img class="thumbnail img-responsive" t-att-src="event.google_map_img()" />
|
||||
</a>
|
||||
</t>
|
||||
<t t-if="'key=' not in event.google_map_img()">
|
||||
<a t-att-href="event.google_map_link()" target="_BLANK">Visualize on Google Maps</a>
|
||||
</t>
|
||||
<div itemprop="location" class="mt16 mb8" t-field="event.address_id" t-options='{
|
||||
"widget": "contact",
|
||||
"fields": ["address", "phone", "mobile", "fax", "email"]
|
||||
|
||||
@@ -52,8 +52,10 @@ class GoogleMap(http.Controller):
|
||||
else:
|
||||
partner_url = '/partners/'
|
||||
|
||||
google_maps_api_key = request.env['ir.config_parameter'].sudo().get_param('google_maps_api_key')
|
||||
values = {
|
||||
'partner_url': partner_url,
|
||||
'partner_data': json.dumps(partner_data)
|
||||
'partner_data': json.dumps(partner_data),
|
||||
'google_maps_api_key': google_maps_api_key,
|
||||
}
|
||||
return request.website.render("website_google_map.google_map", values)
|
||||
|
||||
@@ -14,7 +14,13 @@
|
||||
var odoo_partner_data = <t t-raw="partner_data"/>;
|
||||
</script>
|
||||
<div id="odoo-google-map"></div>
|
||||
<script src="//maps.google.com/maps/api/js?sensor=false"></script>
|
||||
<t t-if="google_maps_api_key">
|
||||
<script t-attf-src="//maps.google.com/maps/api/js?key=#{google_maps_api_key}"></script>
|
||||
</t>
|
||||
<t t-if="not google_maps_api_key">
|
||||
<script src="//maps.google.com/maps/api/js"></script>
|
||||
</t>
|
||||
|
||||
<script type="text/javascript" src="/website_google_map/static/src/lib/markerclusterer.js"></script>
|
||||
<script type="text/javascript" src="/website_google_map/static/src/js/website_google_map.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -138,6 +138,7 @@ class WebsiteMembership(http.Controller):
|
||||
count_members += len(free_partner_ids)
|
||||
|
||||
google_map_partner_ids = ",".join(map(str, google_map_partner_ids))
|
||||
google_maps_api_key = request.env['ir.config_parameter'].sudo().get_param('google_maps_api_key')
|
||||
|
||||
partners = { p.id: p for p in partner_obj.browse(request.cr, SUPERUSER_ID, list(page_partner_ids), request.context)}
|
||||
|
||||
@@ -162,6 +163,7 @@ class WebsiteMembership(http.Controller):
|
||||
'pager': pager,
|
||||
'post': post,
|
||||
'search': "?%s" % werkzeug.url_encode(post),
|
||||
'google_maps_api_key': google_maps_api_key,
|
||||
}
|
||||
return request.website.render("website_membership.index", values)
|
||||
|
||||
|
||||
@@ -104,25 +104,27 @@
|
||||
<template id="opt_index_google_map" name="Left World Map"
|
||||
customize_show="True" inherit_id="website_membership.index">
|
||||
<xpath expr="//div[@id='left_column']/ul[last()]" position="after">
|
||||
<!-- modal for large map -->
|
||||
<div class="modal fade partner_map_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">World Map</h4>
|
||||
<t t-if="google_maps_api_key">
|
||||
<!-- modal for large map -->
|
||||
<div class="modal fade partner_map_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">World Map</h4>
|
||||
</div>
|
||||
<iframe t-attf-src="/google_map/?width=898&height=485&partner_ids=#{ google_map_partner_ids }&partner_url=/members/"
|
||||
style="width:898px; height:485px; border:0; padding:0; margin:0;"></iframe>
|
||||
</div>
|
||||
<iframe t-attf-src="/google_map/?width=898&height=485&partner_ids=#{ google_map_partner_ids }&partner_url=/members/"
|
||||
style="width:898px; height:485px; border:0; padding:0; margin:0;"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- modal end -->
|
||||
<h3>World Map<button class="btn btn-link" data-toggle="modal" data-target=".partner_map_modal"><span class="fa fa-external-link" /></button></h3>
|
||||
<ul class="nav">
|
||||
<iframe t-attf-src="/google_map/?width=260&height=240&partner_ids=#{ google_map_partner_ids }&partner_url=/members/"
|
||||
style="width:260px; height:240px; border:0; padding:0; margin:0;"></iframe>
|
||||
</ul>
|
||||
<!-- modal end -->
|
||||
<h3>World Map<button class="btn btn-link" data-toggle="modal" data-target=".partner_map_modal"><span class="fa fa-external-link" /></button></h3>
|
||||
<ul class="nav">
|
||||
<iframe t-attf-src="/google_map/?width=260&height=240&partner_ids=#{ google_map_partner_ids }&partner_url=/members/"
|
||||
style="width:260px; height:240px; border:0; padding:0; margin:0;"></iframe>
|
||||
</ul>
|
||||
</t>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
+184
-16
@@ -23,11 +23,11 @@ Although the database will follow the same process described on that form.
|
||||
|
||||
The required steps are:
|
||||
|
||||
* creating a request
|
||||
* uploading a database dump
|
||||
* running the upgrade process
|
||||
* obtaining the status of the database request
|
||||
* downloading the upgraded database dump
|
||||
* :ref:`creating a request <upgrade-api-create-method>`
|
||||
* :ref:`uploading a database dump <upgrade-api-upload-method>`
|
||||
* :ref:`running the upgrade process <upgrade-api-process-method>`
|
||||
* :ref:`obtaining the status of the database request <upgrade-api-status-method>`
|
||||
* :ref:`downloading the upgraded database dump <upgrade-api-download-method>`
|
||||
|
||||
The methods
|
||||
~~~~~~~~~~~
|
||||
@@ -60,9 +60,11 @@ The ``create`` method
|
||||
:param str filename: (required) a purely informative name for you database dump file
|
||||
:param str timezone: (optional) the timezone used by your server. Only for Odoo source version < 6.1
|
||||
:return: request result
|
||||
:rtype: json dictionary
|
||||
:rtype: JSON dictionary
|
||||
|
||||
The *create* method returns a json dictionary containing the following keys:
|
||||
The *create* method returns a JSON dictionary containing the following keys:
|
||||
|
||||
.. _upgrade-api-json-failure:
|
||||
|
||||
``failures``
|
||||
''''''''''''
|
||||
@@ -201,11 +203,17 @@ Here are 2 examples of database upgrade request creation using:
|
||||
Uploading your database dump
|
||||
============================
|
||||
|
||||
This action upload your database dump.
|
||||
There are 2 methods to upload your database dump:
|
||||
|
||||
* the ``upload`` method using the HTTPS protocol
|
||||
* the ``request_sftp_access`` method using the SFTP protocol
|
||||
|
||||
The ``upload`` method
|
||||
---------------------
|
||||
|
||||
It's the most simple and most straightforward way of uploading your database dump.
|
||||
It uses the HTTPS protocol.
|
||||
|
||||
.. py:function:: https://upgrade.odoo.com/database/v1/upload
|
||||
|
||||
Uploads a database dump
|
||||
@@ -213,12 +221,12 @@ The ``upload`` method
|
||||
:param str key: (required) your private key
|
||||
:param str request: (required) your request id
|
||||
:return: request result
|
||||
:rtype: json dictionary
|
||||
:rtype: JSON dictionary
|
||||
|
||||
The request id and the private key are obtained using the :ref:`create method
|
||||
<upgrade-api-create-method>`
|
||||
|
||||
The result is a json dictionary containing the list of ``failures``, which
|
||||
The result is a JSON dictionary containing the list of ``failures``, which
|
||||
should be empty if everything went fine.
|
||||
|
||||
.. rst-class:: setup doc-aside
|
||||
@@ -230,8 +238,6 @@ should be empty if everything went fine.
|
||||
import os
|
||||
import pycurl
|
||||
from urllib import urlencode
|
||||
from io import BytesIO
|
||||
import json
|
||||
|
||||
UPLOAD_URL = "https://upgrade.odoo.com/database/v1/upload"
|
||||
DUMPFILE = "openchs.70.cdump"
|
||||
@@ -267,6 +273,144 @@ should be empty if everything went fine.
|
||||
HEADER="Content-Type: application/octet-stream"
|
||||
curl -H $HEADER --data-binary "@${DUMPFILE}" "${UPLOAD_URL}?${URL_PARAMS}"
|
||||
|
||||
.. _upgrade-api-request-sftp-access-method:
|
||||
|
||||
The ``request_sftp_access`` method
|
||||
----------------------------------
|
||||
|
||||
This method is recommanded for big database dumps.
|
||||
It uses the SFTP protocol and supports resuming.
|
||||
|
||||
It will create a temporary SFTP server where you can connect to and allow you
|
||||
to upload your database dump using an SFTP client.
|
||||
|
||||
.. py:function:: https://upgrade.odoo.com/database/v1/request_sftp_access
|
||||
|
||||
Creates an SFTP server
|
||||
|
||||
:param str key: (required) your private key
|
||||
:param str request: (required) your request id
|
||||
:param str ssh_keys: (required) the path to a file listing the ssh public keys you'd like to use
|
||||
:return: request result
|
||||
:rtype: JSON dictionary
|
||||
|
||||
The request id and the private key are obtained using the :ref:`create method
|
||||
<upgrade-api-create-method>`
|
||||
|
||||
The file listing your ssh public keys should be roughly similar to a standard ``authorized_keys`` file.
|
||||
This file should only contains public keys, blank lines or comments (lines starting with the ``#`` character)
|
||||
|
||||
Your database upgrade request should be in the ``draft`` state.
|
||||
|
||||
The ``request_sftp_access`` method returns a JSON dictionary containing the following keys:
|
||||
|
||||
|
||||
.. rst-class:: setup doc-aside
|
||||
|
||||
.. switcher::
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import os
|
||||
import pycurl
|
||||
from urllib import urlencode
|
||||
|
||||
UPLOAD_URL = "https://upgrade.odoo.com/database/v1/request_sftp_access"
|
||||
SSH_KEYS="/path/to/your/authorized_keys"
|
||||
|
||||
fields = dict([
|
||||
('request', '10534'),
|
||||
('key', 'Aw7pItGVKFuZ_FOR3U8VFQ=='),
|
||||
])
|
||||
postfields = urlencode(fields)
|
||||
|
||||
c = pycurl.Curl()
|
||||
c.setopt(pycurl.URL, UPLOAD_URL+"?"+postfields)
|
||||
c.setopt(pycurl.POST, 1)
|
||||
c.setopt(c.HTTPPOST,[("ssh_keys",
|
||||
(c.FORM_FILE, SSH_KEYS,
|
||||
c.FORM_CONTENTTYPE, "text/plain"))
|
||||
])
|
||||
|
||||
c.perform()
|
||||
c.close()
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
REQUEST_SFTP_ACCESS_URL="https://upgrade.odoo.com/database/v1/request_sftp_access"
|
||||
SSH_KEYS=/path/to/your/authorized_keys
|
||||
KEY="Aw7pItGVKFuZ_FOR3U8VFQ=="
|
||||
REQUEST_ID="10534"
|
||||
URL_PARAMS="key=${KEY}&request=${REQUEST}"
|
||||
|
||||
curl -sS "${REQUEST_SFTP_ACCESS_URL}?${URL_PARAMS}" -F ssh_keys=@${SSH_KEYS} > request_sftp_result.json
|
||||
|
||||
# check for failures
|
||||
failures=$(cat request_sftp_result.json | jq -r '.failures[]')
|
||||
if [ "$failures" != "" ]; then
|
||||
echo $failures | jq -r '.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
``failures``
|
||||
''''''''''''
|
||||
|
||||
The list of errors. See :ref:`failures <upgrade-api-json-failure>` for an
|
||||
explanation about the JSON dictionary returned in case of failure.
|
||||
|
||||
``request``
|
||||
'''''''''''
|
||||
|
||||
If the call is successful, the value associated to the *request* key
|
||||
will be a dictionary containing your SFTP connexion parameters:
|
||||
|
||||
* ``hostname``: the host address to connect to
|
||||
* ``sftp_port``: the port to connect to
|
||||
* ``sftp_user``: the SFTP user to use for connecting
|
||||
* ``shared_file``: the filename you need to use (identical to the ``filename`` value you have used when creating the request in the :ref:`create method <upgrade-api-create-method>`.)
|
||||
* ``request_id``: the related upgrade request id (only informative, ,not required for the connection)
|
||||
* ``sample_command``: a sample command using the 'sftp' client
|
||||
|
||||
You should normally be able to connect using the sample command as is.
|
||||
|
||||
You will only have access to the ``shared_file``. No other files will be
|
||||
accessible and you will not be able to create new files in your shared
|
||||
environment on the SFTP server.
|
||||
|
||||
Using the 'sftp' client
|
||||
+++++++++++++++++++++++
|
||||
|
||||
Once you have successfully connected using your SFTP client, you can upload
|
||||
your database dump. Here is a sample session using the 'sftp' client:
|
||||
|
||||
::
|
||||
|
||||
$ sftp -P 2200 user_10534@upgrade.odoo.com
|
||||
Connected to upgrade.odoo.com.
|
||||
sftp> put /path/to/openchs.70.cdump openchs.70.cdump
|
||||
Uploading /path/to/openchs.70.cdump to /openchs.70.cdump
|
||||
sftp> ls -l openchs.70.cdump
|
||||
-rw-rw-rw- 0 0 0 849920 Aug 30 15:58 openchs.70.cdump
|
||||
|
||||
If your connection is interrupted, you can continue your file transfer using
|
||||
the ``-a`` command line switch:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
sftp> put -a /path/to/openchs.70.cdump openchs.70.cdump
|
||||
Resuming upload of /path/to/openchs.70.cdump to /openchs.70.cdump
|
||||
|
||||
If you don't want to manually type the command and need to automate your
|
||||
database upgrade using a script, you can use a batch file or pipe your commands to 'sftp':
|
||||
|
||||
::
|
||||
|
||||
echo "put /path/to/openchs.70.cdump openchs.70.cdump" | sftp -b - -P 2200 user_10534@upgrade.odoo.com
|
||||
|
||||
The ``-b`` parameter takes a filename. If the filename is ``-``, it reads the commands from standard input.
|
||||
|
||||
|
||||
.. _upgrade-api-process-method:
|
||||
|
||||
Asking to process your request
|
||||
@@ -284,12 +428,12 @@ The ``process`` method
|
||||
:param str key: (required) your private key
|
||||
:param str request: (required) your request id
|
||||
:return: request result
|
||||
:rtype: json dictionary
|
||||
:rtype: JSON dictionary
|
||||
|
||||
The request id and the private key are obtained using the :ref:`create method
|
||||
<upgrade-api-create-method>`
|
||||
|
||||
The result is a json dictionary containing the list of ``failures``, which
|
||||
The result is a JSON dictionary containing the list of ``failures``, which
|
||||
should be empty if everything went fine.
|
||||
|
||||
.. rst-class:: setup doc-aside
|
||||
@@ -350,12 +494,12 @@ The ``status`` method
|
||||
:param str key: (required) your private key
|
||||
:param str request: (required) your request id
|
||||
:return: request result
|
||||
:rtype: json dictionary
|
||||
:rtype: JSON dictionary
|
||||
|
||||
The request id and the private key are obtained using the :ref:`create method
|
||||
<upgrade-api-create-method>`
|
||||
|
||||
The result is a json dictionary containing various information about your
|
||||
The result is a JSON dictionary containing various information about your
|
||||
database upgrade request.
|
||||
|
||||
.. rst-class:: setup doc-aside
|
||||
@@ -502,4 +646,28 @@ The ``request`` key contains various useful information about your request:
|
||||
}
|
||||
}
|
||||
|
||||
.. _upgrade-api-download-method:
|
||||
|
||||
Downloading your database dump
|
||||
==============================
|
||||
|
||||
Beside downloading your migrated database using the URL provided by the
|
||||
:ref:`status method <upgrade-api-status-method>`, you can also use the SFTP
|
||||
protocol as described in the :ref:`request_sftp_access method
|
||||
<upgrade-api-request-sftp-access-method>`
|
||||
|
||||
The diffence is that you'll only be able to download the migrated database. No
|
||||
uploading will be possible.
|
||||
|
||||
Your database upgrade request should be in the ``done`` state.
|
||||
|
||||
Once you have successfully connected using your SFTP client, you can download
|
||||
your database dump. Here is a sample session using the 'sftp' client:
|
||||
|
||||
::
|
||||
|
||||
$ sftp -P 2200 user_10534@upgrade.odoo.com
|
||||
Connected to upgrade.odoo.com.
|
||||
sftp> get upgraded_openchs.70.cdump /path/to/upgraded_openchs.70.cdump
|
||||
Downloading /upgraded_openchs.70.cdump to /path/to/upgraded_openchs.70.cdump
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ from operator import itemgetter
|
||||
import json
|
||||
import werkzeug
|
||||
from lxml import etree
|
||||
from lxml.etree import LxmlError
|
||||
from lxml.builder import E
|
||||
|
||||
from odoo import api, fields, models, tools, SUPERUSER_ID, _
|
||||
@@ -330,7 +331,13 @@ actual arch.
|
||||
if values.get('inherit_id'):
|
||||
values['type'] = self.browse(values['inherit_id']).type
|
||||
else:
|
||||
values['type'] = etree.fromstring(values['arch']).tag
|
||||
|
||||
try:
|
||||
values['type'] = etree.fromstring(values.get('arch') or values.get('arch_base')).tag
|
||||
except LxmlError:
|
||||
# don't raise here, the constraint that runs `self._check_xml` will
|
||||
# do the job properly.
|
||||
pass
|
||||
|
||||
if not values.get('name'):
|
||||
values['name'] = "%s %s" % (values.get('model'), values['type'])
|
||||
@@ -342,7 +349,7 @@ actual arch.
|
||||
def write(self, vals):
|
||||
# If view is modified we remove the arch_fs information thus activating the arch_db
|
||||
# version. An `init` of the view will restore the arch_fs for the --dev mode
|
||||
if 'arch' in vals and 'install_mode_data' not in self._context:
|
||||
if ('arch' in vals or 'arch_base' in vals) and 'install_mode_data' not in self._context:
|
||||
vals['arch_fs'] = False
|
||||
|
||||
# drop the corresponding view customizations (used for dashboards for example), otherwise
|
||||
|
||||
@@ -21,11 +21,18 @@ class test_guess_mimetype(unittest.TestCase):
|
||||
|
||||
def test_default_mimetype_empty(self):
|
||||
mimetype = guess_mimetype('')
|
||||
self.assertEqual(mimetype, 'application/octet-stream')
|
||||
# odoo implementation returns application/octet-stream by default
|
||||
# if available, python-magic returns application/x-empty
|
||||
self.assertIn(mimetype, ('application/octet-stream', 'application/x-empty'))
|
||||
|
||||
def test_default_mimetype(self):
|
||||
mimetype = guess_mimetype('', default='test')
|
||||
self.assertEqual(mimetype, 'test')
|
||||
# if available, python-magic returns application/x-empty
|
||||
self.assertIn(mimetype, ('test', 'application/x-empty'))
|
||||
|
||||
def test_mimetype_octet_stream(self):
|
||||
mimetype = guess_mimetype('\0')
|
||||
self.assertEqual(mimetype, 'application/octet-stream')
|
||||
|
||||
def test_mimetype_png(self):
|
||||
content = base64.b64decode(PNG)
|
||||
@@ -35,7 +42,8 @@ class test_guess_mimetype(unittest.TestCase):
|
||||
def test_mimetype_bmp(self):
|
||||
content = base64.b64decode(BMP)
|
||||
mimetype = guess_mimetype(content, default='test')
|
||||
self.assertEqual(mimetype, 'image/bmp')
|
||||
# mimetype should match image/bmp, image/x-ms-bmp, ...
|
||||
self.assertRegexpMatches(mimetype, r'image/.*\bbmp')
|
||||
|
||||
def test_mimetype_jpg(self):
|
||||
content = base64.b64decode(JPG)
|
||||
|
||||
@@ -153,9 +153,9 @@ else:
|
||||
|
||||
# magic from pypi https://pypi.python.org/pypi/python-magic/
|
||||
if hasattr(magic,'from_buffer'):
|
||||
guess_mimetype = lambda bin_data: magic.from_buffer(bin_data, mime=True)
|
||||
guess_mimetype = lambda bin_data, default=None: magic.from_buffer(bin_data, mime=True)
|
||||
# magic from file(1) https://packages.debian.org/squeeze/python-magic
|
||||
elif hasattr(magic,'open'):
|
||||
ms = magic.open(magic.MAGIC_MIME_TYPE)
|
||||
ms.load()
|
||||
guess_mimetype = ms.buffer
|
||||
guess_mimetype = lambda bin_data, default=None: ms.buffer(bin_data)
|
||||
|
||||
Reference in New Issue
Block a user