[IMP] auction: wizard_lots_cancel has been converted into osv_memory
bzr revid: mso@mso-20100329072302-sjhgr93nc25yk0zw
This commit is contained in:
parent
6980e2febf
commit
d596d0f1a4
|
@ -0,0 +1,57 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv
|
||||
from osv import fields
|
||||
|
||||
class auction_lots_cancel(osv.osv):
|
||||
'''
|
||||
Open ERP Model
|
||||
'''
|
||||
_name = 'auction.lots.cancel'
|
||||
_description = 'To cancel auction lots.'
|
||||
|
||||
def _cancel(self, cr, uid, ids, context):
|
||||
"""
|
||||
To cancel the auction lot
|
||||
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param ids: List of IDs selected
|
||||
@param context: A standard dictionary
|
||||
@return:
|
||||
"""
|
||||
|
||||
lots_obj = self.pool.get('auction.lots')
|
||||
invoice_obj = self.pool.get('account.invoice')
|
||||
lot = lots_obj.browse(cr,uid,context['active_id'],context)
|
||||
if lot.ach_inv_id:
|
||||
p = invoice_obj.refund(['lot.ach_inv_id.id'],context)
|
||||
if lot.vnd_inv_id:
|
||||
p = invoice_obj.refund(['lot.vnd_inv_id.id'],context)
|
||||
return {}
|
||||
|
||||
_columns = {
|
||||
|
||||
|
||||
}
|
||||
auction_lots_cancel()
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="name_form" model="ir.ui.view">
|
||||
<field name="name">auction.lots.cancel.form</field>
|
||||
<field name="model">auction.lots.cancel</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Cancel Payment">
|
||||
<label string="Are you sure you want to refund this invoice ?"/>
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="_cancel" string="Cancel Payment"
|
||||
colspan="1" type="object" icon="gtk-ok" />
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,91 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import netsvc
|
||||
import pooler
|
||||
|
||||
paid_form = '''<?xml version="1.0"?>
|
||||
<form string="Cancel Payment">
|
||||
<label string="Are you sure you want to refund this invoice ?"/>
|
||||
</form>'''
|
||||
fields_ask = {
|
||||
}
|
||||
#
|
||||
#def _get_value(self,cr,uid, datas,context={}):
|
||||
## service = netsvc.LocalService("object_proxy")
|
||||
# lots=pool.get('auction.lots').browse(cr,uid,data['id'],context)
|
||||
#
|
||||
#
|
||||
## lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', datas['ids'])
|
||||
#
|
||||
# ids = []
|
||||
# pay_ids = {}
|
||||
# price = 0.0
|
||||
# price_paid = 0.0
|
||||
# uid = False
|
||||
#
|
||||
##TODO: refuse if several payments?
|
||||
# for lot in lots:
|
||||
# price += lot['obj_price']
|
||||
#
|
||||
# # add all the buyer costs
|
||||
# costs = service.execute(cr.dbname,uid, 'auction.lots', 'compute_buyer_costs', [lot['id']])
|
||||
# for cost in costs:
|
||||
# price += cost['amount']
|
||||
#
|
||||
##TODO: pr bien faire, faudrait leur poser la question: continue anyway?
|
||||
# if len(ids)<len(datas['ids']):
|
||||
# raise wizard.except_wizard('UserError', ('Some object(s) are not paid !', 'init'))
|
||||
#
|
||||
# return {'objects':len(ids), 'amount_total':price, 'amount_paid':price_paid}
|
||||
#
|
||||
#def _cancel(self, uid, datas):
|
||||
# service = netsvc.LocalService("object_proxy")
|
||||
# lots = service.execute(cr.dbname,uid, 'auction.lots', 'lots_cancel_payment', datas['ids'])
|
||||
# return {}
|
||||
#
|
||||
|
||||
def _cancel(self,cr,uid,data,context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
lot = pool.get('auction.lots').browse(cr,uid,data['id'],context)
|
||||
if lot.ach_inv_id:
|
||||
p=pool.get('account.invoice').refund(['lot.ach_inv_id.id'],context)
|
||||
if lot.vnd_inv_id:
|
||||
p=pool.get('account.invoice').refund(['lot.vnd_inv_id.id'],context)
|
||||
return {}
|
||||
|
||||
class wiz_auc_lots_cancel(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type': 'form', 'arch':paid_form, 'fields': fields_ask, 'state':[('make_cancel','Cancel Payment'), ('end','Cancel')]}
|
||||
},
|
||||
'make_cancel': {
|
||||
'actions': [_cancel],
|
||||
'result': {'type': 'state', 'state':'end'}
|
||||
}
|
||||
}
|
||||
wiz_auc_lots_cancel('auction.lots.cancel');
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -32,35 +32,42 @@ class product_product(osv.osv):
|
|||
bom_obj = self.pool.get('mrp.bom')
|
||||
product_uom_obj = self.pool.get('product.uom')
|
||||
|
||||
def _compute_price(bom):
|
||||
def _compute_price(bom):
|
||||
print bom.product_id
|
||||
price = 0
|
||||
if bom.bom_lines:
|
||||
for sbom in bom.bom_lines:
|
||||
price += _compute_price(sbom) * sbom.product_qty
|
||||
else:
|
||||
# if bom.bom_lines:
|
||||
# for sbom in bom.bom_lines:
|
||||
# print "--->>>" , sbom.name
|
||||
# price += _compute_price(sbom) * sbom.product_qty
|
||||
# else:
|
||||
parent_bom = bom_obj.search(cr, uid, [('bom_id', '=', False)])
|
||||
print "========", bom.product_id.name
|
||||
for p in parent_bom:
|
||||
test_obj = bom_obj.browse(cr, uid, p)
|
||||
print test_obj
|
||||
print "XXXXXXXXXXXXX", p, test_obj.child_ids
|
||||
|
||||
no_child_bom = bom_obj.search(cr, uid, [('product_id', '=', bom.product_id.id), ('bom_id', '=', False)])
|
||||
if no_child_bom and bom.id not in no_child_bom:
|
||||
other_bom = bom_obj.browse(cr, uid, no_child_bom)[0]
|
||||
if not other_bom.product_id.calculate_price:
|
||||
price += _compute_price(other_bom) * other_bom.product_qty
|
||||
else:
|
||||
price += other_bom.product_id.standard_price
|
||||
else:
|
||||
price += bom.product_id.standard_price
|
||||
|
||||
if bom.routing_id:
|
||||
for wline in bom.routing_id.workcenter_lines:
|
||||
wc = wline.workcenter_id
|
||||
cycle = wline.cycle_nbr
|
||||
hour = (wc.time_start + wc.time_stop + cycle * wc.time_cycle) * (wc.time_efficiency or 1.0)
|
||||
price += wc.costs_cycle * cycle + wc.costs_hour * hour
|
||||
price = product_uom_obj._compute_price(cr, uid, bom.product_uom.id, price, bom.product_id.uom_id.id)
|
||||
if bom.bom_lines:
|
||||
self.write(cr, uid, [bom.product_id.id], {'standard_price' : price/bom.product_qty})
|
||||
if bom.product_uom.id != bom.product_id.uom_id.id:
|
||||
price = product_uom_obj._compute_price(cr, uid, bom.product_uom.id, price, bom.product_id.uom_id.id)
|
||||
return price
|
||||
# if no_child_bom and bom.id not in no_child_bom:
|
||||
# other_bom = bom_obj.browse(cr, uid, no_child_bom)[0]
|
||||
# if not other_bom.product_id.calculate_price:
|
||||
# price += _compute_price(other_bom) * other_bom.product_qty
|
||||
# else:
|
||||
# price += other_bom.product_id.standard_price
|
||||
# else:
|
||||
# price += bom.product_id.standard_price
|
||||
#
|
||||
# if bom.routing_id:
|
||||
# for wline in bom.routing_id.workcenter_lines:
|
||||
# wc = wline.workcenter_id
|
||||
# cycle = wline.cycle_nbr
|
||||
# hour = (wc.time_start + wc.time_stop + cycle * wc.time_cycle) * (wc.time_efficiency or 1.0)
|
||||
# price += wc.costs_cycle * cycle + wc.costs_hour * hour
|
||||
# price = product_uom_obj._compute_price(cr, uid, bom.product_uom.id, price, bom.product_id.uom_id.id)
|
||||
# if bom.bom_lines:
|
||||
# self.write(cr, uid, [bom.product_id.id], {'standard_price' : price/bom.product_qty})
|
||||
# if bom.product_uom.id != bom.product_id.uom_id.id:
|
||||
# price = product_uom_obj._compute_price(cr, uid, bom.product_uom.id, price, bom.product_id.uom_id.id)
|
||||
# return price
|
||||
|
||||
|
||||
bom_ids = bom_obj.search(cr, uid, [('product_id', 'in', ids)])
|
||||
|
|
Loading…
Reference in New Issue