diff options
Diffstat (limited to 'addons/procurement/procurement.py')
| -rw-r--r-- | addons/procurement/procurement.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 2c451dcf9bf..84413116222 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -62,11 +62,11 @@ mrp_property() class StockMove(osv.osv): _inherit = 'stock.move' - + _columns= { 'procurements': fields.one2many('procurement.order', 'move_id', 'Procurements'), } - + def copy(self, cr, uid, id, default=None, context=None): default = default or {} default['procurements'] = [] @@ -134,7 +134,7 @@ class procurement_order(osv.osv): if s['state'] in ['draft','cancel']: unlink_ids.append(s['id']) else: - raise osv.except_osv(_('Invalid action !'), + raise osv.except_osv(_('Invalid action !'), _('Cannot delete Procurement Order(s) which are in %s State!') % \ s['state']) return osv.osv.unlink(self, cr, uid, unlink_ids, context=context) @@ -169,8 +169,9 @@ class procurement_order(osv.osv): """ Checks if move is done or not. @return: True or False. """ - return all(procurement.move_id.state == 'done' for procurement in self.browse(cr, uid, ids, context=context)) - + if not context: + context = {} + return all(not procurement.move_id or procurement.move_id.state == 'done' for procurement in self.browse(cr, uid, ids, context=context)) # # This method may be overrided by objects that override procurement.order # for computing their own purpose @@ -283,7 +284,7 @@ class procurement_order(osv.osv): if procurement.product_id.product_tmpl_id.supply_method <> 'buy': return False if not procurement.product_id.seller_ids: - cr.execute('update procurement_order set message=%s where id=%s', + cr.execute('update procurement_order set message=%s where id=%s', (_('No supplier defined for this product !'), procurement.id)) return False partner = procurement.product_id.seller_id #Taken Main Supplier of Product of Procurement. @@ -293,7 +294,7 @@ class procurement_order(osv.osv): return False address_id = partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery'] if not address_id: - cr.execute('update procurement_order set message=%s where id=%s', + cr.execute('update procurement_order set message=%s where id=%s', (_('No address defined for the supplier'), procurement.id)) return False return True @@ -314,7 +315,7 @@ class procurement_order(osv.osv): move_obj = self.pool.get('stock.move') for procurement in self.browse(cr, uid, ids, context=context): if procurement.product_qty <= 0.00: - raise osv.except_osv(_('Data Insufficient !'), + raise osv.except_osv(_('Data Insufficient !'), _('Please check the Quantity in Procurement Order(s), it should not be less than 1!')) if procurement.product_id.type in ('product', 'consu'): if not procurement.move_id: @@ -342,7 +343,7 @@ class procurement_order(osv.osv): """ Changes procurement state to Running and writes message. @return: True """ - self.write(cr, uid, ids, {'state': 'running', + self.write(cr, uid, ids, {'state': 'running', 'message': _('from stock: products assigned.')}) return True @@ -365,8 +366,8 @@ class procurement_order(osv.osv): ok = ok and self.pool.get('stock.move').action_assign(cr, uid, [id]) cr.execute('select count(id) from stock_warehouse_orderpoint where product_id=%s', (procurement.product_id.id,)) if not cr.fetchone()[0]: - cr.execute('update procurement_order set message=%s where id=%s', - (_('Not enough stock and no minimum orderpoint rule defined.'), + cr.execute('update procurement_order set message=%s where id=%s', + (_('Not enough stock and no minimum orderpoint rule defined.'), procurement.id)) message = _("Procurement '%s' is in exception: not enough stock.") % \ (procurement.name,) @@ -477,7 +478,7 @@ class StockPicking(osv.osv): wf_service.trg_validate(user, 'procurement.order', procurement.id, 'button_check', cursor) return res - + StockPicking() class stock_warehouse_orderpoint(osv.osv): @@ -489,7 +490,7 @@ class stock_warehouse_orderpoint(osv.osv): _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."), + 'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the orderpoint without removing it."), 'logic': fields.selection([('max','Order to Max'),('price','Best price (not yet active!)')], 'Reordering Mode', required=True), 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True, ondelete="cascade"), 'location_id': fields.many2one('stock.location', 'Location', required=True, ondelete="cascade"), @@ -515,7 +516,7 @@ class stock_warehouse_orderpoint(osv.osv): '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_check', 'CHECK( qty_multiple > 0 )', _('Qty Multiple must be greater than zero.')), ] @@ -529,7 +530,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=None): """ Finds UoM for changed product. @param product_id: Changed id of product. |
