Rucha (Open ERP) has proposed merging
lp:~openerp-dev/openobject-server/trunk-temporal-db-shallow-copy-rpa into
lp:~openerp-dev/openobject-server/trunk-temporal-db.
Requested reviews:
qdp (OpenERP) (qdp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-temporal-db-shallow-copy-rpa/+merge/66070
Added shallow_copy in orm(this method will not copy o2m,m2m fields while
copying the temporal record)
--
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-temporal-db-shallow-copy-rpa/+merge/66070
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-server/trunk-temporal-db.
=== modified file 'openerp/osv/orm.py'
--- openerp/osv/orm.py 2011-06-22 13:53:44 +0000
+++ openerp/osv/orm.py 2011-06-28 05:35:47 +0000
@@ -4471,6 +4471,29 @@
self.copy_translations(cr, uid, id, new_id, context)
return new_id
+ def shallow_copy(self, cr, uid, id, default=None, context=None):
+ """
+ This method Duplicates record of given id without copying many2many and one2many fields related to that record
+
+ :param cr: database cursor
+ :param uid: current user id
+ :param id: id of the record to copy
+ :param default: dictionary of field values to override in the original values of the copied record, e.g: ``{'field_name': overriden_value, ...}``
+ :type default: dictionary
+ :param context: context arguments, like lang, time zone
+ :type context: dictionary
+ :return: True
+ """
+ if context is None:
+ context = {}
+ if default is None:
+ default = {}
+ for field in self._columns:
+ if self._columns[field]._type in ('one2many', 'many2many'):
+ # If type of the field is o2m or m2m, assign blank values in default
+ default.update({field: []})
+ return self.copy(cr, uid, id, default=default, context=context)
+
def exists(self, cr, uid, ids, context=None):
if type(ids) in (int, long):
ids = [ids]
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp