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

This commit is contained in:
Christophe Simonis 2015-03-18 13:14:20 +01:00
commit e27744df0c
6 changed files with 43 additions and 14 deletions

View File

@ -7,7 +7,7 @@
wiz = wizards.browse(cr, uid, ref('account.account_configuration_installer_todo')) wiz = wizards.browse(cr, uid, ref('account.account_configuration_installer_todo'))
part = self.pool.get('res.partner').browse(cr, uid, ref('base.main_partner')) part = self.pool.get('res.partner').browse(cr, uid, ref('base.main_partner'))
# if we know the country and the wizard has not yet been executed, we do it # if we know the country and the wizard has not yet been executed, we do it
if (part.country_id.id) and (wiz.state=='open'): if (part.country_id.id) and (part.country_id.code) and (wiz.state=='open'):
mod = 'l10n_'+part.country_id.code.lower() mod = 'l10n_'+part.country_id.code.lower()
ids = modules.search(cr, uid, [ ('name','=',mod) ], context=context) ids = modules.search(cr, uid, [ ('name','=',mod) ], context=context)
if ids: if ids:

View File

@ -170,10 +170,6 @@ class account_asset_asset(osv.osv):
for x in range(len(posted_depreciation_line_ids), undone_dotation_number): for x in range(len(posted_depreciation_line_ids), undone_dotation_number):
i = x + 1 i = x + 1
amount = self._compute_board_amount(cr, uid, asset, i, residual_amount, amount_to_depr, undone_dotation_number, posted_depreciation_line_ids, total_days, depreciation_date, context=context) amount = self._compute_board_amount(cr, uid, asset, i, residual_amount, amount_to_depr, undone_dotation_number, posted_depreciation_line_ids, total_days, depreciation_date, context=context)
company_currency = asset.company_id.currency_id.id
current_currency = asset.currency_id.id
# compute amount into company currency
amount = currency_obj.compute(cr, uid, current_currency, company_currency, amount, context=context)
residual_amount -= amount residual_amount -= amount
vals = { vals = {
'amount': amount, 'amount': amount,
@ -214,7 +210,10 @@ class account_asset_asset(osv.osv):
l.asset_id IN %s GROUP BY l.asset_id """, (tuple(ids),)) l.asset_id IN %s GROUP BY l.asset_id """, (tuple(ids),))
res=dict(cr.fetchall()) res=dict(cr.fetchall())
for asset in self.browse(cr, uid, ids, context): for asset in self.browse(cr, uid, ids, context):
res[asset.id] = asset.purchase_value - res.get(asset.id, 0.0) - asset.salvage_value company_currency = asset.company_id.currency_id.id
current_currency = asset.currency_id.id
amount = self.pool['res.currency'].compute(cr, uid, company_currency, current_currency, res.get(asset.id, 0.0), context=context)
res[asset.id] = asset.purchase_value - amount - asset.salvage_value
for id in ids: for id in ids:
res.setdefault(id, 0.0) res.setdefault(id, 0.0)
return res return res

View File

@ -28,6 +28,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
this.group_by_field = {}; this.group_by_field = {};
this.grouped_by_m2o = false; this.grouped_by_m2o = false;
this.many2manys = []; this.many2manys = [];
this.m2m_context = {};
this.state = { this.state = {
groups : {}, groups : {},
records : {} records : {}
@ -123,6 +124,10 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
this.aggregates[node.attrs.name] = node.attrs[this.group_operators[j]]; this.aggregates[node.attrs.name] = node.attrs[this.group_operators[j]];
break; break;
} }
};
var ftype = node.attrs.widget || this.fields_view.fields[node.attrs.name].type;
if(ftype == "many2many" && "context" in node.attrs) {
this.m2m_context[node.attrs.name] = node.attrs.context;
} }
}, },
transform_qweb_template: function(node) { transform_qweb_template: function(node) {
@ -541,7 +546,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
var field = record.record[name]; var field = record.record[name];
var $el = record.$('.oe_form_field.oe_tags[name=' + name + ']').empty(); var $el = record.$('.oe_form_field.oe_tags[name=' + name + ']').empty();
if (!relations[field.relation]) { if (!relations[field.relation]) {
relations[field.relation] = { ids: [], elements: {}}; relations[field.relation] = { ids: [], elements: {}, context: self.m2m_context[name]};
} }
var rel = relations[field.relation]; var rel = relations[field.relation];
field.raw_value.forEach(function(id) { field.raw_value.forEach(function(id) {
@ -555,7 +560,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
}); });
}); });
_.each(relations, function(rel, rel_name) { _.each(relations, function(rel, rel_name) {
var dataset = new instance.web.DataSetSearch(self, rel_name, self.dataset.get_context()); var dataset = new instance.web.DataSetSearch(self, rel_name, self.dataset.get_context(rel.context));
dataset.name_get(_.uniq(rel.ids)).done(function(result) { dataset.name_get(_.uniq(rel.ids)).done(function(result) {
result.forEach(function(nameget) { result.forEach(function(nameget) {
$(rel.elements[nameget[0]]).append('<span class="oe_tag">' + _.str.escapeHTML(nameget[1]) + '</span>'); $(rel.elements[nameget[0]]).append('<span class="oe_tag">' + _.str.escapeHTML(nameget[1]) + '</span>');

View File

@ -198,7 +198,7 @@ class ir_sequence(openerp.osv.osv.osv):
if new_implementation in ('standard', None): if new_implementation in ('standard', None):
# Implementation has NOT changed. # Implementation has NOT changed.
# Only change sequence if really requested. # Only change sequence if really requested.
if row['number_next'] != n: if values.get('number_next'):
self._alter_sequence(cr, row['id'], i, n) self._alter_sequence(cr, row['id'], i, n)
else: else:
# Just in case only increment changed # Just in case only increment changed

View File

@ -215,8 +215,33 @@ class test_ir_sequence_generate(unittest2.TestCase):
drop_sequence('test_sequence_type_6') drop_sequence('test_sequence_type_6')
if __name__ == '__main__': class Test_ir_sequence_init(common.TransactionCase):
def test_00(self):
registry, cr, uid = self.registry, self.cr, self.uid
# test if read statement return the good number_next value (from postgreSQL sequence and not ir_sequence value)
sequence = registry('ir.sequence')
# first creation of sequence (normal)
values = {'number_next': 1,
'company_id': 1,
'padding': 4,
'number_increment': 1,
'implementation': 'standard',
'name': 'test-sequence-00'}
seq_id = sequence.create(cr, uid, values)
# Call get next 4 times
sequence.next_by_id(cr, uid, seq_id)
sequence.next_by_id(cr, uid, seq_id)
sequence.next_by_id(cr, uid, seq_id)
read_sequence = sequence.next_by_id(cr, uid, seq_id)
# Read the value of the current sequence
assert read_sequence == "0004", 'The actual sequence value must be 4. reading : %s' % read_sequence
# reset sequence to 1 by write method calling
sequence.write(cr, uid, [seq_id], {'number_next': 1})
# Read the value of the current sequence
read_sequence = sequence.next_by_id(cr, uid, seq_id)
assert read_sequence == "0001", 'The actual sequence value must be 1. reading : %s' % read_sequence
if __name__ == "__main__":
unittest2.main() unittest2.main()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -178,7 +178,7 @@ class wkf_workitem(osv.osv):
_columns = { _columns = {
'act_id': fields.many2one('workflow.activity', 'Activity', required=True, ondelete="cascade", select=True), 'act_id': fields.many2one('workflow.activity', 'Activity', required=True, ondelete="cascade", select=True),
'wkf_id': fields.related('act_id','wkf_id', type='many2one', relation='workflow', string='Workflow'), 'wkf_id': fields.related('act_id','wkf_id', type='many2one', relation='workflow', string='Workflow'),
'subflow_id': fields.many2one('workflow.instance', 'Subflow', ondelete="cascade", select=True), 'subflow_id': fields.many2one('workflow.instance', 'Subflow', ondelete="set null", select=True),
'inst_id': fields.many2one('workflow.instance', 'Instance', required=True, ondelete="cascade", select=True), 'inst_id': fields.many2one('workflow.instance', 'Instance', required=True, ondelete="cascade", select=True),
'state': fields.char('Status', select=True), 'state': fields.char('Status', select=True),
} }