[MERGE] forward port of branch 7.0 up to revid 10037 mat@openerp.com-20140507133552...
authorChristophe Simonis <chs@openerp.com>
Wed, 7 May 2014 15:33:48 +0000 (17:33 +0200)
committerChristophe Simonis <chs@openerp.com>
Wed, 7 May 2014 15:33:48 +0000 (17:33 +0200)
bzr revid: chs@openerp.com-20140507153348-g2qw61dkxvps13br

addons/account/account_move_line.py
addons/auth_oauth/auth_oauth_view.xml
addons/hr/hr.py
addons/hr_timesheet_sheet/hr_timesheet_sheet.py
addons/mail/mail_thread.py
addons/mail/res_config.py
addons/stock/stock.py
addons/warning/warning.py

index 640ac90..be41b06 100644 (file)
@@ -1026,7 +1026,7 @@ class account_move_line(osv.osv):
             if opening_reconciliation:
                 obj_move_rec.write(cr, uid, unlink_ids, {'opening_reconciliation': False})
             obj_move_rec.unlink(cr, uid, unlink_ids)
-            if all_moves:
+            if len(all_moves) >= 2:
                 obj_move_line.reconcile_partial(cr, uid, all_moves, 'auto',context=context)
         return True
 
index ffc3975..5c889d3 100644 (file)
@@ -11,6 +11,7 @@
                             <field name="name" />
                             <field name="client_id" />
                             <field name="enabled" />
+                            <field name="body" />
                         </group>
                         <group>
                             <field name="auth_endpoint" />
index 6d46620..a47ec92 100644 (file)
@@ -226,7 +226,13 @@ class hr_employee(osv.osv):
         'image': _get_default_image,
         'color': 0,
     }
-
+    
+    def copy_data(self, cr, uid, ids, default=None, context=None):
+        if default is None:
+            default = {}
+        default.update({'child_ids': False})
+        return super(hr_employee, self).copy_data(cr, uid, ids, default, context=context)
+        
     def create(self, cr, uid, data, context=None):
         if context is None:
             context = {}
@@ -380,18 +386,23 @@ class hr_department(osv.osv):
             res.append((record['id'], name))
         return res
 
-    def copy(self, cr, uid, ids, default=None, context=None):
+    def copy_data(self, cr, uid, ids, default=None, context=None):
         if default is None:
             default = {}
-        default = default.copy()
         default['member_ids'] = []
-        return super(hr_department, self).copy(cr, uid, ids, default, context=context)
+        return super(hr_department, self).copy_data(cr, uid, ids, default, context=context)
 
 
 class res_users(osv.osv):
     _name = 'res.users'
     _inherit = 'res.users'
 
+    def copy_data(self, cr, uid, ids, default=None, context=None):
+        if default is None:
+            default = {}
+        default.update({'employee_ids': False})
+        return super(res_users, self).copy_data(cr, uid, ids, default, context=context)
+    
     _columns = {
         'employee_ids': fields.one2many('hr.employee', 'user_id', 'Related employees'),
     }
index bb42768..83f74e4 100644 (file)
@@ -402,6 +402,9 @@ class hr_attendance(osv.osv):
             employee = employee_obj.browse(cr, uid, employee_id, context=context)
             tz = employee.user_id.partner_id.tz
 
+        if not date:
+            date = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
+
         att_tz = timezone(tz or 'utc')
 
         attendance_dt = datetime.strptime(date, DEFAULT_SERVER_DATETIME_FORMAT)
index 43920ad..fe96029 100644 (file)
@@ -420,14 +420,14 @@ class mail_thread(osv.AbstractModel):
         fol_obj.unlink(cr, SUPERUSER_ID, fol_ids, context=context)
         return res
 
-    def copy(self, cr, uid, id, default=None, context=None):
+    def copy_data(self, cr, uid, id, default=None, context=None):
         # avoid tracking multiple temporary changes during copy
         context = dict(context or {}, mail_notrack=True)
 
         default = default or {}
         default['message_ids'] = []
         default['message_follower_ids'] = []
-        return super(mail_thread, self).copy(cr, uid, id, default=default, context=context)
+        return super(mail_thread, self).copy_data(cr, uid, id, default=default, context=context)
 
     #------------------------------------------------------
     # Automatically log tracked fields
index c19eb4a..2c94b43 100644 (file)
@@ -34,14 +34,14 @@ class project_configuration(osv.TransientModel):
     }
 
     def get_default_alias_domain(self, cr, uid, ids, context=None):
-        alias_domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context)
-        if not alias_domain:
+        alias_domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", default=None, context=context)
+        if alias_domain is None:
             domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "web.base.url", context=context)
             try:
                 alias_domain = urlparse.urlsplit(domain).netloc.split(':')[0]
             except Exception:
                 pass
-        return {'alias_domain': alias_domain}
+        return {'alias_domain': alias_domain or False}
 
     def set_alias_domain(self, cr, uid, ids, context=None):
         config_parameters = self.pool.get("ir.config_parameter")
index 5276e7f..efb8582 100644 (file)
@@ -2307,7 +2307,9 @@ class stock_move(osv.osv):
 
         # if product is set to average price and a specific value was entered in the picking wizard,
         # we use it
-        if move.product_id.cost_method == 'average' and move.price_unit:
+        if move.location_dest_id.usage != 'internal' and move.product_id.cost_method == 'average':
+            reference_amount = qty * move.product_id.standard_price
+        elif move.product_id.cost_method == 'average' and move.price_unit:
             reference_amount = qty * move.price_unit
             reference_currency_id = move.price_currency_id.id or reference_currency_id
 
index d582478..5393164 100644 (file)
@@ -62,14 +62,14 @@ class sale_order(osv.osv):
         message = False
         partner = self.pool.get('res.partner').browse(cr, uid, part, context=context)
         if partner.sale_warn != 'no-message':
-            if partner.sale_warn == 'block':
-                raise osv.except_osv(_('Alert for %s!') % (partner.name), partner.sale_warn_msg)
             title =  _("Warning for %s") % partner.name
             message = partner.sale_warn_msg
             warning = {
                     'title': title,
                     'message': message,
             }
+            if partner.sale_warn == 'block':
+                return {'value': {'partner_id': False}, 'warning': warning}
 
         result =  super(sale_order, self).onchange_partner_id(cr, uid, ids, part, context=context)
 
@@ -90,14 +90,15 @@ class purchase_order(osv.osv):
         message = False
         partner = self.pool.get('res.partner').browse(cr, uid, part)
         if partner.purchase_warn != 'no-message':
-            if partner.purchase_warn == 'block':
-                raise osv.except_osv(_('Alert for %s!') % (partner.name), partner.purchase_warn_msg)
             title = _("Warning for %s") % partner.name
             message = partner.purchase_warn_msg
             warning = {
                 'title': title,
                 'message': message
                 }
+            if partner.purchase_warn == 'block':
+                return {'value': {'partner_id': False}, 'warning': warning}
+
         result =  super(purchase_order, self).onchange_partner_id(cr, uid, ids, part)
 
         if result.get('warning',False):
@@ -123,15 +124,16 @@ class account_invoice(osv.osv):
         message = False
         partner = self.pool.get('res.partner').browse(cr, uid, partner_id)
         if partner.invoice_warn != 'no-message':
-            if partner.invoice_warn == 'block':
-                raise osv.except_osv(_('Alert for %s!') % (partner.name), partner.invoice_warn_msg)
-
             title = _("Warning for %s") % partner.name
             message = partner.invoice_warn_msg
             warning = {
                 'title': title,
                 'message': message
                 }
+
+            if partner.invoice_warn == 'block':
+                return {'value': {'partner_id': False}, 'warning': warning}
+
         result =  super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner_id,
             date_invoice=date_invoice, payment_term=payment_term, 
             partner_bank_id=partner_bank_id, company_id=company_id)
@@ -154,14 +156,15 @@ class stock_picking(osv.osv):
         title = False
         message = False
         if partner.picking_warn != 'no-message':
-            if partner.picking_warn == 'block':
-                raise osv.except_osv(_('Alert for %s!') % (partner.name), partner.picking_warn_msg)
             title = _("Warning for %s") % partner.name
             message = partner.picking_warn_msg
             warning = {
                 'title': title,
                 'message': message
             }
+            if partner.picking_warn == 'block':
+                return {'value': {'partner_id': False}, 'warning': warning}
+
         result =  super(stock_picking, self).onchange_partner_in(cr, uid, ids, partner_id, context)
         if result.get('warning',False):
             warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
@@ -183,14 +186,15 @@ class stock_picking_in(osv.osv):
         title = False
         message = False
         if partner.picking_warn != 'no-message':
-            if partner.picking_warn == 'block':
-                raise osv.except_osv(_('Alert for %s!') % (partner.name), partner.picking_warn_msg)
             title = _("Warning for %s") % partner.name
             message = partner.picking_warn_msg
             warning = {
                 'title': title,
                 'message': message
             }
+            if partner.picking_warn == 'block':
+                return {'value': {'partner_id': False}, 'warning': warning}
+
         result =  super(stock_picking_in, self).onchange_partner_in(cr, uid, ids, partner_id, context)
         if result.get('warning',False):
             warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
@@ -209,14 +213,15 @@ class stock_picking_out(osv.osv):
         title = False
         message = False
         if partner.picking_warn != 'no-message':
-            if partner.picking_warn == 'block':
-                raise osv.except_osv(_('Alert for %s!') % (partner.name), partner.picking_warn_msg)
             title = _("Warning for %s") % partner.name
             message = partner.picking_warn_msg
             warning = {
                 'title': title,
                 'message': message
             }
+            if partner.picking_warn == 'block':
+                return {'value': {'partner_id': False}, 'warning': warning}
+
         result =  super(stock_picking_out, self).onchange_partner_in(cr, uid, ids, partner_id, context)
         if result.get('warning',False):
             warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
@@ -256,12 +261,12 @@ class sale_order_line(osv.osv):
         message = False
 
         if product_info.sale_line_warn != 'no-message':
-            if product_info.sale_line_warn == 'block':
-                raise osv.except_osv(_('Alert for %s!') % (product_info.name), product_info.sale_line_warn_msg)
             title = _("Warning for %s") % product_info.name
             message = product_info.sale_line_warn_msg
             warning['title'] = title
             warning['message'] = message
+            if product_info.sale_line_warn == 'block':
+                return {'value': {'product_id': False}, 'warning': warning}
 
         result =  super(sale_order_line, self).product_id_change( cr, uid, ids, pricelist, product, qty,
             uom, qty_uos, uos, name, partner_id,
@@ -288,12 +293,12 @@ class purchase_order_line(osv.osv):
         message = False
 
         if product_info.purchase_line_warn != 'no-message':
-            if product_info.purchase_line_warn == 'block':
-                raise osv.except_osv(_('Alert for %s!') % (product_info.name), product_info.purchase_line_warn_msg)
             title = _("Warning for %s") % product_info.name
             message = product_info.purchase_line_warn_msg
             warning['title'] = title
             warning['message'] = message
+            if product_info.purchase_line_warn == 'block':
+                return {'value': {'product_id': False}, 'warning': warning}
 
         result =  super(purchase_order_line, self).onchange_product_id(cr, uid, ids, pricelist, product, qty, uom,
             partner_id, date_order, fiscal_position_id)