if test:
testdict.update({prod_id : price})
if test:
- print testdict
return testdict
else:
return True
ctx = context.copy()
ctx.update({'active_id': bom.product_id.id})
wiz_id = wizard_obj.create(cr, uid, {'new_price': price}, context=ctx)
- wizard_obj.change_price(cr, uid, [wiz_id], context=context)
+ wizard_obj.change_price(cr, uid, [wiz_id], context=ctx)
return price
product_product()
def get_product_available(self, cr, uid, ids, context=None):
""" Finds the quantity available of product(s) depending on parameters in the context
- for date, location, state (allows e.g. for calculating future stock), what,
- production lot
+ for what, states, locations (company, warehouse, ), date, lot,
+ states: state of the move
+ what: in (dest in locations) or out (source in locations) moves
+ LOCATIONS:
+ shop: warehouse of the shop
+ warehouse: stock location of the warehouse
+ location: name (ilike) or id of the location
+ force_company: if not warehouse or shop given: will only take from this company
+ compute_child (True if not specified): will also include child locations of locations above
+ (when force_company only from that company)
+
+ from_date and to_date: dates from or to for the date of the stock move to include (=scheduled of effective date)
+ prodlot: lot of the move
+
@return: Dictionary of values for every product id
"""
- #TODO complete the docstring with possible keys in context + their effect
if context is None:
context = {}
from openerp.osv import osv, fields
-#TODO: remove this FILE and put everything in existing core modules (purchase, stock, product...)
class product_product (osv.osv):
_name = "product.product"
_inherit = "product.product"
return super(product_product, self).write(cr, uid, ids, vals, context=context)
def get_stock_matchings_fifolifo(self, cr, uid, ids, qty, fifo, product_uom_id=False, currency_id=False, context=None):
- #TODO: document the parameters (what is fifo? what's its type and is it used for?)...
- #TODO: check if possible to refactore and to split this big method into several smaller
+ # TODO: currency conversions could be omitted
'''
This method returns a list of tuples with quantities from stock in moves
- These are the quantities that would go out theoretically according to the fifo or lifo method if qty needs to go out
- (move_in_id, qty in uom of move out, price (converted to move out), qty in uom of move in
+ These are the quantities from the in moves that would go out theoretically according to the fifo or lifo method
+ (move_in_id, qty in uom of move out, price (converted to move out), qty in uom of move in)
This should be called for only one product at a time
UoMs and currencies from the corresponding moves are converted towards that given in the params
- It is good to use force_company in the context
+ force_company should be used in the context
'''
assert len(ids) == 1, 'Only the fifolifo stock matchings of one product can be calculated at a time.'
if context is None:
_inherit = 'stock.move'
def _get_moves_from_matchings(self, cr, uid, ids, context=None):
- #TOCHECK: self == match_obj ?
- match_obj = self.pool.get("stock.move.matching")
res = set()
- for match in match_obj.browse(cr, uid, ids, context=context):
+ for match in self.browse(cr, uid, ids, context=context):
res.add(match.move_out_id.id)
res.add(match.move_in_id.id)
return list(res)
'prodlot_id': wizard_line.prodlot_id.id,
}
if (picking_type == 'in') and (wizard_line.product_id.cost_method != 'standard'):
- #TODO Maybe better ways to get company or main currency
- #TODO Should not this currency be calculated at the date of the purchase order? (not the case now?)
partial_data['move%s' % (wizard_line.move_id.id)].update(product_price=wizard_line.cost,)
stock_picking.do_partial(cr, uid, [partial.picking_id.id], partial_data, context=context)
return {'type': 'ir.actions.act_window_close'}