ret = round(eval(rule), 3) #print 'Eval success: %s - %s' % (rule, str(ret)) except Exception, e: print 'Wrong parsing "%s" from "%s"' % (rule, orig_rule) print 'Production calculating count: eval error - %s' % e.message raise osv.except_osv(u'Предупреждение', u'Неверная формула расчета') if ret % 1 > 0.95: ret = ret - (ret % 1) + 1 else: ret = ret - (ret % 1) self.write(cr, uid, ids, {'product_qty': ret}) return ret _columns = { 'tmpl_id': fields.dummy(string='Template', relation='product.template', type='many2one'), 'template_id': fields.many2one('product.template', u'Шаблон', required=True, readonly=True, states={'draft':[('readonly',False)]}), 'product_id': fields.many2one('product.product', u'Продукт', required=False, readonly=True, states={'draft':[('readonly',False)]}), #'multi': fields.dummy(string='Multi fields'), 'params': fields.dummy(string='Params fields'), } _defaults = { 'product_qty': 0, } def _check_qty(self, cr, uid, ids, context=None): # for order in self.browse(cr, uid, ids, context=context): # if order.product_qty <= 0: # return False return True
class product_product(osv.osv): def view_header_get(self, cr, uid, view_id, view_type, context=None): if context is None: context = {} res = super(product_product, self).view_header_get(cr, uid, view_id, view_type, context) if (context.get('categ_id', False)): return _('Products: ') + self.pool.get('product.category').browse( cr, uid, context['categ_id'], context=context).name return res def _product_price(self, cr, uid, ids, name, arg, context=None): res = {} if context is None: context = {} quantity = context.get('quantity') or 1.0 pricelist = context.get('pricelist', False) if pricelist: for id in ids: try: price = self.pool.get('product.pricelist').price_get( cr, uid, [pricelist], id, quantity, context=context)[pricelist] except: price = 0.0 res[id] = price for id in ids: res.setdefault(id, 0.0) return res def _get_product_available_func(states, what): def _product_available(self, cr, uid, ids, name, arg, context=None): return {}.fromkeys(ids, 0.0) return _product_available _product_qty_available = _get_product_available_func(('done', ), ('in', 'out')) _product_virtual_available = _get_product_available_func( ('confirmed', 'waiting', 'assigned', 'done'), ('in', 'out')) _product_outgoing_qty = _get_product_available_func( ('confirmed', 'waiting', 'assigned'), ('out', )) _product_incoming_qty = _get_product_available_func( ('confirmed', 'waiting', 'assigned'), ('in', )) def _product_lst_price(self, cr, uid, ids, name, arg, context=None): res = {} product_uom_obj = self.pool.get('product.uom') for id in ids: res.setdefault(id, 0.0) for product in self.browse(cr, uid, ids, context=context): if 'uom' in context: uom = product.uos_id or product.uom_id res[product.id] = product_uom_obj._compute_price( cr, uid, uom.id, product.list_price, context['uom']) else: res[product.id] = product.list_price res[product.id] = (res[product.id] or 0.0) * ( product.price_margin or 1.0) + product.price_extra return res def _get_partner_code_name(self, cr, uid, ids, product, partner_id, context=None): for supinfo in product.seller_ids: if supinfo.name.id == partner_id: return { 'code': supinfo.product_code or product.default_code, 'name': supinfo.product_name or product.name, 'variants': '' } res = { 'code': product.default_code, 'name': product.name, 'variants': product.variants } return res def _product_code(self, cr, uid, ids, name, arg, context=None): res = {} if context is None: context = {} for p in self.browse(cr, uid, ids, context=context): res[p.id] = self._get_partner_code_name(cr, uid, [], p, context.get( 'partner_id', None), context=context)['code'] return res def _product_partner_ref(self, cr, uid, ids, name, arg, context=None): res = {} if context is None: context = {} for p in self.browse(cr, uid, ids, context=context): data = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context=context) if not data['variants']: data['variants'] = p.variants if not data['code']: data['code'] = p.code if not data['name']: data['name'] = p.name res[p.id] = (data['code'] and ('['+data['code']+'] ') or '') + \ (data['name'] or '') + (data['variants'] and (' - '+data['variants']) or '') return res _defaults = { 'active': lambda *a: 1, 'price_extra': lambda *a: 0.0, 'price_margin': lambda *a: 1.0, } _name = "product.product" _description = "Product" _table = "product_product" _inherits = {'product.template': 'product_tmpl_id'} _order = 'default_code,name_template' _columns = { 'qty_available': fields.function(_product_qty_available, method=True, type='float', string='Real Stock'), 'virtual_available': fields.function(_product_virtual_available, method=True, type='float', string='Virtual Stock'), 'incoming_qty': fields.function(_product_incoming_qty, method=True, type='float', string='Incoming'), 'outgoing_qty': fields.function(_product_outgoing_qty, method=True, type='float', string='Outgoing'), 'price': fields.function(_product_price, method=True, type='float', string='Pricelist', digits_compute=dp.get_precision('Sale Price')), 'lst_price': fields.function(_product_lst_price, method=True, type='float', string='Public Price', digits_compute=dp.get_precision('Sale Price')), 'code': fields.function(_product_code, method=True, type='char', string='Reference'), 'partner_ref': fields.function(_product_partner_ref, method=True, type='char', string='Customer ref'), 'default_code': fields.char('Reference', size=64), 'active': fields.boolean( 'Active', help= "If the active field is set to False, it will allow you to hide the product without removing it." ), 'variants': fields.char('Variants', size=64), 'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=True, ondelete="cascade"), 'ean13': fields.char('EAN13', size=13), 'packaging': fields.one2many( 'product.packaging', 'product_id', 'Logistical Units', help= "Gives the different ways to package the same product. This has no impact on the picking order and is mainly used if you use the EDI module." ), 'price_extra': fields.float('Variant Price Extra', digits_compute=dp.get_precision('Sale Price')), 'price_margin': fields.float('Variant Price Margin', digits_compute=dp.get_precision('Sale Price')), 'pricelist_id': fields.dummy(string='Pricelist', relation='product.pricelist', type='many2one'), 'name_template': fields.related('product_tmpl_id', 'name', string="Name", type='char', size=128, store=True), } def unlink(self, cr, uid, ids, context=None): unlink_ids = [] unlink_product_tmpl_ids = [] for product in self.browse(cr, uid, ids, context=context): tmpl_id = product.product_tmpl_id.id # Check if the product is last product of this template other_product_ids = self.search(cr, uid, [('product_tmpl_id', '=', tmpl_id), ('id', '!=', product.id)], context=context) if not other_product_ids: unlink_product_tmpl_ids.append(tmpl_id) unlink_ids.append(product.id) self.pool.get('product.template').unlink(cr, uid, unlink_product_tmpl_ids, context=context) return super(product_product, self).unlink(cr, uid, unlink_ids, context=context) def onchange_uom(self, cursor, user, ids, uom_id, uom_po_id): if uom_id and uom_po_id: uom_obj = self.pool.get('product.uom') uom = uom_obj.browse(cursor, user, [uom_id])[0] uom_po = uom_obj.browse(cursor, user, [uom_po_id])[0] if uom.category_id.id != uom_po.category_id.id: return {'value': {'uom_po_id': uom_id}} return False def _check_ean_key(self, cr, uid, ids, context=None): for product in self.browse(cr, uid, ids, context=context): res = check_ean(product.ean13) return res _constraints = [(_check_ean_key, 'Error: Invalid ean code', ['ean13'])] def on_order(self, cr, uid, ids, orderline, quantity): pass def name_get(self, cr, user, ids, context=None): if context is None: context = {} if not len(ids): return [] def _name_get(d): name = d.get('name', '') code = d.get('default_code', False) if code: name = '[%s] %s' % (code, name) if d.get('variants'): name = name + ' - %s' % (d['variants'], ) return (d['id'], name) partner_id = context.get('partner_id', False) result = [] for product in self.browse(cr, user, ids, context=context): sellers = filter(lambda x: x.name.id == partner_id, product.seller_ids) if sellers: for s in sellers: mydict = { 'id': product.id, 'name': s.product_name or product.name, 'default_code': s.product_code or product.default_code, 'variants': product.variants } result.append(_name_get(mydict)) else: mydict = { 'id': product.id, 'name': product.name, 'default_code': product.default_code, 'variants': product.variants } result.append(_name_get(mydict)) return result def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100): if not args: args = [] if name: ids = self.search(cr, user, [('default_code', '=', name)] + args, limit=limit, context=context) if not len(ids): ids = self.search(cr, user, [('ean13', '=', name)] + args, limit=limit, context=context) if not len(ids): ids = self.search(cr, user, [ '|', ('name', operator, name), ('default_code', operator, name) ] + args, limit=limit, context=context) if not len(ids): ptrn = re.compile('(\[(.*?)\])') res = ptrn.search(name) if res: ids = self.search( cr, user, [('default_code', '=', res.group(2))] + args, limit=limit, context=context) else: ids = self.search(cr, user, args, limit=limit, context=context) result = self.name_get(cr, user, ids, context=context) return result # # Could be overrided for variants matrices prices # def price_get(self, cr, uid, ids, ptype='list_price', context=None): if context is None: context = {} if 'currency_id' in context: pricetype_obj = self.pool.get('product.price.type') price_type_id = pricetype_obj.search(cr, uid, [('field', '=', ptype)])[0] price_type_currency_id = pricetype_obj.browse( cr, uid, price_type_id).currency_id.id res = {} product_uom_obj = self.pool.get('product.uom') for product in self.browse(cr, uid, ids, context=context): res[product.id] = product[ptype] or 0.0 if ptype == 'list_price': res[product.id] = (res[product.id] * (product.price_margin or 1.0)) + \ product.price_extra if 'uom' in context: uom = product.uos_id or product.uom_id res[product.id] = product_uom_obj._compute_price( cr, uid, uom.id, res[product.id], context['uom']) # Convert from price_type currency to asked one if 'currency_id' in context: # Take the price_type currency from the product field # This is right cause a field cannot be in more than one currency res[product.id] = self.pool.get('res.currency').compute( cr, uid, price_type_currency_id, context['currency_id'], res[product.id], context=context) return res def copy(self, cr, uid, id, default=None, context=None): if context is None: context = {} product = self.read(cr, uid, id, ['name'], context=context) if not default: default = {} default = default.copy() default['name'] = product['name'] + _(' (copy)') if context.get('variant', False): fields = [ 'product_tmpl_id', 'active', 'variants', 'default_code', 'price_margin', 'price_extra' ] data = self.read(cr, uid, id, fields=fields, context=context) for f in fields: if f in default: data[f] = default[f] data['product_tmpl_id'] = data.get('product_tmpl_id', False) \ and data['product_tmpl_id'][0] del data['id'] return self.create(cr, uid, data) else: return super(product_product, self).copy(cr, uid, id, default=default, context=context)
class product_product(osv.osv): _inherit = "product.product" def get_product_accounts(self, cr, uid, product_id, context=None): """ To get the stock input account, stock output account and stock journal related to product. @param product_id: product id @return: dictionary which contains information regarding stock input account, stock output account and stock journal """ if context is None: context = {} product_obj = self.pool.get('product.product').browse(cr, uid, product_id, context=context) stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False if not stock_input_acc: stock_input_acc = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id or False stock_output_acc = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id or False if not stock_output_acc: stock_output_acc = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id or False journal_id = product_obj.categ_id.property_stock_journal and product_obj.categ_id.property_stock_journal.id or False account_variation = product_obj.categ_id.property_stock_variation and product_obj.categ_id.property_stock_variation.id or False return { 'stock_account_input': stock_input_acc, 'stock_account_output': stock_output_acc, 'stock_journal': journal_id, 'property_stock_variation': account_variation } def do_change_standard_price(self, cr, uid, ids, datas, context=None): """ Changes the Standard Price of Product and creates an account move accordingly. @param datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal @param context: A standard dictionary @return: """ location_obj = self.pool.get('stock.location') move_obj = self.pool.get('account.move') move_line_obj = self.pool.get('account.move.line') if context is None: context = {} new_price = datas.get('new_price', 0.0) stock_output_acc = datas.get('stock_output_account', False) stock_input_acc = datas.get('stock_input_account', False) journal_id = datas.get('stock_journal', False) product_obj=self.browse(cr, uid, ids, context=context)[0] account_variation = product_obj.categ_id.property_stock_variation account_variation_id = account_variation and account_variation.id or False if not account_variation_id: raise osv.except_osv(_('Error!'), _('Variation Account is not specified for Product Category: %s') % (product_obj.categ_id.name)) move_ids = [] loc_ids = location_obj.search(cr, uid,[('usage','=','internal')]) for rec_id in ids: for location in location_obj.browse(cr, uid, loc_ids, context=context): c = context.copy() c.update({ 'location': location.id, 'compute_child': False }) product = self.browse(cr, uid, rec_id, context=c) qty = product.qty_available diff = product.standard_price - new_price if not diff: raise osv.except_osv(_('Error!'), _("Could not find any difference between standard price and new price!")) if qty: company_id = location.company_id and location.company_id.id or False if not company_id: raise osv.except_osv(_('Error!'), _('Company is not specified in Location')) # # Accounting Entries # if not journal_id: journal_id = product.categ_id.property_stock_journal and product.categ_id.property_stock_journal.id or False if not journal_id: raise osv.except_osv(_('Error!'), _('There is no journal defined '\ 'on the product category: "%s" (id: %d)') % \ (product.categ_id.name, product.categ_id.id,)) move_id = move_obj.create(cr, uid, { 'journal_id': journal_id, 'company_id': company_id }) move_ids.append(move_id) if diff > 0: if not stock_input_acc: stock_input_acc = product.product_tmpl_id.\ property_stock_account_input.id if not stock_input_acc: stock_input_acc = product.categ_id.\ property_stock_account_input_categ.id if not stock_input_acc: raise osv.except_osv(_('Error!'), _('There is no stock input account defined ' \ 'for this product: "%s" (id: %d)') % \ (product.name, product.id,)) amount_diff = qty * diff move_line_obj.create(cr, uid, { 'name': product.name, 'account_id': stock_input_acc, 'debit': amount_diff, 'move_id': move_id, }) move_line_obj.create(cr, uid, { 'name': product.categ_id.name, 'account_id': account_variation_id, 'credit': amount_diff, 'move_id': move_id }) elif diff < 0: if not stock_output_acc: stock_output_acc = product.product_tmpl_id.\ property_stock_account_output.id if not stock_output_acc: stock_output_acc = product.categ_id.\ property_stock_account_output_categ.id if not stock_output_acc: raise osv.except_osv(_('Error!'), _('There is no stock output account defined ' \ 'for this product: "%s" (id: %d)') % \ (product.name, product.id,)) amount_diff = qty * -diff move_line_obj.create(cr, uid, { 'name': product.name, 'account_id': stock_output_acc, 'credit': amount_diff, 'move_id': move_id }) move_line_obj.create(cr, uid, { 'name': product.categ_id.name, 'account_id': account_variation_id, 'debit': amount_diff, 'move_id': move_id }) self.write(cr, uid, rec_id, {'standard_price': new_price}) return move_ids def view_header_get(self, cr, user, view_id, view_type, context=None): if context is None: context = {} res = super(product_product, self).view_header_get(cr, user, view_id, view_type, context) if res: return res if (context.get('active_id', False)) and (context.get('active_model') == 'stock.location'): return _('Products: ')+self.pool.get('stock.location').browse(cr, user, context['active_id'], context).name return res def get_product_available(self, cr, uid, ids, context=None): """ Finds whether product is available or not in particular warehouse. @return: Dictionary of values """ if context is None: context = {} states = context.get('states',[]) what = context.get('what',()) if not ids: ids = self.search(cr, uid, []) res = {}.fromkeys(ids, 0.0) if not ids: return res # TODO: write in more ORM way, less queries, more pg84 magic if context.get('shop', False): cr.execute('select warehouse_id from sale_shop where id=%s', (int(context['shop']),)) res2 = cr.fetchone() if res2: context['warehouse'] = res2[0] if context.get('warehouse', False): cr.execute('select lot_stock_id from stock_warehouse where id=%s', (int(context['warehouse']),)) res2 = cr.fetchone() if res2: context['location'] = res2[0] if context.get('location',False): xt=type(context['location']) if context.get('location', False): if type(context['location']) == type(1): location_ids = [context['location']] elif type(context['location']) in (type(''), type(u'')): location_ids = self.pool.get('stock.location').search(cr, uid, [('name','ilike',context['location'])], context=context) else: location_ids = context['location'] else: location_ids = [] wids = self.pool.get('stock.warehouse').search(cr, uid, [], context=context) for w in self.pool.get('stock.warehouse').browse(cr, uid, wids, context=context): location_ids.append(w.lot_stock_id.id) # build the list of ids of children of the location given by id if context.get('compute_child',True): child_location_ids = self.pool.get('stock.location').search(cr, uid, [('location_id', 'child_of', location_ids)]) location_ids = child_location_ids or location_ids else: location_ids = location_ids uoms_o = {} product2uom = {} for product in self.browse(cr, uid, ids, context=context): product2uom[product.id] = product.uom_id.id uoms_o[product.uom_id.id] = product.uom_id results = [] results2 = [] from_date = context.get('from_date',False) to_date = context.get('to_date',False) date_str = False date_values = False where = [tuple(location_ids),tuple(location_ids),tuple(ids),tuple(states)] if from_date and to_date: date_str = "date>=%s and date<=%s" where.append(tuple([from_date])) where.append(tuple([to_date])) elif from_date: date_str = "date>=%s" date_values = [from_date] elif to_date: date_str = "date<=%s" date_values = [to_date] # TODO: perhaps merge in one query. if date_values: where.append(tuple(date_values)) if 'in' in what: # all moves from a location out of the set to a location in the set cr.execute( 'select sum(product_qty), product_id, product_uom '\ 'from stock_move '\ 'where location_id NOT IN %s'\ 'and location_dest_id IN %s'\ 'and product_id IN %s'\ 'and state IN %s' + (date_str and 'and '+date_str+' ' or '') +''\ 'group by product_id,product_uom',tuple(where)) results = cr.fetchall() if 'out' in what: # all moves from a location in the set to a location out of the set cr.execute( 'select sum(product_qty), product_id, product_uom '\ 'from stock_move '\ 'where location_id IN %s'\ 'and location_dest_id NOT IN %s '\ 'and product_id IN %s'\ 'and state in %s' + (date_str and 'and '+date_str+' ' or '') + ''\ 'group by product_id,product_uom',tuple(where)) results2 = cr.fetchall() uom_obj = self.pool.get('product.uom') uoms = map(lambda x: x[2], results) + map(lambda x: x[2], results2) if context.get('uom', False): uoms += [context['uom']] uoms = filter(lambda x: x not in uoms_o.keys(), uoms) if uoms: uoms = uom_obj.browse(cr, uid, list(set(uoms)), context=context) for o in uoms: uoms_o[o.id] = o #TOCHECK: before change uom of product, stock move line are in old uom. context.update({'raise-exception': False}) for amount, prod_id, prod_uom in results: amount = uom_obj._compute_qty_obj(cr, uid, uoms_o[prod_uom], amount, uoms_o[context.get('uom', False) or product2uom[prod_id]], context=context) res[prod_id] += amount for amount, prod_id, prod_uom in results2: amount = uom_obj._compute_qty_obj(cr, uid, uoms_o[prod_uom], amount, uoms_o[context.get('uom', False) or product2uom[prod_id]], context=context) res[prod_id] -= amount return res def _product_available(self, cr, uid, ids, field_names=None, arg=False, context=None): """ Finds the incoming and outgoing quantity of product. @return: Dictionary of values """ warehouse_obj=self.pool.get('stock.warehouse') warehouses=warehouse_obj.search(cr,uid,[]) depot1=warehouses[0] depot2=warehouses[1] if not field_names: field_names = [] if context is None: context = {} res = {} for id in ids: res[id] = {}.fromkeys(field_names, 0.0) for f in field_names: c = context.copy() if f == 'qty_available': c.update({ 'states': ('done',), 'what': ('in', 'out') }) if f == 'virtual_available': c.update({ 'states': ('confirmed','waiting','assigned','done'), 'what': ('in', 'out') }) if f == 'incoming_qty': c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('in',) }) if f == 'outgoing_qty': c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('out',) }) if f == 'stock_depot1': c.update({ 'states': ('confirmed','waiting','assigned','done'), 'what': ('in', 'out'),'warehouse':depot1 }) if f == 'stock_depot2': c.update({ 'states': ('confirmed','waiting','assigned','done'), 'what': ('in', 'out'),'warehouse':depot2 }) stock = self.get_product_available(cr, uid, ids, context=c) for id in ids: res[id][f] = stock.get(id, 0.0) return res _columns = { 'qty_available': fields.function(_product_available, method=True, type='float', string='Real Stock', help="Current quantities of products in selected locations or all internal if none have been selected.", multi='qty_available', digits_compute=dp.get_precision('Product UoM')), 'virtual_available': fields.function(_product_available, method=True, type='float', string='Virtual Stock', help="Future stock for this product according to the selected locations or all internal if none have been selected. Computed as: Real Stock - Outgoing + Incoming.", multi='qty_available', digits_compute=dp.get_precision('Product UoM')), 'incoming_qty': fields.function(_product_available, method=True, type='float', string='Incoming', help="Quantities of products that are planned to arrive in selected locations or all internal if none have been selected.", multi='qty_available', digits_compute=dp.get_precision('Product UoM')), 'outgoing_qty': fields.function(_product_available, method=True, type='float', string='Outgoing', help="Quantities of products that are planned to leave in selected locations or all internal if none have been selected.", multi='qty_available', digits_compute=dp.get_precision('Product UoM')), 'track_production': fields.boolean('Track Manufacturing Lots' , help="Forces to specify a Production Lot for all moves containing this product and generated by a Manufacturing Order"), 'track_incoming': fields.boolean('Track Incoming Lots', help="Forces to specify a Production Lot for all moves containing this product and coming from a Supplier Location"), 'track_outgoing': fields.boolean('Track Outgoing Lots', help="Forces to specify a Production Lot for all moves containing this product and going to a Customer Location"), 'location_id': fields.dummy(string='Stock Location', relation='stock.location', type='many2one'), 'valuation':fields.selection([('manual_periodic', 'Periodical (manual)'), ('real_time','Real Time (automated)'),], 'Inventory Valuation', help="If real-time valuation is enabled for a product, the system will automatically write journal entries corresponding to stock moves." \ "The inventory variation account set on the product category will represent the current inventory value, and the stock input and stock output account will hold the counterpart moves for incoming and outgoing products." , required=True), } _defaults = { 'valuation': lambda *a: 'manual_periodic', } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(product_product,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) if context is None: context = {} if ('location' in context) and context['location']: location_info = self.pool.get('stock.location').browse(cr, uid, context['location']) fields=res.get('fields',{}) if fields: if location_info.usage == 'supplier': if fields.get('virtual_available'): res['fields']['virtual_available']['string'] = _('Future Receptions') if fields.get('qty_available'): res['fields']['qty_available']['string'] = _('Received Qty') if location_info.usage == 'internal': if fields.get('virtual_available'): res['fields']['virtual_available']['string'] = _('Future Stock') if location_info.usage == 'customer': if fields.get('virtual_available'): res['fields']['virtual_available']['string'] = _('Future Deliveries') if fields.get('qty_available'): res['fields']['qty_available']['string'] = _('Delivered Qty') if location_info.usage == 'inventory': if fields.get('virtual_available'): res['fields']['virtual_available']['string'] = _('Future P&L') if fields.get('qty_available'): res['fields']['qty_available']['string'] = _('P&L Qty') if location_info.usage == 'procurement': if fields.get('virtual_available'): res['fields']['virtual_available']['string'] = _('Future Qty') if fields.get('qty_available'): res['fields']['qty_available']['string'] = _('Unplanned Qty') if location_info.usage == 'production': if fields.get('virtual_available'): res['fields']['virtual_available']['string'] = _('Future Productions') if fields.get('qty_available'): res['fields']['qty_available']['string'] = _('Produced Qty') return res