[MERGE] forward port of branch saas-3 up to a66f3dd

This commit is contained in:
Christophe Simonis 2014-06-25 12:33:17 +02:00
commit f68c83545a
13 changed files with 50 additions and 44 deletions

View File

@ -139,6 +139,13 @@
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record>
<record id="account_subscription_line_comp_rule" model="ir.rule">
<field name="name">Account subscription line company rule</field>
<field name="model_id" ref="model_account_subscription_line"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('subscription_id.model_id.company_id','=',False),('subscription_id.model_id.company_id','child_of',[user.company_id.id])]</field>
</record>
<record model="ir.rule" id="account_invoice_line_comp_rule">
<field name="name">Invoice Line company rule</field>
<field name="model_id" ref="model_account_invoice_line"/>

View File

@ -36,11 +36,11 @@ class account_subscription_generate(osv.osv_memory):
def action_generate(self, cr, uid, ids, context=None):
mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window')
sub_line_obj = self.pool.get('account.subscription.line')
moves_created=[]
for data in self.read(cr, uid, ids, context=context):
cr.execute('select id from account_subscription_line where date<%s and move_id is null', (data['date'],))
line_ids = map(lambda x: x[0], cr.fetchall())
moves = self.pool.get('account.subscription.line').move_create(cr, uid, line_ids, context=context)
line_ids = sub_line_obj.search(cr, uid, [('date', '<', data['date']), ('move_id', '=', False)], context=context)
moves = sub_line_obj.move_create(cr, uid, line_ids, context=context)
moves_created.extend(moves)
result = mod_obj.get_object_reference(cr, uid, 'account', 'action_move_line_form')
id = result and result[1] or False

View File

@ -164,6 +164,13 @@ class crm_claim(osv.osv):
# context: no_log, because subtype already handle this
return super(crm_claim, self).create(cr, uid, vals, context=context)
def copy(self, cr, uid, id, default=None, context=None):
claim = self.browse(cr, uid, id, context=context)
default = dict(default or {},
stage_id = self._get_default_stage_id(cr, uid, context=context),
name = _('%s (copy)') % claim.name)
return super(crm_claim, self).copy(cr, uid, id, default, context=context)
# -------------------------------------------------------
# Mail gateway
# -------------------------------------------------------

View File

@ -224,7 +224,7 @@ class partner_vat_intra(osv.osv_memory):
data_head = """<?xml version="1.0" encoding="ISO-8859-1"?>
<ns2:IntraConsignment xmlns="http://www.minfin.fgov.be/InputCommon" xmlns:ns2="http://www.minfin.fgov.be/IntraConsignment" IntraListingsNbr="1">
<ns2:Representative>
<RepresentativeID identificationType="NVAT" issuedBy="%(issued_by)s">%(company_vat)s</RepresentativeID>
<RepresentativeID identificationType="NVAT" issuedBy="%(issued_by)s">%(vatnum)s</RepresentativeID>
<Name>%(company_name)s</Name>
<Street>%(street)s</Street>
<PostCode>%(post_code)s</PostCode>

View File

@ -71,6 +71,8 @@ class purchase_requisition(osv.osv):
for purchase_id in purchase.purchase_ids:
if str(purchase_id.state) in('draft'):
purchase_order_obj.action_cancel(cr,uid,[purchase_id.id])
procurement_ids = self.pool['procurement.order'].search(cr, uid, [('requisition_id', 'in', ids)], context=context)
self.pool['procurement.order'].action_done(cr, uid, procurement_ids)
return self.write(cr, uid, ids, {'state': 'cancel'})
def tender_in_progress(self, cr, uid, ids, context=None):
@ -80,6 +82,8 @@ class purchase_requisition(osv.osv):
return self.write(cr, uid, ids, {'state': 'draft'})
def tender_done(self, cr, uid, ids, context=None):
procurement_ids = self.pool['procurement.order'].search(cr, uid, [('requisition_id', 'in', ids)], context=context)
self.pool['procurement.order'].action_done(cr, uid, procurement_ids)
return self.write(cr, uid, ids, {'state':'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
def _planned_date(self, requisition, delay=0.0):
@ -212,6 +216,10 @@ class purchase_order(osv.osv):
proc_obj.write(cr, uid, proc_ids, {'purchase_id': po.id})
self.signal_purchase_cancel(cr, uid, [order.id])
po.requisition_id.tender_done(context=context)
if po.requisition_id and all(purchase_id.state in ['draft', 'cancel'] for purchase_id in po.requisition_id.purchase_ids if purchase_id.id != po.id):
procurement_ids = self.pool['procurement.order'].search(cr, uid, [('requisition_id', '=', po.requisition_id.id)], context=context)
for procurement in proc_obj.browse(cr, uid, procurement_ids, context=context):
procurement.move_id.write({'location_id': procurement.move_id.location_dest_id.id})
return res
@ -268,7 +276,7 @@ class procurement_order(osv.osv):
for procurement in self.browse(cr, uid, ids, context=context):
if procurement.product_id.purchase_requisition:
user_company = self.pool['res.users'].browse(cr, uid, uid, context=context).company_id
req = res[procurement.id] = requisition_obj.create(cr, uid, {
req = requisition_obj.create(cr, uid, {
'origin': procurement.origin,
'date_end': procurement.date_planned,
'warehouse_id': self._get_warehouse(procurement, user_company),
@ -284,6 +292,7 @@ class procurement_order(osv.osv):
'state': 'running',
'requisition_id': req
})
res[procurement.id] = 0
else:
non_requisition.append(procurement.id)

View File

@ -271,7 +271,7 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) {
value, (date_pattern + ' ' + time_pattern));
if (datetime !== null)
return instance.web.datetime_to_str(datetime);
datetime = Date.parseExact(value.replace(/\d+/g, function(m){
datetime = Date.parseExact(value.toString().replace(/\d+/g, function(m){
return m.length === 1 ? "0" + m : m ;
}), (date_pattern + ' ' + time_pattern));
if (datetime !== null)
@ -284,7 +284,7 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) {
var date = Date.parseExact(value, date_pattern);
if (date !== null)
return instance.web.date_to_str(date);
date = Date.parseExact(value.replace(/\d+/g, function(m){
date = Date.parseExact(value.toString().replace(/\d+/g, function(m){
return m.length === 1 ? "0" + m : m ;
}), date_pattern);
if (date !== null)

View File

@ -1108,7 +1108,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
ids = value;
}
new instance.web.Model(column.relation)
.call('name_get', [ids]).done(function (names) {
.call('name_get', [ids, this.dataset.context]).done(function (names) {
// FIXME: nth horrible hack in this poor listview
record.set(column.id + '__display',
_(names).pluck(1).join(', '));

View File

@ -664,17 +664,13 @@ openerp.web_calendar = function(instance) {
date_start_day = new Date(event.start.getFullYear(),event.start.getMonth(),event.start.getDate(),7);
date_stop_day = new Date(event_end.getFullYear(),event_end.getMonth(),event_end.getDate(),19);
}
data[this.date_start] = instance.web.parse_value(date_start_day, this.fields[this.date_start]);
if (this.date_stop) {
data[this.date_stop] = instance.web.parse_value(date_stop_day, this.fields[this.date_stop]);
}
diff_seconds = Math.round((date_stop_day.getTime() - date_start_day.getTime()) / 1000);
}
else {
data[this.date_start] = instance.web.parse_value(event.start, this.fields[this.date_start]);
data[this.date_start] = event.start;
if (this.date_stop) {
data[this.date_stop] = instance.web.parse_value(event_end, this.fields[this.date_stop]);
data[this.date_stop] = event_end;
}
diff_seconds = Math.round((event_end.getTime() - event.start.getTime()) / 1000);
}

View File

@ -373,7 +373,7 @@ class view(osv.osv):
node.getparent().remove(node)
elif pos == 'attributes':
for child in spec.getiterator('attribute'):
attribute = (child.get('name'), child.text and child.text.encode('utf8') or None)
attribute = (child.get('name'), child.text or None)
if attribute[1]:
node.set(attribute[0], attribute[1])
elif attribute[0] in node.attrib:

View File

@ -103,17 +103,7 @@ class base_module_upgrade(osv.osv_memory):
openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
ir_model_data = self.pool.get('ir.model.data')
__, res_id = ir_model_data.get_object_reference(cr, uid, 'base', 'view_base_module_upgrade_install')
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'base.module.upgrade',
'views': [(res_id, 'form')],
'view_id': False,
'type': 'ir.actions.act_window',
'target': 'new',
}
return {'type': 'ir.actions.act_window_close'}
def config(self, cr, uid, ids, context=None):
return self.pool.get('res.config').next(cr, uid, [], context=context)

View File

@ -13,7 +13,7 @@
<separator string="Impacted Modules"/>
<field name="module_info"/>
<footer>
<button name="upgrade_module" string="Update" type="object" class="oe_highlight"/>
<button name="upgrade_module" string="Confirm" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" name="upgrade_module_cancel" type="object"/>
</footer>

View File

@ -1036,34 +1036,30 @@ class expression(object):
unaccent = self._unaccent if sql_operator.endswith('like') else lambda x: x
trans_left = unaccent('value')
quote_left = unaccent(_quote(left))
instr = unaccent('%s')
if sql_operator == 'in':
# params will be flatten by to_sql() => expand the placeholders
instr = '(%s)' % ', '.join(['%s'] * len(right))
subselect = """(SELECT res_id
FROM ir_translation
WHERE name = %s
AND lang = %s
AND type = %s
AND {trans_left} {operator} {right}
) UNION (
SELECT id
FROM "{table}"
WHERE {left} {operator} {right}
)
""".format(trans_left=trans_left, operator=sql_operator,
right=instr, table=working_model._table, left=quote_left)
subselect = """WITH temp_irt_current (id, name) as (
SELECT ct.id, coalesce(it.value,ct.{quote_left})
FROM {current_table} ct
LEFT JOIN ir_translation it ON (it.name = %s and
it.lang = %s and
it.type = %s and
it.res_id = ct.id and
it.value != '')
)
SELECT id FROM temp_irt_current WHERE {name} {operator} {right} order by name
""".format(current_table=working_model._table, quote_left=_quote(left), name=unaccent('name'),
operator=sql_operator, right=instr)
params = (
working_model._name + ',' + left,
context.get('lang') or 'en_US',
'model',
right,
right,
)
push(create_substitution_leaf(leaf, ('id', inselect_operator, (subselect, params)), working_model))

View File

@ -1556,7 +1556,8 @@ class property(function):
default_val = self._get_default(obj, cr, uid, prop_name, context)
property_create = False
if isinstance(default_val, openerp.osv.orm.browse_record):
if isinstance(default_val, (openerp.osv.orm.browse_record,
openerp.osv.orm.browse_null)):
if default_val.id != id_val:
property_create = True
elif default_val != id_val: