return "make_to_order"
return "make_to_stock"
+
+
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)
'''
+
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)
move = stock_move.copy(cr, uid, move_id, default = {
'location_id': source_location_id,
'location_dest_id': dest_location_id,
'procure_method': self._get_raw_material_procure_method(cr, uid, product, context=context),
'raw_material_production_id': False,
'move_dest_id': move_id,
+ 'picking_type_id': types and types[0] or False,
}, context=context)
return move
if prev_move:
prev_move = self._create_previous_move(cr, uid, move_id, product, prod_location_id, source_location_id, context=context)
+ stock_move.action_confirm(cr, uid, [prev_move], context=context)
return move_id
def _make_production_consume_line(self, cr, uid, line, context=None):
'group_id': procurement.group_id.id or group_id, #move group is same as group of procurements if it exists, otherwise take another group
'procurement_id': procurement.id,
'invoice_state': procurement.rule_id.invoice_state or (procurement.location_id and procurement.location_id.usage == 'customer' and procurement.invoice_state=='picking' and '2binvoiced') or (order.invoice_method == 'picking' and '2binvoiced') or 'none', #dropship case takes from sale
+ 'propagate': procurement.rule_id.propagate,
})
diff_quantity -= min(procurement_qty, diff_quantity)
res.append(tmp)
picking_vals = {
'picking_type_id': order.picking_type_id.id,
'partner_id': order.dest_address_id.id or order.partner_id.id,
- 'date': max([l.date_planned for l in order.order_line])
+ 'date': max([l.date_planned for l in order.order_line]),
+ 'origin': order.name
}
picking_id = self.pool.get('stock.picking').create(cr, uid, picking_vals, context=context)
self._create_stock_moves(cr, uid, order, order.order_line, picking_id, context=context)
product_obj = self.pool.get('product.product')
warning = {}
res = self.product_id_change(cr, uid, ids, pricelist, product, qty=qty,
- uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,
+ uom=False, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,
lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context)
if not product:
'active': True,
}
+ def _prepare_push_apply(self, cr, uid, rule, move, context=None):
+ newdate = (datetime.strptime(move.date_expected, DEFAULT_SERVER_DATETIME_FORMAT) + relativedelta.relativedelta(days=rule.delay or 0)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
+ return {
+ 'location_id': move.location_dest_id.id,
+ 'location_dest_id': rule.location_dest_id.id,
+ 'date': newdate,
+ 'company_id': rule.company_id and rule.company_id.id or False,
+ 'date_expected': newdate,
+ 'picking_id': False,
+ 'picking_type_id': rule.picking_type_id and rule.picking_type_id.id or False,
+ 'propagate': rule.propagate,
+ 'push_rule_id': rule.id,
+ 'warehouse_id': rule.warehouse_id and rule.warehouse_id.id or False,
+ }
+
+
def _apply(self, cr, uid, rule, move, context=None):
move_obj = self.pool.get('stock.move')
newdate = (datetime.strptime(move.date_expected, DEFAULT_SERVER_DATETIME_FORMAT) + relativedelta.relativedelta(days=rule.delay or 0)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
#call again push_apply to see if a next step is defined
move_obj._push_apply(cr, uid, [move], context=context)
else:
- move_id = move_obj.copy(cr, uid, move.id, {
- 'location_id': move.location_dest_id.id,
- 'location_dest_id': rule.location_dest_id.id,
- 'date': newdate,
- 'company_id': rule.company_id and rule.company_id.id or False,
- 'date_expected': newdate,
- 'picking_id': False,
- 'picking_type_id': rule.picking_type_id and rule.picking_type_id.id or False,
- 'propagate': rule.propagate,
- 'push_rule_id': rule.id,
- 'warehouse_id': rule.warehouse_id and rule.warehouse_id.id or False,
- })
+ vals = self._prepare_push_apply(cr, uid, rule, move, context=context)
+ move_id = move_obj.copy(cr, uid, move.id, vals, context=context)
move_obj.write(cr, uid, [move.id], {
'move_dest_id': move_id,
})
'invoice_state': '',
}
+ def _prepare_push_apply(self, cr, uid, rule, move, context=None):
+ res = super(stock_location_path, self)._prepare_push_apply(cr, uid, rule, move, context=context)
+ res['invoice_state'] = rule.invoice_state or 'none'
+ return res
+
#----------------------------------------------------------
# Procurement Rule
#----------------------------------------------------------