[FIX] sale: problem of company id on move and picking when validating SO

add button set last track name

bzr revid: nel@tinyerp.com-20100615191908-nmcdaihdz04zof1r
This commit is contained in:
nel@tinyerp.com 2010-06-15 21:19:08 +02:00
parent 706e4c24b0
commit 06e7359da7
6 changed files with 45 additions and 5 deletions

View File

@ -60,7 +60,7 @@
'stock_view.xml',
# 'process/sale_process.xml',
],
'demo_xml': ['sale_demo.xml'],
# 'demo_xml': ['sale_demo.xml'],
'test': [
'test/shipping_manual_sale_order.yml',
'test/prepaid_sale_order.yml',

View File

@ -42,3 +42,5 @@
"access_stock_inventory_merge","stock.inventory.merge","model_stock_inventory_merge","stock.group_stock_user",1,0,0,0
"access_stock_change_standard_price","stock.change.standard.price","model_stock_change_standard_price","stock.group_stock_user",1,0,0,0
"access_action_traceability","action.traceability","model_action_traceability","stock.group_stock_user",1,0,0,0
"access_stock_split_into","stock.split.into","model_stock_split_into","stock.group_stock_user",1,0,0,0
"access_stock_split_into_manager","stock.split.into","model_stock_split_into","stock.group_stock_manager",1,1,1,1

Can't render this file because it contains an unexpected character in line 40 and column 53.

View File

@ -612,7 +612,7 @@ class stock_picking(osv.osv):
'type': lambda *a: 'in',
'invoice_state': lambda *a: 'none',
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock_picking', context=c)
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.picking', context=c)
}
def copy(self, cr, uid, id, default=None, context={}):
@ -1302,6 +1302,7 @@ stock_production_lot_revision()
# location_dest_id is only used for predicting futur stocks
#
class stock_move(osv.osv):
def _getSSCC(self, cr, uid, context={}):
cr.execute('select id from stock_tracking where create_uid=%s order by id desc limit 1', (uid,))
res = cr.fetchone()
@ -1572,6 +1573,7 @@ class stock_move(osv.osv):
def create_chained_picking(self, cr, uid, moves, context):
new_moves = []
res_obj = self.pool.get('res.company')
for picking, todo in self._chain_compute(cr, uid, moves, context).items():
ptype = todo[0][1][5] and todo[0][1][5] or self.pool.get('stock.location').picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
pick_name = ''
@ -1585,8 +1587,9 @@ class stock_move(osv.osv):
'move_type': picking.move_type,
'auto_picking': todo[0][1][1] == 'auto',
'stock_journal_id': todo[0][1][3],
'company_id': todo[0][1][4],
'company_id': todo[0][1][4] or res_obj._company_default_get(cr, uid, 'stock.company', context),
'address_id': picking.address_id.id,
'invoice_state': 'none'
})
for move, (loc, auto, delay, journal, company_id, ptype) in todo:
@ -1596,7 +1599,7 @@ class stock_move(osv.osv):
'date_moved': time.strftime('%Y-%m-%d'),
'picking_id': pickid,
'state': 'waiting',
'company_id': company_id,
'company_id': company_id or res_obj._company_default_get(cr, uid, 'stock.company', context) ,
'move_history_ids': [],
'date_planned': (datetime.strptime(move.date_planned, '%Y-%m-%d %H:%M:%S') + relativedelta(days=delay or 0)).strftime('%Y-%m-%d'),
'move_history_ids2': []}
@ -1682,6 +1685,17 @@ class stock_move(osv.osv):
wf_service.trg_write(uid, 'stock.picking', pick_id, cr)
return count
def setlast_tracking(self, cr, uid, ids, context=None):
new_move = []
update_val = {}
last_prod = [line.prodlot_id for line in self.browse(cr, uid, ids)[0].picking_id.move_lines if line.prodlot_id]
last_prod.sort(key=lambda p: p.date, reverse=True)
last_prod_id = last_prod and last_prod[0].id
update_val['prodlot_id'] = last_prod_id
self.write(cr, uid, ids, update_val)
return True
#
# Cancel move => cancel others move and pickings
#

View File

@ -636,6 +636,9 @@
<button name="%(split_into)d" string="Split Stock Moves" type="action"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date_planned"/>
@ -788,6 +791,9 @@
<button name="%(split_into)d" string="Split Stock Moves" type="action"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date_planned"/>
@ -985,6 +991,9 @@
<button name="%(split_into)d" string="Split Stock Moves" type="action"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
<field name="date_planned"/>
<field name="state"/>
@ -1171,6 +1180,9 @@
<button name="%(split_into)d" string="Split Stock Moves" type="action"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="state"/>
<button name="%(stock.move_scrap)d"
string="Scrap Products" type="action"
@ -1357,6 +1369,9 @@
<button name="%(split_into)d" string="Split Stock Moves" type="action"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date_planned"/>
@ -1511,6 +1526,9 @@
<button name="%(split_into)d" string="Split Stock Moves" type="action"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="date_planned"/>
<field name="backorder_id" groups="base.group_extended"/>
<field name="state"/>

View File

@ -56,12 +56,16 @@ class stock_split_into(osv.osv_memory):
update_val = {}
value_to_split = self.browse(cr, uid, data[0], context)
quantity = value_to_split.quantity or 0.0
ir_sequence_obj = self.pool.get('ir.sequence')
prodlot_obj = self.pool.get('stock.production.lot')
for move in move_obj.browse(cr, uid, rec_id):
move_qty = move.product_qty
uos_qty_rest = move.product_uos_qty
quantity_rest = move_qty - quantity
if quantity_rest == 0:
continue
sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence}, {'product_id': move.product_id.id})
uos_qty = quantity / move_qty * move.product_uos_qty
uos_qty_rest = quantity_rest / move_qty * move.product_uos_qty
default_val = {
@ -72,6 +76,7 @@ class stock_split_into(osv.osv_memory):
current_move = move_obj.copy(cr, uid, move.id, default_val)
new_move.append(current_move)
update_val['product_qty'] = quantity_rest
update_val['prodlot_id'] = prodlot_id
update_val['product_uos_qty'] = uos_qty_rest
move_obj.write(cr, uid, [move.id], update_val)
return {}

View File

@ -8,7 +8,8 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Split Move">
<field name="quantity" colspan="4"/>
<separator string="Set quantity to split your palets" colspan="4"/>
<field name="quantity"/>
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="split" string="Ok"