[MERGE]: Merge with lp:openobject-trunk-dev-addons2
bzr revid: ksa@tinyerp.co.in-20110113045825-2wopsg998t6vfifk
This commit is contained in:
+2
-2
@@ -714,9 +714,9 @@ class mrp_production(osv.osv):
|
||||
if production_mode == 'consume_produce':
|
||||
# To produce remaining qty of final product
|
||||
vals = {'state':'confirmed'}
|
||||
final_product_todo = [x.id for x in production.move_created_ids]
|
||||
#final_product_todo = [x.id for x in production.move_created_ids]
|
||||
#stock_mov_obj.write(cr, uid, final_product_todo, vals)
|
||||
stock_mov_obj.action_confirm(cr, uid, final_product_todo, context)
|
||||
#stock_mov_obj.action_confirm(cr, uid, final_product_todo, context)
|
||||
produced_products = {}
|
||||
for produced_product in production.move_created_ids2:
|
||||
if produced_product.scrapped:
|
||||
|
||||
+71
-2
@@ -343,6 +343,54 @@
|
||||
<field name="date_start"/>
|
||||
<field name="date_stop"/>
|
||||
</tree>
|
||||
<form string="Bill of Material">
|
||||
<group colspan="4" col="6">
|
||||
<field name="product_id" on_change="onchange_product_id(product_id, name)" select="1"/>
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1" string="Reference" groups="base.group_extended"/>
|
||||
<newline/>
|
||||
<field name="product_qty"/>
|
||||
<field name="product_uom"/>
|
||||
<field name="routing_id" groups="base.group_extended"/>
|
||||
<newline/>
|
||||
<field name="product_uos_qty" groups="product.group_uos" />
|
||||
<field name="product_uos" groups="product.group_uos"/>
|
||||
<newline/>
|
||||
<field name="type" groups="base.group_extended"/>
|
||||
<field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/>
|
||||
</group>
|
||||
<group groups="base.group_extended">
|
||||
<notebook colspan="4">
|
||||
<page string="Components">
|
||||
<field colspan="4" name="bom_lines" nolabel="1" widget="one2many_list">
|
||||
<tree string="Components" editable="bottom">
|
||||
<field name="product_id" on_change="onchange_product_id(product_id, name)" select="1"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="product_uom"/>
|
||||
<field name="name" invisible="1"/>
|
||||
<field name="date_start"/>
|
||||
<field name="date_stop"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Revisions" groups="base.group_extended" attrs="{'invisible': [('bom_id','!=',False)]}">
|
||||
<field colspan="4" name="revision_ids" nolabel="1" widget="one2many_list"/>
|
||||
</page>
|
||||
<page string="Properties" groups="base.group_extended">
|
||||
<field name="position"/>
|
||||
<field name="active"/>
|
||||
<field name="sequence"/>
|
||||
<field name="bom_id"/>
|
||||
|
||||
<field name="date_start"/>
|
||||
<field name="date_stop"/>
|
||||
<field name="product_rounding"/>
|
||||
<field name="product_efficiency" groups="base.group_extended"/>
|
||||
<field colspan="4" name="property_ids" nolabel="2" groups="base.group_extended"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Revisions" groups="base.group_extended" attrs="{'invisible': [('bom_id','!=',False)]}">
|
||||
@@ -412,6 +460,28 @@
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="mrp_bom_component_tree_view" model="ir.ui.view">
|
||||
<field name="name">mrp.bom.component.tree</field>
|
||||
<field name="model">mrp.bom</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="field_parent">child_complete_ids</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="BoM Structure" colors="blue:method">
|
||||
<field name="sequence" invisible="1"/>
|
||||
<field name="name" string="Component Name"/>
|
||||
<field name="code"/>
|
||||
<field name="product_id" string="Component Product"/>
|
||||
<field name="bom_id"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="product_uom"/>
|
||||
<field name="type"/>
|
||||
<field name="method" groups="base.group_extended"/>
|
||||
<field name="routing_id" groups="base.group_extended"/>
|
||||
<field name="date_start" groups="base.group_extended"/>
|
||||
<field name="date_stop" groups="base.group_extended"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="mrp_bom_form_action" model="ir.actions.act_window">
|
||||
<field name="name">Bill of Materials</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
@@ -426,6 +496,7 @@
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">mrp.bom</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="mrp_bom_component_tree_view"/>
|
||||
<field name="domain">[('bom_id','!=',False)]</field>
|
||||
<field name="help">Bills of materials components are components and sub-products used to create master bills of materials. Use this menu to search in which BoM a specific component is used.</field>
|
||||
</record>
|
||||
@@ -616,7 +687,6 @@
|
||||
<field name="product_id" readonly="1"/>
|
||||
<field name="product_qty" readonly="1" string="Qty"/>
|
||||
<field name="product_uom" readonly="1" string="UOM"/>
|
||||
<field name="location_dest_id" readonly="1" string="Destination Loc."/>
|
||||
<field name="prodlot_id" context="{'product_id': product_id}"/>
|
||||
<field name="state" invisible="1"/>
|
||||
<field name="scrapped" invisible="1"/>
|
||||
@@ -646,7 +716,6 @@
|
||||
<field name="product_id" />
|
||||
<field name="product_qty" string="Qty"/>
|
||||
<field name="product_uom" string="UOM"/>
|
||||
<field name="location_id" string="Source Loc." />
|
||||
<field name="state" invisible="1"/>
|
||||
<button name="%(stock.action_partial_move)d"
|
||||
string="Partial"
|
||||
|
||||
@@ -30,6 +30,11 @@ class StockMove(osv.osv):
|
||||
_columns = {
|
||||
'production_id': fields.many2one('mrp.production', 'Production', select=True),
|
||||
}
|
||||
|
||||
def create_chained_picking(self, cr, uid, moves, context=None):
|
||||
new_moves = super(StockMove, self).create_chained_picking(cr, uid, moves, context=context)
|
||||
self.write(cr, uid, [x.id for x in new_moves], {'production_id': False}, context=context)
|
||||
return new_moves
|
||||
|
||||
def _action_explode(self, cr, uid, move, context=None):
|
||||
""" Explodes pickings.
|
||||
|
||||
@@ -148,7 +148,7 @@ class purchase_order(osv.osv):
|
||||
STATE_SELECTION = [
|
||||
('draft', 'Request for Quotation'),
|
||||
('wait', 'Waiting'),
|
||||
('confirmed', 'Waiting Supplier Ack'),
|
||||
('confirmed', 'Waiting Approval'),
|
||||
('approved', 'Approved'),
|
||||
('except_picking', 'Shipping Exception'),
|
||||
('except_invoice', 'Invoice Exception'),
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
<button name="invoice_ok" states="except_invoice" string="Manually Corrected" icon="gtk-convert"/>
|
||||
<button name="purchase_confirm" states="draft" string="Convert to Purchase Order" icon="gtk-go-forward"/>
|
||||
<button name="purchase_appbuyer" states="wait_auth" string="Approve Purchase" icon="gtk-ok"/>
|
||||
<button name="purchase_approve" states="confirmed" string="Approved by Supplier" icon="gtk-go-forward"/>
|
||||
<button name="purchase_approve" states="confirmed" string="Approved" icon="gtk-go-forward"/>
|
||||
<button name="%(report_purchase_order)d" string="Print" states="approved" type="action" icon="gtk-print"/>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
@@ -705,7 +705,6 @@ class sale_order(osv.osv):
|
||||
#'state': 'waiting',
|
||||
'note': line.notes,
|
||||
'company_id': order.company_id.id,
|
||||
'returned_price': line.price_unit,
|
||||
})
|
||||
|
||||
if line.product_id:
|
||||
|
||||
@@ -172,6 +172,7 @@
|
||||
<page groups="base.group_extended" string="Extra Info">
|
||||
<field name="th_weight"/>
|
||||
<field name="address_allotment_id"/>
|
||||
<field name="property_ids" colspan="4"/>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
<field colspan="4" name="notes" nolabel="1"/>
|
||||
|
||||
+48
-43
@@ -1223,8 +1223,6 @@ class stock_picking(osv.osv):
|
||||
{'price_unit': product_price,
|
||||
'price_currency_id': product_currency})
|
||||
|
||||
if not move.returned_price:
|
||||
move_obj.write(cr, uid, [move.id], {'returned_price': move.price_unit})
|
||||
|
||||
for move in too_few:
|
||||
product_qty = move_product_qty[move.id]
|
||||
@@ -1545,7 +1543,6 @@ class stock_move(osv.osv):
|
||||
|
||||
# used for colors in tree views:
|
||||
'scrapped': fields.related('location_dest_id','scrap_location',type='boolean',relation='stock.location',string='Scrapped', readonly=True),
|
||||
'returned_price': fields.float('Returned product price', digits_compute= dp.get_precision('Sale Price')),
|
||||
}
|
||||
_constraints = [
|
||||
(_check_tracking,
|
||||
@@ -1794,6 +1791,51 @@ class stock_move(osv.osv):
|
||||
'date': picking.date,
|
||||
})
|
||||
return pick_id
|
||||
def create_chained_picking(self, cr, uid, moves, context=None):
|
||||
res_obj = self.pool.get('res.company')
|
||||
location_obj = self.pool.get('stock.location')
|
||||
move_obj = self.pool.get('stock.move')
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
new_moves = []
|
||||
if context is None:
|
||||
context = {}
|
||||
seq_obj = self.pool.get('ir.sequence')
|
||||
for picking, todo in self._chain_compute(cr, uid, moves, context=context).items():
|
||||
ptype = todo[0][1][5] and todo[0][1][5] or location_obj.picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
|
||||
if picking:
|
||||
# name of new picking according to its type
|
||||
new_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + ptype)
|
||||
pickid = self._create_chained_picking(cr, uid, new_pick_name, picking, ptype, todo, context=context)
|
||||
# Need to check name of old picking because it always considers picking as "OUT" when created from Sale Order
|
||||
old_ptype = location_obj.picking_type_get(cr, uid, picking.move_lines[0].location_id, picking.move_lines[0].location_dest_id)
|
||||
if old_ptype != picking.type:
|
||||
old_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + old_ptype)
|
||||
self.pool.get('stock.picking').write(cr, uid, picking.id, {'name': old_pick_name}, context=context)
|
||||
else:
|
||||
pickid = False
|
||||
for move, (loc, dummy, delay, dummy, company_id, ptype) in todo:
|
||||
new_id = move_obj.copy(cr, uid, move.id, {
|
||||
'location_id': move.location_dest_id.id,
|
||||
'location_dest_id': loc.id,
|
||||
'date_moved': time.strftime('%Y-%m-%d'),
|
||||
'picking_id': pickid,
|
||||
'state': 'waiting',
|
||||
'company_id': company_id or res_obj._company_default_get(cr, uid, 'stock.company', context=context) ,
|
||||
'move_history_ids': [],
|
||||
'date': (datetime.strptime(move.date, '%Y-%m-%d %H:%M:%S') + relativedelta(days=delay or 0)).strftime('%Y-%m-%d'),
|
||||
'move_history_ids2': []}
|
||||
)
|
||||
move_obj.write(cr, uid, [move.id], {
|
||||
'move_dest_id': new_id,
|
||||
'move_history_ids': [(4, new_id)]
|
||||
})
|
||||
new_moves.append(self.browse(cr, uid, [new_id])[0])
|
||||
if pickid:
|
||||
wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr)
|
||||
if new_moves:
|
||||
new_moves += self.create_chained_picking(cr, uid, new_moves, context)
|
||||
return new_moves
|
||||
|
||||
def action_confirm(self, cr, uid, ids, context=None):
|
||||
""" Confirms stock move.
|
||||
@return: List of ids.
|
||||
@@ -1805,46 +1847,7 @@ class stock_move(osv.osv):
|
||||
move_obj = self.pool.get('stock.move')
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
|
||||
def create_chained_picking(self, cr, uid, moves, context=None):
|
||||
new_moves = []
|
||||
if context is None:
|
||||
context = {}
|
||||
seq_obj = self.pool.get('ir.sequence')
|
||||
for picking, todo in self._chain_compute(cr, uid, moves, context=context).items():
|
||||
ptype = todo[0][1][5] and todo[0][1][5] or location_obj.picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
|
||||
if picking:
|
||||
# name of new picking according to its type
|
||||
new_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + ptype)
|
||||
pickid = self._create_chained_picking(cr, uid, new_pick_name, picking, ptype, todo, context=context)
|
||||
# Need to check name of old picking because it always considers picking as "OUT" when created from Sale Order
|
||||
old_ptype = location_obj.picking_type_get(cr, uid, picking.move_lines[0].location_id, picking.move_lines[0].location_dest_id)
|
||||
if old_ptype != picking.type:
|
||||
old_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + old_ptype)
|
||||
self.pool.get('stock.picking').write(cr, uid, picking.id, {'name': old_pick_name}, context=context)
|
||||
else:
|
||||
pickid = False
|
||||
for move, (loc, dummy, delay, dummy, company_id, ptype) in todo:
|
||||
new_id = move_obj.copy(cr, uid, move.id, {
|
||||
'location_id': move.location_dest_id.id,
|
||||
'location_dest_id': loc.id,
|
||||
'date_moved': time.strftime('%Y-%m-%d'),
|
||||
'picking_id': pickid,
|
||||
'state': 'waiting',
|
||||
'company_id': company_id or res_obj._company_default_get(cr, uid, 'stock.company', context=context) ,
|
||||
'move_history_ids': [],
|
||||
'date': (datetime.strptime(move.date, '%Y-%m-%d %H:%M:%S') + relativedelta(days=delay or 0)).strftime('%Y-%m-%d'),
|
||||
'move_history_ids2': []}
|
||||
)
|
||||
move_obj.write(cr, uid, [move.id], {
|
||||
'move_dest_id': new_id,
|
||||
'move_history_ids': [(4, new_id)]
|
||||
})
|
||||
new_moves.append(self.browse(cr, uid, [new_id])[0])
|
||||
if pickid:
|
||||
wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr)
|
||||
if new_moves:
|
||||
create_chained_picking(self, cr, uid, new_moves, context)
|
||||
create_chained_picking(self, cr, uid, moves, context)
|
||||
self.create_chained_picking(cr, uid, moves, context)
|
||||
return []
|
||||
|
||||
def action_assign(self, cr, uid, ids, *args):
|
||||
@@ -2112,6 +2115,8 @@ class stock_move(osv.osv):
|
||||
prodlot_id = partial_datas and partial_datas.get('move%s_prodlot_id' % (move.id), False)
|
||||
if prodlot_id:
|
||||
self.write(cr, uid, [move.id], {'prodlot_id': prodlot_id}, context=context)
|
||||
if move.state not in ('confirmed','done'):
|
||||
self.action_confirm(cr, uid, move_ids, context=context)
|
||||
|
||||
self.write(cr, uid, move_ids, {'state': 'done', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
|
||||
for id in move_ids:
|
||||
|
||||
@@ -53,10 +53,8 @@ class stock_return_picking(osv.osv_memory):
|
||||
res['invoice_state'] = 'none'
|
||||
for line in pick.move_lines:
|
||||
return_id = 'return%s'%(line.id)
|
||||
return_price = 'return_price%s'%(line.id)
|
||||
if return_id in fields:
|
||||
res[return_id] = line.product_qty
|
||||
res[return_price]=line.price_unit
|
||||
return res
|
||||
|
||||
def view_init(self, cr, uid, fields_list, context=None):
|
||||
@@ -88,11 +86,8 @@ class stock_return_picking(osv.osv_memory):
|
||||
valid_lines += 1
|
||||
if 'return%s'%(m.id) not in self._columns:
|
||||
self._columns['return%s'%(m.id)] = fields.float(string=m.name, required=True)
|
||||
if 'return_price%s'%(m.id) not in self._columns:
|
||||
self._columns['return_price%s'%(m.id)] = fields.float(string=m.name, required=True)
|
||||
if 'invoice_state' not in self._columns:
|
||||
self._columns['invoice_state'] = fields.selection([('2binvoiced', 'To be refunded/invoiced'), ('none', 'No invoicing')], string='Invoicing', required=True)
|
||||
|
||||
if not valid_lines:
|
||||
raise osv.except_osv(_('Warning !'), _("There are no products to return (only lines in Done state and not fully returned yet can be returned)!"))
|
||||
return res
|
||||
@@ -126,10 +121,6 @@ class stock_return_picking(osv.osv_memory):
|
||||
if m.state=='done' and quantity > return_history[m.id]:
|
||||
arch_lst.append('<field name="return%s"/>\n<newline/>' % (m.id,))
|
||||
res['fields']['return%s' % m.id]={'string':m.name, 'type':'float', 'required':True}
|
||||
|
||||
if m.product_id.cost_method == 'average' and pick.type == 'in':
|
||||
arch_lst.append('<field name="return_price%s"/>\n<newline/>' % (m.id,))
|
||||
res['fields']['return_price%s' % m.id]={'string':'Price', 'type':'float', 'required':True}
|
||||
res.setdefault('returns', []).append(m.id)
|
||||
arch_lst.append('<field name="invoice_state"/>\n<newline/>')
|
||||
res['fields']['invoice_state']={'string':_('Invoicing'), 'type':'selection','required':True, 'selection':[('2binvoiced', _('To be refunded/invoiced')), ('none', _('No invoicing'))]}
|
||||
@@ -142,7 +133,7 @@ class stock_return_picking(osv.osv_memory):
|
||||
return res
|
||||
|
||||
def create_returns(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
"""
|
||||
Creates return picking.
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@@ -152,13 +143,13 @@ class stock_return_picking(osv.osv_memory):
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
context = {}
|
||||
record_id = context and context.get('active_id', False) or False
|
||||
move_obj = self.pool.get('stock.move')
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
uom_obj = self.pool.get('product.uom')
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
|
||||
|
||||
pick = pick_obj.browse(cr, uid, record_id, context=context)
|
||||
data = self.read(cr, uid, ids[0])
|
||||
new_picking = None
|
||||
@@ -180,7 +171,6 @@ class stock_return_picking(osv.osv_memory):
|
||||
new_location=move.location_dest_id.id
|
||||
if move.state=='done':
|
||||
new_qty = data['return%s' % move.id]
|
||||
price_unit = data['return_price%s' % move.id]
|
||||
returned_qty = move.product_qty
|
||||
|
||||
for rec in move.move_history_ids2:
|
||||
@@ -188,6 +178,7 @@ class stock_return_picking(osv.osv_memory):
|
||||
|
||||
if returned_qty != new_qty:
|
||||
set_invoice_state_to_none = False
|
||||
|
||||
if new_qty:
|
||||
returned_lines += 1
|
||||
new_move=move_obj.copy(cr, uid, move.id, {
|
||||
@@ -196,8 +187,7 @@ class stock_return_picking(osv.osv_memory):
|
||||
new_qty, move.product_uos.id),
|
||||
'picking_id':new_picking, 'state':'draft',
|
||||
'location_id':new_location, 'location_dest_id':move.location_id.id,
|
||||
'date':date_cur,
|
||||
'price_unit':price_unit})
|
||||
'date':date_cur,})
|
||||
move_obj.write(cr, uid, [move.id], {'move_history_ids2':[(4,new_move)]})
|
||||
|
||||
if not returned_lines:
|
||||
|
||||
Reference in New Issue
Block a user