[FIX] sale,purchase,stock
bzr revid: fp@tinyerp.com-20100621184058-try3rw3m59uc4e55
This commit is contained in:
parent
a11f329d20
commit
9c3da9c251
|
@ -679,30 +679,28 @@ class mrp_production(osv.osv):
|
|||
raw_product_todo = []
|
||||
final_product_todo = []
|
||||
|
||||
produced_qty = 0
|
||||
for produced_product in production.move_created_ids2:
|
||||
if (produced_product.scraped) or (produced_product.product_id.id<>production.product_id.id):
|
||||
continue
|
||||
produced_qty += produced_product.product_qty
|
||||
|
||||
if production_mode in ['consume','consume_produce']:
|
||||
# To consume remaining qty of raw materials
|
||||
consumed_products = {}
|
||||
produced_qty = 0
|
||||
for consumed_product in production.move_lines2:
|
||||
if consumed_product.scraped:
|
||||
continue
|
||||
if not consumed_products.get(consumed_product.product_id.id, False):
|
||||
consumed_products[consumed_product.product_id.id] = 0
|
||||
consumed_products[consumed_product.product_id.id] += consumed_product.product_qty
|
||||
|
||||
for produced_product in production.move_created_ids2:
|
||||
if produced_product.scraped:
|
||||
continue
|
||||
produced_qty += produced_product.product_qty
|
||||
consumed_products[consumed_product.product_id.id] -= consumed_product.product_qty
|
||||
|
||||
for raw_product in production.move_lines:
|
||||
consumed_qty = consumed_products.get(raw_product.product_id.id, 0)
|
||||
consumed_qty -= produced_qty
|
||||
rest_qty = production_qty - consumed_qty
|
||||
if rest_qty > production.product_qty:
|
||||
rest_qty = production.product_qty
|
||||
if rest_qty > 0:
|
||||
stock_mov_obj.action_consume(cr, uid, [raw_product.id], rest_qty, production.location_src_id.id, context=context)
|
||||
for f in production.product_lines:
|
||||
if f.product_id.id==raw_product.product_id.id:
|
||||
consumed_qty = consumed_products.get(raw_product.product_id.id, 0)
|
||||
rest_qty = production_qty * f.product_qty / production.product_qty - consumed_qty
|
||||
if rest_qty > 0:
|
||||
stock_mov_obj.action_consume(cr, uid, [raw_product.id], rest_qty, production.location_src_id.id, context=context)
|
||||
|
||||
if production_mode == 'consume_produce':
|
||||
# To produce remaining qty of final product
|
||||
|
@ -725,7 +723,6 @@ class mrp_production(osv.osv):
|
|||
if rest_qty > 0 :
|
||||
stock_mov_obj.action_consume(cr, uid, [produce_product.id], production_qty, production.location_dest_id.id, context=context)
|
||||
|
||||
|
||||
for raw_product in production.move_lines2:
|
||||
new_parent_ids = []
|
||||
parent_move_ids = [x.id for x in raw_product.move_history_ids]
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
"access_procurement_stock_worker","procurement.order stock_worker","model_procurement_order","stock.group_stock_user",1,1,1,1
|
||||
"access_mrp_production_stock_worker","mrp.production stock_worker","model_mrp_production","stock.group_stock_user",1,0,0,0
|
||||
"access_mrp_installer","mrp.installer","model_mrp_installer","base.group_system",1,1,1,1
|
||||
"access_mrp_product_produce","mrp.product.produce","model_mrp_product_produce","mrp.group_mrp_user",1,0,0,0
|
||||
"access_mrp_product_produce","mrp.product.produce","model_mrp_product_produce","mrp.group_mrp_user",1,1,1,1
|
||||
"access_mrp_change_production_qty","change.production.qty","model_change_production_qty","mrp.group_mrp_user",1,0,0,0
|
||||
"access_mrp_production_order","mrp.production.order","model_mrp_production_order","mrp.group_mrp_user",1,0,0,0
|
||||
"access_report_workcenter_load","report.workcenter.load","model_report_workcenter_load","mrp.group_mrp_manager",1,0,0,0
|
||||
|
|
|
|
@ -237,14 +237,12 @@
|
|||
-
|
||||
!record {model: stock.partial.picking, id: stock_partial_picking0}:
|
||||
date: '2010-04-30 16:53:36'
|
||||
partner_id: base.res_partner_asus
|
||||
address_id: base.res_partner_address_tang
|
||||
-
|
||||
I make my pickings done.
|
||||
-
|
||||
!python {model: stock.partial.picking}: |
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
picking_ids = pick_obj.search(cr, uid, [('type','=','in')])
|
||||
self.view_init(cr, uid, ['date','partner_id','address_id'],context={'active_ids': picking_ids})
|
||||
self.view_init(cr, uid, ['date'],context={'active_ids': picking_ids})
|
||||
self.do_partial(cr, uid, [1], context={'active_ids': picking_ids})
|
||||
|
||||
|
|
|
@ -361,7 +361,7 @@ class procurement_order(osv.osv):
|
|||
ok = ok and self.pool.get('stock.move').action_assign(cr, uid, [id])
|
||||
cr.execute('select count(id) from stock_warehouse_orderpoint where product_id=%s', (procurement.product_id.id,))
|
||||
if not cr.fetchone()[0]:
|
||||
cr.execute('update procurement_order set message=%s where id=%s', (_('Stock is not enough and No minimum orderpoint rule defined'), procurement.id))
|
||||
cr.execute('update procurement_order set message=%s where id=%s', (_('Not enough stock and no minimum orderpoint rule defined.'), procurement.id))
|
||||
return ok
|
||||
|
||||
def action_produce_assign_service(self, cr, uid, ids, context={}):
|
||||
|
|
|
@ -251,6 +251,11 @@
|
|||
<field name="view_type">tree</field>
|
||||
<field name="view_id" ref="product_category_tree_view"/>
|
||||
</record>
|
||||
<menuitem
|
||||
action="product_category_action"
|
||||
id="product.menu_products_category"
|
||||
parent="base.menu_product"
|
||||
sequence="0"/>
|
||||
<record id="product_category_action_form" model="ir.actions.act_window">
|
||||
<field name="name">Products Categories</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
|
|
|
@ -37,7 +37,6 @@ class stock_production_lot(osv.osv):
|
|||
result.append((line.id, line.name))
|
||||
return result
|
||||
|
||||
|
||||
def _get_date(dtype):
|
||||
"""Return a function to compute the limit date for this type"""
|
||||
def calc_date(self, cr, uid, context=None):
|
||||
|
|
|
@ -26,55 +26,45 @@ from tools.translate import _
|
|||
import netsvc
|
||||
import pooler
|
||||
import time
|
||||
import datetime
|
||||
import datetime, time
|
||||
import wizard
|
||||
|
||||
class stock_partial_lot_picking(osv.osv_memory):
|
||||
_inherit = "stock.partial.picking"
|
||||
_name = "stock.partial.picking"
|
||||
_description = "Partial Picking"
|
||||
|
||||
def do_partial(self, cr, uid, ids, context):
|
||||
res = super(stock_partial_lot_picking, self).do_partial(cr, uid, ids, context=context)
|
||||
class stock_production_lot(osv.osv):
|
||||
_inherit = "stock.production.lot"
|
||||
def create(self, cr, uid, vals, context={}):
|
||||
new_id = super(stock_production_lot, self).create(cr, uid, vals, context=context)
|
||||
prodlot_obj = self.pool.get('stock.production.lot')
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
picking_ids = context.get('active_ids', False)
|
||||
partial = self.browse(cr, uid, ids[0], context)
|
||||
for pick in pick_obj.browse(cr, uid, picking_ids):
|
||||
for m in pick.move_lines:
|
||||
for pick in pick_obj.browse(cr, uid, picking_ids):
|
||||
for m in pick.move_lines:
|
||||
res = {}
|
||||
if (pick.type == 'in') and m.prodlot_id:
|
||||
if not m.prodlot_id.life_date:
|
||||
date_life = (datetime.datetime.strptime(partial.date, '%Y-%m-%d %H:%M:%S') + datetime.timedelta(days=m.product_id.life_time))
|
||||
res['life_date'] = date_life.strftime('%Y-%m-%d')
|
||||
if not m.prodlot_id.use_date:
|
||||
date_use = (datetime.datetime.strptime(partial.date, '%Y-%m-%d %H:%M:%S') + datetime.timedelta(days=m.product_id.use_time))
|
||||
res['use_date'] = date_use.strftime('%Y-%m-%d')
|
||||
if not m.prodlot_id.removal_date:
|
||||
date_removal = (datetime.datetime.strptime(partial.date, '%Y-%m-%d %H:%M:%S') + datetime.timedelta(days=m.product_id.removal_time))
|
||||
res['removal_date'] = date_removal.strftime('%Y-%m-%d')
|
||||
if not m.prodlot_id.alert_date:
|
||||
date_alert = (datetime.datetime.strptime(partial.date, '%Y-%m-%d %H:%M:%S') + datetime.timedelta(days=m.product_id.alert_time))
|
||||
res['alert_date'] = date_alert.strftime('%Y-%m-%d')
|
||||
prodlot_obj.write(cr, uid, [m.prodlot_id.id], res)
|
||||
return res
|
||||
stock_partial_lot_picking()
|
||||
prod = prodlot_obj.browse(cr, uid, new_id, context=context)
|
||||
res = {}
|
||||
current_date = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
if not prod.life_date:
|
||||
date_life = (datetime.datetime.strptime(current_date, '%Y-%m-%d %H:%M:%S') + datetime.timedelta(days=prod.product_id.life_time))
|
||||
res['life_date'] = date_life.strftime('%Y-%m-%d')
|
||||
if not prod.use_date:
|
||||
date_use = (datetime.datetime.strptime(current_date, '%Y-%m-%d %H:%M:%S') + datetime.timedelta(days=prod.product_id.use_time))
|
||||
res['use_date'] = date_use.strftime('%Y-%m-%d')
|
||||
if not prod.removal_date:
|
||||
date_removal = (datetime.datetime.strptime(current_date, '%Y-%m-%d %H:%M:%S') + datetime.timedelta(days=prod.product_id.removal_time))
|
||||
res['removal_date'] = date_removal.strftime('%Y-%m-%d')
|
||||
if not prod.alert_date:
|
||||
date_alert = (datetime.datetime.strptime(current_date, '%Y-%m-%d %H:%M:%S') + datetime.timedelta(days=prod.product_id.alert_time))
|
||||
res['alert_date'] = date_alert.strftime('%Y-%m-%d')
|
||||
prodlot_obj.write(cr, uid, [prod.id], res)
|
||||
return new_id
|
||||
stock_production_lot()
|
||||
|
||||
class stock_move_split_lines_exist(osv.osv_memory):
|
||||
_name = "stock.move.split.lines.exist"
|
||||
_inherit = "stock.move.split.lines.exist"
|
||||
_inherit = "stock.move.split.lines"
|
||||
_columns = {
|
||||
'date': fields.date('Expiry Date'),
|
||||
}
|
||||
# TODO: use this date instead of default one
|
||||
def on_change_product(self, cr, uid, ids, product_id):
|
||||
if not product_id:
|
||||
return {'value':{'date': False}}
|
||||
day_life = self.pool.get('product.product').browse(cr, uid, product_id).life_time
|
||||
date_life = (datetime.datetime.now() + datetime.timedelta(days=day_life))
|
||||
return {'value':{'date': date_life.strftime('%Y-%m-%d')
|
||||
}}
|
||||
|
||||
|
||||
return {'value':
|
||||
{'date': date_life.strftime('%Y-%m-%d')}
|
||||
}
|
||||
stock_move_split_lines_exist()
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_split_in_lots" model="ir.ui.view">
|
||||
<field name="name">Split in lots</field>
|
||||
<field name="model">stock.move.split</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">Split in lots</field>
|
||||
<field name="model">stock.move.split</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="stock.view_split_in_lots"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//form/group/field[@name='line_exist_ids']/tree/field[@name='prodlot_id']" position="replace">
|
||||
<field name="prodlot_id" on_change="on_change_product(parent.product_id)"/>
|
||||
<xpath expr="//form/group/field[@name='line_ids']/tree/field[@name='name']" position="replace">
|
||||
<field name="name" on_change="on_change_product(parent.product_id)"/>
|
||||
</xpath>
|
||||
<xpath expr="//form/group/field[@name='line_exist_ids']/tree/field[@name='quantity']" position="after">
|
||||
<xpath expr="//form/group/field[@name='line_ids']/tree/field[@name='quantity']" position="after">
|
||||
<field name="date"/>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_product_manufacturer_attribute","product.manufacturer.attribute","model_product_manufacturer_attribute","product.group_uos",1,0,0,0
|
||||
"access_product_manufacturer_attribute","product.manufacturer.attribute","model_product_manufacturer_attribute",,1,0,0,0
|
||||
"access_product_manufacturer_attribute_manager","product.manufacturer.attribute","model_product_manufacturer_attribute","product.group_product_manager",1,1,1,1
|
||||
"access_partner_manufacturer","res.partner.manufacturer","model_res_partner_manufacturer","product.group_uos",1,0,0,0
|
||||
"access_partner_manufacturer_manager","res.partner.manufacturer","model_res_partner_manufacturer","product.group_uos",1,1,1,1
|
||||
"access_partner_manufacturer","res.partner.manufacturer","model_res_partner_manufacturer",,1,0,0,0
|
||||
"access_partner_manufacturer_manager","res.partner.manufacturer","model_res_partner_manufacturer","product.group_product_manager",1,1,1,1
|
||||
|
|
|
|
@ -52,7 +52,7 @@ class sale_report(osv.osv):
|
|||
'company_id':fields.many2one('res.company', 'Company', readonly=True),
|
||||
'user_id':fields.many2one('res.users', 'Salesman', readonly=True),
|
||||
'price_total':fields.float('Total Price', readonly=True),
|
||||
'delay':fields.float('Days to Close', digits=(16,2), readonly=True),
|
||||
'delay':fields.float('Commitment Delay', digits=(16,2), readonly=True),
|
||||
'price_average':fields.float('Average Price', readonly=True,group_operator="avg"),
|
||||
'categ_id': fields.many2one('product.category','Category of Product', readonly=True),
|
||||
'nbr':fields.integer('# of Lines', readonly=True),
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<field name="uom_name" invisible="not context.get('set_visible',False)"/>
|
||||
<field name="price_average" avg="Average Price"/>
|
||||
<field name="price_total" sum="Total Price"/>
|
||||
<field name="delay" avg="Days to Close"/>
|
||||
<field name="delay" avg="Commitment Delay"/>
|
||||
<field name="state" invisible="1"/>
|
||||
<field name="analytic_account_id" invisible="1"/>
|
||||
</tree>
|
||||
|
|
|
@ -611,6 +611,7 @@ class sale_order(osv.osv):
|
|||
picking_id = False
|
||||
company = self.pool.get('res.users').browse(cr, uid, uid).company_id
|
||||
for order in self.browse(cr, uid, ids, context={}):
|
||||
proc_ids = []
|
||||
output_id = order.shop_id.warehouse_id.lot_output_id.id
|
||||
picking_id = False
|
||||
for line in order.order_line:
|
||||
|
@ -619,6 +620,7 @@ class sale_order(osv.osv):
|
|||
date_planned = (date_planned - relativedelta(company.security_lead)).strftime('%Y-%m-%d %H:%M:%S')
|
||||
if line.state == 'done':
|
||||
continue
|
||||
move_id = False
|
||||
if line.product_id and line.product_id.product_tmpl_id.type in ('product', 'consu'):
|
||||
location_id = order.shop_id.warehouse_id.lot_stock_id.id
|
||||
if not picking_id:
|
||||
|
@ -659,8 +661,9 @@ class sale_order(osv.osv):
|
|||
'note': line.notes,
|
||||
'company_id': order.company_id.id,
|
||||
})
|
||||
if line.product_id:
|
||||
proc_id = self.pool.get('procurement.order').create(cr, uid, {
|
||||
'name': order.name,
|
||||
'name': line.name,
|
||||
'origin': order.name,
|
||||
'date_planned': date_planned,
|
||||
'product_id': line.product_id.id,
|
||||
|
@ -676,36 +679,18 @@ class sale_order(osv.osv):
|
|||
'property_ids': [(6, 0, [x.id for x in line.property_ids])],
|
||||
'company_id': order.company_id.id,
|
||||
})
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr)
|
||||
proc_ids.append(proc_id)
|
||||
self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id})
|
||||
elif line.product_id and line.product_id.product_tmpl_id.type == 'service':
|
||||
proc_id = self.pool.get('procurement.order').create(cr, uid, {
|
||||
'name': line.name,
|
||||
'origin': order.name,
|
||||
'date_planned': date_planned,
|
||||
'product_id': line.product_id.id,
|
||||
'product_qty': line.product_uom_qty,
|
||||
'product_uom': line.product_uom.id,
|
||||
'location_id': order.shop_id.warehouse_id.lot_stock_id.id,
|
||||
'procure_method': line.type,
|
||||
'property_ids': [(6, 0, [x.id for x in line.property_ids])],
|
||||
'company_id': order.company_id.id,
|
||||
})
|
||||
self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id})
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr)
|
||||
else:
|
||||
#
|
||||
# No procurement because no product in the sale.order.line.
|
||||
#
|
||||
pass
|
||||
|
||||
val = {}
|
||||
if picking_id:
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
|
||||
|
||||
for proc_id in proc_ids:
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr)
|
||||
|
||||
if order.state == 'shipping_except':
|
||||
val['state'] = 'progress'
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@
|
|||
</para>
|
||||
<section>
|
||||
<para style="terp_default_8">[[ repeatIn(ob['product'],'p') ]]</para>
|
||||
<blockTable colWidths="72.0,35.0,133.0,47.0,58.0,33.0,60.0,43.0" repeatRows="1" style="Table4">
|
||||
<blockTable colWidths="20.0,120.0,133.0,47.0,58.0,33.0,60.0,43.0" repeatRows="1" style="Table4">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P2">
|
||||
|
|
|
@ -253,7 +253,7 @@
|
|||
<para style="terp_default_9">[ [[ move_lines.product_id.default_code ]] ] [[ move_lines.product_id.name ]] [[ move_lines.product_id.variants or '']] </para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_9">[[ move_lines.tracking_id and move_lines.tracking_id.name or '' ]]</para>
|
||||
<para style="terp_default_9">[[ (move_lines.tracking_id and move_lines.tracking_id.name) or '/' ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_9">[[ (move_lines.prodlot_id and move_lines.prodlot_id.name) or '' ]]</para>
|
||||
|
@ -281,11 +281,14 @@
|
|||
<para style="terp_default_1cm_above_space">[[ (line.state == 'done' or line.state == 'confirmed') and removeParentNode('para') ]]</para>
|
||||
<section>
|
||||
<para style="terp_default_8">[[ repeatIn([line for line in picking.move_lines if (line.state != 'assigned' )],'move_lines') ]]</para>
|
||||
<blockTable colWidths="257.0,57.0,62.0,46.0,26.0,74.0" style="Move_Line_Content_Other_State">
|
||||
<blockTable colWidths="197.0,68.0,61.0,57,46.0,26.0,74.0" style="Move_Line_Content_Other_State">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="terp_default_9">[ [[ move_lines.product_id.default_code ]] ] [[ move_lines.product_id.name ]] [[ move_lines.product_id.variants or '']]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_9">[[ (move_lines.tracking_id and move_lines.tracking_id.name) or '/' ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_9">[[ (move_lines.prodlot_id and move_lines.prodlot_id.name) or '' ]]</para>
|
||||
</td>
|
||||
|
@ -303,15 +306,6 @@
|
|||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<para style="terp_default_2">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</section>
|
||||
<para style="terp_default_9">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<para style="Standard">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</story>
|
||||
</document>
|
||||
|
|
|
@ -25,7 +25,7 @@ from osv import fields,osv
|
|||
|
||||
class report_stock_move(osv.osv):
|
||||
_name = "report.stock.move"
|
||||
_description = "Stock Statistics"
|
||||
_description = "Moves Statistics"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'date_planned': fields.date('Date', readonly=True),
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
src_model="product.product"
|
||||
groups="base.group_extended"/>
|
||||
|
||||
<act_window
|
||||
<act_window
|
||||
domain="[('tracking_id', '=', active_id)]"
|
||||
id="act_stock_tracking_lot_2_stock_report_tracklots"
|
||||
name="Stock" res_model="stock.report.tracklots"
|
||||
|
|
|
@ -410,22 +410,23 @@ class stock_tracking(osv.osv):
|
|||
_name = "stock.tracking"
|
||||
_description = "Stock Tracking Lots"
|
||||
|
||||
def get_create_tracking_lot(self, cr, uid, ids, tracking_lot):
|
||||
"""
|
||||
@param tracking_lot: Name of tracking lot
|
||||
@return:
|
||||
"""
|
||||
tracking_lot_list = self.search(cr, uid, [('name', '=', tracking_lot)],
|
||||
limit=1)
|
||||
if tracking_lot_list:
|
||||
tracking_lot = tracking_lot_list[0]
|
||||
tracking_obj = self.browse(cr, uid, tracking_lot)
|
||||
if not tracking_obj:
|
||||
tracking_lot_vals = {
|
||||
'name': tracking_lot
|
||||
}
|
||||
tracking_lot = self.create(cr, uid, tracking_lot_vals)
|
||||
return tracking_lot
|
||||
#def get_create_tracking_lot(self, cr, uid, ids, tracking_lot):
|
||||
# """
|
||||
# @param tracking_lot: Name of tracking lot
|
||||
# @return:
|
||||
# """
|
||||
# tracking_lot_list = self.search(cr, uid, [('name', '=', tracking_lot)],
|
||||
# limit=1)
|
||||
# if tracking_lot_list:
|
||||
# tracking_lot = tracking_lot_list[0]
|
||||
# tracking_obj = self.browse(cr, uid, tracking_lot)
|
||||
# if not tracking_obj:
|
||||
# tracking_lot_vals = {
|
||||
# 'name': tracking_lot
|
||||
# }
|
||||
# tracking_lot = self.create(cr, uid, tracking_lot_vals)
|
||||
# return tracking_lot
|
||||
|
||||
def checksum(sscc):
|
||||
salt = '31' * 8 + '3'
|
||||
sum = 0
|
||||
|
@ -445,7 +446,6 @@ class stock_tracking(osv.osv):
|
|||
'move_ids': fields.one2many('stock.move', 'tracking_id', 'Moves Tracked'),
|
||||
'date': fields.datetime('Created Date', required=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'active': lambda *a: 1,
|
||||
'name': make_sscc,
|
||||
|
@ -1372,9 +1372,7 @@ class stock_move(osv.osv):
|
|||
'move_history_ids': fields.many2many('stock.move', 'stock_move_history_ids', 'parent_id', 'child_id', 'Move History'),
|
||||
'move_history_ids2': fields.many2many('stock.move', 'stock_move_history_ids', 'child_id', 'parent_id', 'Move History'),
|
||||
'picking_id': fields.many2one('stock.picking', 'Picking List', select=True),
|
||||
|
||||
'note': fields.text('Notes'),
|
||||
|
||||
'state': fields.selection([('draft', 'Draft'), ('waiting', 'Waiting'), ('confirmed', 'Confirmed'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True,
|
||||
help='When the stock move is created it is in the \'Draft\' state.\n After that it is set to \'Confirmed\' state.\n If stock is available state is set to \'Avaiable\'.\n When the picking it done the state is \'Done\'.\
|
||||
\nThe state is \'Waiting\' if the move is waiting for another one.'),
|
||||
|
@ -1651,7 +1649,7 @@ class stock_move(osv.osv):
|
|||
done = []
|
||||
count = 0
|
||||
pickings = {}
|
||||
for move in self.browse(cr, uid, ids):
|
||||
for move in self.browse(cr, uid, ids, context=context):
|
||||
if move.product_id.type == 'consu':
|
||||
if move.state in ('confirmed', 'waiting'):
|
||||
done.append(move.id)
|
||||
|
@ -1686,31 +1684,16 @@ class stock_move(osv.osv):
|
|||
return count
|
||||
|
||||
def setlast_tracking(self, cr, uid, ids, context=None):
|
||||
new_move = []
|
||||
update_val = {}
|
||||
ir_sequence_obj = self.pool.get('ir.sequence')
|
||||
tracking_obj = self.pool.get('stock.tracking')
|
||||
tracking = False
|
||||
tracking = context.get('tracking', False)
|
||||
# import pdb; pdb.set_trace()
|
||||
if tracking:
|
||||
tracking_id = tracking_obj.search(cr, uid, ['name','=', tracking])
|
||||
if prodlot_id:
|
||||
update_val['prodlot_id'] = prodlot_id
|
||||
else:
|
||||
tracking_id = tracking_obj.create(cr, uid, {'name': tracking}, {'product_id': self.browse(cr, uid, ids)[0].product_id.id})
|
||||
update_val['tracking_id'] = tracking_id
|
||||
last_track = [line.tracking_id.id for line in self.browse(cr, uid, ids)[0].picking_id.move_lines if line.tracking_id]
|
||||
if not last_track:
|
||||
last_track = tracking_obj.create(cr, uid, {}, context=context)
|
||||
else:
|
||||
last_track = [line.tracking_id for line in self.browse(cr, uid, ids)[0].picking_id.move_lines if line.tracking_id]
|
||||
if not last_track:
|
||||
track_ids= tracking_obj.search(cr, uid, [])
|
||||
last_track = [track for track in tracking_obj.browse(cr, uid, track_ids)]
|
||||
last_track.sort(key=lambda p: p.date, reverse=True)
|
||||
last_track_id = last_track and last_track[0].id
|
||||
update_val['tracking_id'] = last_track_id
|
||||
self.write(cr, uid, ids, update_val)
|
||||
last_track.sort()
|
||||
last_track = last_track[-1]
|
||||
self.write(cr, uid, ids, {'tracking_id': last_track})
|
||||
return True
|
||||
|
||||
|
||||
#
|
||||
# Cancel move => cancel others move and pickings
|
||||
|
@ -1793,10 +1776,11 @@ class stock_move(osv.osv):
|
|||
picking_ids = []
|
||||
product_uom_obj = self.pool.get('product.uom')
|
||||
price_type_obj = self.pool.get('product.price.type')
|
||||
product_obj=self.pool.get('product.product')
|
||||
product_obj=self.pool.get('product.product')
|
||||
move_obj = self.pool.get('account.move')
|
||||
for move in self.browse(cr, uid, ids):
|
||||
if move.picking_id: picking_ids.append(move.picking_id.id)
|
||||
if move.picking_id:
|
||||
picking_ids.append(move.picking_id.id)
|
||||
if move.move_dest_id.id and (move.state != 'done'):
|
||||
cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id))
|
||||
if move.move_dest_id.state in ('waiting', 'confirmed'):
|
||||
|
@ -1846,25 +1830,27 @@ class stock_move(osv.osv):
|
|||
'line_id': line,
|
||||
'ref': move.picking_id and move.picking_id.name,
|
||||
})
|
||||
tracking_lot = False
|
||||
if context:
|
||||
tracking_lot = context.get('tracking_lot', False)
|
||||
if tracking_lot:
|
||||
rec_id = context and context.get('active_id', False)
|
||||
tracking = self.pool.get('stock.tracking')
|
||||
tracking_lot = tracking.get_create_tracking_lot(cr, uid,[rec_id], tracking_lot)
|
||||
|
||||
self.write(cr, uid, ids, {'state': 'done', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S'), 'tracking_id': tracking_lot or False})
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
for pick in picking_obj.browse(cr, uid, picking_ids):
|
||||
if all(move.state == 'done' for move in pick.move_lines):
|
||||
picking_obj.action_done(cr, uid, [pick.id])
|
||||
# This can be removed
|
||||
#tracking_lot = False
|
||||
#if context:
|
||||
# tracking_lot = context.get('tracking_lot', False)
|
||||
# if tracking_lot:
|
||||
# rec_id = context and context.get('active_id', False)
|
||||
# tracking = self.pool.get('stock.tracking')
|
||||
# tracking_lot = tracking.get_create_tracking_lot(cr, uid,[rec_id], tracking_lot)
|
||||
|
||||
self.write(cr, uid, ids, {'state': 'done', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S')})
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for id in ids:
|
||||
wf_service.trg_trigger(uid, 'stock.move', id, cr)
|
||||
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
for pick in picking_obj.browse(cr, uid, picking_ids):
|
||||
if len([move.state == 'done' for move in pick.move_lines]) == len(pick.move_lines):
|
||||
if len([(move.state in ('done','cancelled')) for move in pick.move_lines]) == len(pick.move_lines):
|
||||
picking_obj.action_done(cr, uid, [pick.id])
|
||||
wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_done', cr)
|
||||
|
||||
return True
|
||||
|
||||
def create_account_move(self, cr, uid, move,account_id,account_variation,amount, context=None):
|
||||
|
@ -1906,19 +1892,9 @@ class stock_move(osv.osv):
|
|||
@return: Production lot id
|
||||
"""
|
||||
prodlot_obj = self.pool.get('stock.production.lot')
|
||||
ir_sequence_obj = self.pool.get('ir.sequence')
|
||||
sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
|
||||
if not sequence:
|
||||
raise osv.except_osv(_('Error!'), _('No production sequence defined'))
|
||||
prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix': prefix}, {'product_id': product_id})
|
||||
prodlot = prodlot_obj.browse(cr, uid, prodlot_id)
|
||||
ref = ','.join(map(lambda x:str(x),ids))
|
||||
if prodlot.ref:
|
||||
ref = '%s, %s' % (prodlot.ref, ref)
|
||||
prodlot_obj.write(cr, uid, [prodlot_id], {'ref': ref})
|
||||
prodlot_id = prodlot_obj.create(cr, uid, {'prefix': prefix, 'product_id': product_id})
|
||||
return prodlot_id
|
||||
|
||||
|
||||
def action_scrap(self, cr, uid, ids, quantity, location_id, context=None):
|
||||
""" Move the scrap/damaged product into scrap location
|
||||
@param cr: the database cursor
|
||||
|
@ -2094,7 +2070,6 @@ class stock_move(osv.osv):
|
|||
partner_id = partial_datas.get('partner_id', False)
|
||||
address_id = partial_datas.get('address_id', False)
|
||||
delivery_date = partial_datas.get('delivery_date', False)
|
||||
tracking_lot = context.get('tracking_lot', False)
|
||||
|
||||
new_moves = []
|
||||
|
||||
|
@ -2111,10 +2086,6 @@ class stock_move(osv.osv):
|
|||
product_price = partial_data.get('product_price',0.0)
|
||||
product_currency = partial_data.get('product_currency',False)
|
||||
if move.product_qty == product_qty:
|
||||
self.write(cr, uid, move.id,
|
||||
{
|
||||
'tracking_id': tracking_lot
|
||||
})
|
||||
complete.append(move)
|
||||
elif move.product_qty > product_qty:
|
||||
too_few.append(move)
|
||||
|
@ -2159,7 +2130,7 @@ class stock_move(osv.osv):
|
|||
'state': 'assigned',
|
||||
'move_dest_id': False,
|
||||
'price_unit': move.price_unit,
|
||||
'tracking_id': tracking_lot,
|
||||
#'tracking_id': tracking_lot,
|
||||
})
|
||||
complete.append(self.browse(cr, uid, new_move))
|
||||
self.write(cr, uid, move.id,
|
||||
|
@ -2174,7 +2145,7 @@ class stock_move(osv.osv):
|
|||
{
|
||||
'product_qty': move.product_qty,
|
||||
'product_uos_qty': move.product_qty,
|
||||
'tracking_id': tracking_lot
|
||||
#'tracking_id': tracking_lot
|
||||
})
|
||||
complete.append(move)
|
||||
|
||||
|
|
|
@ -405,7 +405,7 @@
|
|||
<field name="model">stock.location</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Stock location">
|
||||
<form string="Stock Location">
|
||||
<field name="name"/>
|
||||
<field name="active" groups="base.group_extended"/>
|
||||
<newline/>
|
||||
|
@ -464,7 +464,7 @@
|
|||
<field name="type">tree</field>
|
||||
<field name="priority" eval="2"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Stock location" colors="blue:usage=='view';darkred:usage=='internal'">
|
||||
<tree string="Stock Location" colors="blue:usage=='view';darkred:usage=='internal'">
|
||||
<field name="complete_name"/>
|
||||
<field name="usage"/>
|
||||
<field name="stock_real" invisible="'product_id' not in context"/>
|
||||
|
@ -596,6 +596,7 @@
|
|||
<field name="date"/>
|
||||
<field name="min_date"/>
|
||||
<field name="invoice_state"/>
|
||||
<field name="stock_journal_id" groups="base.group_extended" widget="selection"/>
|
||||
<field name="state"/>
|
||||
<button name="%(action_partial_picking)d" states="assigned" string="Validate" type="action" icon="gtk-go-forward" help="Validate Picking"/>
|
||||
<button name="button_cancel" states="assigned,confirmed,draft" string="Cancel" icon="gtk-cancel" help="Cancel" confirm="This operation will cancel the picking. Do you want to continue?"/>
|
||||
|
@ -621,7 +622,7 @@
|
|||
<notebook colspan="4">
|
||||
<page string="General Information">
|
||||
<field colspan="4" name="move_lines" nolabel="1" widget="one2many_list" default_get="{'move_line':move_lines, 'address_out_id': address_id}">
|
||||
<tree colors="grey:state in ('cancel')" string="Stock Moves" editable="top">
|
||||
<tree colors="grey:scraped == True" string="Stock Moves" editable="top">
|
||||
<field name="name" string="Move Name"/>
|
||||
<field name="product_id"/>
|
||||
<field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"/>
|
||||
|
@ -636,9 +637,10 @@
|
|||
states="draft,waiting,confirmed,assigned" />
|
||||
<field groups="base.group_extended" name="tracking_id"/>
|
||||
<button name="%(split_into)d" string="Split Stock Moves" type="action"
|
||||
groups="base.group_extended"
|
||||
icon="terp-stock_effects-object-colorize"
|
||||
states="draft,assigned,confirmed,done"/>
|
||||
attrs="{'invisible': [('tracking_id','<>',False)]}"
|
||||
groups="base.group_extended"
|
||||
icon="terp-stock_effects-object-colorize"
|
||||
states="draft,assigned,confirmed,done"/>
|
||||
<button name="setlast_tracking" string="Set Last Tracking" type="object"
|
||||
attrs="{'invisible': [('tracking_id','<>',False)]}"
|
||||
icon="terp-stock_effects-object-colorize"
|
||||
|
@ -654,6 +656,7 @@
|
|||
string="Scrap Products" type="action"
|
||||
icon="gtk-convert" context="{'scrap': True}"
|
||||
states="draft,waiting,confirmed,assigned" />
|
||||
<field name="scraped" invisible="1"/>
|
||||
</tree>
|
||||
<form string="Stock Moves">
|
||||
<notebook colspan="4">
|
||||
|
@ -684,6 +687,7 @@
|
|||
groups="base.group_extended" />
|
||||
<button name="%(move_scrap)d" string="Scrap Move Line" type="action" icon="gtk-justify-fill"/>
|
||||
<button name="%(split_into)d" string="Split Stock Moves" type="action"
|
||||
attrs="{'invisible': [('tracking_id','<>',False)]}"
|
||||
groups="base.group_extended"
|
||||
icon="terp-stock_effects-object-colorize" />
|
||||
<separator colspan="4" string="Move State"/>
|
||||
|
@ -761,6 +765,7 @@
|
|||
<field name="origin"/>
|
||||
<field name="date"/>
|
||||
<field name="min_date"/>
|
||||
<field name="stock_journal_id" groups="base.group_extended" widget="selection"/>
|
||||
<field name="state"/>
|
||||
<button name="%(action_partial_picking)d" states="assigned" string="Validate" type="action" icon="gtk-go-forward" help="Validate Delivery"/>
|
||||
<button name="button_cancel" states="assigned,confirmed,draft" string="Cancel" icon="gtk-cancel" help="Cancel" confirm="This operation will cancel the delivery. Do you want to continue?"/>
|
||||
|
@ -787,7 +792,7 @@
|
|||
<notebook colspan="4">
|
||||
<page string="General Information">
|
||||
<field colspan="4" name="move_lines" nolabel="1" widget="one2many_list" default_get="{'move_line':move_lines, 'address_out_id': address_id}" >
|
||||
<tree colors="grey:state in ('cancel')" string="Stock Moves" editable="top">
|
||||
<tree colors="grey:scraped == True" string="Stock Moves" editable="top">
|
||||
<field name="name" string="Move Name"/>
|
||||
<field name="product_id"/>
|
||||
<field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"/>
|
||||
|
@ -815,10 +820,11 @@
|
|||
type="action" icon="terp-stock_effects-object-colorize"
|
||||
groups="base.group_extended"
|
||||
states="draft,waiting,confirmed,assigned" />
|
||||
<button name="%(stock.move_scrap)d"
|
||||
<button name="%(stock.move_scrap)d"
|
||||
string="Scrap Products" type="action"
|
||||
icon="gtk-convert" context="{'scrap': True}"
|
||||
states="draft,waiting,confirmed,assigned" />
|
||||
<field name="scraped" invisible="1"/>
|
||||
</tree>
|
||||
<form string="Stock Moves">
|
||||
<notebook colspan="4">
|
||||
|
@ -849,6 +855,7 @@
|
|||
type="action" icon="terp-stock_effects-object-colorize"/>
|
||||
<label/>
|
||||
<button name="%(split_into)d" string="Split Stock Moves" type="action"
|
||||
attrs="{'invisible': [('tracking_id','<>',False)]}"
|
||||
groups="base.group_extended"
|
||||
icon="terp-stock_effects-object-colorize"
|
||||
states="draft,assigned,confirmed,done"/>
|
||||
|
@ -962,6 +969,7 @@
|
|||
<field name="min_date"/>
|
||||
<field name="backorder_id" groups="base.group_extended"/>
|
||||
<field name="invoice_state"/>
|
||||
<field name="stock_journal_id" groups="base.group_extended" widget="selection"/>
|
||||
<field name="state"/>
|
||||
<button name="%(action_partial_picking)d" states="assigned" string="Validate" type="action" icon="gtk-go-forward" help="Validate Picking"/>
|
||||
</tree>
|
||||
|
@ -987,7 +995,7 @@
|
|||
<notebook colspan="4">
|
||||
<page string="General Information">
|
||||
<field colspan="4" name="move_lines" nolabel="1" widget="one2many_list" default_get="{'move_line':move_lines, 'address_out_id': address_id}" >
|
||||
<tree colors="grey:state in ('cancel')" string="Stock Moves" editable="top">
|
||||
<tree colors="grey:scraped=True" string="Stock Moves" editable="top">
|
||||
<field name="product_id"/>
|
||||
<field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"/>
|
||||
<field name="product_uom" string="UOM"/>
|
||||
|
@ -1001,10 +1009,11 @@
|
|||
states="assigned,confirmed,done"
|
||||
groups="base.group_extended"/>
|
||||
<field name="tracking_id" groups="base.group_extended"/>
|
||||
<button name="%(split_into)d" string="Split Stock Moves" type="action"
|
||||
icon="terp-stock_effects-object-colorize"
|
||||
groups="base.group_extended"
|
||||
states="draft,assigned,confirmed,done"/>
|
||||
<button name="%(split_into)d" string="Split Stock Moves" type="action"
|
||||
attrs="{'invisible': [('tracking_id','<>',False)]}"
|
||||
icon="terp-stock_effects-object-colorize"
|
||||
groups="base.group_extended"
|
||||
states="draft,assigned,confirmed,done"/>
|
||||
<button name="setlast_tracking" string="Set Last Tracking" type="object"
|
||||
attrs="{'invisible': [('tracking_id','<>',False)]}"
|
||||
groups="base.group_extended"
|
||||
|
@ -1015,6 +1024,7 @@
|
|||
<field name="state"/>
|
||||
<button name="%(action_partial_move)d" string="Partial" type="action" states="confirmed,assigned" icon="gtk-justify-fill"/>
|
||||
<button name="action_done" states="confirmed,assigned" string="Done" type="object" icon="gtk-jump-to"/>
|
||||
<field name="scraped" invisible="1"/>
|
||||
</tree>
|
||||
<form string="Stock Moves">
|
||||
<notebook colspan="4">
|
||||
|
@ -1044,6 +1054,7 @@
|
|||
/>
|
||||
<label/>
|
||||
<button name="%(split_into)d" string="Split Stock Moves" type="action"
|
||||
attrs="{'invisible': [('tracking_id','<>',False)]}"
|
||||
groups="base.group_extended"
|
||||
icon="terp-stock_effects-object-colorize"
|
||||
states="draft,assigned,confirmed,done"/>
|
||||
|
@ -1156,6 +1167,7 @@
|
|||
<field name="date"/>
|
||||
<field name="min_date"/>
|
||||
<field name="invoice_state" groups="base.group_extended"/>
|
||||
<field name="stock_journal_id" groups="base.group_extended" widget="selection"/>
|
||||
<field name="state"/>
|
||||
<button name="%(action_partial_picking)d" states="assigned" string="Validate" type="action" icon="gtk-ok" help="Receive products"/>
|
||||
<button name="button_cancel" states="assigned,confirmed,draft" string="Cancel" icon="gtk-cancel" help="Cancel" confirm="This operation will cancel the shipment. Do you want to continue?" />
|
||||
|
@ -1184,7 +1196,7 @@
|
|||
<notebook colspan="4">
|
||||
<page string="General Information">
|
||||
<field colspan="4" name="move_lines" nolabel="1" widget="one2many_list" default_get="{'move_line':move_lines, 'address_in_id': address_id}" >
|
||||
<tree colors="grey:state in ('cancel')" string="Stock Moves" editable="top">
|
||||
<tree colors="grey:scraped==True" string="Stock Moves" editable="top">
|
||||
<field name="product_id" readonly="1"/>
|
||||
<field name="product_qty" readonly="1"/>
|
||||
<field name="product_uom" string="UOM" readonly="1"/>
|
||||
|
@ -1210,6 +1222,7 @@
|
|||
string="Scrap Products" type="action"
|
||||
icon="gtk-convert" context="{'scrap': True}"
|
||||
states="draft,waiting,confirmed,assigned" />
|
||||
<field name="scraped" invisible="1"/>
|
||||
</tree>
|
||||
<form string="Stock Moves">
|
||||
<notebook colspan="4">
|
||||
|
@ -1232,7 +1245,7 @@
|
|||
|
||||
<newline/>
|
||||
<label/>
|
||||
<button groups="base.group_extended" name="267" string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize"/>
|
||||
<button groups="base.group_extended" name="267" string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize"/>
|
||||
<label/>
|
||||
<button name="275" string="Split Stock Moves" type="action"
|
||||
groups="base.group_extended"
|
||||
|
@ -1456,14 +1469,14 @@
|
|||
<newline/>
|
||||
<group colspan="4" col="4">
|
||||
<label/>
|
||||
<button name="%(track_line)d"
|
||||
groups="base.group_extended"
|
||||
string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize" colspan="2" />
|
||||
<button name="%(track_line)d"
|
||||
groups="base.group_extended"
|
||||
string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize" colspan="2" />
|
||||
<label/>
|
||||
<button name="%(split_into)d" string="Split Stock Moves" type="action"
|
||||
groups="base.group_extended"
|
||||
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','<>',False)]}"
|
||||
states="draft,assigned,confirmed,done"/>
|
||||
<button name="%(split_into)d" string="Split Stock Moves" type="action"
|
||||
groups="base.group_extended"
|
||||
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','<>',False)]}"
|
||||
states="draft,assigned,confirmed,done"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
|
@ -1607,15 +1620,15 @@
|
|||
<field name="picking_id"/>
|
||||
<group col="2" colspan="2">
|
||||
<label/>
|
||||
<button name="%(split_into)d" string="Split Stock Moves" type="action"
|
||||
groups="base.group_extended"
|
||||
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','<>',False)]}"
|
||||
states="draft,assigned,confirmed,done"/>
|
||||
<button name="%(split_into)d" string="Split Stock Moves" type="action"
|
||||
groups="base.group_extended"
|
||||
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','<>',False)]}"
|
||||
states="draft,assigned,confirmed,done"/>
|
||||
<label/>
|
||||
<button name="%(track_line)d" string="Split in production lots"
|
||||
groups="base.group_extended"
|
||||
type="action" icon="terp-stock_effects-object-colorize"/>
|
||||
</group>
|
||||
<button name="%(track_line)d" string="Split in production lots"
|
||||
groups="base.group_extended"
|
||||
type="action" icon="terp-stock_effects-object-colorize"/>
|
||||
</group>
|
||||
<separator colspan="4" string="Move State"/>
|
||||
<field name="state"/>
|
||||
<group col="5" colspan="2">
|
||||
|
|
|
@ -251,21 +251,15 @@ class split_in_production_lot(osv.osv_memory):
|
|||
if quantity_rest == 0:
|
||||
current_move = move.id
|
||||
prodlot_id = False
|
||||
if data.use_exist and line.prodlot_id:
|
||||
prodlot_id = prodlot_obj.search(cr, uid, [('id','=',line.prodlot_id.id)])
|
||||
if prodlot_id:
|
||||
prodlot_id = prodlot_id[0]
|
||||
if data.use_exist:
|
||||
prodlot_id = line.prodlot_id.id
|
||||
if not prodlot_id:
|
||||
# sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
|
||||
prodlot_id = prodlot_obj.create(cr, uid, {'name': line.name},
|
||||
# 'prefix' : line.name},
|
||||
{'product_id': move.product_id.id})
|
||||
prodlot_id = prodlot_obj.create(cr, uid, {
|
||||
'name': line.name,
|
||||
'product_id': move.product_id.id},
|
||||
context=context)
|
||||
print 'write', current_move, {'prodlot_id': prodlot_id, 'state':move.state}
|
||||
move_obj.write(cr, uid, [current_move], {'prodlot_id': prodlot_id, 'state':move.state})
|
||||
prodlot = prodlot_obj.browse(cr, uid, prodlot_id)
|
||||
# ref = '%d' % (move.id)
|
||||
# if prodlot.ref:
|
||||
# ref = '%s, %s' % (prodlot.ref, ref)
|
||||
# prodlot_obj.write(cr, uid, [prodlot_id], {'ref': ref})
|
||||
|
||||
update_val = {}
|
||||
if quantity_rest > 0:
|
||||
|
|
|
@ -1,57 +1,57 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_stock_move_track_wizard" model="ir.ui.view">
|
||||
<field name="name">Tracking a move</field>
|
||||
<field name="model">stock.move.track</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Tracking a move">
|
||||
<field name="tracking_prefix" colspan="4"/>
|
||||
<field name="quantity" colspan="4"/>
|
||||
<newline/>
|
||||
<separator string="" colspan="4" />
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="track_lines" string="Ok"
|
||||
type="object" icon="gtk-ok" />
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="track_line_old" model="ir.actions.act_window">
|
||||
<field name="name">Tracking a move</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">stock.move.track</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<record id="view_stock_move_track_wizard" model="ir.ui.view">
|
||||
<field name="name">Tracking a move</field>
|
||||
<field name="model">stock.move.track</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Tracking a move">
|
||||
<field name="tracking_prefix" colspan="4"/>
|
||||
<field name="quantity" colspan="4"/>
|
||||
<newline/>
|
||||
<separator string="" colspan="4" />
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="track_lines" string="Ok"
|
||||
type="object" icon="gtk-ok" />
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="track_line_old" model="ir.actions.act_window">
|
||||
<field name="name">Tracking a move</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">stock.move.track</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Consume, scrap move -->
|
||||
|
||||
<record id="view_stock_move_consume_wizard" model="ir.ui.view">
|
||||
|
||||
<record id="view_stock_move_consume_wizard" model="ir.ui.view">
|
||||
<field name="name">Consume Move</field>
|
||||
<field name="model">stock.move.consume</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Consume Move">
|
||||
<separator string="Consume Products" colspan="4"/>
|
||||
<field name="product_id" colspan="4" readonly="1"/>
|
||||
<field name="location_id" colspan="4" widget="selection"/>
|
||||
<field name="product_qty" colspan="2"/>
|
||||
<field name="product_uom" nolabel="1" readonly="1"/>
|
||||
<newline/>
|
||||
<separator string="" colspan="4" />
|
||||
<label string="" colspan="2" />
|
||||
<group col="2" colspan="1">
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="do_move_consume" string="Ok"
|
||||
colspan="1" type="object" icon="gtk-ok" />
|
||||
</group>
|
||||
<separator string="Consume Products" colspan="4"/>
|
||||
<field name="product_id" colspan="4" readonly="1"/>
|
||||
<field name="location_id" colspan="4" widget="selection"/>
|
||||
<field name="product_qty" colspan="2"/>
|
||||
<field name="product_uom" nolabel="1" readonly="1"/>
|
||||
<newline/>
|
||||
<separator string="" colspan="4" />
|
||||
<label string="" colspan="2" />
|
||||
<group col="2" colspan="1">
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="do_move_consume" string="Ok"
|
||||
colspan="1" type="object" icon="gtk-ok" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -64,27 +64,27 @@
|
|||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="view_stock_move_scrap_wizard" model="ir.ui.view">
|
||||
<field name="name">Scrap Move</field>
|
||||
<field name="model">stock.move.scrap</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Scrap Move">
|
||||
<separator string="Scrap Products" colspan="4"/>
|
||||
<field name="product_id" colspan="4" readonly="1"/>
|
||||
<field name="location_id" colspan="4" string="Dest. Location" domain="[('usage','<>','view'),('scrap_location','=',True)]" widget="selection"/>
|
||||
<field name="product_qty" colspan="2"/>
|
||||
<field name="product_uom" nolabel="1" readonly="1"/>
|
||||
<newline/>
|
||||
<separator string="" colspan="4" />
|
||||
<label string="" colspan="2" />
|
||||
<group col="2" colspan="1">
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="move_scrap" string="Ok"
|
||||
colspan="1" type="object" icon="gtk-ok" />
|
||||
</group>
|
||||
<separator string="Scrap Products" colspan="4"/>
|
||||
<field name="product_id" colspan="4" readonly="1"/>
|
||||
<field name="location_id" colspan="4" string="Dest. Location" domain="[('usage','<>','view'),('scrap_location','=',True)]" widget="selection"/>
|
||||
<field name="product_qty" colspan="2"/>
|
||||
<field name="product_uom" nolabel="1" readonly="1"/>
|
||||
<newline/>
|
||||
<separator string="" colspan="4" />
|
||||
<label string="" colspan="2" />
|
||||
<group col="2" colspan="1">
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="move_scrap" string="Ok"
|
||||
colspan="1" type="object" icon="gtk-ok" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -97,12 +97,12 @@
|
|||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="view_split_in_lots" model="ir.ui.view">
|
||||
<field name="name">Split in lots</field>
|
||||
<field name="model">stock.move.split</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="name">Split in lots</field>
|
||||
<field name="model">stock.move.split</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Split in lots">
|
||||
<field name="product_id" colspan="4" readonly="1"/>
|
||||
<newline/>
|
||||
|
@ -119,47 +119,47 @@
|
|||
</group>
|
||||
|
||||
<group colspan="4" attrs="{'invisible':[('use_exist','=',True)]}">
|
||||
<field name="line_ids" colspan="4" nolabel="1">
|
||||
<tree string="Lots Number" editable="bottom">
|
||||
<field name="name" string="Lots"/>
|
||||
<field name="quantity" />
|
||||
</tree>
|
||||
<form string="Lots Number">
|
||||
<field name="name" string="Lots"/>
|
||||
<field name="quantity" />
|
||||
</form>
|
||||
</field>
|
||||
<field name="line_ids" colspan="4" nolabel="1">
|
||||
<tree string="Lots Number" editable="bottom">
|
||||
<field name="name" string="Lots"/>
|
||||
<field name="quantity" />
|
||||
</tree>
|
||||
<form string="Lots Number">
|
||||
<field name="name" string="Lots"/>
|
||||
<field name="quantity" />
|
||||
</form>
|
||||
</field>
|
||||
</group>
|
||||
<group colspan="4" attrs="{'invisible':[('use_exist','!=',True)]}">
|
||||
<field name="line_exist_ids" colspan="4" nolabel="1">
|
||||
<tree string="Lots Number" editable="bottom">
|
||||
<field name="prodlot_id" string="Lots" domain="[('product_id','=',parent.product_id)]"/>
|
||||
<field name="quantity" />
|
||||
</tree>
|
||||
<form string="Lots Number">
|
||||
<field name="prodlot_id" string="Lots" domain="[('product_id','=',parent.product_id)]"/>
|
||||
<field name="quantity" />
|
||||
</form>
|
||||
</field>
|
||||
<field name="line_exist_ids" colspan="4" nolabel="1">
|
||||
<tree string="Lots Number" editable="bottom">
|
||||
<field name="prodlot_id" string="Lots" domain="[('product_id','=',parent.product_id)]"/>
|
||||
<field name="quantity" />
|
||||
</tree>
|
||||
<form string="Lots Number">
|
||||
<field name="prodlot_id" string="Lots" domain="[('product_id','=',parent.product_id)]"/>
|
||||
<field name="quantity" />
|
||||
</form>
|
||||
</field>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<label string="" colspan="2" />
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="split_lot" string="Ok"
|
||||
type="object" icon="gtk-ok" />
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="track_line" model="ir.actions.act_window">
|
||||
<field name="name">Split in lots</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">stock.move.split</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
<separator string="" colspan="4" />
|
||||
<label string="" colspan="2" />
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="split_lot" string="Ok"
|
||||
type="object" icon="gtk-ok" />
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
<record id="track_line" model="ir.actions.act_window">
|
||||
<field name="name">Split in lots</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">stock.move.split</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -27,22 +27,22 @@ import pooler
|
|||
import time
|
||||
|
||||
class stock_partial_move(osv.osv_memory):
|
||||
_name = "stock.partial.move"
|
||||
_description = "Partial Move"
|
||||
_name = "stock.partial.move"
|
||||
_description = "Partial Move"
|
||||
_columns = {
|
||||
'date': fields.datetime('Date', required=True),
|
||||
'partner_id': fields.many2one('res.partner',string="Partner"),
|
||||
'type': fields.char("Type", size=3),
|
||||
'address_id': fields.many2one('res.partner.address', 'Delivery Address', help="Address where goods are to be delivered"),
|
||||
'address_id': fields.many2one('res.partner.address', 'Address', help="Address where goods are to be delivered"),
|
||||
}
|
||||
|
||||
def view_init(self, cr, uid, fields_list, context=None):
|
||||
res = super(stock_partial_move, self).view_init(cr, uid, fields_list, context=context)
|
||||
move_obj = self.pool.get('stock.move')
|
||||
move_obj = self.pool.get('stock.move')
|
||||
if not context:
|
||||
context={}
|
||||
moveids = []
|
||||
for m in move_obj.browse(cr, uid, context.get('active_ids', [])):
|
||||
for m in move_obj.browse(cr, uid, context.get('active_ids', [])):
|
||||
if m.state in ('done', 'cancel'):
|
||||
continue
|
||||
if 'move%s_product_id'%(m.id) not in self._columns:
|
||||
|
@ -57,58 +57,58 @@ class stock_partial_move(osv.osv_memory):
|
|||
self._columns['move%s_product_price'%(m.id)] = fields.float("Price")
|
||||
if 'move%s_product_currency'%(m.id) not in self._columns:
|
||||
self._columns['move%s_product_currency'%(m.id)] = fields.many2one('res.currency',string="Currency")
|
||||
return res
|
||||
return res
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False):
|
||||
result = super(stock_partial_move, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)
|
||||
result = super(stock_partial_move, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)
|
||||
move_obj = self.pool.get('stock.move')
|
||||
move_ids = context.get('active_ids', False)
|
||||
move_ids = context.get('active_ids', False)
|
||||
move_ids = move_obj.search(cr, uid, [('id','in',move_ids)])
|
||||
_moves_arch_lst = """<form string="Deliver Products">
|
||||
<separator colspan="4" string="Delivery Information"/>
|
||||
<field name="date" colspan="4" />
|
||||
_moves_arch_lst = """<form string="Process Products">
|
||||
<separator colspan="4" string="Information"/>
|
||||
<field name="date" colspan="4" />
|
||||
<group colspan="4" attrs="{'invisible':[('type','=','in')]}">
|
||||
<field name="partner_id" attrs="{'required':[('type','!=','in')]}" />
|
||||
<field name="address_id" attrs="{'required':[('type','!=','in')]}"/>
|
||||
<field name="type" invisible="1"/>
|
||||
<newline/>
|
||||
<field name="partner_id" attrs="{'required':[('type','!=','in')]}" />
|
||||
<field name="address_id" attrs="{'required':[('type','!=','in')]}"/>
|
||||
<field name="type" invisible="1"/>
|
||||
<newline/>
|
||||
</group>
|
||||
<separator colspan="4" string="Move Detail"/>
|
||||
"""
|
||||
"""
|
||||
_moves_fields = result['fields']
|
||||
if move_ids and view_type in ['form']:
|
||||
for m in move_obj.browse(cr, uid, move_ids, context):
|
||||
if move_ids and view_type in ['form']:
|
||||
for m in move_obj.browse(cr, uid, move_ids, context):
|
||||
if m.state in ('done', 'cancel'):
|
||||
continue
|
||||
_moves_fields.update({
|
||||
'move%s_product_id'%(m.id) : {
|
||||
'string': _('Product'),
|
||||
'type' : 'many2one',
|
||||
'relation': 'product.product',
|
||||
'required' : True,
|
||||
'readonly' : True,
|
||||
'type' : 'many2one',
|
||||
'relation': 'product.product',
|
||||
'required' : True,
|
||||
'readonly' : True,
|
||||
},
|
||||
'move%s_product_qty'%(m.id) : {
|
||||
'string': _('Quantity'),
|
||||
'type' : 'float',
|
||||
'required': True,
|
||||
'required': True,
|
||||
},
|
||||
'move%s_product_uom'%(m.id) : {
|
||||
'string': _('Product UOM'),
|
||||
'type' : 'many2one',
|
||||
'relation': 'product.uom',
|
||||
'required' : True,
|
||||
'readonly' : True,
|
||||
'type' : 'many2one',
|
||||
'relation': 'product.uom',
|
||||
'required' : True,
|
||||
'readonly' : True,
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
_moves_arch_lst += """
|
||||
<group colspan="4" col="10">
|
||||
<field name="move%s_product_id" nolabel="1"/>
|
||||
<field name="move%s_product_qty" string="Qty" />
|
||||
<field name="move%s_product_uom" nolabel="1" />
|
||||
"""%(m.id, m.id, m.id)
|
||||
if (m.picking_id.type == 'in') and (m.product_id.cost_method == 'average'):
|
||||
if (m.picking_id.type == 'in') and (m.product_id.cost_method == 'average'):
|
||||
_moves_fields.update({
|
||||
'move%s_product_price'%(m.id) : {
|
||||
'string': _('Price'),
|
||||
|
@ -116,9 +116,9 @@ class stock_partial_move(osv.osv_memory):
|
|||
},
|
||||
'move%s_product_currency'%(m.id): {
|
||||
'string': _('Currency'),
|
||||
'type' : 'float',
|
||||
'type' : 'many2one',
|
||||
'relation': 'res.currency',
|
||||
'type' : 'float',
|
||||
'type' : 'many2one',
|
||||
'relation': 'res.currency',
|
||||
}
|
||||
})
|
||||
_moves_arch_lst += """
|
||||
|
@ -132,14 +132,14 @@ class stock_partial_move(osv.osv_memory):
|
|||
<separator string="" colspan="4" />
|
||||
<label string="" colspan="2"/>
|
||||
<group col="2" colspan="2">
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="_Cancel" />
|
||||
<button name="do_partial" string="_Deliver"
|
||||
colspan="1" type="object" icon="gtk-apply" />
|
||||
</group>
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="_Cancel" />
|
||||
<button name="do_partial" string="_Deliver"
|
||||
colspan="1" type="object" icon="gtk-apply" />
|
||||
</group>
|
||||
</form>"""
|
||||
result['arch'] = _moves_arch_lst
|
||||
result['fields'] = _moves_fields
|
||||
result['fields'] = _moves_fields
|
||||
return result
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
|
@ -147,13 +147,13 @@ class stock_partial_move(osv.osv_memory):
|
|||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param fields: List of fields for which we want default values
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
@param fields: List of fields for which we want default values
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
|
||||
res = super(stock_partial_move, self).default_get(cr, uid, fields, context=context)
|
||||
move_obj = self.pool.get('stock.move')
|
||||
move_obj = self.pool.get('stock.move')
|
||||
if not context:
|
||||
context={}
|
||||
moveids = address_delivery = address_default = []
|
||||
|
@ -161,7 +161,7 @@ class stock_partial_move(osv.osv_memory):
|
|||
res.update({'date': time.strftime('%Y-%m-%d %H:%M:%S')})
|
||||
move_ids = context.get('active_ids', [])
|
||||
move_ids = move_obj.search(cr, uid, [('id','in',move_ids)])
|
||||
for m in move_obj.browse(cr, uid, context.get('active_ids', [])):
|
||||
for m in move_obj.browse(cr, uid, context.get('active_ids', [])):
|
||||
if m.state in ('done', 'cancel'):
|
||||
continue
|
||||
res['type'] = m.picking_id and m.picking_id.type or ''
|
||||
|
@ -170,7 +170,7 @@ class stock_partial_move(osv.osv_memory):
|
|||
if len(address_ids1) == 1:
|
||||
if m.picking_id and m.picking_id.type=='out':
|
||||
res['address_id'] = address_ids[0][0] or False
|
||||
res['partner_id'] = address_ids[0][1] or False
|
||||
res['partner_id'] = address_ids[0][1] or False
|
||||
if m.picking_id and m.picking_id.type=='in':
|
||||
res['partner_id'] = m.company_id.partner_id.id or False
|
||||
if m.company_id.partner_id:
|
||||
|
@ -196,7 +196,7 @@ class stock_partial_move(osv.osv_memory):
|
|||
currency = False
|
||||
if hasattr(m.picking_id, 'sale_id') and m.picking_id.sale_id:
|
||||
currency = m.picking_id.sale_id.pricelist_id.currency_id.id
|
||||
|
||||
|
||||
if 'move%s_product_price'%(m.id) in fields:
|
||||
res['move%s_product_price'%(m.id)] = price
|
||||
if 'move%s_product_currency'%(m.id) in fields:
|
||||
|
@ -210,38 +210,38 @@ class stock_partial_move(osv.osv_memory):
|
|||
currency = False
|
||||
if hasattr(m.picking_id, 'purchase_id') and m.picking_id.purchase_id:
|
||||
currency = m.picking_id.purchase_id.pricelist_id.currency_id.id
|
||||
|
||||
|
||||
if 'move%s_product_price'%(m.id) in fields:
|
||||
res['move%s_product_price'%(m.id)] = price
|
||||
if 'move%s_product_currency'%(m.id) in fields:
|
||||
res['move%s_product_currency'%(m.id)] = currency
|
||||
return res
|
||||
return res
|
||||
|
||||
def do_partial(self, cr, uid, ids, context):
|
||||
""" Makes partial moves and pickings done.
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param fields: List of fields for which we want default values
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
|
||||
@param fields: List of fields for which we want default values
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
|
||||
rec_id = context and context.get('active_id', False)
|
||||
tracking_lot = context.get('tracking_lot', False)
|
||||
if tracking_lot:
|
||||
tracking = self.pool.get('stock.tracking')
|
||||
tracking_lot = tracking.get_create_tracking_lot(cr, uid,[rec_id], tracking_lot)
|
||||
context ['tracking_lot'] = tracking_lot
|
||||
move_obj = self.pool.get('stock.move')
|
||||
#tracking_lot = context.get('tracking_lot', False)
|
||||
#if tracking_lot:
|
||||
# tracking = self.pool.get('stock.tracking')
|
||||
# tracking_lot = tracking.get_create_tracking_lot(cr, uid,[rec_id], tracking_lot)
|
||||
# context ['tracking_lot'] = tracking_lot
|
||||
move_obj = self.pool.get('stock.move')
|
||||
move_ids = context.get('active_ids', False)
|
||||
partial = self.browse(cr, uid, ids[0], context)
|
||||
partial_datas = {
|
||||
'partner_id' : partial.partner_id and partial.partner_id.id or False,
|
||||
'address_id' : partial.address_id and partial.address_id.id or False,
|
||||
'delivery_date' : partial.date
|
||||
'delivery_date' : partial.date
|
||||
}
|
||||
for m in move_obj.browse(cr, uid, move_ids):
|
||||
for m in move_obj.browse(cr, uid, move_ids):
|
||||
if m.state in ('done', 'cancel'):
|
||||
continue
|
||||
partial_datas['move%s'%(m.id)] = {
|
||||
|
@ -250,15 +250,15 @@ class stock_partial_move(osv.osv_memory):
|
|||
'product_uom' : getattr(partial, 'move%s_product_uom'%(m.id)).id
|
||||
}
|
||||
|
||||
if (m.picking_id.type == 'in') and (m.product_id.cost_method == 'average'):
|
||||
partial_datas['move%s'%(m.id)].update({
|
||||
if (m.picking_id.type == 'in') and (m.product_id.cost_method == 'average'):
|
||||
partial_datas['move%s'%(m.id)].update({
|
||||
'product_price' : getattr(partial, 'move%s_product_price'%(m.id)),
|
||||
'product_currency': getattr(partial, 'move%s_product_currency'%(m.id)).id
|
||||
})
|
||||
})
|
||||
res = move_obj.do_partial(cr, uid, move_ids, partial_datas, context=context)
|
||||
return {}
|
||||
|
||||
stock_partial_move()
|
||||
|
||||
stock_partial_move()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -34,11 +34,11 @@ class stock_partial_picking(osv.osv_memory):
|
|||
|
||||
def view_init(self, cr, uid, fields_list, context=None):
|
||||
res = super(stock_partial_picking, self).view_init(cr, uid, fields_list, context=context)
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
if not context:
|
||||
context={}
|
||||
moveids = []
|
||||
for pick in pick_obj.browse(cr, uid, context.get('active_ids', [])):
|
||||
for pick in pick_obj.browse(cr, uid, context.get('active_ids', [])):
|
||||
for m in pick.move_lines:
|
||||
if m.state in ('done', 'cancel'):
|
||||
continue
|
||||
|
@ -54,17 +54,17 @@ class stock_partial_picking(osv.osv_memory):
|
|||
self._columns['move%s_product_price'%(m.id)] = fields.float("Price")
|
||||
if 'move%s_product_currency'%(m.id) not in self._columns:
|
||||
self._columns['move%s_product_currency'%(m.id)] = fields.many2one('res.currency',string="Currency")
|
||||
return res
|
||||
return res
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False):
|
||||
result = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)
|
||||
result = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
picking_ids = context.get('active_ids', False)
|
||||
picking_ids = context.get('active_ids', False)
|
||||
_moves_arch_lst = """<form string="Deliver Products">
|
||||
<separator colspan="4" string="Delivery Information"/>
|
||||
<field name="date" colspan="4" />
|
||||
<separator colspan="4" string="General Information"/>
|
||||
<field name="date" colspan="4" />
|
||||
<separator colspan="4" string="Move Detail"/>
|
||||
"""
|
||||
"""
|
||||
_moves_fields = result['fields']
|
||||
if picking_ids and view_type in ['form']:
|
||||
for pick in pick_obj.browse(cr, uid, picking_ids, context):
|
||||
|
@ -74,32 +74,32 @@ class stock_partial_picking(osv.osv_memory):
|
|||
_moves_fields.update({
|
||||
'move%s_product_id'%(m.id) : {
|
||||
'string': _('Product'),
|
||||
'type' : 'many2one',
|
||||
'relation': 'product.product',
|
||||
'required' : True,
|
||||
'readonly' : True,
|
||||
'type' : 'many2one',
|
||||
'relation': 'product.product',
|
||||
'required' : True,
|
||||
'readonly' : True,
|
||||
},
|
||||
'move%s_product_qty'%(m.id) : {
|
||||
'string': _('Quantity'),
|
||||
'type' : 'float',
|
||||
'required': True,
|
||||
'required': True,
|
||||
},
|
||||
'move%s_product_uom'%(m.id) : {
|
||||
'string': _('Product UOM'),
|
||||
'type' : 'many2one',
|
||||
'relation': 'product.uom',
|
||||
'required' : True,
|
||||
'readonly' : True,
|
||||
'type' : 'many2one',
|
||||
'relation': 'product.uom',
|
||||
'required' : True,
|
||||
'readonly' : True,
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
_moves_arch_lst += """
|
||||
<group colspan="4" col="10">
|
||||
<field name="move%s_product_id" nolabel="1"/>
|
||||
<field name="move%s_product_qty" string="Qty" />
|
||||
<field name="move%s_product_uom" nolabel="1" />
|
||||
"""%(m.id, m.id, m.id)
|
||||
if (m.product_id.cost_method == 'average'):
|
||||
if (m.product_id.cost_method == 'average'):
|
||||
_moves_fields.update({
|
||||
'move%s_product_price'%(m.id) : {
|
||||
'string': _('Price'),
|
||||
|
@ -107,9 +107,9 @@ class stock_partial_picking(osv.osv_memory):
|
|||
},
|
||||
'move%s_product_currency'%(m.id): {
|
||||
'string': _('Currency'),
|
||||
'type' : 'float',
|
||||
'type' : 'many2one',
|
||||
'relation': 'res.currency',
|
||||
'type' : 'float',
|
||||
'type' : 'many2one',
|
||||
'relation': 'res.currency',
|
||||
}
|
||||
})
|
||||
_moves_arch_lst += """
|
||||
|
@ -123,14 +123,14 @@ class stock_partial_picking(osv.osv_memory):
|
|||
<separator string="" colspan="4" />
|
||||
<label string="" colspan="2"/>
|
||||
<group col="2" colspan="2">
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="_Cancel" />
|
||||
<button name="do_partial" string="_Deliver"
|
||||
colspan="1" type="object" icon="gtk-apply" />
|
||||
</group>
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="_Cancel" />
|
||||
<button name="do_partial" string="_Validate"
|
||||
colspan="1" type="object" icon="gtk-apply" />
|
||||
</group>
|
||||
</form>"""
|
||||
result['arch'] = _moves_arch_lst
|
||||
result['fields'] = _moves_fields
|
||||
result['fields'] = _moves_fields
|
||||
return result
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
|
@ -138,13 +138,13 @@ class stock_partial_picking(osv.osv_memory):
|
|||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param fields: List of fields for which we want default values
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
@param fields: List of fields for which we want default values
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
|
||||
res = super(stock_partial_picking, self).default_get(cr, uid, fields, context=context)
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
if not context:
|
||||
context={}
|
||||
moveids = []
|
||||
|
@ -178,22 +178,22 @@ class stock_partial_picking(osv.osv_memory):
|
|||
res['move%s_product_price'%(m.id)] = price
|
||||
if 'move%s_product_currency'%(m.id) in fields:
|
||||
res['move%s_product_currency'%(m.id)] = currency
|
||||
return res
|
||||
return res
|
||||
|
||||
def do_partial(self, cr, uid, ids, context):
|
||||
def do_partial(self, cr, uid, ids, context):
|
||||
""" Makes partial moves and pickings done.
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param fields: List of fields for which we want default values
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
@param fields: List of fields for which we want default values
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
picking_ids = context.get('active_ids', False)
|
||||
partial = self.browse(cr, uid, ids[0], context)
|
||||
partial_datas = {
|
||||
'delivery_date' : partial.date
|
||||
'delivery_date' : partial.date
|
||||
}
|
||||
for pick in pick_obj.browse(cr, uid, picking_ids):
|
||||
for m in pick.move_lines:
|
||||
|
@ -205,15 +205,15 @@ class stock_partial_picking(osv.osv_memory):
|
|||
'product_uom' : getattr(partial, 'move%s_product_uom'%(m.id)).id
|
||||
}
|
||||
|
||||
if (m.product_id.cost_method == 'average'):
|
||||
partial_datas['move%s'%(m.id)].update({
|
||||
if (m.product_id.cost_method == 'average'):
|
||||
partial_datas['move%s'%(m.id)].update({
|
||||
'product_price' : getattr(partial, 'move%s_product_price'%(m.id)),
|
||||
'product_currency': getattr(partial, 'move%s_product_currency'%(m.id)).id
|
||||
})
|
||||
})
|
||||
res = pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context)
|
||||
return {}
|
||||
|
||||
stock_partial_picking()
|
||||
|
||||
stock_partial_picking()
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -26,59 +26,40 @@ from tools.translate import _
|
|||
class stock_split_into(osv.osv_memory):
|
||||
_name = "stock.split.into"
|
||||
_description = "Split into"
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
""" Get default values
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param fields: List of fields for default value
|
||||
@param context: A standard dictionary
|
||||
@return: Default values of fields
|
||||
"""
|
||||
res = super(stock_split_into, self).default_get(cr, uid, fields, context=context)
|
||||
move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
|
||||
if 'quantity' in fields:
|
||||
res.update({'quantity': move.product_qty})
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'quantity': fields.integer('Quantity'),
|
||||
'quantity': fields.float('Quantity', digits=(16,2)),
|
||||
}
|
||||
_defaults = {
|
||||
'quantity': lambda *x: 1,
|
||||
'quantity': lambda *x: 0,
|
||||
}
|
||||
|
||||
def split(self, cr, uid, data, context=None):
|
||||
rec_id = context and context.get('active_ids', False)
|
||||
move_obj = self.pool.get('stock.move')
|
||||
new_move = []
|
||||
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')
|
||||
track_obj = self.pool.get('stock.tracking')
|
||||
|
||||
quantity = self.browse(cr, uid, data[0], context).quantity or 0.0
|
||||
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:
|
||||
if quantity == 0:
|
||||
tracking_id = track_obj.create(cr, uid, {})
|
||||
move_obj.write(cr, uid, [move.id], {'tracking_id': tracking_id})
|
||||
continue
|
||||
sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.tracking')
|
||||
tracking_id = track_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 = {
|
||||
move_obj.setlast_tracking(cr, uid, [move.id], context=context)
|
||||
move_obj.write(cr, uid, [move.id], {
|
||||
'product_qty': quantity,
|
||||
'product_uos_qty': uos_qty,
|
||||
'state': move.state
|
||||
'product_uos_qty': quantity,
|
||||
'product_uos': move.product_uom.id,
|
||||
})
|
||||
quantity_rest = move.product_qty - quantity
|
||||
tracking_id = track_obj.create(cr, uid, {})
|
||||
default_val = {
|
||||
'product_qty': quantity_rest,
|
||||
'product_uos_qty': quantity_rest,
|
||||
'tracking_id': tracking_id,
|
||||
'state': move.state,
|
||||
'product_uos': move.product_uom.id
|
||||
}
|
||||
current_move = move_obj.copy(cr, uid, move.id, default_val)
|
||||
new_move.append(current_move)
|
||||
update_val['product_qty'] = quantity_rest
|
||||
update_val['tracking_id'] = tracking_id
|
||||
update_val['product_uos_qty'] = uos_qty_rest
|
||||
move_obj.write(cr, uid, [move.id], update_val)
|
||||
return {}
|
||||
stock_split_into()
|
||||
|
||||
|
|
Loading…
Reference in New Issue