[IMP] Put wkf_action_cancel back, so the method does not call itself recursively (issue 2079)

This commit is contained in:
Josse Colpaert 2014-09-05 14:50:41 +02:00
parent 1512534320
commit d38fafdee8
4 changed files with 15 additions and 10 deletions

View File

@ -672,6 +672,11 @@ class purchase_order(osv.osv):
return True
return False
def wkf_action_cancel(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'cancel'})
self.set_order_line_status(cr, uid, ids, 'cancel', context=context)
def action_cancel(self, cr, uid, ids, context=None):
for purchase in self.browse(cr, uid, ids, context=context):
for pick in purchase.picking_ids:

View File

@ -37,7 +37,7 @@
<field name="name">cancel</field>
<field name="kind">function</field>
<field name="flow_stop">True</field>
<field name="action">action_cancel()</field>
<field name="action">wkf_action_cancel()</field>
</record>
<record id="act_except_invoice" model="workflow.activity">
<field name="wkf_id" ref="purchase_order"/>

View File

@ -70,7 +70,7 @@ class stock_move(osv.osv):
purchase_order = move.purchase_line_id.order_id
return purchase_order.partner_id, purchase_order.create_uid.id, purchase_order.currency_id.id
else:
partner = move.partner_id or (move.picking_id and move.picking_id.partner_id) or False
partner = move.picking_id and move.picking_id.partner_id or False
if partner:
if partner.property_product_pricelist_purchase and move.location_id.usage != 'internal' and move.location_dest_id.usage == 'internal':
currency = partner.property_product_pricelist_purchase.currency_id.id
@ -92,7 +92,7 @@ class stock_move(osv.osv):
Attribute price to move, important in inter-company moves or receipts with only one partner
"""
if not move.purchase_line_id and move.location_id.usage != 'internal' and move.location_dest_id.usage == 'internal' and not move.price_unit:
partner = move.partner_id or (move.picking_id and move.picking_id.partner_id)
partner = move.picking_id and move.picking_id.partner_id or False
price = False
# If partner given, search price in its purchase pricelist
if partner and partner.property_product_pricelist_purchase:

View File

@ -97,7 +97,8 @@ class stock_move(osv.osv):
def _get_master_data(self, cr, uid, move, company, context=None):
''' returns a tuple (browse_record(res.partner), ID(res.users), ID(res.currency)'''
currency = company.currency_id.id
partner = move.partner_id or (move.picking_id and move.picking_id.partner_id) or False
import pdb; pdb.set_trace()
partner = move.picking_id and move.picking_id.partner_id
if partner:
if partner.property_product_pricelist and move.location_id.usage == 'internal' and move.location_dest_id.usage != 'internal':
currency = partner.property_product_pricelist.currency_id.id
@ -115,12 +116,11 @@ class stock_move(osv.osv):
if context is None:
context = {}
if type in ('in_invoice', 'in_refund'):
if move_line.partner_id:
if move_line.price_unit:
return move_line.price_unit
else:
# Take the user company and pricetype
# TODO: This intercompany still needed?
product = move_line.product_id.with_context(currency_id=move_line.company_id.currency_id.id)
# Take the company of the move line
product = move_line.product_id.with_context(company_id=move_line.company_id.id)
amount_unit = product.price_get('standard_price')[move_line.product_id.id]
return amount_unit
else:
@ -129,7 +129,7 @@ class stock_move(osv.osv):
pricelist_obj = self.pool.get("product.pricelist")
pricelist = move_line.partner_id.property_product_pricelist.id
price = pricelist_obj.price_get(cr, uid, [pricelist],
product, move_line.product_uom_qty, move_line.partner_id.id, {
move_line.product_id.id, move_line.product_uom_qty, move_line.partner_id.id, {
'uom': move_line.product_uom.id,
'date': move_line.date,
})[pricelist]
@ -206,7 +206,7 @@ class stock_picking(osv.osv):
("2binvoiced", "To Be Invoiced"),
("none", "Not Applicable")
], string="Invoice Control", required=True,
fnct_inv = _set_inv_state,
#fnct_inv = _set_inv_state,
store={
'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['state'], 10),
'stock.move': (__get_picking_move, ['picking_id', 'invoice_state'], 10),