commit
c4ea44517b
|
@ -372,6 +372,13 @@ class base_module_record(osv.osv):
|
|||
self.ids[(rec[2], result)] = id
|
||||
record = self._create_yaml_record(cr, uid, rec[2], rec[4], id)
|
||||
return record
|
||||
if self.mode=="workflow":
|
||||
id,update = self._get_id(cr, uid, rec[2], rec[4])
|
||||
data = {}
|
||||
data['model'] = rec[2]
|
||||
data['action'] = rec[3]
|
||||
data['ref'] = id
|
||||
return data
|
||||
data=self.get_copy_data(cr,uid,rec[2],rec[4],rec[5])
|
||||
copy_rec=(rec[0],rec[1],rec[2],rec[3],rec[4],data,rec[5])
|
||||
rec=copy_rec
|
||||
|
@ -394,7 +401,7 @@ class base_module_record(osv.osv):
|
|||
doc.appendChild(terp)
|
||||
for rec in self.recording_data:
|
||||
if rec[0]=='workflow':
|
||||
rec_id,noupdate = self._get_id(cr, uid, rec[1][3], rec[1][5])
|
||||
rec_id,noupdate = self._get_id(cr, uid, rec[1][2], rec[1][4])
|
||||
if not rec_id:
|
||||
continue
|
||||
data = doc.createElement("data")
|
||||
|
@ -433,6 +440,15 @@ class record(yaml.YAMLObject):
|
|||
def __repr__(self):
|
||||
return '!record {model: %s, id: %s}:' % (str(self.model,), str(self.id,))
|
||||
|
||||
class workflow(yaml.YAMLObject):
|
||||
yaml_tag = u'!workflow'
|
||||
def __init__(self, model, action, ref=None):
|
||||
self.model = model
|
||||
self.ref = ref
|
||||
self.action=action
|
||||
def __repr__(self):
|
||||
return '!workflow {model: %s, action: %s, ref: %s}' % (str(self.model,), str(self.action,), str(self.ref,))
|
||||
|
||||
class ref(yaml.YAMLObject):
|
||||
yaml_tag = u'!ref'
|
||||
def __init__(self, expr="False"):
|
||||
|
@ -453,11 +469,20 @@ class eval(yaml.YAMLObject):
|
|||
self.mode="create"
|
||||
elif rec[1][3] == 'copy':
|
||||
self.mode="copy"
|
||||
elif rec[0] == 'workflow':
|
||||
self.mode="workflow"
|
||||
else:
|
||||
continue
|
||||
record= self._generate_object_yaml(cr, uid, rec[1],rec[3])
|
||||
strg+="object=yaml.load(unicode('''\n !record %s \n''','iso-8859-1'))"%record
|
||||
strg+='''
|
||||
if self.mode == "workflow":
|
||||
record= self._generate_object_yaml(cr, uid, rec[1],rec[0])
|
||||
strg+="object=yaml.load(unicode('''\n !workflow %s \n''','iso-8859-1'))"%record
|
||||
strg+='''
|
||||
print object
|
||||
'''
|
||||
else:
|
||||
record= self._generate_object_yaml(cr, uid, rec[1],rec[3])
|
||||
strg+="object=yaml.load(unicode('''\n !record %s \n''','iso-8859-1'))"%record
|
||||
strg+='''
|
||||
print object
|
||||
attrs=yaml.dump(object.attrs, default_flow_style=False)
|
||||
print attrs \n\n'''
|
||||
|
@ -476,6 +501,8 @@ print attrs \n\n'''
|
|||
line=line.replace("''","'")
|
||||
if line.find('!record') == 0:
|
||||
line = "- \n" + " " + line
|
||||
elif line.find('!workflow') == 0:
|
||||
line = "- \n" + " " + line
|
||||
elif line.find('- -') != -1:
|
||||
line=line.replace('- -',' -')
|
||||
line = " " + line
|
||||
|
|
|
@ -148,8 +148,7 @@
|
|||
<field name="rsvp" select="1" />
|
||||
<field name="cutype" select="1" />
|
||||
<field name="role" select="1" />
|
||||
<separator colspan="4" string="" />
|
||||
<field name="state" />
|
||||
<separator colspan="4" string=""/>
|
||||
<group col="6" colspan="4">
|
||||
<field name="state" select="2" />
|
||||
<button name="do_tentative" states="needs-action,declined,accepted"
|
||||
|
|
|
@ -56,11 +56,7 @@ def _mass_mail_send(self, cr, uid, data, context):
|
|||
model = hist_obj.log_id.model_id.model
|
||||
model_pool = pool.get(model)
|
||||
case = model_pool.browse(cr, uid, hist_obj.log_id.res_id)
|
||||
model_pool._history(cr, uid, [case], _('Send'), history=True, email=False)
|
||||
model_pool.write(cr, uid, [case.id], {
|
||||
'som': False,
|
||||
'canal_id': False,
|
||||
})
|
||||
model_pool._history(cr, uid, [case], _('Send'), history=True, email=False)
|
||||
emails = [data['form']['to']] + (data['form']['cc'] or '').split(',')
|
||||
emails = filter(None, emails)
|
||||
body = data['form']['text']
|
||||
|
|
|
@ -157,6 +157,8 @@ class document_file(osv.osv):
|
|||
context = {}
|
||||
vals['title'] = vals['name']
|
||||
vals['parent_id'] = context.get('parent_id', False) or vals.get('parent_id', False)
|
||||
if not vals['parent_id']:
|
||||
vals['parent_id'] = self.pool.get('document.directory')._get_root_directory(cr,uid, context)
|
||||
if not vals.get('res_id', False) and context.get('default_res_id', False):
|
||||
vals['res_id'] = context.get('default_res_id', False)
|
||||
if not vals.get('res_model', False) and context.get('default_res_model', False):
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
"update_xml" : [
|
||||
"security/ir.model.access.csv",
|
||||
"hr_evaluation_view.xml",
|
||||
"hr_evaluation_data.xml",
|
||||
"report/hr_evaluation_report_view.xml"],
|
||||
"active": False,
|
||||
"installable": True
|
||||
|
|
|
@ -1285,201 +1285,5 @@ class mrp_procurement(osv.osv):
|
|||
self._procure_orderpoint_confirm(cr, uid, automatic=automatic,\
|
||||
use_new_cursor=use_new_cursor, context=context)
|
||||
mrp_procurement()
|
||||
|
||||
class stock_warehouse_orderpoint(osv.osv):
|
||||
_name = "stock.warehouse.orderpoint"
|
||||
_description = "Orderpoint minimum rule"
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=32, required=True),
|
||||
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the orderpoint without removing it."),
|
||||
'logic': fields.selection([('max','Order to Max'),('price','Best price (not yet active!)')], 'Reordering Mode', required=True),
|
||||
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
|
||||
'location_id': fields.many2one('stock.location', 'Location', required=True),
|
||||
'product_id': fields.many2one('product.product', 'Product', ondelete='cascade', required=True, domain=[('type','=','product')]),
|
||||
'product_uom': fields.many2one('product.uom', 'Product UOM', required=True ),
|
||||
'product_min_qty': fields.float('Min Quantity', required=True,
|
||||
help="When the virtual stock goes belong the Min Quantity, Open ERP generates "\
|
||||
"a requisition to bring the virtual stock to the Max Quantity."),
|
||||
'product_max_qty': fields.float('Max Quantity', required=True,
|
||||
help="When the virtual stock goes belong the Min Quantity, Open ERP generates "\
|
||||
"a requisition to bring the virtual stock to the Max Quantity."),
|
||||
'qty_multiple': fields.integer('Qty Multiple', required=True,
|
||||
help="The requisition quantity will by rounded up to this multiple."),
|
||||
'procurement_id': fields.many2one('mrp.procurement', 'Latest Requisition'),
|
||||
'company_id': fields.many2one('res.company','Company',required=True),
|
||||
}
|
||||
_defaults = {
|
||||
'active': lambda *a: 1,
|
||||
'logic': lambda *a: 'max',
|
||||
'qty_multiple': lambda *a: 1,
|
||||
'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'mrp.warehouse.orderpoint') or '',
|
||||
'product_uom': lambda sel, cr, uid, context: context.get('product_uom', False),
|
||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.warehouse.orderpoint', context=c)
|
||||
}
|
||||
def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context={}):
|
||||
if warehouse_id:
|
||||
w=self.pool.get('stock.warehouse').browse(cr,uid,warehouse_id, context)
|
||||
v = {'location_id':w.lot_stock_id.id}
|
||||
return {'value': v}
|
||||
return {}
|
||||
def onchange_product_id(self, cr, uid, ids, product_id, context={}):
|
||||
if product_id:
|
||||
prod=self.pool.get('product.product').browse(cr,uid,product_id)
|
||||
v = {'product_uom':prod.uom_id.id}
|
||||
return {'value': v}
|
||||
return {}
|
||||
def copy(self, cr, uid, id, default=None,context={}):
|
||||
if not default:
|
||||
default = {}
|
||||
default.update({
|
||||
'name': self.pool.get('ir.sequence').get(cr, uid, 'mrp.warehouse.orderpoint') or '',
|
||||
})
|
||||
return super(stock_warehouse_orderpoint, self).copy(cr, uid, id, default, context)
|
||||
stock_warehouse_orderpoint()
|
||||
|
||||
|
||||
class StockMove(osv.osv):
|
||||
_inherit = 'stock.move'
|
||||
_columns = {
|
||||
'procurements': fields.one2many('mrp.procurement', 'move_id', 'Requisitions'),
|
||||
}
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
default = default or {}
|
||||
default['procurements'] = []
|
||||
return super(StockMove, self).copy(cr, uid, id, default, context)
|
||||
|
||||
def _action_explode(self, cr, uid, move, context={}):
|
||||
if move.product_id.supply_method=='produce' and move.product_id.procure_method=='make_to_order':
|
||||
bis = self.pool.get('mrp.bom').search(cr, uid, [
|
||||
('product_id','=',move.product_id.id),
|
||||
('bom_id','=',False),
|
||||
('type','=','phantom')])
|
||||
if bis:
|
||||
factor = move.product_qty
|
||||
bom_point = self.pool.get('mrp.bom').browse(cr, uid, bis[0])
|
||||
res = self.pool.get('mrp.bom')._bom_explode(cr, uid, bom_point, factor, [])
|
||||
dest = move.product_id.product_tmpl_id.property_stock_production.id
|
||||
state = 'confirmed'
|
||||
if move.state=='assigned':
|
||||
state='assigned'
|
||||
for line in res[0]:
|
||||
valdef = {
|
||||
'picking_id': move.picking_id.id,
|
||||
'product_id': line['product_id'],
|
||||
'product_uom': line['product_uom'],
|
||||
'product_qty': line['product_qty'],
|
||||
'product_uos': line['product_uos'],
|
||||
'product_uos_qty': line['product_uos_qty'],
|
||||
'move_dest_id': move.id,
|
||||
'state': state,
|
||||
'name': line['name'],
|
||||
'location_dest_id': dest,
|
||||
'move_history_ids': [(6,0,[move.id])],
|
||||
'move_history_ids2': [(6,0,[])],
|
||||
'procurements': [],
|
||||
}
|
||||
mid = self.pool.get('stock.move').copy(cr, uid, move.id, default=valdef)
|
||||
prodobj = self.pool.get('product.product').browse(cr, uid, line['product_id'], context=context)
|
||||
proc_id = self.pool.get('mrp.procurement').create(cr, uid, {
|
||||
'name': (move.picking_id.origin or ''),
|
||||
'origin': (move.picking_id.origin or ''),
|
||||
'date_planned': move.date_planned,
|
||||
'product_id': line['product_id'],
|
||||
'product_qty': line['product_qty'],
|
||||
'product_uom': line['product_uom'],
|
||||
'product_uos_qty': line['product_uos'] and line['product_uos_qty'] or False,
|
||||
'product_uos': line['product_uos'],
|
||||
'location_id': move.location_id.id,
|
||||
'procure_method': prodobj.procure_method,
|
||||
'move_id': mid,
|
||||
'company_id': line['company_id'],
|
||||
})
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
|
||||
self.pool.get('stock.move').write(cr, uid, [move.id], {
|
||||
'location_id': move.location_dest_id.id,
|
||||
'auto_validate': True,
|
||||
'picking_id': False,
|
||||
'location_id': dest,
|
||||
'state': 'waiting'
|
||||
})
|
||||
for m in self.pool.get('mrp.procurement').search(cr, uid, [('move_id','=',move.id)], context):
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'mrp.procurement', m, 'button_wait_done', cr)
|
||||
return True
|
||||
|
||||
|
||||
def consume_moves(self, cr, uid, ids, product_qty, location_id=False, location_dest_id=False, consume=True, context=None):
|
||||
res = []
|
||||
production_obj = self.pool.get('mrp.production')
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for move in self.browse(cr, uid, ids):
|
||||
new_moves = super(StockMove, self).consume_moves(cr, uid, [move.id], product_qty, location_id, location_dest_id, consume, context=context)
|
||||
production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
|
||||
for prod in production_obj.browse(cr, uid, production_ids, context=context):
|
||||
if prod.state == 'confirmed':
|
||||
production_obj.force_production(cr, uid, [prod.id])
|
||||
wf_service.trg_validate(uid, 'mrp.production', prod.id, 'button_produce', cr)
|
||||
for new_move in new_moves:
|
||||
production_obj.write(cr, uid, production_ids, {'move_lines': [(4, new_move)]})
|
||||
res.append(new_move)
|
||||
return res
|
||||
|
||||
def scrap_moves(self, cr, uid, ids, product_qty, location_id, context=None):
|
||||
res = []
|
||||
production_obj = self.pool.get('mrp.production')
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for move in self.browse(cr, uid, ids):
|
||||
new_moves = super(StockMove, self).scrap_moves(cr, uid, [move.id], product_qty, location_id, context=context)
|
||||
production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
|
||||
for prod_id in production_ids:
|
||||
wf_service.trg_validate(uid, 'mrp.production', prod_id, 'button_produce', cr)
|
||||
for new_move in new_moves:
|
||||
production_obj.write(cr, uid, production_ids, {'move_lines': [(4, new_move)]})
|
||||
res.append(new_move)
|
||||
return {}
|
||||
|
||||
StockMove()
|
||||
|
||||
|
||||
class StockPicking(osv.osv):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
def test_finnished(self, cursor, user, ids):
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
res = super(StockPicking, self).test_finnished(cursor, user, ids)
|
||||
for picking in self.browse(cursor, user, ids):
|
||||
for move in picking.move_lines:
|
||||
if move.state == 'done' and move.procurements:
|
||||
for procurement in move.procurements:
|
||||
wf_service.trg_validate(user, 'mrp.procurement',
|
||||
procurement.id, 'button_check', cursor)
|
||||
return res
|
||||
|
||||
#
|
||||
# Explode picking by replacing phantom BoMs
|
||||
#
|
||||
def action_explode(self, cr, uid, picks, *args):
|
||||
for move in self.pool.get('stock.move').browse(cr, uid, picks):
|
||||
self.pool.get('stock.move')._action_explode(cr, uid, move)
|
||||
return picks
|
||||
|
||||
StockPicking()
|
||||
|
||||
|
||||
class spilt_in_production_lot(osv.osv_memory):
|
||||
_inherit = "stock.move.split"
|
||||
def split(self, cr, uid, ids, move_ids, context=None):
|
||||
production_obj = self.pool.get('mrp.production')
|
||||
move_obj = self.pool.get('stock.move')
|
||||
res = []
|
||||
for move in move_obj.browse(cr, uid, move_ids, context=context):
|
||||
new_moves = super(spilt_in_production_lot, self).split(cr, uid, ids, move_ids, context=context)
|
||||
production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
|
||||
for new_move in new_moves:
|
||||
production_obj.write(cr, uid, production_ids, {'move_lines': [(4, new_move)]})
|
||||
return res
|
||||
spilt_in_production_lot()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@
|
|||
</group>
|
||||
<group colspan="2" col="2">
|
||||
<separator string="Dates" colspan="2"/>
|
||||
<field name="create_date"/>
|
||||
<field name="create_date" widget="datetime"/>
|
||||
<field name="date_confirm"/>
|
||||
</group>
|
||||
<separator colspan="4" string="Notes"/>
|
||||
|
|
Loading…
Reference in New Issue