[MERGE] merged dev2 branch
bzr revid: qdp-launchpad@openerp.com-20110309155527-l9d77rtquhtto7ts
This commit is contained in:
commit
d129e16e85
|
@ -38,7 +38,7 @@ class RPCProxyOne(object):
|
|||
self.rpc = xmlrpclib.ServerProxy(local_url)
|
||||
self.ressource = ressource
|
||||
def __getattr__(self, name):
|
||||
return lambda cr, uid, *args, **kwargs: self.rpc.execute(self.server.server_db, self.uid, self.server.password, self.ressource, name, *args, **kwargs)
|
||||
return lambda cr, uid, *args, **kwargs: self.rpc.execute(self.server.server_db, self.uid, self.server.password, self.ressource, name, *args)
|
||||
|
||||
class RPCProxy(object):
|
||||
def __init__(self, server):
|
||||
|
@ -79,6 +79,7 @@ class base_synchro(osv.osv_memory):
|
|||
eval(object.domain),
|
||||
{'action':'d'}
|
||||
)
|
||||
|
||||
if object.action in ('u','b'):
|
||||
ids += pool2.get('base.synchro.obj').get_ids(cr, uid,
|
||||
object.model_id.model,
|
||||
|
@ -102,7 +103,7 @@ class base_synchro(osv.osv_memory):
|
|||
if object.model_id.model=='crm.case.history':
|
||||
fields = ['email','description','log_id']
|
||||
value = pool_src.get(object.model_id.model).read(cr, uid, [id], fields)[0]
|
||||
value = self.data_transform(cr, uid, pool_src, pool_dest, object.model_id.model, value, action)
|
||||
value = self.data_transform(cr, uid, pool_src, pool_dest, object.model_id.model, value, action, context=context)
|
||||
id2 = self.get_id(cr, uid, object.id, id, action, context)
|
||||
#
|
||||
# Transform value
|
||||
|
@ -110,7 +111,6 @@ class base_synchro(osv.osv_memory):
|
|||
#tid=pool_dest.get(object.model_id.model).name_search(cr, uid, value['name'],[],'=',)
|
||||
if not (iii%50):
|
||||
print 'Record', iii
|
||||
|
||||
# Filter fields to not sync
|
||||
for field in object.avoid_ids:
|
||||
if field.name in value:
|
||||
|
@ -133,7 +133,7 @@ class base_synchro(osv.osv_memory):
|
|||
})
|
||||
self.report_total+=1
|
||||
self.report_create+=1
|
||||
self.meta = {}
|
||||
self.meta = {}
|
||||
return True
|
||||
|
||||
def get_id(self, cr, uid, object_id, id, action, context=None):
|
||||
|
@ -216,16 +216,16 @@ class base_synchro(osv.osv_memory):
|
|||
start_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss')
|
||||
syn_obj = self.browse(cr, uid, ids, context=context)[0]
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
server = pool.get('base.synchro.server').browse(cr, uid, ids, context=context)[0]
|
||||
server = pool.get('base.synchro.server').browse(cr, uid, syn_obj.server_url.id, context=context)
|
||||
for object in server.obj_ids:
|
||||
dt = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
self.synchronize(cr, uid, server, object, context)
|
||||
self.synchronize(cr, uid, server, object, context=context)
|
||||
if object.action=='b':
|
||||
time.sleep(1)
|
||||
dt = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
self.pool.get('base.synchro.obj').write(cr, uid, [object.id], {'synchronize_date': dt})
|
||||
end_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss')
|
||||
if 'user_id' in syn_obj.user_id:
|
||||
if syn_obj.user_id:
|
||||
request = pooler.get_pool(cr.dbname).get('res.request')
|
||||
if not self.report:
|
||||
self.report.append('No exception.')
|
||||
|
@ -244,7 +244,7 @@ Exceptions:
|
|||
request.create(cr, uid, {
|
||||
'name' : "Synchronization report",
|
||||
'act_from' : uid,
|
||||
'act_to' : syn_obj.user_id,
|
||||
'act_to' : syn_obj.user_id.id,
|
||||
'body': summary,
|
||||
})
|
||||
return True
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
<field name="res_model">base.synchro</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_base_synchro"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
|
|
|
@ -240,10 +240,28 @@ class mrp_bom(osv.osv):
|
|||
return False
|
||||
level -= 1
|
||||
return True
|
||||
_constraints = [
|
||||
(_check_recursion, 'Error ! You can not create recursive BoM.', ['parent_id'])
|
||||
]
|
||||
|
||||
def _check_product(self, cr, uid, ids, context=None):
|
||||
all_prod = []
|
||||
bom_obj = self.pool.get('mrp.bom')
|
||||
boms = self.browse(cr, uid, ids, context=context)
|
||||
def check_bom(boms):
|
||||
res = True
|
||||
for bom in boms:
|
||||
if bom.product_id.id in all_prod:
|
||||
res = res and False
|
||||
all_prod.append(bom.product_id.id)
|
||||
lines = bom.bom_lines
|
||||
if lines:
|
||||
newboms = [a for a in lines if a not in boms]
|
||||
res = res and check_bom(newboms)
|
||||
return res
|
||||
return check_bom(boms)
|
||||
|
||||
_constraints = [
|
||||
(_check_recursion, 'Error ! You can not create recursive BoM.', ['parent_id']),
|
||||
(_check_product, 'BoM line product should not be same as BoM product.', ['product_id']),
|
||||
]
|
||||
|
||||
def onchange_product_id(self, cr, uid, ids, product_id, name, context=None):
|
||||
""" Changes UoM and name if product_id changes.
|
||||
|
|
|
@ -407,6 +407,8 @@
|
|||
<field name="date_stop"/>
|
||||
<field name="product_rounding"/>
|
||||
<field name="product_efficiency" groups="base.group_extended"/>
|
||||
<separator string="Properties" colspan="4"/>
|
||||
<newline/>
|
||||
<field colspan="4" name="property_ids" nolabel="2" groups="base.group_extended"/>
|
||||
</page>
|
||||
</notebook>
|
||||
|
|
|
@ -119,11 +119,12 @@ class mrp_production_workcenter_line(osv.osv):
|
|||
@return: Nothing
|
||||
"""
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
prod_obj_pool = self.pool.get('mrp.production')
|
||||
oper_obj = self.browse(cr, uid, ids)[0]
|
||||
prod_obj = oper_obj.production_id
|
||||
if action == 'start':
|
||||
if prod_obj.state =='confirmed':
|
||||
self.pool.get('mrp.production').force_production(cr, uid, [prod_obj.id])
|
||||
prod_obj_pool.force_production(cr, uid, [prod_obj.id])
|
||||
wf_service.trg_validate(uid, 'mrp.production', prod_obj.id, 'button_produce', cr)
|
||||
elif prod_obj.state =='ready':
|
||||
wf_service.trg_validate(uid, 'mrp.production', prod_obj.id, 'button_produce', cr)
|
||||
|
@ -139,6 +140,9 @@ class mrp_production_workcenter_line(osv.osv):
|
|||
if line.state != 'done':
|
||||
flag = False
|
||||
if flag:
|
||||
for production in prod_obj_pool.browse(cr, uid, [prod_obj.id], context= None):
|
||||
if production.move_lines or production.move_created_ids:
|
||||
prod_obj_pool.action_produce(cr,uid, production.id, production.product_qty, 'consume_produce', context = None)
|
||||
wf_service.trg_validate(uid, 'mrp.production', oper_obj.production_id.id, 'button_produce_done', cr)
|
||||
return
|
||||
|
||||
|
@ -244,10 +248,12 @@ class mrp_production(osv.osv):
|
|||
wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_start_working', cr)
|
||||
return super(mrp_production,self).action_in_production(cr, uid, ids)
|
||||
|
||||
def action_cancel(self, cr, uid, ids):
|
||||
def action_cancel(self, cr, uid, ids, context=None):
|
||||
""" Cancels work order if production order is canceled.
|
||||
@return: Super method
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
obj = self.browse(cr, uid, ids)[0]
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for workcenter_line in obj.workcenter_lines:
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
<field name="name">procurement.order.tree.board</field>
|
||||
<field name="model">procurement.order</field>
|
||||
<field name="type">tree</field>
|
||||
<field eval="20" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Procurement Lines" colors="red:date_planned<current_date and state in ('exception');black:state=='running';darkgreen:state=='confirmed';gray:state in ['done','cancel'];blue:state in ('ready')">
|
||||
<field name="date_planned" widget="date"/>
|
||||
|
@ -246,8 +247,8 @@
|
|||
<act_window
|
||||
context="{'search_default_warehouse_id': active_id, 'default_warehouse_id': active_id}"
|
||||
id="act_stock_warehouse_2_stock_warehouse_orderpoint"
|
||||
name="Minimum Stock Rules"
|
||||
res_model="stock.warehouse.orderpoint"
|
||||
name="Minimum Stock Rules"
|
||||
res_model="stock.warehouse.orderpoint"
|
||||
src_model="stock.warehouse"
|
||||
groups="stock.group_stock_user"/>
|
||||
|
||||
|
|
|
@ -245,7 +245,8 @@ class product_pricelist(osv.osv):
|
|||
if sinfo:
|
||||
qty_in_product_uom = qty
|
||||
product_default_uom = product_obj.read(cr, uid, [tmpl_id], ['uom_id'])[0]['uom_id'][0]
|
||||
seller_uom = supplierinfo_obj.read(cr, uid, sinfo, ['product_uom'])[0]['product_uom'][0]
|
||||
supplier = supplierinfo_obj.browse(cr, uid, sinfo, context=context)[0]
|
||||
seller_uom = supplier.product_uom and supplier.product_uom.id or False
|
||||
if seller_uom and product_default_uom and product_default_uom != seller_uom:
|
||||
uom_price_already_computed = True
|
||||
qty_in_product_uom = product_uom_obj._compute_qty(cr, uid, product_default_uom, qty, to_uom_id=seller_uom)
|
||||
|
@ -262,9 +263,9 @@ class product_pricelist(osv.osv):
|
|||
price = currency_obj.compute(cr, uid,
|
||||
price_type.currency_id.id, res['currency_id'],
|
||||
product_obj.price_get(cr, uid, [product_id],
|
||||
price_type.field,context=context)[product_id], round=False, context=context)
|
||||
price_type.field, context=context)[product_id], round=False, context=context)
|
||||
|
||||
if price:
|
||||
if price >= 0.0:
|
||||
price_limit = price
|
||||
|
||||
price = price * (1.0+(res['price_discount'] or 0.0))
|
||||
|
@ -385,7 +386,7 @@ class product_pricelist(osv.osv):
|
|||
else:
|
||||
price_tmp = self.price_get(cr, uid,
|
||||
[res['base_pricelist_id']], prod_id,
|
||||
qty,context=context)[res['base_pricelist_id']]
|
||||
qty, context=context)[res['base_pricelist_id']]
|
||||
ptype_src = self.browse(cr, uid,
|
||||
res['base_pricelist_id']).currency_id.id
|
||||
price = currency_obj.compute(cr, uid, ptype_src,
|
||||
|
@ -413,7 +414,7 @@ class product_pricelist(osv.osv):
|
|||
price = currency_obj.compute(cr, uid,
|
||||
price_type.currency_id.id, res['currency_id'],
|
||||
product_obj.price_get(cr, uid, [prod_id],
|
||||
price_type.field,context=context)[prod_id], round=False, context=context)
|
||||
price_type.field, context=context)[prod_id], round=False, context=context)
|
||||
|
||||
if price:
|
||||
price_limit = price
|
||||
|
|
|
@ -139,7 +139,7 @@ class product_uom(osv.osv):
|
|||
context = {}
|
||||
if from_unit.category_id.id <> to_unit.category_id.id:
|
||||
if context.get('raise-exception', True):
|
||||
raise osv.except_osv(_('Error !'), _('Conversion from Product UoM m to Default UoM PCE is not possible as they both belong to different Category!.'))
|
||||
raise osv.except_osv(_('Error !'), _('Conversion from Product UoM %s to Default UoM %s is not possible as they both belong to different Category!.') % (from_unit.name,to_unit.name,))
|
||||
else:
|
||||
return qty
|
||||
amount = qty / from_unit.factor
|
||||
|
@ -482,7 +482,7 @@ class product_product(osv.osv):
|
|||
'pricelist_id': fields.dummy(string='Pricelist', relation='product.pricelist', type='many2one'),
|
||||
'name_template': fields.related('product_tmpl_id', 'name', string="Name", type='char', size=128, store=True),
|
||||
}
|
||||
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
unlink_ids = []
|
||||
unlink_product_tmpl_ids = []
|
||||
|
@ -715,10 +715,10 @@ class product_supplierinfo(osv.osv):
|
|||
result[supplier_info.id]['qty'] = qty
|
||||
return result
|
||||
|
||||
def _get_uom_id(self, cr, uid, *args):
|
||||
cr.execute('select id from product_uom order by id limit 1')
|
||||
res = cr.fetchone()
|
||||
return res and res[0] or False
|
||||
def _get_uom_id(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
return context.get('uom_id', False)
|
||||
|
||||
_columns = {
|
||||
'name' : fields.many2one('res.partner', 'Supplier', required=True,domain = [('supplier','=',True)], ondelete='cascade', help="Supplier of this product"),
|
||||
|
|
|
@ -150,7 +150,7 @@
|
|||
|
||||
</page>
|
||||
<page string="Suppliers">
|
||||
<field colspan="4" name="seller_ids" nolabel="1"/>
|
||||
<field colspan="4" name="seller_ids" nolabel="1" context="{'uom_id': uom_id}"/>
|
||||
</page>
|
||||
<page string="Descriptions">
|
||||
<separator string="Description"/>
|
||||
|
|
|
@ -37,7 +37,7 @@ class procurement_order(osv.osv):
|
|||
self.write(cr, uid, [procurement.id], {'state': 'running'})
|
||||
planned_hours = procurement.product_qty
|
||||
task_id = self.pool.get('project.task').create(cr, uid, {
|
||||
'name': '%s:%s' % (procurement.origin or '', procurement.name),
|
||||
'name': '%s:%s' % (procurement.origin or '', procurement.product_id.name),
|
||||
'date_deadline': procurement.date_planned,
|
||||
'planned_hours':planned_hours,
|
||||
'remaining_hours': planned_hours,
|
||||
|
|
|
@ -170,7 +170,7 @@ class purchase_order(osv.osv):
|
|||
'partner_id':fields.many2one('res.partner', 'Supplier', required=True, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]}, change_default=True),
|
||||
'partner_address_id':fields.many2one('res.partner.address', 'Address', required=True,
|
||||
states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]},domain="[('partner_id', '=', partner_id)]"),
|
||||
'dest_address_id':fields.many2one('res.partner.address', 'Destination Address',
|
||||
'dest_address_id':fields.many2one('res.partner.address', 'Destination Address', domain="[('partner_id', '!=', False)]",
|
||||
states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]},
|
||||
help="Put an address if you want to deliver directly from the supplier to the customer." \
|
||||
"In this case, it will remove the warehouse link and set the customer location."
|
||||
|
@ -665,7 +665,6 @@ class purchase_order_line(osv.osv):
|
|||
'notes': notes or'', 'product_uom' : uom or False}, 'domain':{'product_uom':[]}}
|
||||
res = {}
|
||||
prod= self.pool.get('product.product').browse(cr, uid, product)
|
||||
|
||||
product_uom_pool = self.pool.get('product.uom')
|
||||
lang=False
|
||||
if partner_id:
|
||||
|
@ -681,6 +680,11 @@ class purchase_order_line(osv.osv):
|
|||
date_order = time.strftime('%Y-%m-%d')
|
||||
qty = qty or 1.0
|
||||
seller_delay = 0
|
||||
if uom:
|
||||
uom1_cat = prod.uom_id.category_id.id
|
||||
uom2_cat = product_uom_pool.browse(cr, uid, uom).category_id.id
|
||||
if uom1_cat != uom2_cat:
|
||||
uom = False
|
||||
|
||||
prod_name = self.pool.get('product.product').name_get(cr, uid, [prod.id], context=context)[0][1]
|
||||
res = {}
|
||||
|
@ -707,14 +711,13 @@ class purchase_order_line(osv.osv):
|
|||
'taxes_id':map(lambda x: x.id, prod.supplier_taxes_id),
|
||||
'date_planned': date_planned or dt,'notes': notes or prod.description_purchase,
|
||||
'product_qty': qty,
|
||||
'product_uom': uom}})
|
||||
'product_uom': prod.uom_id.id}})
|
||||
domain = {}
|
||||
|
||||
taxes = self.pool.get('account.tax').browse(cr, uid,map(lambda x: x.id, prod.supplier_taxes_id))
|
||||
fpos = fiscal_position and self.pool.get('account.fiscal.position').browse(cr, uid, fiscal_position) or False
|
||||
res['value']['taxes_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
|
||||
|
||||
res2 = self.pool.get('product.uom').read(cr, uid, [uom], ['category_id'])
|
||||
res2 = self.pool.get('product.uom').read(cr, uid, [prod.uom_id.id], ['category_id'])
|
||||
res3 = prod.uom_id.category_id.id
|
||||
domain = {'product_uom':[('category_id','=',res2[0]['category_id'][0])]}
|
||||
if res2[0]['category_id'][0] != res3:
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
groups="group_purchase_manager"
|
||||
parent="base.menu_purchase_root" sequence="100"/>
|
||||
|
||||
<menuitem
|
||||
<menuitem
|
||||
id="menu_purchase_config_pricelist" name="Pricelists"
|
||||
parent="menu_purchase_config_purchase" sequence="50"/>
|
||||
|
||||
|
@ -29,22 +29,22 @@
|
|||
parent="menu_purchase_config_pricelist" sequence="2"
|
||||
groups="base.group_extended"/>
|
||||
|
||||
<menuitem
|
||||
<menuitem
|
||||
id="menu_product_in_config_purchase" name="Product"
|
||||
parent="menu_purchase_config_purchase" sequence="30"/>
|
||||
|
||||
<menuitem
|
||||
action="product.product_category_action_form" id="menu_product_category_config_purchase"
|
||||
parent="purchase.menu_product_in_config_purchase" sequence="10"/>
|
||||
|
||||
<menuitem
|
||||
|
||||
<menuitem
|
||||
id="menu_purchase_unit_measure_purchase" name="Units of Measure"
|
||||
parent="purchase.menu_product_in_config_purchase" sequence="20"/>
|
||||
|
||||
<menuitem
|
||||
action="product.product_uom_categ_form_action" id="menu_purchase_uom_categ_form_action"
|
||||
parent="menu_purchase_unit_measure_purchase" sequence="30"/>
|
||||
|
||||
|
||||
<menuitem
|
||||
action="product.product_uom_form_action" id="menu_purchase_uom_form_action"
|
||||
parent="menu_purchase_unit_measure_purchase" sequence="30"/>
|
||||
|
@ -217,7 +217,6 @@
|
|||
<separator string="Invoices" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="invoice_ids" groups="base.group_extended" nolabel="1" colspan="4" context="{'type':'in_invoice', 'journal_type':'purchase'}"/>
|
||||
<field name="invoice_ids" groups="base.group_extended" nolabel="1" colspan="4" context="{'type':'in_invoice', 'journal_type': 'purchase'}"/>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
<field colspan="4" name="notes" nolabel="1"/>
|
||||
|
|
|
@ -1166,8 +1166,7 @@ class stock_picking(osv.osv):
|
|||
for move in pick.move_lines:
|
||||
if move.state in ('done', 'cancel'):
|
||||
continue
|
||||
partial_data = partial_datas.get('move%s'%(move.id), False)
|
||||
assert partial_data, _('Missing partial picking data for move #%s') % (move.id)
|
||||
partial_data = partial_datas.get('move%s'%(move.id), {})
|
||||
product_qty = partial_data.get('product_qty',0.0)
|
||||
move_product_qty[move.id] = product_qty
|
||||
product_uom = partial_data.get('product_uom',False)
|
||||
|
@ -1248,9 +1247,9 @@ class stock_picking(osv.osv):
|
|||
|
||||
if new_picking:
|
||||
move_obj.write(cr, uid, [c.id for c in complete], {'picking_id': new_picking})
|
||||
for move in complete:
|
||||
if prodlot_ids.get(move.id):
|
||||
move_obj.write(cr, uid, move.id, {'prodlot_id': prodlot_ids[move.id]})
|
||||
for move in complete:
|
||||
if prodlot_ids.get(move.id):
|
||||
move_obj.write(cr, uid, move.id, {'prodlot_id': prodlot_ids[move.id]})
|
||||
for move in too_many:
|
||||
product_qty = move_product_qty[move.id]
|
||||
defaults = {
|
||||
|
@ -1463,7 +1462,7 @@ class stock_move(osv.osv):
|
|||
_description = "Stock Move"
|
||||
_order = 'date_expected desc, id'
|
||||
_log_create = False
|
||||
|
||||
|
||||
def action_partial_move(self, cr, uid, ids, context=None):
|
||||
if context is None: context = {}
|
||||
partial_id = self.pool.get("stock.partial.move").create(
|
||||
|
@ -1481,7 +1480,7 @@ class stock_move(osv.osv):
|
|||
'domain': '[]',
|
||||
'context': context
|
||||
}
|
||||
|
||||
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
res = []
|
||||
|
@ -1855,11 +1854,6 @@ class stock_move(osv.osv):
|
|||
"""
|
||||
moves = self.browse(cr, uid, ids, context=context)
|
||||
self.write(cr, uid, ids, {'state': 'confirmed'})
|
||||
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")
|
||||
|
||||
self.create_chained_picking(cr, uid, moves, context)
|
||||
return []
|
||||
|
||||
|
@ -1886,6 +1880,14 @@ class stock_move(osv.osv):
|
|||
@return: True
|
||||
"""
|
||||
self.write(cr, uid, ids, {'state': 'confirmed'})
|
||||
|
||||
# fix for bug lp:707031
|
||||
# called write of related picking because changing move availability does
|
||||
# not trigger workflow of picking in order to change the state of picking
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
for move in self.browse(cr, uid, ids, context):
|
||||
if move.picking_id:
|
||||
wf_service.trg_write(uid, 'stock.picking', move.picking_id.id, cr)
|
||||
return True
|
||||
|
||||
#
|
||||
|
@ -2136,7 +2138,7 @@ 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'):
|
||||
if move.state not in ('confirmed','done', 'assigned'):
|
||||
todo.append(move.id)
|
||||
|
||||
if todo:
|
||||
|
|
|
@ -29,65 +29,68 @@ class stock_inventory_line_split(osv.osv_memory):
|
|||
_name = "stock.inventory.line.split"
|
||||
_description = "Split inventory lines"
|
||||
|
||||
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
""" To check the availability of production lot.
|
||||
""" To check the availability of production lot.
|
||||
@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.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
record_id = context and context.get('active_id',False)
|
||||
res = {}
|
||||
line = self.pool.get('stock.inventory.line').browse(cr, uid, record_id, context=context)
|
||||
line = self.pool.get('stock.inventory.line').browse(cr, uid, record_id, context=context)
|
||||
if 'product_id' in fields:
|
||||
res.update({'product_id':line.product_id.id})
|
||||
if 'product_uom' in fields:
|
||||
res.update({'product_uom': line.product_uom.id})
|
||||
if 'qty' in fields:
|
||||
res.update({'qty': line.product_qty})
|
||||
res.update({'qty': line.product_qty})
|
||||
return res
|
||||
|
||||
|
||||
def split(self, cr, uid, ids, line_ids, context=None):
|
||||
""" To split stock inventory lines according to production lot.
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param ids: the ID or list of IDs if we want more than one
|
||||
@param ids: the ID or list of IDs if we want more than one
|
||||
@param line_ids: the ID or list of IDs of inventory lines we want to split
|
||||
@param context: A standard dictionary
|
||||
@return:
|
||||
"""
|
||||
@param context: A standard dictionary
|
||||
@return:
|
||||
"""
|
||||
prodlot_obj = self.pool.get('stock.production.lot')
|
||||
ir_sequence_obj = self.pool.get('ir.sequence')
|
||||
line_obj = self.pool.get('stock.inventory.line')
|
||||
new_line = []
|
||||
new_line = []
|
||||
for data in self.browse(cr, uid, ids, context=context):
|
||||
for inv_line in line_obj.browse(cr, uid, line_ids, context=context):
|
||||
line_qty = inv_line.product_qty
|
||||
quantity_rest = inv_line.product_qty
|
||||
new_line = []
|
||||
quantity_rest = inv_line.product_qty
|
||||
new_line = []
|
||||
if data.use_exist:
|
||||
lines = [l for l in data.line_exist_ids if l]
|
||||
else:
|
||||
lines = [l for l in data.line_ids if l]
|
||||
lines = [l for l in data.line_ids if l]
|
||||
for line in lines:
|
||||
quantity = line.quantity
|
||||
if quantity <= 0 or line_qty == 0:
|
||||
continue
|
||||
quantity_rest -= quantity
|
||||
if quantity_rest <= 0:
|
||||
quantity_rest -= quantity
|
||||
if quantity_rest < 0:
|
||||
quantity_rest = quantity
|
||||
break
|
||||
default_val = {
|
||||
'product_qty': quantity,
|
||||
'product_qty': quantity,
|
||||
}
|
||||
current_line = line_obj.copy(cr, uid, inv_line.id, default_val)
|
||||
new_line.append(current_line)
|
||||
if quantity_rest > 0:
|
||||
current_line = line_obj.copy(cr, uid, inv_line.id, default_val)
|
||||
new_line.append(current_line)
|
||||
if quantity_rest == 0:
|
||||
current_line = inv_line.id
|
||||
prodlot_id = False
|
||||
if data.use_exist:
|
||||
prodlot_id = line.prodlot_id.id
|
||||
|
@ -97,13 +100,13 @@ class stock_inventory_line_split(osv.osv_memory):
|
|||
'product_id': inv_line.product_id.id},
|
||||
context=context)
|
||||
line_obj.write(cr, uid, [current_line], {'prod_lot_id': prodlot_id})
|
||||
prodlot = prodlot_obj.browse(cr, uid, prodlot_id)
|
||||
|
||||
prodlot = prodlot_obj.browse(cr, uid, prodlot_id)
|
||||
|
||||
update_val = {}
|
||||
if quantity_rest > 0:
|
||||
update_val['product_qty'] = quantity_rest
|
||||
if quantity_rest > 0:
|
||||
update_val['product_qty'] = quantity_rest
|
||||
line_obj.write(cr, uid, [inv_line.id], update_val)
|
||||
|
||||
|
||||
return new_line
|
||||
stock_inventory_line_split()
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ class stock_invoice_onshipping(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
picking_pool = self.pool.get('stock.picking')
|
||||
onshipdata_obj = self.read(cr, uid, ids, ['journal_id', 'group', 'invoice_date'])
|
||||
onshipdata_obj = self.read(cr, uid, ids, ['journal_id', 'group', 'invoice_date'], context=context)
|
||||
if context.get('new_picking', False):
|
||||
onshipdata_obj['id'] = onshipdata_obj.new_picking
|
||||
onshipdata_obj[ids] = onshipdata_obj.new_picking
|
||||
|
@ -127,7 +127,7 @@ class stock_invoice_onshipping(osv.osv_memory):
|
|||
res = picking_pool.action_invoice_create(cr, uid, active_ids,
|
||||
journal_id = onshipdata_obj[0]['journal_id'],
|
||||
group = onshipdata_obj[0]['group'],
|
||||
type = None,
|
||||
type = context.get('inv_type'),
|
||||
context=context)
|
||||
return res
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class stock_location_product(osv.osv_memory):
|
|||
@return: Invoice type
|
||||
"""
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
for location_obj in self.read(cr, uid, ids, ['from_date', 'to_date']):
|
||||
for location_obj in self.read(cr, uid, ids, ['from_date', 'to_date'], context=context):
|
||||
return {
|
||||
'name': False,
|
||||
'view_type': 'form',
|
||||
|
|
|
@ -151,7 +151,7 @@ class stock_return_picking(osv.osv_memory):
|
|||
wf_service = netsvc.LocalService("workflow")
|
||||
|
||||
pick = pick_obj.browse(cr, uid, record_id, context=context)
|
||||
data = self.read(cr, uid, ids[0])
|
||||
data = self.read(cr, uid, ids[0], context=context)
|
||||
new_picking = None
|
||||
date_cur = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
|
|
Loading…
Reference in New Issue