diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index e982930d69e..955d55b3825 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -318,21 +318,26 @@ class purchase_order(osv.osv): for po in self.browse(cr, uid, ids, context=context): pick_ids += [picking.id for picking in po.picking_ids] - res = mod_obj.get_object_reference(cr, uid, 'stock', 'view_picking_in_form') - res_id = res and res[1] or False - - return { - 'name': _('Receptions'), - 'view_type': 'form', - 'view_mode': 'form', - 'view_id': [res_id], - 'res_model': 'stock.picking', - 'context': "{'contact_display': 'partner'}", - 'type': 'ir.actions.act_window', - 'nodestroy': True, - 'target': 'current', - 'res_id': pick_ids and pick_ids[0] or False, - } + action_model, action_id = tuple(mod_obj.get_object_reference(cr, uid, 'stock', 'action_picking_tree4')) + action = self.pool.get(action_model).read(cr, uid, action_id, context=context) + ctx = eval(action['context']) + ctx.update({ + 'search_default_purchase_id': ids[0] + }) + if pick_ids and len(pick_ids) == 1: + form_view_ids = [view_id for view_id, view in action['views'] if view == 'form'] + view_id = form_view_ids and form_view_ids[0] or False + action.update({ + 'views': [], + 'view_mode': 'form', + 'view_id': view_id, + 'res_id': pick_ids[0] + }) + + action.update({ + 'context': ctx, + }) + return action def wkf_approve_order(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state': 'approved', 'date_approve': fields.date.context_today(self,cr,uid,context=context)}) @@ -863,6 +868,12 @@ class purchase_order_line(osv.osv): supplier_delay = int(supplier_info.delay) if supplier_info else 0 return datetime.strptime(date_order_str, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=supplier_delay) + def _check_product_uom_group(self, cr, uid, context=None): + group_uom = self.pool.get('ir.model.data').get_object(cr, uid, 'product', 'group_uom') + res = [user for user in group_uom.users if user.id == uid] + return len(res) and True or False + + def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id, partner_id, date_order=False, fiscal_position_id=False, date_planned=False, name=False, price_unit=False, context=None): @@ -908,7 +919,8 @@ class purchase_order_line(osv.osv): uom_id = product_uom_po_id if product.uom_id.category_id.id != product_uom.browse(cr, uid, uom_id, context=context).category_id.id: - res['warning'] = {'title': _('Warning!'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure.')} + if self._check_product_uom_group(cr, uid, context=context): + res['warning'] = {'title': _('Warning!'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure.')} uom_id = product_uom_po_id res['value'].update({'product_uom': uom_id}) @@ -1083,15 +1095,15 @@ class procurement_order(osv.osv): procurement_order() -class mail_message(osv.osv): - _name = 'mail.message' - _inherit = 'mail.message' +class mail_mail(osv.osv): + _name = 'mail.mail' + _inherit = 'mail.mail' - def _postprocess_sent_message(self, cr, uid, message, context=None): - if message.model == 'purchase.order': + def _postprocess_sent_message(self, cr, uid, mail, context=None): + if mail.model == 'purchase.order': wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'purchase.order', message.res_id, 'send_rfq', cr) - return super(mail_message, self)._postprocess_sent_message(cr, uid, message=message, context=context) + wf_service.trg_validate(uid, 'purchase.order', mail.res_id, 'send_rfq', cr) + return super(mail_mail, self)._postprocess_sent_message(cr, uid, mail=mail, context=context) -mail_message() +mail_mail() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 796fd1351a9..759c0561631 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -14,19 +14,40 @@ + + + Pricelist Versions + ir.actions.act_window + product.pricelist.version + form + + [('pricelist_id.type','=','purchase')] + +

+ Click to add a pricelist version. +

+ There can be more than one version of a pricelist, each of + these must be valid during a certain period of time. Some + examples of versions: Main Prices, 2010, 2011, Summer Sales, + etc. +

+
+
+ action="purchase_pricelist_version_action" id="menu_purchase_pricelist_version_action" + parent="menu_purchase_config_pricelist" sequence="2" groups="product.group_purchase_pricelist"/> + - + action="product.product_price_type_action" id="menu_product_pricelist_action2_purchase_type" + parent="menu_purchase_config_pricelist" sequence="60" /> @@ -188,7 +209,7 @@