diff --git a/addons/account/partner_view.xml b/addons/account/partner_view.xml
index a22e6860a15..1c1ae438094 100644
--- a/addons/account/partner_view.xml
+++ b/addons/account/partner_view.xml
@@ -72,8 +72,8 @@
2
-
-
+
+
@@ -121,7 +121,7 @@
-
+
diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py
index 80166298edb..3a56f15ed3d 100644
--- a/addons/audittrail/audittrail.py
+++ b/addons/audittrail/audittrail.py
@@ -25,6 +25,7 @@ from tools.translate import _
import ir
import pooler
import time
+import tools
class audittrail_rule(osv.osv):
"""
@@ -33,25 +34,28 @@ class audittrail_rule(osv.osv):
_name = 'audittrail.rule'
_description = "Audittrail Rule"
_columns = {
- "name": fields.char("Rule Name", size=32, required=True),
- "object_id": fields.many2one('ir.model', 'Object', required=True),
- "user_id": fields.many2many('res.users', 'audittail_rules_users',
- 'user_id', 'rule_id', 'Users'),
- "log_read": fields.boolean("Log reads"),
- "log_write": fields.boolean("Log writes"),
- "log_unlink": fields.boolean("Log deletes"),
- "log_create": fields.boolean("Log creates"),
- "state": fields.selection((("draft", "Draft"),
- ("subscribed", "Subscribed")),
- "State", required=True),
- "action_id": fields.many2one('ir.actions.act_window', "Action ID"),
+ "name": fields.char("Rule Name", size=32, required=True),
+ "object_id": fields.many2one('ir.model', 'Object', required=True),
+ "user_id": fields.many2many('res.users', 'audittail_rules_users',
+ 'user_id', 'rule_id', 'Users', help="if User is not added then it will applicable for all users"),
+ "log_read": fields.boolean("Log Reads"),
+ "log_write": fields.boolean("Log Writes"),
+ "log_unlink": fields.boolean("Log Deletes"),
+ "log_create": fields.boolean("Log Creates"),
+ "log_action": fields.boolean("Log Action"),
+ "log_workflow": fields.boolean("Log Workflow"),
+ "state": fields.selection((("draft", "Draft"),
+ ("subscribed", "Subscribed")),
+ "State", required=True),
+ "action_id": fields.many2one('ir.actions.act_window', "Action ID"),
+
}
_defaults = {
- 'state': lambda *a: 'draft',
- 'log_create': lambda *a: 1,
- 'log_unlink': lambda *a: 1,
- 'log_write': lambda *a: 1,
+ 'state': lambda *a: 'draft',
+ 'log_create': lambda *a: 1,
+ 'log_unlink': lambda *a: 1,
+ 'log_write': lambda *a: 1,
}
_sql_constraints = [
@@ -65,7 +69,7 @@ class audittrail_rule(osv.osv):
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Auddittrail Rule’s IDs.
- @return: True
+ @return: True
"""
obj_action = self.pool.get('ir.actions.act_window')
obj_model = self.pool.get('ir.model.data')
@@ -74,20 +78,20 @@ class audittrail_rule(osv.osv):
obj = self.pool.get(thisrule.object_id.model)
if not obj:
raise osv.except_osv(
- _('WARNING: audittrail is not part of the pool'),
+ _('WARNING: audittrail is not part of the pool'),
_('Change audittrail depends -- Setting rule as DRAFT'))
self.write(cr, uid, [thisrule.id], {"state": "draft"})
val = {
- "name": 'View Log',
- "res_model": 'audittrail.log',
- "src_model": thisrule.object_id.model,
+ "name": 'View Log',
+ "res_model": 'audittrail.log',
+ "src_model": thisrule.object_id.model,
"domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
}
- id = obj_action.create(cr, uid, val)
- self.write(cr, uid, [thisrule.id], {"state": "subscribed", "action_id": id})
+ action_id = obj_action.create(cr, uid, val)
+ self.write(cr, uid, [thisrule.id], {"state": "subscribed", "action_id": action_id})
keyword = 'client_action_relate'
- value = 'ir.actions.act_window,' + str(id)
+ value = 'ir.actions.act_window,' + str(action_id)
res = obj_model.ir_set(cr, uid, 'action', keyword, 'View_log_' + thisrule.object_id.model, [thisrule.object_id.model], value, replace=True, isobject=True, xml_id=False)
#End Loop
return True
@@ -98,7 +102,7 @@ class audittrail_rule(osv.osv):
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Auddittrail Rule’s IDs.
- @return: True
+ @return: True
"""
obj_action = self.pool.get('ir.actions.act_window')
val_obj = self.pool.get('ir.values')
@@ -127,17 +131,28 @@ class audittrail_log(osv.osv):
_name = 'audittrail.log'
_description = "Audittrail Log"
+ def _name_get_resname(self, cr, uid, ids, *args):
+ data = {}
+ for resname in self.browse(cr, uid, ids,[]):
+ model_object = resname.object_id
+ res_id = resname.res_id
+ if model_object and res_id:
+ model_pool = self.pool.get(model_object.model)
+ res = model_pool.read(cr, uid, res_id, ['name'])
+ data[resname.id] = res['name']
+ else:
+ data[resname.id] = False
+ return data
+
_columns = {
- "name": fields.char("Name", size=32),
- "object_id": fields.many2one('ir.model', 'Object'),
- "user_id": fields.many2one('res.users', 'User'),
- "method": fields.selection((('read', 'Read'),
- ('write', 'Write'),
- ('unlink', 'Delete'),
- ('create', 'Create')), "Method"),
- "timestamp": fields.datetime("Date"),
- "res_id": fields.integer('Resource Id'),
- "line_ids": fields.one2many('audittrail.log.line', 'log_id', 'Log lines'),
+ "name": fields.char("Resource Name",size=64),
+ # "name": fields.function(_name_get_resname, type='char', string='Resource Name', method=True),
+ "object_id": fields.many2one('ir.model', 'Object'),
+ "user_id": fields.many2one('res.users', 'User'),
+ "method": fields.char("Method", size=64),
+ "timestamp": fields.datetime("Date"),
+ "res_id": fields.integer('Resource Id'),
+ "line_ids": fields.one2many('audittrail.log.line', 'log_id', 'Log lines'),
}
_defaults = {
@@ -155,14 +170,14 @@ class audittrail_log_line(osv.osv):
_name = 'audittrail.log.line'
_description = "Log Line"
_columns = {
- 'field_id': fields.many2one('ir.model.fields', 'Fields', required=True),
- 'log_id': fields.many2one('audittrail.log', 'Log'),
- 'log': fields.integer("Log ID"),
- 'old_value': fields.text("Old Value"),
- 'new_value': fields.text("New Value"),
- 'old_value_text': fields.text('Old value Text'),
- 'new_value_text': fields.text('New value Text'),
- 'field_description': fields.char('Field Description', size=64),
+ 'field_id': fields.many2one('ir.model.fields', 'Fields', required=True),
+ 'log_id': fields.many2one('audittrail.log', 'Log'),
+ 'log': fields.integer("Log ID"),
+ 'old_value': fields.text("Old Value"),
+ 'new_value': fields.text("New Value"),
+ 'old_value_text': fields.text('Old value Text'),
+ 'new_value_text': fields.text('New value Text'),
+ 'field_description': fields.char('Field Description', size=64),
}
audittrail_log_line()
@@ -170,276 +185,366 @@ audittrail_log_line()
class audittrail_objects_proxy(osv_pool):
""" Uses Object proxy for auditing changes on object of subscribed Rules"""
-
- def get_value_text(self, cr, uid, field_name, values, object, context=None):
+
+ def get_value_text(self, cr, uid, field_name, values, model, context=None):
"""
Gets textual values for the fields
e.g.: For field of type many2one it gives its name value instead of id
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
- @param field_name: List of fields for text values
- @param values: Values for field to be converted into textual values
- @return: values: List of textual values for given fields
+ @param field_name: List of fields for text values
+ @param values: Values for field to be converted into textual values
+ @return: values: List of textual values for given fields
"""
if not context:
context = {}
pool = pooler.get_pool(cr.dbname)
- f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', field_name), ('model_id', '=', object.id)])
- if f_id:
- field = pool.get('ir.model.fields').read(cr, uid, f_id)[0]
- model = field['relation']
+ field_pool = pool.get('ir.model.fields')
+ model_pool = pool.get('ir.model')
+ obj_pool = pool.get(model.model)
+ if obj_pool._inherits:
+ inherits_ids = model_pool.search(cr, uid, [('model', '=', obj_pool._inherits.keys()[0])])
+ field_ids = field_pool.search(cr, uid, [('name', '=', field_name), ('model_id', 'in', (model.id, inherits_ids[0]))])
+ else:
+ field_ids = field_pool.search(cr, uid, [('name', '=', field_name), ('model_id', '=', model.id)])
+ field_id = field_ids and field_ids[0] or False
+ assert field_id, _("'%s' field is not exits in '%s' model" %(field_name, model.model))
- if field['ttype'] == 'many2one':
- if values:
- if type(values) == tuple:
- values = values[0]
- val = pool.get(model).read(cr, uid, [values], [pool.get(model)._rec_name])
- if val:
- return val[0][pool.get(model)._rec_name]
- elif field['ttype'] == 'many2many':
- value = []
- if values:
- for id in values:
- val = pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
- if val:
- value.append(val[0][pool.get(model)._rec_name])
- return value
+ field = field_pool.read(cr, uid, field_id)
+ relation_model = field['relation']
+ relation_model_pool = relation_model and pool.get(relation_model) or False
- elif field['ttype'] == 'one2many':
- if values:
- value = []
- for id in values:
- val = pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
+ if field['ttype'] == 'many2one':
+ res = False
+ relation_id = False
+ if values and type(values) == tuple:
+ relation_id = values[0]
+ if relation_id and relation_model_pool:
+ relation_model_object = relation_model_pool.read(cr, uid, relation_id, [relation_model_pool._rec_name])
+ res = relation_model_object[relation_model_pool._rec_name]
+ return res
- if val:
- value.append(val[0][pool.get(model)._rec_name])
- return value
- return values
+ elif field['ttype'] in ('many2many','one2many'):
+ res = []
+ for relation_model_object in relation_model_pool.read(cr, uid, values, [relation_model_pool._rec_name]):
+ res.append(relation_model_object[relation_model_pool._rec_name])
+ return res
- def create_log_line(self, cr, uid, id, object, lines=[]):
+ return values
+
+ def create_log_line(self, cr, uid, log_id, model, lines=[]):
"""
Creates lines for changed fields with its old and new values
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
- @param object: Object who's values are being changed
+ @param model: Object who's values are being changed
@param lines: List of values for line is to be created
"""
-
pool = pooler.get_pool(cr.dbname)
- obj = pool.get(object.model)
+ obj_pool = pool.get(model.model)
+ model_pool = pool.get('ir.model')
+ field_pool = pool.get('ir.model.fields')
+ log_line_pool = pool.get('audittrail.log.line')
#start Loop
for line in lines:
- if obj._inherits:
- inherits_ids = pool.get('ir.model').search(cr, uid, [('model', '=', obj._inherits.keys()[0])])
- f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', 'in', (object.id, inherits_ids[0]))])
+ if obj_pool._inherits:
+ inherits_ids = model_pool.search(cr, uid, [('model', '=', obj_pool._inherits.keys()[0])])
+ field_ids = field_pool.search(cr, uid, [('name', '=', line['name']), ('model_id', 'in', (model.id, inherits_ids[0]))])
else:
- f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', '=', object.id)])
- if f_id:
- fields = pool.get('ir.model.fields').read(cr, uid, f_id)
- old_value = 'old_value' in line and line['old_value'] or ''
- new_value = 'new_value' in line and line['new_value'] or ''
- old_value_text = 'old_value_text' in line and line['old_value_text'] or ''
- new_value_text = 'new_value_text' in line and line['new_value_text'] or ''
-
- if old_value_text == new_value_text:
- continue
- if fields[0]['ttype'] == 'many2one':
- if type(old_value) == tuple:
- old_value = old_value[0]
- if type(new_value) == tuple:
- new_value = new_value[0]
- vals = {
- "log_id": id,
- "field_id": f_id[0],
- "old_value": old_value,
- "new_value": new_value,
- "old_value_text": old_value_text,
- "new_value_text": new_value_text,
- "field_description": fields[0]['field_description']
- }
- line_id = pool.get('audittrail.log.line').create(cr, uid, vals)
- cr.commit()
- #End Loop
+ field_ids = field_pool.search(cr, uid, [('name', '=', line['name']), ('model_id', '=', model.id)])
+ field_id = field_ids and field_ids[0] or False
+ assert field_id, _("'%s' field is not exits in '%s' model" %(line['name'], model.model))
+
+ field = field_pool.read(cr, uid, field_id)
+ old_value = 'old_value' in line and line['old_value'] or ''
+ new_value = 'new_value' in line and line['new_value'] or ''
+ old_value_text = 'old_value_text' in line and line['old_value_text'] or ''
+ new_value_text = 'new_value_text' in line and line['new_value_text'] or ''
+
+ if old_value_text == new_value_text:
+ continue
+ if field['ttype'] == 'many2one':
+ if type(old_value) == tuple:
+ old_value = old_value[0]
+ if type(new_value) == tuple:
+ new_value = new_value[0]
+ vals = {
+ "log_id": log_id,
+ "field_id": field_id,
+ "old_value": old_value,
+ "new_value": new_value,
+ "old_value_text": old_value_text,
+ "new_value_text": new_value_text,
+ "field_description": field['field_description']
+ }
+ line_id = log_line_pool.create(cr, uid, vals)
+ #End Loop
return True
- def log_fct(self, db, uid, object, method, fct_src, *args):
+
+ def log_fct(self, db, uid, model, method, fct_src, *args):
"""
Logging function: This function is performs logging oprations according to method
@param db: the current database
@param uid: the current user’s ID for security checks,
@param object: Object who's values are being changed
- @param method: method to log: create, read, write, unlink
+ @param method: method to log: create, read, write, unlink
@param fct_src: execute method of Object proxy
-
- @return: Returns result as per method of Object proxy
+
+ @return: Returns result as per method of Object proxy
"""
- logged_uids = []
+ res2 = args
pool = pooler.get_pool(db)
cr = pooler.get_db(db).cursor()
- obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)])
- model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0]
+ resource_pool = pool.get(model)
+ log_pool = pool.get('audittrail.log')
+ model_pool = pool.get('ir.model')
+
+ model_ids = model_pool.search(cr, uid, [('model', '=', model)])
+ model_id = model_ids and model_ids[0] or False
+ assert model_id, _("'%s' Model is not exits..." %(model))
+ model = model_pool.browse(cr, uid, model_id)
+
if method in ('create'):
- res_id = fct_src(db, uid, object, method, *args)
+ res_id = fct_src(db, uid, model.model, method, *args)
cr.commit()
- new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0]
- if 'id' in new_value:
- del new_value['id']
- if not logged_uids or uid in logged_uids:
- resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
- resource_name = resource_name and resource_name[0][1] or ''
- vals = {
- "method": method,
- "object_id": model_object.id,
- "user_id": uid, "res_id": res_id,
- "name": resource_name
- }
- id = pool.get('audittrail.log').create(cr, uid, vals)
- lines = []
- for field in new_value:
- if new_value[field]:
- line = {
- 'name': field,
- 'new_value': new_value[field],
- 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object)
- }
- lines.append(line)
- self.create_log_line(cr, uid, id, model_object, lines)
+ resource = resource_pool.read(cr, uid, res_id, args[0].keys())
+ vals = {
+ "method": method,
+ "object_id": model.id,
+ "user_id": uid,
+ "res_id": resource['id'],
+ }
+ if 'id' in resource:
+ del resource['id']
+ log_id = log_pool.create(cr, uid, vals)
+ lines = []
+ for field in resource:
+ line = {
+ 'name': field,
+ 'new_value': resource[field],
+ 'new_value_text': self.get_value_text(cr, uid, field, resource[field], model)
+ }
+ lines.append(line)
+ self.create_log_line(cr, uid, log_id, model, lines)
+
cr.commit()
cr.close()
return res_id
- if method in ('write'):
- res_ids = args[0]
- for res_id in res_ids:
- old_values = pool.get(model_object.model).read(cr, uid, res_id, args[1].keys())
- old_values_text = {}
- for field in args[1].keys():
- old_values_text[field] = self.get_value_text(cr, uid, field, old_values[field], model_object)
- res = fct_src(db, uid, object, method, *args)
- cr.commit()
- if res:
- new_values = pool.get(model_object.model).read(cr, uid, res_ids, args[1].keys())[0]
- if not logged_uids or uid in logged_uids:
- resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
- resource_name = resource_name and resource_name[0][1] or ''
- id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines = []
- for field in args[1].keys():
- if args[1].keys():
- line = {
- 'name': field,
- 'new_value': field in new_values and new_values[field] or '',
- 'old_value': field in old_values and old_values[field] or '',
- 'new_value_text': self.get_value_text(cr, uid, field, new_values[field], model_object),
- 'old_value_text': old_values_text[field]
- }
- lines.append(line)
- cr.commit()
- self.create_log_line(cr, uid, id, model_object, lines)
- cr.close()
- return res
-
- if method in ('read'):
+ elif method in ('read'):
res_ids = args[0]
old_values = {}
- res = fct_src(db, uid, object, method, *args)
+ res = fct_src(db, uid, model.model, method, *args)
if type(res) == list:
-
for v in res:
old_values[v['id']] = v
else:
old_values[res['id']] = res
for res_id in old_values:
- if not logged_uids or uid in logged_uids:
- resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
- resource_name = resource_name and resource_name[0][1] or ''
- id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines = []
- for field in old_values[res_id]:
- if old_values[res_id][field]:
- line = {
- 'name': field,
- 'old_value': old_values[res_id][field],
- 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
- }
- lines.append(line)
- cr.commit()
- self.create_log_line(cr, uid, id, model_object, lines)
+ vals = {
+ "method": method,
+ "object_id": model.id,
+ "user_id": uid,
+ "res_id": res_id,
+
+ }
+ log_id = log_pool.create(cr, uid, vals)
+ lines = []
+ for field in old_values[res_id]:
+ line = {
+ 'name': field,
+ 'old_value': old_values[res_id][field],
+ 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model)
+ }
+ lines.append(line)
+
+ self.create_log_line(cr, uid, log_id, model, lines)
+
cr.close()
return res
- if method in ('unlink'):
+ elif method in ('unlink'):
res_ids = args[0]
old_values = {}
for res_id in res_ids:
- old_values[res_id] = pool.get(model_object.model).read(cr, uid, res_id, [])
+ old_values[res_id] = resource_pool.read(cr, uid, res_id)
for res_id in res_ids:
- if not logged_uids or uid in logged_uids:
- resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
- resource_name = resource_name and resource_name[0][1] or ''
- id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines = []
- for field in old_values[res_id]:
- if old_values[res_id][field]:
- line = {
- 'name': field,
- 'old_value': old_values[res_id][field],
- 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
- }
- lines.append(line)
- cr.commit()
- self.create_log_line(cr, uid, id, model_object, lines)
- res = fct_src(db, uid, object, method, *args)
+ vals = {
+ "method": method,
+ "object_id": model.id,
+ "user_id": uid,
+ "res_id": res_id,
+
+ }
+ log_id = log_pool.create(cr, uid, vals)
+ lines = []
+ for field in old_values[res_id]:
+ if field in ('id'):
+ continue
+ line = {
+ 'name': field,
+ 'old_value': old_values[res_id][field],
+ 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model)
+ }
+ lines.append(line)
+
+ self.create_log_line(cr, uid, log_id, model, lines)
+ res = fct_src(db, uid, model.model, method, *args)
+ cr.commit()
cr.close()
return res
- cr.close()
+ else:
+ res_ids = args[0]
+ old_values = {}
+ fields = []
+ if len(args)>1 and type(args[1]) == dict:
+ fields = args[1].keys()
+ if type(res_ids) in (long, int):
+ res_ids = [res_ids]
+ if res_ids:
+ for resource in resource_pool.read(cr, uid, res_ids):
+ resource_id = resource['id']
+ if 'id' in resource:
+ del resource['id']
+ old_values_text = {}
+ old_value = {}
+ for field in resource.keys():
+ old_value[field] = resource[field]
+ old_values_text[field] = self.get_value_text(cr, uid, field, resource[field], model)
+ old_values[resource_id] = {'text':old_values_text, 'value': old_value}
- def execute(self, db, uid, object, method, *args, **kw):
+ res = fct_src(db, uid, model.model, method, *args)
+ cr.commit()
+
+ if res_ids:
+ for resource in resource_pool.read(cr, uid, res_ids):
+ resource_id = resource['id']
+ if 'id' in resource:
+ del resource['id']
+ vals = {
+ "method": method,
+ "object_id": model.id,
+ "user_id": uid,
+ "res_id": resource_id,
+ }
+
+
+ log_id = log_pool.create(cr, uid, vals)
+ lines = []
+ for field in resource.keys():
+ line = {
+ 'name': field,
+ 'new_value': resource[field],
+ 'old_value': old_values[resource_id]['value'][field],
+ 'new_value_text': self.get_value_text(cr, uid, field, resource[field], model),
+ 'old_value_text': old_values[resource_id]['text'][field]
+ }
+ lines.append(line)
+
+ self.create_log_line(cr, uid, log_id, model, lines)
+ cr.commit()
+ cr.close()
+ return res
+ return True
+
+
+
+ def execute(self, db, uid, model, method, *args, **kw):
"""
Overrides Object Proxy execute method
@param db: the current database
@param uid: the current user’s ID for security checks,
@param object: Object who's values are being changed
- @param method: method to log: create, read, write, unlink
-
- @return: Returns result as per method of Object proxy
+ @param method: get any method and create log
+
+ @return: Returns result as per method of Object proxy
"""
pool = pooler.get_pool(db)
+ model_pool = pool.get('ir.model')
+ rule_pool = pool.get('audittrail.rule')
cr = pooler.get_db(db).cursor()
cr.autocommit(True)
logged_uids = []
fct_src = super(audittrail_objects_proxy, self).execute
- def my_fct(db, uid, object, method, *args):
- field = method
+ def my_fct(db, uid, model, method, *args):
rule = False
- obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)])
- for obj_name in pool.obj_list():
- if obj_name == 'audittrail.rule':
+ model_ids = model_pool.search(cr, uid, [('model', '=', model)])
+ model_id = model_ids and model_ids[0] or False
+
+ for model_name in pool.obj_list():
+ if model_name == 'audittrail.rule':
rule = True
if not rule:
- return fct_src(db, uid, object, method, *args)
- if not obj_ids:
- return fct_src(db, uid, object, method, *args)
- rule_ids = pool.get('audittrail.rule').search(cr, uid, [('object_id', '=', obj_ids[0]), ('state', '=', 'subscribed')])
- if not rule_ids:
- return fct_src(db, uid, object, method, *args)
+ return fct_src(db, uid, model, method, *args)
+ if not model_id:
+ return fct_src(db, uid, model, method, *args)
- for thisrule in pool.get('audittrail.rule').browse(cr, uid, rule_ids):
+ rule_ids = rule_pool.search(cr, uid, [('object_id', '=', model_id), ('state', '=', 'subscribed')])
+ if not rule_ids:
+ return fct_src(db, uid, model, method, *args)
+
+ for thisrule in rule_pool.browse(cr, uid, rule_ids):
for user in thisrule.user_id:
logged_uids.append(user.id)
if not logged_uids or uid in logged_uids:
- if field in ('read', 'write', 'create', 'unlink'):
- if getattr(thisrule, 'log_' + field):
- return self.log_fct(db, uid, object, method, fct_src, *args)
- return fct_src(db, uid, object, method, *args)
- res = my_fct(db, uid, object, method, *args)
+ if method in ('read', 'write', 'create', 'unlink'):
+ if getattr(thisrule, 'log_' + method):
+ return self.log_fct(db, uid, model, method, fct_src, *args)
+
+ elif method not in ('default_get','read','fields_view_get','fields_get','search','search_count','name_search','name_get','get','request_get', 'get_sc', 'unlink', 'write', 'create'):
+ if thisrule.log_action:
+ return self.log_fct(db, uid, model, method, fct_src, *args)
+
+ return fct_src(db, uid, model, method, *args)
+ res = my_fct(db, uid, model, method, *args)
cr.close()
return res
+
+ def exec_workflow(self, db, uid, model, method, *args, **argv):
+ pool = pooler.get_pool(db)
+ cr = pooler.get_db(db).cursor()
+ cr.autocommit(True)
+ logged_uids = []
+ fct_src = super(audittrail_objects_proxy, self).exec_workflow
+ field = method
+ rule = False
+ model_pool = pool.get('ir.model')
+ rule_pool = pool.get('audittrail.rule')
+ model_ids = model_pool.search(cr, uid, [('model', '=', model)])
+ for obj_name in pool.obj_list():
+ if obj_name == 'audittrail.rule':
+ rule = True
+ if not rule:
+ cr.close()
+ return super(audittrail_objects_proxy, self).exec_workflow(db, uid, model, method, *args, **argv)
+ if not model_ids:
+ cr.close()
+ return super(audittrail_objects_proxy, self).exec_workflow(db, uid, model, method, *args, **argv)
+
+ rule_ids = rule_pool.search(cr, uid, [('object_id', 'in', model_ids), ('state', '=', 'subscribed')])
+ if not rule_ids:
+ cr.close()
+ return super(audittrail_objects_proxy, self).exec_workflow(db, uid, model, method, *args, **argv)
+
+ for thisrule in rule_pool.browse(cr, uid, rule_ids):
+ for user in thisrule.user_id:
+ logged_uids.append(user.id)
+ if not logged_uids or uid in logged_uids:
+ if thisrule.log_workflow:
+ cr.close()
+ return self.log_fct(db, uid, model, method, fct_src, *args)
+ cr.close()
+ return super(audittrail_objects_proxy, self).exec_workflow(db, uid, model, method, *args, **argv)
+
+ cr.close()
+ return True
+
audittrail_objects_proxy()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/audittrail/audittrail_view.xml b/addons/audittrail/audittrail_view.xml
index a79e6a0b6c0..17b2594d470 100644
--- a/addons/audittrail/audittrail_view.xml
+++ b/addons/audittrail/audittrail_view.xml
@@ -12,12 +12,15 @@
diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py
index 5dcb655e8db..6e7a8edb807 100644
--- a/addons/crm/__openerp__.py
+++ b/addons/crm/__openerp__.py
@@ -69,7 +69,6 @@ Create dashboard for CRM that includes:
'crm_opportunity_data.xml',
'crm_phonecall_data.xml',
],
-
'update_xml': [
'wizard/crm_lead_to_partner_view.xml',
'wizard/crm_lead_to_opportunity_view.xml',
diff --git a/addons/crm/crm_data.xml b/addons/crm/crm_data.xml
index 1873f53f573..e8d5965a4c0 100644
--- a/addons/crm/crm_data.xml
+++ b/addons/crm/crm_data.xml
@@ -5,18 +5,5 @@
Sales Department
Sales
-
-
-
- Check cases rules
- 4
- hours
- -1
-
-
-
-
-
-
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index c1060f3e658..2260a9f0965 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -30,12 +30,10 @@ from crm import crm_case
class crm_lead(osv.osv, crm_case):
""" CRM Lead Case """
-
_name = "crm.lead"
_description = "Lead"
_order = "priority, id desc"
- _inherit = ['res.partner.address']
- _inherits = {'mailgate.thread': 'thread_id'}
+ _inherit = ['mailgate.thread','res.partner.address']
def _compute_day(self, cr, uid, ids, fields, args, context={}):
"""
@@ -112,7 +110,6 @@ and users by email"),
'write_date': fields.datetime('Update Date' , readonly=True),
# Lead fields
- 'thread_id': fields.many2one('mailgate.thread', 'Thread', required=False),
'categ_id': fields.many2one('crm.case.categ', 'Lead Source', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.lead')]"),
@@ -142,6 +139,8 @@ and users by email"),
\nIf the case is in progress the state is set to \'Open\'.\
\nWhen the case is over, the state is set to \'Done\'.\
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
+ 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True),('res_model','=',_name)]),
+ 'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False),('res_model','=',_name)]),
}
_defaults = {
diff --git a/addons/crm/crm_mailgate.py b/addons/crm/crm_mailgate.py
index f2380182aad..d39293e4716 100644
--- a/addons/crm/crm_mailgate.py
+++ b/addons/crm/crm_mailgate.py
@@ -38,9 +38,8 @@ from tools import command_re
class mailgate_thread(osv.osv):
""" mailgate_thread """
-
_name = "mailgate.thread"
- _inherit = "mailgate.thread"
+ _inherit = "mailgate.thread"
def message_new(self, cr, uid, msg, context):
"""
diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py
index e45ee85b31d..f90d1dc896f 100644
--- a/addons/crm/crm_meeting.py
+++ b/addons/crm/crm_meeting.py
@@ -43,9 +43,7 @@ class crm_meeting(osv.osv, crm_case):
_name = 'crm.meeting'
_description = "Meeting"
_order = "id desc"
- _inherit = ["calendar.event"]
- _inherits = {'mailgate.thread': 'thread_id'}
-
+ _inherit = ['mailgate.thread',"calendar.event"]
_columns = {
# From crm.case
'name': fields.char('Summary', size=124, required=True),
@@ -59,7 +57,6 @@ class crm_meeting(osv.osv, crm_case):
'id': fields.integer('ID'),
# Meeting fields
- 'thread_id': fields.many2one('mailgate.thread', 'Thread', required=False),
'categ_id': fields.many2one('crm.case.categ', 'Meeting Type', \
domain="[('object_id.model', '=', 'crm.meeting')]", \
),
@@ -69,6 +66,8 @@ class crm_meeting(osv.osv, crm_case):
'event_id', 'attendee_id', 'Attendees'),
'date_closed': fields.datetime('Closed', readonly=True),
'date_deadline': fields.datetime('Deadline'),
+ 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True),('res_model','=',_name)]),
+ 'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False),('res_model','=',_name)]),
'state': fields.selection([('open', 'Confirmed'),
('draft', 'Unconfirmed'),
('cancel', 'Cancelled'),
diff --git a/addons/crm/crm_phonecall.py b/addons/crm/crm_phonecall.py
index 657360a4206..a94bf5d9b59 100644
--- a/addons/crm/crm_phonecall.py
+++ b/addons/crm/crm_phonecall.py
@@ -31,13 +31,11 @@ class crm_phonecall(osv.osv, crm_case):
_name = "crm.phonecall"
_description = "Phonecall"
_order = "id desc"
- _inherits = {'mailgate.thread': 'thread_id'}
-
+ _inherit = ['mailgate.thread']
_columns = {
# From crm.case
'name': fields.char('Name', size=64),
'active': fields.boolean('Active', required=False),
- 'thread_id': fields.many2one('mailgate.thread', 'Thread', required=False),
'date_action_last': fields.datetime('Last Action', readonly=1),
'date_action_next': fields.datetime('Next Action', readonly=1),
'create_date': fields.datetime('Creation Date' , readonly=True),
@@ -84,6 +82,8 @@ class crm_phonecall(osv.osv, crm_case):
'date_closed': fields.datetime('Closed', readonly=True),
'date': fields.datetime('Date'),
'opportunity_id': fields.many2one ('crm.lead', 'Opportunity'),
+ 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True),('res_model','=',_name)]),
+ 'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False),('res_model','=',_name)]),
}
_defaults = {
diff --git a/addons/crm/process/crm_configuration_process.xml b/addons/crm/process/crm_configuration_process.xml
index 146d76cc8d2..362c8982b96 100644
--- a/addons/crm/process/crm_configuration_process.xml
+++ b/addons/crm/process/crm_configuration_process.xml
@@ -1,91 +1,87 @@
-
+
-
+
-
-
-
-
+
+
+
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
\ No newline at end of file
+
+
diff --git a/addons/crm/report/crm_lead_report.py b/addons/crm/report/crm_lead_report.py
index db9837b5d0c..9061e6a62d4 100644
--- a/addons/crm/report/crm_lead_report.py
+++ b/addons/crm/report/crm_lead_report.py
@@ -109,7 +109,6 @@ class crm_lead_report(osv.osv):
'date_closed': fields.date('Close Date', readonly=True),
'company_id': fields.many2one('res.company', 'Company', readonly=True),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
-
'type':fields.selection([
('lead','Lead'),
('opportunity','Opportunity'),
@@ -148,7 +147,7 @@ class crm_lead_report(osv.osv):
0 as avg_answers,
0.0 as perc_done,
0.0 as perc_cancel,
- (select count(id) from mailgate_message where thread_id=c.id) as email,
+ (select count(id) from mailgate_message where res_id=c.id and res_model='crm.lead') as email,
date_trunc('day',c.create_date) as create_date,
avg(extract('epoch' from (c.date_closed-c.create_date)))/(3600*24) as delay_close,
avg(extract('epoch' from (c.date_deadline - c.date_closed)))/(3600*24) as delay_expected,
diff --git a/addons/crm/wizard/crm_forward_to_partner.py b/addons/crm/wizard/crm_forward_to_partner.py
index 945066506d7..47bc02e0ca1 100644
--- a/addons/crm/wizard/crm_forward_to_partner.py
+++ b/addons/crm/wizard/crm_forward_to_partner.py
@@ -185,23 +185,12 @@ class crm_lead_forward_to_partner(osv.osv_memory):
email_from = this.email_from or False
case_pool._history(cr, uid, [case], _('Forward'), history=True, email=this.email_to, details=body, email_from=email_from)
- flag = False
- if case.section_id and case.section_id.server_id:
- flag = smtp_pool.send_email(
- cr=cr,
- uid=uid,
- server_id=case.section_id.server_id.id,
- emailto=emails,
- subject=this.subject,
- body="%s
" % body,
- )
- else:
- flag = tools.email_send(
- email_from,
- emails,
- this.subject,
- body,
- )
+ flag = tools.email_send(
+ email_from,
+ emails,
+ this.subject,
+ body,
+ )
if this.add_cc:
case_pool.write(cr, uid, case.id, {'email_cc' : case.email_cc and case.email_cc + ', ' + this.email_to or this.email_to})
return {}
diff --git a/addons/crm/wizard/crm_send_email.py b/addons/crm/wizard/crm_send_email.py
index 3588371984b..68930e2b85f 100644
--- a/addons/crm/wizard/crm_send_email.py
+++ b/addons/crm/wizard/crm_send_email.py
@@ -96,11 +96,10 @@ class crm_send_new_email(osv.osv_memory):
else:
hist = hist_obj.browse(cr, uid, res_id)
message_id = hist.message_id
- model = hist.model_id.model
+ model = hist.res_model
model_pool = self.pool.get(model)
- res_ids = model_pool.search(cr, uid, [('thread_id','=', hist.thread_id.id)])
- res_id = res_ids and res_ids[0] or False
- case = model_pool.browse(cr, uid, res_id)
+ case = model_pool.browse(cr, uid, hist.res_id)
+ res_id = hist.res_id
emails = [obj.email_to] + (obj.email_cc or '').split(',')
emails = filter(None, emails)
body = obj.text
@@ -120,15 +119,14 @@ class crm_send_new_email(osv.osv_memory):
if message_id:
x_headers['References'] = "%s" % (message_id)
- flag = False
-
+ print case.section_id
flag = tools.email_send(
email_from,
emails,
obj.subject,
body,
attach=attach,
- reply_to=case.section_id.reply_to,
+ reply_to=case.section_id and case.section_id.reply_to or email_from,
openobject_id=str(case.id),
x_headers=x_headers
)
@@ -196,15 +194,14 @@ class crm_send_new_email(osv.osv_memory):
include_original = context and context.get('include_original', False) or False
res = {}
for hist in hist_obj.browse(cr, uid, res_ids, context=context):
- model = hist.model_id.model
+ model = hist.res_model
# In the case where the crm.case does not exist in the database
if not model:
return {}
model_pool = self.pool.get(model)
- res_ids = model_pool.search(cr, uid, [('thread_id','=', hist.thread_id.id)])
- res_id = res_ids and res_ids[0] or False
+ res_id = hist.res_id or False
case = model_pool.browse(cr, uid, res_id)
if 'email_to' in fields:
res.update({'email_to': case.email_from or hist.email_from or False})
diff --git a/addons/crm/wizard/crm_send_email_view.xml b/addons/crm/wizard/crm_send_email_view.xml
index f56bf5e6a88..c0125014c1a 100644
--- a/addons/crm/wizard/crm_send_email_view.xml
+++ b/addons/crm/wizard/crm_send_email_view.xml
@@ -9,13 +9,15 @@
crm.send.mail
form
-
-
-
+
+
diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py
index e8a14df42a8..b068f121b8a 100644
--- a/addons/crm_claim/crm_claim.py
+++ b/addons/crm_claim/crm_claim.py
@@ -29,10 +29,8 @@ class crm_claim(osv.osv, crm.crm_case):
_name = "crm.claim"
_description = "Claim Cases"
_order = "id desc"
- _inherits = {'mailgate.thread': 'thread_id'}
-
+ _inherit = ['mailgate.thread']
_columns = {
- 'thread_id': fields.many2one('mailgate.thread', 'Thread', required=False),
'id': fields.integer('ID', readonly=True),
'name': fields.char('Name', size=128, required=True),
'active': fields.boolean('Active', required=False),
@@ -90,6 +88,8 @@ class crm_claim(osv.osv, crm.crm_case):
\nIf the case is in progress the state is set to \'Open\'.\
\nWhen the case is over, the state is set to \'Done\'.\
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
+ 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True),('res_model','=',_name)]),
+ 'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False),('res_model','=',_name)]),
}
_defaults = {
diff --git a/addons/crm_fundraising/crm_fundraising.py b/addons/crm_fundraising/crm_fundraising.py
index 356c3baec73..0841fdac998 100644
--- a/addons/crm_fundraising/crm_fundraising.py
+++ b/addons/crm_fundraising/crm_fundraising.py
@@ -28,10 +28,8 @@ class crm_fundraising(osv.osv, crm.crm_case):
_name = "crm.fundraising"
_description = "Fund Raising Cases"
_order = "id desc"
- _inherits = {'mailgate.thread': 'thread_id'}
-
+ _inherit = ['mailgate.thread']
_columns = {
- 'thread_id': fields.many2one('mailgate.thread', 'Thread', required=False),
'id': fields.integer('ID'),
'name': fields.char('Name', size=128, required=True),
'active': fields.boolean('Active', required=False),
@@ -87,6 +85,8 @@ class crm_fundraising(osv.osv, crm.crm_case):
\nIf the case is in progress the state is set to \'Open\'.\
\nWhen the case is over, the state is set to \'Done\'.\
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
+ 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True),('res_model','=',_name)]),
+ 'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False),('res_model','=',_name)]),
}
_defaults = {
diff --git a/addons/crm_helpdesk/crm_helpdesk.py b/addons/crm_helpdesk/crm_helpdesk.py
index d07d2261013..e3f0bd476d9 100644
--- a/addons/crm_helpdesk/crm_helpdesk.py
+++ b/addons/crm_helpdesk/crm_helpdesk.py
@@ -28,10 +28,8 @@ class crm_helpdesk(osv.osv, crm.crm_case):
_name = "crm.helpdesk"
_description = "Helpdesk Cases"
_order = "id desc"
- _inherits = {'mailgate.thread': 'thread_id'}
-
+ _inherit = ['mailgate.thread']
_columns = {
- 'thread_id': fields.many2one('mailgate.thread', 'Thread', required=False),
'id': fields.integer('ID', readonly=True),
'name': fields.char('Name', size=128, required=True),
'active': fields.boolean('Active', required=False),
diff --git a/addons/delivery/delivery.py b/addons/delivery/delivery.py
index 4b87e4c790e..f1fadd81bd4 100644
--- a/addons/delivery/delivery.py
+++ b/addons/delivery/delivery.py
@@ -149,7 +149,7 @@ class delivery_grid_line(osv.osv):
'name': fields.char('Name', size=32, required=True),
'grid_id': fields.many2one('delivery.grid', 'Grid',required=True),
'type': fields.selection([('weight','Weight'),('volume','Volume'),('wv','Weight * Volume'), ('price','Price')], 'Variable', required=True),
- 'operator': fields.selection([('=','='),('<=','<='),('>=','>=')], 'Operator', required=True),
+ 'operator': fields.selection([('==','='),('<=','<='),('>=','>=')], 'Operator', required=True),
'max_value': fields.float('Maximum Value', required=True),
'price_type': fields.selection([('fixed','Fixed'),('variable','Variable')], 'Price Type', required=True),
'variable_factor': fields.selection([('weight','Weight'),('volume','Volume'),('wv','Weight * Volume'), ('price','Price')], 'Variable Factor', required=True),
diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py
index a335e233585..4764887fff5 100644
--- a/addons/hr_recruitment/hr_recruitment.py
+++ b/addons/hr_recruitment/hr_recruitment.py
@@ -57,11 +57,11 @@ class hr_applicant(osv.osv, crm.crm_case):
_name = "hr.applicant"
_description = "Applicant"
_order = "id desc"
- _inherits = {'mailgate.thread': 'thread_id'}
-
+ _inherit = ['mailgate.thread']
_columns = {
- 'thread_id': fields.many2one('mailgate.thread', 'Thread', required=False),
'name': fields.char('Name', size=128, required=True),
+ 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True),('res_model','=',_name)]),
+ 'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False),('res_model','=',_name)]),
'active': fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the case without removing it."),
'description': fields.text('Description'),
'section_id': fields.many2one('crm.case.section', 'Sales Team', \
diff --git a/addons/mail_gateway/mail_gateway.py b/addons/mail_gateway/mail_gateway.py
index 48b3a12aee4..fd7a5753ecf 100644
--- a/addons/mail_gateway/mail_gateway.py
+++ b/addons/mail_gateway/mail_gateway.py
@@ -30,14 +30,10 @@ class mailgate_thread(osv.osv):
'''
_name = 'mailgate.thread'
_description = 'Mailgateway Thread'
- _rec_name = 'thread'
-
_columns = {
- 'thread': fields.char('Thread', size=32, required=False),
- 'message_ids': fields.one2many('mailgate.message', 'thread_id', 'Messages', domain=[('history', '=', True)], required=False),
- 'log_ids': fields.one2many('mailgate.message', 'thread_id', 'Logs', domain=[('history', '=', False)], required=False),
+ 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True)]),
+ 'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False)]),
}
-
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=None, context=None):
"""
@param self: The object pointer
@@ -60,18 +56,16 @@ class mailgate_thread(osv.osv):
if all(isinstance(case_id, (int, long)) for case_id in cases):
cases = self.browse(cr, uid, cases, context=context)
- model_obj = self.pool.get('ir.model')
att_obj = self.pool.get('ir.attachment')
obj = self.pool.get('mailgate.message')
for case in cases:
- model_ids = model_obj.search(cr, uid, [('model', '=', case._name)])
data = {
'name': keyword,
'user_id': uid,
- 'model_id' : model_ids and model_ids[0] or False,
+ 'res_model' : case._name,
+ 'res_id': case.id,
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
- 'thread_id': case.thread_id.id,
'message_id': message_id,
}
attachments = []
@@ -83,7 +77,7 @@ class mailgate_thread(osv.osv):
'name': subject or 'History',
'history': True,
'user_id': uid,
- 'model_id' : model_ids and model_ids[0] or False,
+ 'res_model' : case._name,
'res_id': case.id,
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
'description': details or (hasattr(case, 'description') and case.description or False),
@@ -94,16 +88,11 @@ class mailgate_thread(osv.osv):
(hasattr(case, 'user_id') and case.user_id and case.user_id.address_id and \
case.user_id.address_id.email) or tools.config.get('email_from', False),
'partner_id': hasattr(case, 'partner_id') and (case.partner_id and case.partner_id.id or False) or False,
- 'thread_id': case.thread_id.id,
'message_id': message_id,
'attachment_ids': [(6, 0, attachments)]
}
res = obj.create(cr, uid, data, context)
return True
-
- __history = history = _history
-
-
mailgate_thread()
class mailgate_message(osv.osv):
@@ -112,15 +101,13 @@ class mailgate_message(osv.osv):
'''
_name = 'mailgate.message'
_description = 'Mailgateway Message'
- _order = 'date desc'
-
+ _order = 'id desc'
_columns = {
'name':fields.char('Message', size=64),
- 'model_id': fields.many2one('ir.model', 'Model'),
+ 'res_model': fields.char('Object Name', size=128),
'res_id': fields.integer('Resource ID'),
- 'thread_id':fields.many2one('mailgate.thread', 'Thread'),
'date': fields.datetime('Date'),
- 'history': fields.boolean('Is History?', required=False),
+ 'history': fields.boolean('Is History?'),
'user_id': fields.many2one('res.users', 'User Responsible', readonly=True),
'message': fields.text('Description'),
'email_from': fields.char('Email From', size=84),
@@ -135,5 +122,3 @@ class mailgate_message(osv.osv):
mailgate_message()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mail_gateway/scripts/openerp_mailgate/openerp_mailgate.py b/addons/mail_gateway/scripts/openerp_mailgate/openerp_mailgate.py
index c4cad98b046..b9a9eefee15 100755
--- a/addons/mail_gateway/scripts/openerp_mailgate/openerp_mailgate.py
+++ b/addons/mail_gateway/scripts/openerp_mailgate/openerp_mailgate.py
@@ -127,13 +127,11 @@ class rpc_proxy(object):
return self.rpc.execute(self.dbname, self.user_id, self.passwd, *request, **kwargs)
class email_parser(object):
- def __init__(self, uid, password, model, email, email_default, dbname, host, port):
+ def __init__(self, uid, password, model, email, email_default, dbname, host, port):
self.rpc = rpc_proxy(uid, password, host=host, port=port, dbname=dbname)
try:
- self.model_id = int(model)
self.model = str(model)
except:
- self.model_id = self.rpc('ir.model', 'search', [('model', '=', model)])[0]
self.model = str(model)
self.email = email
self.email_default = email_default
@@ -188,7 +186,7 @@ class email_parser(object):
values = {
'message_ids' : [
(0, 0, {
- 'model_id' : self.rpc('ir.model', 'search', [('name', '=', self.model)])[0],
+ 'res_model' : self.model,
'date' : time.strftime('%Y-%m-%d %H:%M:%S'),
'description' : message['body'],
'email_from' : msg_from,
@@ -200,8 +198,6 @@ class email_parser(object):
)
]
}
- thread_id = self.rpc('mailgate.thread', 'create', values)
- data['thread_id'] = thread_id
oid = self.rpc(self.model, 'create', data)
attachments = message['attachment']
@@ -216,7 +212,7 @@ class email_parser(object):
}
self.rpc('ir.attachment', 'create', data_attach)
- return (oid, thread_id,)
+ return (oid, )
def msg_body_get(self, msg):
message = {
@@ -320,8 +316,7 @@ class email_parser(object):
> create_message(id, msg['From'], msg['To'], 'Send', message['body'])
"""
values = {
- 'thread_id' : self.rpc(self.model, 'read', [oid], ['thread_id'])[0]['thread_id'][0],
- 'model_id' : self.rpc('ir.model', 'search', [('name', '=', self.model)])[0],
+ 'res_model' : self.model,
'res_id' : oid,
'date' : time.strftime('%Y-%m-%d %H:%M:%S'),
'description' : body,
@@ -390,13 +385,7 @@ class email_parser(object):
logging.info("email: %s -> %s -- %s", msg['From'], self.email, msg['Subject'])
(case_id, emails) = self.msg_test(msg, case_str)
- thread_id = None
if case_id:
- values = self.rpc(self.model, 'read', [case_id], ['thread_id'])
- if values:
- thread_id = values[0]['thread_id'][0]
- emails = emails[str(thread_id)]
-
user_email = filter(None, emails['user_email'])[0]
if user_email and self.email_get(user_email) == self.email_get(self._decode_header(msg['From'])):
@@ -404,13 +393,12 @@ class email_parser(object):
else:
self.msg_partner(msg, case_id)
else:
- case_id, thread_id = self.msg_new(msg)
+ case_id = self.msg_new(msg)
subject = self._decode_header(msg['Subject'])
msg['Subject'] = "[%s] %s" % (case_id, subject,)
msg['Message-Id'] = "<%s-openerpcrm-%s@%s>" % (time.time(), case_id, socket.gethostname(),)
logging.info(" case: %r", case_id)
- logging.info(" thread: %r", thread_id)
values = self.rpc(self.model, 'emails_get', [case_id])
@@ -431,7 +419,7 @@ class email_parser(object):
a = self._decode_header(msg['Subject'])
msg['Subject'] = '[OpenERP-CaseError] ' + a
self.msg_send(msg, self.email_default.split(','))
- return case_id, thread_id, emails
+ return case_id, emails
if __name__ == '__main__':
parser = optparse.OptionParser(usage='usage: %prog [options]', version='%prog v1.0')
diff --git a/addons/procurement/company.py b/addons/procurement/company.py
index ce39ca9a684..f6d1e69d122 100644
--- a/addons/procurement/company.py
+++ b/addons/procurement/company.py
@@ -28,11 +28,11 @@ class company(osv.osv):
help="This is the time frame analysed by the scheduler when "\
"computing procurements. All procurements that are not between "\
"today and today+range are skipped for futur computation."),
- }
+ }
_defaults = {
- 'schedule_range': lambda *a: 80.0,
- }
+ 'schedule_range': 80.0,
+ }
+
company()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py
index d10cc89234c..45db8854e0d 100644
--- a/addons/procurement/procurement.py
+++ b/addons/procurement/procurement.py
@@ -464,7 +464,7 @@ class stock_warehouse_orderpoint(osv.osv):
"""
_name = "stock.warehouse.orderpoint"
_description = "Minimum Inventory Rule"
-
+
_columns = {
'name': fields.char('Name', size=32, required=True),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the orderpoint without removing it."),
@@ -485,17 +485,17 @@ class stock_warehouse_orderpoint(osv.osv):
'company_id': fields.many2one('res.company','Company',required=True),
}
_defaults = {
- 'active': lambda *a: 1,
- 'logic': lambda *a: 'max',
- 'qty_multiple': lambda *a: 1,
+ 'active': 1,
+ 'logic': 'max',
+ 'qty_multiple': 1,
'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'stock.orderpoint') or '',
'product_uom': lambda sel, cr, uid, context: context.get('product_uom', False),
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.warehouse.orderpoint', context=c)
}
_sql_constraints = [
('qty_multiple_check', 'CHECK( qty_multiple > 0 )', _('Qty Multiple must be greater than zero.')),
- ]
-
+ ]
+
def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context={}):
""" Finds location id for changed warehouse.
@param warehouse_id: Changed id of warehouse.
@@ -506,7 +506,7 @@ class stock_warehouse_orderpoint(osv.osv):
v = {'location_id': w.lot_stock_id.id}
return {'value': v}
return {}
-
+
def onchange_product_id(self, cr, uid, ids, product_id, context={}):
""" Finds UoM for changed product.
@param product_id: Changed id of product.
@@ -517,7 +517,7 @@ class stock_warehouse_orderpoint(osv.osv):
v = {'product_uom': prod.uom_id.id}
return {'value': v}
return {}
-
+
def copy(self, cr, uid, id, default=None,context={}):
if not default:
default = {}
@@ -525,6 +525,6 @@ class stock_warehouse_orderpoint(osv.osv):
'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.orderpoint') or '',
})
return super(stock_warehouse_orderpoint, self).copy(cr, uid, id, default, context)
-
+
stock_warehouse_orderpoint()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/procurement/schedulers.py b/addons/procurement/schedulers.py
index 36215dcdc73..dc66d9e3e8b 100644
--- a/addons/procurement/schedulers.py
+++ b/addons/procurement/schedulers.py
@@ -19,12 +19,12 @@
#
##############################################################################
+import time
+from mx import DateTime
+
from osv import osv
import netsvc
import pooler
-from mx import DateTime
-import time
-
class procurement_order(osv.osv):
_inherit = 'procurement.order'
@@ -37,7 +37,7 @@ class procurement_order(osv.osv):
context = {}
if use_new_cursor:
- cr = pooler.get_db(use_new_cursor).cursor()
+ cr = pooler.get_db(use_new_cursor).cursor()
wf_service = netsvc.LocalService("workflow")
procurement_obj = self.pool.get('procurement.order')
@@ -172,7 +172,7 @@ class procurement_order(osv.osv):
if not context:
context = {}
if use_new_cursor:
- cr = pooler.get_db(use_new_cursor).cursor()
+ cr = pooler.get_db(use_new_cursor).cursor()
orderpoint_obj = self.pool.get('stock.warehouse.orderpoint')
location_obj = self.pool.get('stock.location')
procurement_obj = self.pool.get('procurement.order')
@@ -196,7 +196,7 @@ class procurement_order(osv.osv):
qty = max(op.product_min_qty, op.product_max_qty)-prods
reste = qty % op.qty_multiple
if reste > 0:
- qty += op.qty_multiple - reste
+ qty += op.qty_multiple - reste
newdate = DateTime.now() + DateTime.RelativeDateTime(
days = int(op.product_id.seller_delay))
if op.product_id.supply_method == 'buy':
@@ -238,6 +238,7 @@ class procurement_order(osv.osv):
cr.commit()
cr.close()
return {}
+
procurement_order()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/procurement/wizard/orderpoint_procurement.py b/addons/procurement/wizard/orderpoint_procurement.py
index ee3207833d3..cec7d13554d 100644
--- a/addons/procurement/wizard/orderpoint_procurement.py
+++ b/addons/procurement/wizard/orderpoint_procurement.py
@@ -30,36 +30,36 @@ from osv import fields,osv
class procurement_compute(osv.osv_memory):
_name = 'procurement.orderpoint.compute'
_description = 'Automatic Order Point'
-
+
_columns = {
- 'automatic': fields.boolean('Automatic Orderpoint', help='If the stock of a product is under 0, it will act like an orderpoint'),
+ 'automatic': fields.boolean('Automatic Orderpoint', help='If the stock of a product is under 0, it will act like an orderpoint'),
}
_defaults = {
- 'automatic' : lambda *a: False,
+ 'automatic': False,
}
-
+
def _procure_calculation_orderpoint(self, cr, uid, ids, context):
- """
+ """
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
- @param ids: List of IDs selected
- @param context: A standard dictionary
- """
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+ """
proc_obj = self.pool.get('procurement.order')
for proc in self.browse(cr, uid, ids):
proc_obj._procure_orderpoint_confirm(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname, context=context)
-
+
return {}
-
+
def procure_calculation(self, cr, uid, ids, context):
- """
+ """
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
- @param ids: List of IDs selected
- @param context: A standard dictionary
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
"""
threaded_calculation = threading.Thread(target=self._procure_calculation_orderpoint, args=(cr, uid, ids, context))
threaded_calculation.start()
diff --git a/addons/procurement/wizard/schedulers_all.py b/addons/procurement/wizard/schedulers_all.py
index 8b1be81d276..9b2ac6d59b8 100644
--- a/addons/procurement/wizard/schedulers_all.py
+++ b/addons/procurement/wizard/schedulers_all.py
@@ -26,43 +26,41 @@ from osv import osv, fields
class procurement_compute_all(osv.osv_memory):
_name = 'procurement.order.compute.all'
_description = 'Compute all schedulers'
-
+
_columns = {
'automatic': fields.boolean('Automatic orderpoint',help='Triggers an automatic procurement for all products that have a virtual stock under 0. You should probably not use this option, we suggest using a MTO configuration on products.'),
}
-
+
_defaults ={
'automatic': lambda *a: False,
}
-
+
def _procure_calculation_all(self, cr, uid, ids, context):
- """
+ """
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
- @param ids: List of IDs selected
- @param context: A standard dictionary
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
"""
proc_obj = self.pool.get('procurement.order')
for proc in self.browse(cr, uid, ids):
proc_obj.run_scheduler(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname,\
- context=context)
+ context=context)
return {}
def procure_calculation(self, cr, uid, ids, context):
- """
+ """
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
- @param ids: List of IDs selected
- @param context: A standard dictionary
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
"""
threaded_calculation = threading.Thread(target=self._procure_calculation_all, args=(cr, uid, ids, context))
threaded_calculation.start()
return {}
-
+
procurement_compute_all()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py
index c763306e602..675818214a5 100644
--- a/addons/project_issue/project_issue.py
+++ b/addons/project_issue/project_issue.py
@@ -36,7 +36,7 @@ class project_issue(osv.osv, crm.crm_case):
_name = "project.issue"
_description = "Project Issue"
_order = "priority, id desc"
- _inherits = {'mailgate.thread': 'thread_id'}
+ _inherit = ['mailgate.thread']
def case_open(self, cr, uid, ids, *args):
"""
@@ -121,7 +121,6 @@ class project_issue(osv.osv, crm.crm_case):
return res
_columns = {
- 'thread_id': fields.many2one('mailgate.thread', 'Thread', required=False),
'id': fields.integer('ID'),
'name': fields.char('Name', size=128, required=True),
'active': fields.boolean('Active', required=False),
@@ -179,6 +178,8 @@ class project_issue(osv.osv, crm.crm_case):
method=True, multi='working_days_open', type="float", store=True),
'working_hours_close': fields.function(_compute_day, string='Working Hours to Close the Issue', \
method=True, multi='working_days_close', type="float", store=True),
+ 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True),('res_model','=',_name)]),
+ 'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False),('res_model','=',_name)]),
}
def _get_project(self, cr, uid, context):
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index 9fbdac14a23..acb2bf079e5 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -205,7 +205,8 @@ class sale_order(osv.osv):
return result.keys()
_columns = {
- 'name': fields.char('Order Reference', size=64, required=True, select=True, help="unique number of the sale order,computed automatically when the sale order is created"),
+ 'name': fields.char('Order Reference', size=64, required=True,
+ readonly=True, states={'draft': [('readonly', False)]}, select=True),
'shop_id': fields.many2one('sale.shop', 'Shop', required=True, readonly=True, states={'draft': [('readonly', False)]}),
'origin': fields.char('Source document', size=64, help="Reference of the document that generated this sale order request."),
'client_order_ref': fields.char('Customer Reference', size=64),
@@ -429,7 +430,6 @@ class sale_order(osv.osv):
for preline in preinv.invoice_line:
inv_line_id = self.pool.get('account.invoice.line').copy(cr, uid, preline.id, {'invoice_id': False, 'price_unit': -preline.price_unit})
lines.append(inv_line_id)
-
inv = {
'name': order.client_order_ref or order.name,
'origin': order.name,
@@ -462,7 +462,7 @@ class sale_order(osv.osv):
invoices = {}
invoice_ids = []
picking_obj = self.pool.get('stock.picking')
-
+ invoice = self.pool.get('account.invoice')
if context is None:
context = {}
# If date was specified, use it as date invoiced, usefull when invoices are generated this month and put the
@@ -477,7 +477,6 @@ class sale_order(osv.osv):
created_lines = self.pool.get('sale.order.line').invoice_line_create(cr, uid, lines)
if created_lines:
invoices.setdefault(o.partner_id.id, []).append((o, created_lines))
-
if not invoices:
for o in self.browse(cr, uid, ids):
for i in o.invoice_ids:
@@ -486,11 +485,14 @@ class sale_order(osv.osv):
for val in invoices.values():
if grouped:
res = self._make_invoice(cr, uid, val[0][0], reduce(lambda x,y: x + y, [l for o,l in val], []), context=context)
+ invoice_ref = ''
for o, l in val:
+ invoice_ref += o.name + '|'
self.write(cr, uid, [o.id], {'state': 'progress'})
if o.order_policy == 'picking':
picking_obj.write(cr, uid, map(lambda x: x.id, o.picking_ids), {'invoice_state': 'invoiced'})
cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%s,%s)', (o.id, res))
+ invoice.write(cr, uid, [res], {'origin': invoice_ref, 'name': invoice_ref})
else:
for order, il in val:
res = self._make_invoice(cr, uid, order, il, context=context)
diff --git a/addons/sale/test/advance_invoice.yml b/addons/sale/test/advance_invoice.yml
index 870b3ec0428..8b93b031d39 100644
--- a/addons/sale/test/advance_invoice.yml
+++ b/addons/sale/test/advance_invoice.yml
@@ -65,7 +65,6 @@
-
!record {model: account.account, id: account_account_receivable0}:
code: AR
- company_id: base.main_company
currency_mode: current
name: Receivable
parent_id: account_account_minimalchart0
@@ -79,7 +78,6 @@
-
!record {model: account.account, id: account_account_cash0}:
code: C
- company_id: base.main_company
currency_mode: current
name: Cash
parent_id: account_account_minimalchart0
@@ -142,7 +140,6 @@
-
!record {model: account.journal, id: account_journal_bankjournal0}:
code: BNK
- company_id: base.main_company
default_credit_account_id: account_account_cash0
default_debit_account_id: account_account_cash0
name: Bank Journal
diff --git a/addons/sale/test/prepaid_sale_order.yml b/addons/sale/test/prepaid_sale_order.yml
index 03f5ddf8aae..ce344bb23ae 100644
--- a/addons/sale/test/prepaid_sale_order.yml
+++ b/addons/sale/test/prepaid_sale_order.yml
@@ -78,7 +78,6 @@
-
!record {model: account.account, id: account_account_cash0}:
code: C
- company_id: base.main_company
currency_mode: current
name: Cash
parent_id: account_account_minimalchart0
diff --git a/addons/sale/test/so_make_invoice.yml b/addons/sale/test/so_make_invoice.yml
index e34b11ffb2b..c5860ed875e 100644
--- a/addons/sale/test/so_make_invoice.yml
+++ b/addons/sale/test/so_make_invoice.yml
@@ -65,7 +65,6 @@
-
!record {model: account.account, id: account_account_receivable0}:
code: AR
- company_id: base.main_company
currency_mode: current
name: Receivable
parent_id: account_account_minimalchart0
@@ -79,7 +78,6 @@
-
!record {model: account.account, id: account_account_cash0}:
code: C
- company_id: base.main_company
currency_mode: current
name: Cash
parent_id: account_account_minimalchart0
@@ -142,7 +140,6 @@
-
!record {model: account.journal, id: account_journal_bankjournal0}:
code: BNK
- company_id: base.main_company
default_credit_account_id: account_account_cash0
default_debit_account_id: account_account_cash0
name: Bank Journal
diff --git a/addons/sale/test/so_make_line_invoice.yml b/addons/sale/test/so_make_line_invoice.yml
index de5782c8517..c09e4bf2c11 100644
--- a/addons/sale/test/so_make_line_invoice.yml
+++ b/addons/sale/test/so_make_line_invoice.yml
@@ -65,7 +65,6 @@
-
!record {model: account.account, id: account_account_receivable0}:
code: AR
- company_id: base.main_company
currency_mode: current
name: Receivable
parent_id: account_account_minimalchart0
@@ -79,7 +78,6 @@
-
!record {model: account.account, id: account_account_cash0}:
code: C
- company_id: base.main_company
currency_mode: current
name: Cash
parent_id: account_account_minimalchart0
@@ -142,7 +140,6 @@
-
!record {model: account.journal, id: account_journal_bankjournal0}:
code: BNK
- company_id: base.main_company
default_credit_account_id: account_account_cash0
default_debit_account_id: account_account_cash0
name: Bank Journal
diff --git a/addons/sale/wizard/sale_make_invoice.py b/addons/sale/wizard/sale_make_invoice.py
index 0ce2705ac77..850fc2e25d4 100644
--- a/addons/sale/wizard/sale_make_invoice.py
+++ b/addons/sale/wizard/sale_make_invoice.py
@@ -26,7 +26,7 @@ class sale_make_invoice(osv.osv_memory):
_name = "sale.make.invoice"
_description = "Sale Make Invoice"
_columns = {
- 'grouped': fields.boolean('Group the invoices'),
+ 'grouped': fields.boolean('Group the invoices', help='Check the box to group the invoices for the same customers'),
'invoice_date':fields.date('Invoice Date'),
}
_default = {
@@ -50,11 +50,11 @@ class sale_make_invoice(osv.osv_memory):
for o in order_obj.browse(cr, uid, context.get(('active_ids'),[]), context):
for i in o.invoice_ids:
newinv.append(i.id)
-
+
mod_obj =self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
- id = mod_obj.read(cr, uid, result, ['res_id'])
+ id = mod_obj.read(cr, uid, result, ['res_id'])
return {
'domain': "[('id','in', ["+','.join(map(str,newinv))+"])]",
'name': 'Invoices',
@@ -64,7 +64,7 @@ class sale_make_invoice(osv.osv_memory):
'view_id': False,
'context': "{'type':'out_refund'}",
'type': 'ir.actions.act_window',
- 'search_view_id': id['id']
+ 'search_view_id': id['res_id']
}
sale_make_invoice()
diff --git a/addons/sale/wizard/sale_make_invoice.xml b/addons/sale/wizard/sale_make_invoice.xml
index ade720be1f4..e019786c40d 100644
--- a/addons/sale/wizard/sale_make_invoice.xml
+++ b/addons/sale/wizard/sale_make_invoice.xml
@@ -6,14 +6,15 @@
sale.make.invoice
form
-
+
diff --git a/addons/sale_delivery_report/__openerp__.py b/addons/sale_delivery_report/__openerp__.py
index a5f6cc437fd..dfcbe1acb29 100644
--- a/addons/sale_delivery_report/__openerp__.py
+++ b/addons/sale_delivery_report/__openerp__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,7 +15,7 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+# along with this program. If not, see .
#
##############################################################################
@@ -29,7 +29,7 @@
'depends': ['sale', 'delivery'],
'init_xml': [],
'update_xml': [
- 'delivery_report.xml'
+ 'sale_delivery_report.xml'
],
'demo_xml': [],
'installable': True,
diff --git a/addons/sale_delivery_report/delivery_report.xml b/addons/sale_delivery_report/sale_delivery_report.xml
similarity index 100%
rename from addons/sale_delivery_report/delivery_report.xml
rename to addons/sale_delivery_report/sale_delivery_report.xml
diff --git a/addons/sale_journal/sale_journal.py b/addons/sale_journal/sale_journal.py
index 41d770d5760..63bef68b4d6 100644
--- a/addons/sale_journal/sale_journal.py
+++ b/addons/sale_journal/sale_journal.py
@@ -127,6 +127,7 @@ class picking_journal(osv.osv):
'state': fields.selection([
('draft','Draft'),
('open','Open'),
+ ('cancel','Cancel'),
('done','Done'),
], 'Creation date', required=True, readonly=True),
'note': fields.text('Note'),
@@ -138,6 +139,7 @@ class picking_journal(osv.osv):
'state': lambda self,cr,uid,context: 'draft',
}
def button_picking_cancel(self, cr, uid, ids, context={}):
+ self.write(cr, uid, ids, {'state':'cancel'})
for id in ids:
pick_ids = self.pool.get('stock.picking').search(cr, uid, [('journal_id','=',id)])
for pickid in pick_ids:
@@ -177,7 +179,7 @@ res_partner()
class picking(osv.osv):
_inherit="stock.picking"
_columns = {
- 'journal_id': fields.many2one('sale_journal.picking.journal', 'Journal'),
+ 'journal_id': fields.many2one('sale_journal.picking.journal', 'Journal', domain=[('state','!=', 'done')]),
'sale_journal_id': fields.many2one('sale_journal.sale.journal', 'Sale Journal'),
'invoice_type_id': fields.many2one('sale_journal.invoice.type', 'Invoice Type', readonly=True)
}
@@ -186,7 +188,7 @@ picking()
class sale(osv.osv):
_inherit="sale.order"
_columns = {
- 'journal_id': fields.many2one('sale_journal.sale.journal', 'Journal'),
+ 'journal_id': fields.many2one('sale_journal.sale.journal', 'Journal', domain=[('state','!=', 'done')]),
'invoice_type_id': fields.many2one('sale_journal.invoice.type', 'Invoice Type')
}
def action_ship_create(self, cr, uid, ids, *args):
diff --git a/addons/sale_journal/sale_journal_view.xml b/addons/sale_journal/sale_journal_view.xml
index 08d197e3441..052d7e09777 100644
--- a/addons/sale_journal/sale_journal_view.xml
+++ b/addons/sale_journal/sale_journal_view.xml
@@ -113,13 +113,16 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -131,6 +134,7 @@
sale_journal.sale.journal
form
tree,form
+ {'search_default_user_id':uid}
@@ -386,7 +390,7 @@
-
+
@@ -417,13 +421,15 @@
-
-
+
+
+
+
-
-
-
-
+
+
+
+
@@ -436,6 +442,7 @@
sale_journal.picking.journal
form
tree,form
+ {'search_default_user_id':uid}
diff --git a/addons/sale_margin/sale_margin.py b/addons/sale_margin/sale_margin.py
index c390bf769e2..37da229733a 100644
--- a/addons/sale_margin/sale_margin.py
+++ b/addons/sale_margin/sale_margin.py
@@ -26,6 +26,16 @@ class sale_order_line(osv.osv):
_name = "sale.order.line"
_inherit = "sale.order.line"
+ def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
+ uom=False, qty_uos=0, uos=False, name='', partner_id=False,
+ lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False):
+ res = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty=qty,
+ uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,
+ lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag)
+ purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price
+ res['value'].update({'purchase_price':purchase_price})
+ return res
+
def _product_margin(self, cr, uid, ids, field_name, arg, context=None):
res = {}
for line in self.browse(cr, uid, ids):
@@ -38,7 +48,7 @@ class sale_order_line(osv.osv):
return res
_columns = {
- 'margin': fields.function(_product_margin, method=True, string='Margin', store=True),
+ 'margin': fields.function(_product_margin, method=True, string='Margin', store={}),
'purchase_price': fields.float('Cost Price', digits=(16,2))
}
diff --git a/addons/sale_margin/sale_margin_view.xml b/addons/sale_margin/sale_margin_view.xml
index 1b46a850df8..0b470ec824c 100644
--- a/addons/sale_margin/sale_margin_view.xml
+++ b/addons/sale_margin/sale_margin_view.xml
@@ -13,6 +13,31 @@
+
+
+ sale.order.line.margin.view.form
+ form
+ sale.order
+
+
+
+
+
+
+
+
+
+ sale.order.line.tree.margin.view.form
+ form
+ sale.order
+
+
+
+
+
+
+
+
sale.order.margin.view.tree
tree
@@ -24,7 +49,7 @@
-
+
sale.order.margin.line.view.tree
tree
@@ -42,7 +67,7 @@
picking.margin.view.form
form
stock.picking
-
+