+
def _create_previous_move(self, cr, uid, move_id, product, source_location_id, dest_location_id, context=None):
'''
When the routing gives a different location than the raw material location of the production order,
we should create an extra move from the raw material location to the location of the routing, which
- precedes the consumption line (chained)
+ precedes the consumption line (chained). The picking type depends on the warehouse in which this happens
+ and the type of locations.
'''
-
+ loc_obj = self.pool.get("stock.location")
stock_move = self.pool.get('stock.move')
type_obj = self.pool.get('stock.picking.type')
- types = type_obj.search(cr, uid, [('code','=','outgoing')], context=context)
+ # Need to search for a picking type
+ src_loc = loc_obj.browse(cr, uid, source_location_id, context=context)
+ dest_loc = loc_obj.browse(cr, uid, dest_location_id, context=context)
+ code = 'internal'
+ check_loc = dest_loc
+ if src_loc.usage == 'internal' and dest_loc.usage != 'internal':
+ code = 'outgoing'
+ check_loc = src_loc
+ if src_loc.usage != 'internal' and dest_loc.usage == 'internal':
+ code = 'incoming'
+ wh = loc_obj.get_warehouse(cr, uid, check_loc, context=context)
+ domain = [('code','=', code)]
+ if wh:
+ domain += [('warehouse_id', '=', wh)]
+ types = type_obj.search(cr, uid, domain, context=context)
move = stock_move.copy(cr, uid, move_id, default = {
'location_id': source_location_id,
'location_dest_id': dest_location_id,
return self._default_removal_strategy(cr, uid, context=context)
+ def get_warehouse(self, cr, uid, location, context=None):
+ """
+ Returns warehouse id of warehouse that contains location
+ :param location: browse record (stock.location)
+ """
+ wh_obj = self.pool.get("stock.warehouse")
+ whs = wh_obj.search(cr, uid, [('view_location_id.parent_left', '<=', location.parent_left),
+ ('view_location_id.parent_right', '>=', location.parent_left)], context=context)
+ return whs and whs[0] or False
+
#----------------------------------------------------------
# Routes
#----------------------------------------------------------
'limit': 20
}
+
class stock_location_path(osv.osv):
_name = "stock.location.path"
_description = "Pushed Flows"
def _get_master_data(self, cr, uid, move, company, context=None):
''' returns a tuple (browse_record(res.partner), ID(res.users), ID(res.currency)'''
currency = company.currency_id.id
- import pdb; pdb.set_trace()
partner = move.picking_id and move.picking_id.partner_id
if partner:
if partner.property_product_pricelist and move.location_id.usage == 'internal' and move.location_dest_id.usage != 'internal':
res.append(move.picking_id.id)
return res
- def _set_inv_state(self, cr, uid, picking_id, name, value, arg, context=None):
- pick = self.browse(cr, uid, picking_id, context=context)
- moves = [x.id for x in pick.move_lines]
- move_obj= self.pool.get("stock.move")
- move_obj.write(cr, uid, moves, {'invoice_state': pick.invoice_state})
_columns = {
("2binvoiced", "To Be Invoiced"),
("none", "Not Applicable")
], string="Invoice Control", required=True,
- #fnct_inv = _set_inv_state,
store={
'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['state'], 10),
'stock.move': (__get_picking_move, ['picking_id', 'invoice_state'], 10),
</xpath>
</field>
</record>
+ <record model="ir.ui.view" id="view_move_picking_from_stockaccount_inherit">
+ <field name="name">stock.move.form.invoice_state</field>
+ <field name="model">stock.move</field>
+ <field name="inherit_id" ref="stock.view_move_picking_form"/>
+ <field name="arch" type="xml">
+ <xpath expr="//field[@name='date_expected']" position="after">
+ <field name="invoice_state" groups="account.group_account_invoice"/>
+ </xpath>
+ </field>
+ </record>
</data>
</openerp>