[MERGE] branch merged with lp:~openerp-commiter/openobject-addons/module1_addons

bzr revid: mso@mso-20100505133531-jqebx6hzpdsave2t
This commit is contained in:
mso 2010-05-05 19:05:31 +05:30
commit e9265f0d9b
23 changed files with 504 additions and 359 deletions

View File

@ -96,15 +96,16 @@ class auction_dates(osv.osv):
"""
# objects vendus mais non factures
#TODO: convert this query to tiny API
lots_obj = self.pool.get('auction.lots')
cr.execute('select count(*) as c from auction_lots where auction_id =ANY(%s) and state=%s and obj_price>0', (ids,'draft',))
nbr = cr.fetchone()[0]
ach_uids = {}
cr.execute('select id from auction_lots where auction_id =ANY(%s) and state=%s and obj_price>0', (ids,'draft',))
r=self.pool.get('auction.lots').lots_invoice(cr, uid, [x[0] for x in cr.fetchall()],{},None)
r = lots_obj.lots_invoice(cr, uid, [x[0] for x in cr.fetchall()],{},None)
cr.execute('select id from auction_lots where auction_id =ANY(%s) and obj_price>0',(ids,))
ids2 = [x[0] for x in cr.fetchall()]
# for auction in auction_ids:
c=self.pool.get('auction.lots').seller_trans_create(cr, uid, ids2,{})
c = lots_obj.seller_trans_create(cr, uid, ids2,{})
self.write(cr, uid, ids, {'state':'closed'}) #close the auction
return True
auction_dates()
@ -509,14 +510,14 @@ class auction_lots(osv.osv):
##CHECKME: est-ce que ca vaudrait la peine de faire des groupes de lots qui ont les memes couts pour passer des listes de lots a compute?
taxes = []
amount=0.0
# pt_tax=pool.get('account.tax')
pt_tax = self.pool.get('account.tax')
for lot in lots:
taxes = lot.product_id.taxes_id
if lot.author_right:
taxes.append(lot.author_right)
elif lot.auction_id:
taxes += lot.auction_id.buyer_costs
tax=self.pool.get('account.tax').compute(cr,uid,taxes,lot.obj_price,1)
tax=pt_tax.compute(cr,uid,taxes,lot.obj_price,1)
for t in tax:
amount+=t['amount']
#amount+=lot.obj_price*0.2
@ -631,18 +632,20 @@ class auction_lots(osv.osv):
def buyer_proforma(self,cr,uid,ids,context):
invoices = {}
inv_ref=self.pool.get('account.invoice')
inv_ref = self.pool.get('account.invoice')
partner_r = self.pool.get('res.partner')
inv_line_obj = self.pool.get('account.invoice.line')
wf_service = netsvc.LocalService('workflow')
# acc_receiv=self.pool.get('account.account').search([cr,uid,[('code','=','4010')]])
for lot in self.browse(cr,uid,ids,context):
if not lot.obj_price>0:
continue
partner_r=self.pool.get('res.partner')
if not lot.ach_uid.id:
raise orm.except_orm(_('Missed buyer !'), _('The object "%s" has no buyer assigned.') % (lot.name,))
else:
partner_ref =lot.ach_uid.id
lot_name = lot.obj_num
res = self.pool.get('res.partner').address_get(cr, uid, [partner_ref], ['contact', 'invoice'])
res = partner_r.address_get(cr, uid, [partner_ref], ['contact', 'invoice'])
contact_addr_id = res['contact']
invoice_addr_id = res['invoice']
if not invoice_addr_id:
@ -676,12 +679,11 @@ class auction_lots(osv.osv):
'account_id': lot.auction_id.acc_income.id,
'price_unit': lot.obj_price,
}
self.pool.get('account.invoice.line').create(cr, uid, inv_line,context)
inv_line_obj.create(cr, uid, inv_line,context)
# inv_ref.button_compute(cr, uid, [inv_id])
# wf_service = netsvc.LocalService('workflow')
# wf_service.trg_validate(uid, 'account.invoice', inv_id, 'invoice_open', cr)
inv_ref.button_compute(cr, uid, invoice.values())
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'account.invoice', inv_id, 'invoice_proforma', cr)
return invoices.values()
@ -695,6 +697,9 @@ class auction_lots(osv.osv):
# use each list of object in turn
invoices = {}
inv_ref=self.pool.get('account.invoice')
partner_obj = self.pool.get('res.partner')
inv_line_obj = self.pool.get('account.invoice.line')
wf_service = netsvc.LocalService('workflow')
for lot in self.browse(cr,uid,ids,context):
partner_id = lot.bord_vnd_id.partner_id.id
if not lot.auction_id.id:
@ -703,7 +708,7 @@ class auction_lots(osv.osv):
if lot.bord_vnd_id.id in invoices:
inv_id = invoices[lot.bord_vnd_id.id]
else:
res = self.pool.get('res.partner').address_get(cr, uid, [lot.bord_vnd_id.partner_id.id], ['contact', 'invoice'])
res = partner_obj.address_get(cr, uid, [lot.bord_vnd_id.partner_id.id], ['contact', 'invoice'])
contact_addr_id = res['contact']
invoice_addr_id = res['invoice']
inv = {
@ -735,13 +740,12 @@ class auction_lots(osv.osv):
'account_id': lot.auction_id.acc_expense.id,
'price_unit': lot.obj_price,
}
self.pool.get('account.invoice.line').create(cr, uid, inv_line,context)
inv_line_obj.create(cr, uid, inv_line,context)
inv_ref.button_compute(cr, uid, invoices.values())
for inv in inv_ref.browse(cr, uid, invoices.values(), context):
inv_ref.write(cr, uid, [inv.id], {
'check_total': inv.amount_total
})
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_open', cr)
return invoices.values()
@ -757,13 +761,15 @@ class auction_lots(osv.osv):
RETURN: id of generated invoice
"""
dt = time.strftime('%Y-%m-%d')
inv_ref=self.pool.get('account.invoice')
inv_ref = self.pool.get('account.invoice')
partner_r = self.pool.get('res.partner')
inv_line_obj = self.pool.get('account.invoice.line')
wf_service = netsvc.LocalService('workflow')
invoices={}
for lot in self.browse(cr, uid, ids,context):
# partner_ref = lot.ach_uid.id
if not lot.auction_id.id:
continue
partner_r=self.pool.get('res.partner')
if not lot.ach_uid.id:
raise orm.except_orm(_('Missed buyer !'), _('The object "%s" has no buyer assigned.') % (lot.name,))
if (lot.auction_id.id,lot.ach_uid.id) in invoices:
@ -774,13 +780,12 @@ class auction_lots(osv.osv):
raise orm.except_orm(_('Missed Address !'), _('The Buyer has no Invoice Address.'))
price = lot.obj_price or 0.0
lot_name =lot.obj_num
inv={
inv = {
'name':lot.auction_id.name or '',
'reference': lot.ach_login,
'journal_id': lot.auction_id.journal_id.id,
'partner_id': lot.ach_uid.id,
'type': 'out_invoice',
}
if invoice_number:
inv['number'] = invoice_number
@ -805,12 +810,11 @@ class auction_lots(osv.osv):
'account_id': lot.auction_id.acc_income.id,
'price_unit': lot.obj_price,
}
self.pool.get('account.invoice.line').create(cr, uid, inv_line,context)
inv_line_obj.create(cr, uid, inv_line,context)
# inv_ref.button_compute(cr, uid, [inpq tu dis cav_id])
# inv_ref.button_compute(cr, uid, [inv_id])
inv_ref.button_compute(cr, uid, [inv_id])
for l in inv_ref.browse(cr, uid, invoices.values(), context):
wf_service = netsvc.LocalService('workflow')
# wf_service.trg_validate(uid, 'account.invoice',l.id, 'invoice_proforma', cr)
wf_service.trg_validate(uid, 'account.invoice',l.id, 'invoice_open', cr)
return invoices.values()

View File

@ -40,9 +40,21 @@ class auction_catalog_flagey(osv.osv_memory):
return res
def view_init(self, cr, uid, fields, context):
current_auction = self.pool.get('auction.dates').browse(cr,uid,context.get('active_ids', []))
v_lots = self.pool.get('auction.lots').search(cr,uid,[('auction_id','=',current_auction.id)])
v_ids = self.pool.get('auction.lots').browse(cr,uid,v_lots)
"""
Creates view dynamically, adding fields at runtime, raises exception
at the time of initialization of view.
@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: New arch of view with new columns.
"""
lots_obj = self.pool.get('auction.lots')
auc_dates_obj = self.pool.get('auction.dates')
current_auction = auc_dates_obj.browse(cr,uid,context.get('active_ids', []))
v_lots = lots_obj.search(cr,uid,[('auction_id','=',current_auction.id)])
v_ids = lots_obj.browse(cr,uid,v_lots)
for ab in v_ids:
if not ab.auction_id :
raise osv.except_osv('Error!','No Lots belong to this Auction Date')

View File

@ -32,16 +32,16 @@ class auction_lots_auction_move(osv.osv_memory):
_name = "auction.lots.auction.move"
_description = "Auction move "
_columns= {
'auction_id':fields.many2one('auction.dates', 'Auction Date', required=True),
}
'auction_id':fields.many2one('auction.dates', 'Auction Date', required=True),
}
def _top(self, cr, uid, ids, context={}):
refs = self.pool.get('auction.lots')
rec_ids = refs.browse(cr, uid, context['active_ids'])
for rec in rec_ids:
if not rec.auction_id:
raise osv.except_osv('Error !', 'You can not move a lot that has no auction date')
return {}
# def _top(self, cr, uid, ids, context={}):
# refs = self.pool.get('auction.lots')
# rec_ids = refs.browse(cr, uid, context['active_ids'])
# for rec in rec_ids:
# if not rec.auction_id:
# raise osv.except_osv('Error !', 'You can not move a lot that has no auction date')
# return {}
def auction_move_set(self, cr, uid, ids, context={}):
"""
@ -56,13 +56,13 @@ class auction_lots_auction_move(osv.osv_memory):
auction_bid_line_obj = self.pool.get('auction.bid_line')
auction_lot_history_obj = self.pool.get('auction.lot.history')
auction_lots_obj = self.pool.get('auction.lots')
rec_ids = refs.browse(cr, uid, context['active_ids'])
for datas in self.read(cr, uid, ids):
if not (datas['auction_id'] and len(context['active_ids'])) :
return {}
rec_ids = refs.browse(cr, uid, context['active_ids'])
line_ids = auction_bid_line_obj.search(cr, uid, [('lot_id', 'in', context['active_ids'])])
# pooler.get_pool(cr.dbname).get('auction.bid_line').unlink(cr, uid, line_ids)
# line_ids = auction_bid_line_obj.search(cr, uid, [('lot_id', 'in', context['active_ids'])])
# pooler.get_pool(cr.dbname).get('auction.bid_line').unlink(cr, uid, line_ids)
for rec in rec_ids:
new_id = auction_lot_history_obj.create(cr, uid, {
'auction_id': rec.auction_id.id,

View File

@ -19,20 +19,14 @@
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_lots_enable(osv.osv_memory):
_name = "auction.lots.enable"
_description = "Lots Enable"
_columns= {
'confirm_en':fields.integer('Catalog Number')
}
'confirm_en':fields.integer('Catalog Number')
}
def confirm_enable(self, cr, uid, ids, context={}):
"""

View File

@ -27,20 +27,29 @@ import tools
import wizard
class auction_lots_make_invoice(osv.osv_memory):
_name = "auction.lots.make.invoice"
_description = "Make invoice"
_columns = {
'amount': fields.float('Invoiced Amount', required =True, readonly=True),
'objects':fields.integer('# of objects', required =True, readonly=True),
'number':fields.char('Invoice Number', size=64),
}
_defaults = {
'number': lambda *a: False,
}
def default_get(self, cr, uid, fields, context):
"""
To get default values for the object.
@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.
To get default values for the object.
@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.
"""
res = super(auction_lots_make_invoice, self).default_get(cr, uid, fields, context=context)
for lot in self.pool.get('auction.lots').browse(cr, uid, context.get('active_ids', [])):
@ -53,7 +62,7 @@ class auction_lots_make_invoice(osv.osv_memory):
def makeInvoices(self, cr, uid, ids, context):
"""
seller invoice :Create an invoice.
Seller invoice :Create an invoice.
@param cr: the current row, from the database cursor.
@param uid: the current users ID for security checks.
@param ids: List of Auction lots make invoices IDs
@ -61,36 +70,20 @@ class auction_lots_make_invoice(osv.osv_memory):
"""
order_obj = self.pool.get('auction.lots')
mod_obj = self.pool.get('ir.model.data')
for data in self.read(cr, uid, ids):
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
newinv = []
ids = order_obj.seller_trans_create(cr, uid, context['active_ids'], context)
cr.commit()
return {
'domain': "[('id','in', ["+','.join(map(str, ids))+"])]",
'name': 'Seller invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'context': "{'type':'out_refund'}",
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
lots_ids = order_obj.seller_trans_create(cr, uid, context['active_ids'], context)
cr.commit()
return {
'domain': "[('id','in', ["+','.join(map(str, lots_ids))+"])]",
'name': 'Seller invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'context': "{'type':'out_refund'}",
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
_name = "auction.lots.make.invoice"
_description = "Make invoice"
_columns= {
'amount': fields.float('Invoiced Amount', required =True, readonly=True),
'objects':fields.integer('# of objects', required =True, readonly=True),
'number':fields.char('Invoice Number', size=64),
}
_defaults={
'number':lambda *a: False,
}
auction_lots_make_invoice()

View File

@ -19,27 +19,31 @@
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_lots_make_invoice_buyer(osv.osv_memory):
_name = "auction.lots.make.invoice.buyer"
_description = "Make invoice buyer "
_columns= {
'amount': fields.float('Invoiced Amount', required =True, readonly=True),
'objects':fields.integer('# of objects', required =True, readonly=True),
'number':fields.char('Invoice Number', size=64),
'buyer_id':fields.many2one('res.partner', 'Buyer', required=True),
}
_defaults={
'number': lambda *a: False,
}
def default_get(self, cr, uid, fields, context):
"""
To get default values for the object.
@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.
To get default values for the object.
@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.
"""
res = super(auction_lots_make_invoice_buyer, self).default_get(cr, uid, fields, context=context)
for lot in self.pool.get('auction.lots').browse(cr, uid, context.get('active_ids', [])):
@ -59,22 +63,19 @@ class auction_lots_make_invoice_buyer(osv.osv_memory):
@param ids: List of Auction lots make invoice buyers IDs
@return: dictionary of account invoice form.
"""
newinv = []
order_obj = self.pool.get('auction.lots')
mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
lots = order_obj.browse(cr, uid, context['active_ids'])
for data in self.read(cr, uid, ids):
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
lots = order_obj.browse(cr, uid, context['active_ids'])
invoice_number = data['number']
for lot in lots:
up_auction = order_obj.write(cr, uid, [lot.id], {'ach_uid':data['buyer_id']})
ids = order_obj.lots_invoice(cr, uid, context['active_ids'], context, data['number'])
up_auction = order_obj.write(cr, uid, [lot.id], {'ach_uid': data['buyer_id']})
lots_ids = order_obj.lots_invoice(cr, uid, context['active_ids'], context, data['number'])
cr.commit()
return {
'domain': "[('id','in', ["+','.join(map(str, ids))+"])]",
'domain': "[('id','in', ["+','.join(map(str, lots_ids))+"])]",
'name': 'Buyer invoices',
'view_type': 'form',
'view_mode': 'tree,form',
@ -84,17 +85,5 @@ class auction_lots_make_invoice_buyer(osv.osv_memory):
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
_name = "auction.lots.make.invoice.buyer"
_description = "Make invoice buyer "
_columns= {
'amount': fields.float('Invoiced Amount', required =True, readonly=True),
'objects':fields.integer('# of objects', required =True, readonly=True),
'number':fields.char('Invoice Number', size=64),
'buyer_id':fields.many2one('res.partner', 'Buyer', required=True),
}
_defaults={
'number':lambda *a: False,
}
auction_lots_make_invoice_buyer()

View File

@ -21,26 +21,33 @@
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_pay_buy(osv.osv_memory):
_name = "auction.pay.buy"
_description = "Pay buy"
_columns= {
'amount': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy']))),
'buyer_id':fields.many2one('res.partner', 'Buyer'),
'statement_id1':fields.many2one('account.bank.statement', 'Statement', required=True),
'amount2': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy']))),
'statement_id2':fields.many2one('account.bank.statement', 'Statement'),
'amount3': fields.float('Amount paid', digits = (16, int(tools.config['price_accuracy']))),
'statement_id3':fields.many2one('account.bank.statement', 'Statement'),
'total': fields.float('Amount paid', digits = (16, int(tools.config['price_accuracy'])), readonly =True),
}
def default_get(self, cr, uid, fields, context):
"""
To get default values for the object.
@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.
To get default values for the object.
@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.
"""
res = super(auction_pay_buy, self).default_get(cr, uid, fields, context=context)
for lot in self.pool.get('auction.lots').browse(cr, uid, context.get('active_ids', [])):
@ -54,13 +61,12 @@ class auction_pay_buy(osv.osv_memory):
def pay_and_reconcile(self, cr, uid, ids, context):
"""
Pay and Reconcile
@param cr: the current row, from the database cursor.
@param uid: the current users ID for security checks.
@param ids: the ID or list of IDs
@param context: A standard dictionary
@return:
Pay and Reconcile
@param cr: the current row, from the database cursor.
@param uid: the current users ID for security checks.
@param ids: the ID or list of IDs
@param context: A standard dictionary
@return:
"""
lot_obj = self.pool.get('auction.lots')
bank_statement_line_obj = self.pool.get('account.bank.statement.line')
@ -94,22 +100,8 @@ class auction_pay_buy(osv.osv_memory):
for lot in lots:
lot_obj.write(cr, uid, [lot.id], {'statement_id':[(4, new_id)]})
return {}
_name = "auction.pay.buy"
_description = "Pay buy"
_columns= {
'amount': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy']))),
'buyer_id':fields.many2one('res.partner', 'Buyer'),
'statement_id1':fields.many2one('account.bank.statement', 'Statement', required=True),
'amount2': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy']))),
'statement_id2':fields.many2one('account.bank.statement', 'Statement'),
'amount3': fields.float('Amount paid', digits = (16, int(tools.config['price_accuracy']))),
'statement_id3':fields.many2one('account.bank.statement', 'Statement'),
'total': fields.float('Amount paid', digits = (16, int(tools.config['price_accuracy'])), readonly =True),
}
auction_pay_buy()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -20,33 +20,27 @@
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_pay_sel(osv.osv_memory):
_name = "auction.pay.sel"
_description = "Pay Invoice"
_columns= {
'amount': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy'])), required=True),
'dest_account_id':fields.many2one('account.account', 'Payment to Account', required=True, domain= [('type', '=', 'cash')]),
'journal_id':fields.many2one('account.journal', 'Journal', required=True),
'period_id':fields.many2one('account.period', 'Period', required=True),
}
'amount': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy'])), required=True),
'dest_account_id':fields.many2one('account.account', 'Payment to Account', required=True, domain= [('type', '=', 'cash')]),
'journal_id':fields.many2one('account.journal', 'Journal', required=True),
'period_id':fields.many2one('account.period', 'Period', required=True),
}
def pay_and_reconcile(self, cr, uid, ids, context):
"""
Pay and Reconcile
@param cr: the current row, from the database cursor.
@param uid: the current users ID for security checks.
@param ids: the ID or list of IDs
@param context: A standard dictionary
@return:
Pay and Reconcile
@param cr: the current row, from the database cursor.
@param uid: the current users ID for security checks.
@param ids: the ID or list of IDs
@param context: A standard dictionary
@return:
"""
lot = self.pool.get('auction.lots').browse(cr, uid, context['active_id'], context)
invoice_obj = self.pool.get('account.invoice')

View File

@ -20,15 +20,8 @@
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_payer(osv.osv_memory):
_name = "auction.payer"
_description = "Auction payer"

View File

@ -32,10 +32,10 @@ class auction_taken(osv.osv_memory):
"""
_name = "auction.taken"
_description = "Auction taken"
_columns = {
'lot_ids':fields.many2many('auction.lots', 'auction_taken_rel', 'taken_id', 'lot_id', 'Lots Emportes'),
}
'lot_ids':fields.many2many('auction.lots', 'auction_taken_rel', 'taken_id', 'lot_id', 'Lots Emportes'),
}
def _to_xml(s):
return s.replace('&','&amp;').replace('<','&lt;').replace('>','&gt;')

View File

@ -29,10 +29,18 @@ class auction_transfer_unsold_object(osv.osv):
_name = 'auction.transfer.unsold.object'
_description = 'To transfer unsold objects'
_columns = {
'auction_id_from':fields.many2one('auction.dates', 'From Auction Date', required=True),
'auction_id_to':fields.many2one('auction.dates', 'To Auction Date', required=True),
}
_defaults = {
'auction_id_from': _start,
}
def _start(self, cr, uid, context):
"""
To initialize auction_id_from
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@ -48,14 +56,12 @@ class auction_transfer_unsold_object(osv.osv):
def transfer_unsold_object(self, cr, uid, ids, context):
"""
To Transfer the unsold object
@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:
"""
bid_line_obj = self.pool.get('auction.bid_line')
lots_obj = self.pool.get('auction.lots')
@ -76,13 +82,5 @@ class auction_transfer_unsold_object(osv.osv):
'sel_inv_id':None,
'state':'draft'})
return {}
_columns = {
'auction_id_from':fields.many2one('auction.dates', 'From Auction Date', required=True),
'auction_id_to':fields.many2one('auction.dates', 'To Auction Date', required=True),
}
_defaults = {
'auction_id_from': _start,
}
auction_transfer_unsold_object()

View File

@ -65,6 +65,9 @@ mrp_workcenter()
class mrp_property_group(osv.osv):
"""
Group of mrp properties.
"""
_name = 'mrp.property.group'
_description = 'Property Group'
_columns = {
@ -74,6 +77,9 @@ class mrp_property_group(osv.osv):
mrp_property_group()
class mrp_property(osv.osv):
"""
Properties of mrp.
"""
_name = 'mrp.property'
_description = 'Property'
_columns = {
@ -88,6 +94,9 @@ class mrp_property(osv.osv):
mrp_property()
class mrp_routing(osv.osv):
"""
For specifying the routings of workcenters.
"""
_name = 'mrp.routing'
_description = 'Routing'
_columns = {
@ -110,6 +119,9 @@ class mrp_routing(osv.osv):
mrp_routing()
class mrp_routing_workcenter(osv.osv):
"""
Defines working cycles and hours of a workcenter using routings.
"""
_name = 'mrp.routing.workcenter'
_description = 'Routing workcenter usage'
_columns = {
@ -131,19 +143,22 @@ class mrp_routing_workcenter(osv.osv):
mrp_routing_workcenter()
class mrp_bom(osv.osv):
"""
Defines bills of material for a product.
"""
_name = 'mrp.bom'
_description = 'Bills of Material'
def _child_compute(self, cr, uid, ids, name, arg, context={}):
"""
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: the ID of mrp.production object
@param name: name of the field
@param arg: user defined argument
@return: True
""" Gets child bom.
@param self: The object pointer
@param cr: The current row, from the database cursor,
@param uid: The current user ID for security checks
@param ids: List of selected IDs
@param name: Name of the field
@param arg: User defined argument
@param context: A standard dictionary for contextual values
@return: Dictionary of values
"""
result = {}
for bom in self.browse(cr, uid, ids, context=context):
@ -158,7 +173,13 @@ class mrp_bom(osv.osv):
result[bom.id] += map(lambda x: x.id, bom2.bom_lines)
return result
def _compute_type(self, cr, uid, ids, field_name, arg, context):
""" Sets particular method for the selected bom type.
@param field_name: Name of the field
@param arg: User defined argument
@return: Dictionary of values
"""
res = dict(map(lambda x: (x,''), ids))
for line in self.browse(cr, uid, ids):
if line.type=='phantom' and not line.bom_id:
@ -172,6 +193,7 @@ class mrp_bom(osv.osv):
else:
res[line.id] = 'order'
return res
_columns = {
'name': fields.char('Name', size=64, required=True),
'code': fields.char('Code', size=16),
@ -234,6 +256,11 @@ class mrp_bom(osv.osv):
def onchange_product_id(self, cr, uid, ids, product_id, name, context={}):
""" Changes UoM and name if product_id changes.
@param name: Name of the field
@param product_id: Changed product_id
@return: Dictionary of changed values
"""
if product_id:
prod=self.pool.get('product.product').browse(cr,uid,[product_id])[0]
v = {'product_uom':prod.uom_id.id}
@ -243,6 +270,12 @@ class mrp_bom(osv.osv):
return {}
def _bom_find(self, cr, uid, product_id, product_uom, properties=[]):
""" Finds BoM for particular product and product uom.
@param product_id: Selected product.
@param product_uom: Unit of measure of a product.
@param properties: List of related properties.
@return: False or BoM id.
"""
bom_result = False
# Why searching on BoM without parent ?
cr.execute('select id from mrp_bom where product_id=%s and bom_id is null order by sequence', (product_id,))
@ -260,6 +293,15 @@ class mrp_bom(osv.osv):
return result
def _bom_explode(self, cr, uid, bom, factor, properties, addthis=False, level=0):
""" Finds Products and Workcenters for related BoM for manufacturing order.
@param bom: BoM of particular product.
@param factor: Factor of product UoM.
@param properties: A dictionary for contextual values.
@param addthis: If BoM found then True else False.
@param level: Depth level to find BoM lines starts from 10.
@return: result: List of dictionaries containing product details.
result2: List of dictionaries containing workcenter details.
"""
factor = factor / (bom.product_efficiency or 1.0)
factor = rounding(factor, bom.product_rounding)
if factor<bom.product_rounding:
@ -307,6 +349,9 @@ class mrp_bom(osv.osv):
return result, result2
def set_indices(self, cr, uid, ids, context = {}):
""" Sets Indices.
@return: True
"""
if not ids or (ids and not ids[0]):
return True
res = self.read(cr, uid, ids, ['revision_ids', 'revision_type'])
@ -389,11 +434,19 @@ class one2many_domain(fields.one2many):
return res
class mrp_production(osv.osv):
"""
Production Orders / Manufacturing Orders
"""
_name = 'mrp.production'
_description = 'Production'
_date_name = 'date_planned'
def _production_calc(self, cr, uid, ids, prop, unknow_none, context={}):
""" Calculates total hours and total no. of cycles for a production order.
@param prop:
@param unknow_none:
@return: Dictionary of values.
"""
result = {}
for prod in self.browse(cr, uid, ids, context=context):
result[prod.id] = {
@ -406,18 +459,33 @@ class mrp_production(osv.osv):
return result
def _production_date_end(self, cr, uid, ids, prop, unknow_none, context={}):
""" Finds production end date.
@param prop: Name of field.
@param unknow_none:
@return: Dictionary of values.
"""
result = {}
for prod in self.browse(cr, uid, ids, context=context):
result[prod.id] = prod.date_planned
return result
def _production_date(self, cr, uid, ids, prop, unknow_none, context={}):
""" Finds production planned date.
@param prop: Name of field.
@param unknow_none:
@return: Dictionary of values.
"""
result = {}
for prod in self.browse(cr, uid, ids, context=context):
result[prod.id] = prod.date_planned[:10]
return result
def _ref_calc(self, cr, uid, ids, field_names=None, arg=False, context={}):
""" Finds reference sale order for production order.
@param field_names: Names of fields.
@param arg: User defined arguments
@return: Dictionary of values.
"""
res = {}
for f in field_names:
for order_id in ids:
@ -499,6 +567,11 @@ class mrp_production(osv.osv):
return super(mrp_production, self).copy(cr, uid, id, default, context)
def location_id_change(self, cr, uid, ids, src, dest, context={}):
""" Changes destination location if source location is changed.
@param src: Source location id.
@param dest: Destination location id.
@return: Dictionary of values.
"""
if dest:
return {}
if src:
@ -506,6 +579,10 @@ class mrp_production(osv.osv):
return {}
def product_id_change(self, cr, uid, ids, product):
""" Finds UoM of changed product.
@param product: Id of changed product.
@return: Dictionary of values.
"""
if not product:
return {}
res = self.pool.get('product.product').read(cr, uid, [product], ['uom_id'])[0]
@ -514,6 +591,10 @@ class mrp_production(osv.osv):
return {'value':result}
def bom_id_change(self, cr, uid, ids, product):
""" Finds routing for changed BoM.
@param product: Id of product.
@return: Dictionary of values.
"""
if not product:
return {}
res = self.pool.get('mrp.bom').read(cr, uid, [product], ['routing_id'])[0]
@ -522,10 +603,17 @@ class mrp_production(osv.osv):
return {'value':result}
def action_picking_except(self, cr, uid, ids):
""" Changes the state to Exception.
@return: True
"""
self.write(cr, uid, ids, {'state':'picking_except'})
return True
def action_compute(self, cr, uid, ids, properties=[]):
""" Computes bills of material of a product.
@param properties: List containing dictionaries of properties.
@return: No. of products.
"""
results = []
bom_obj = self.pool.get('mrp.bom')
prod_line_obj = self.pool.get('mrp.production.product.line')
@ -561,6 +649,9 @@ class mrp_production(osv.osv):
return len(results)
def action_cancel(self, cr, uid, ids):
""" Cancels the production order and related stock moves.
@return: True
"""
move_obj = self.pool.get('stock.move')
for production in self.browse(cr, uid, ids):
if production.move_created_ids:
@ -572,6 +663,9 @@ class mrp_production(osv.osv):
#XXX: may be a bug here; lot_lines are unreserved for a few seconds;
# between the end of the picking list and the call to this function
def action_ready(self, cr, uid, ids):
""" Changes the production state to Ready and location id of stock move.
@return: True
"""
move_obj = self.pool.get('stock.move')
self.write(cr, uid, ids, {'state':'ready'})
for production in self.browse(cr, uid, ids):
@ -581,11 +675,17 @@ class mrp_production(osv.osv):
return True
def action_production_end(self, cr, uid, ids):
""" Changes production state to Finish and writes finished date.
@return: True
"""
for production in self.browse(cr, uid, ids):
self._costs_generate(cr, uid, production)
return self.write(cr, uid, ids, {'state': 'done', 'date_finnished': time.strftime('%Y-%m-%d %H:%M:%S')})
def test_production_done(self, cr, uid, ids):
""" Tests whether production is done or not.
@return: True or False
"""
res = True
for production in self.browse(cr, uid, ids):
if production.move_lines:
@ -596,21 +696,14 @@ class mrp_production(osv.osv):
return res
def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None):
"""
To produce final product base on production mode (consume/consume&produce).
If Production mode is consume, all stock move lines of raw materials will be done/consumed.
If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed
and stock move lines of final product will be also done/produced.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param production_id: the ID of mrp.production object
@param production_qty: specify qty to produce
@param production_mode: specify production mode (consume/consume&produce).
@return: True
""" To produce final product base on production mode (consume/consume&produce).
If Production mode is consume, all stock move lines of raw materials will be done/consumed.
If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed
and stock move lines of final product will be also done/produced.
@param production_id: the ID of mrp.production object
@param production_qty: specify qty to produce
@param production_mode: specify production mode (consume/consume&produce).
@return: True
"""
stock_mov_obj = self.pool.get('stock.move')
production = self.browse(cr, uid, production_id)
@ -679,6 +772,10 @@ class mrp_production(osv.osv):
return True
def _costs_generate(self, cr, uid, production):
""" Calculates total costs at the end of the production.
@param production: Id of production order.
@return: Calculated amount.
"""
amount = 0.0
analytic_line_obj = self.pool.get('account.analytic.line')
for wc_line in production.workcenter_lines:
@ -712,11 +809,17 @@ class mrp_production(osv.osv):
return amount
def action_in_production(self, cr, uid, ids):
""" Changes state to In Production and writes starting date.
@return: True
"""
move_ids = []
self.write(cr, uid, ids, {'state': 'in_production','date_start':time.strftime('%Y-%m-%d %H:%M:%S')})
return True
def test_if_product(self, cr, uid, ids):
"""
@return: True or False
"""
res = True
for production in self.browse(cr, uid, ids):
if not production.product_lines:
@ -728,6 +831,9 @@ class mrp_production(osv.osv):
return True
def action_confirm(self, cr, uid, ids):
""" Confirms production order.
@return: Newly generated picking Id.
"""
picking_id=False
proc_ids = []
seq_obj = self.pool.get('ir.sequence')
@ -835,6 +941,10 @@ class mrp_production(osv.osv):
return picking_id
def force_production(self, cr, uid, ids, *args):
""" Assigns products.
@param *args: Arguments
@return: True
"""
pick_obj = self.pool.get('stock.picking')
pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)])
return True
@ -882,6 +992,9 @@ mrp_production_product_line()
# then wizard for picking lists & move
#
class mrp_procurement(osv.osv):
"""
Procument Orders / Requisitions
"""
_name = "mrp.procurement"
_description = "Procurement"
_order = 'priority,date_planned'
@ -948,6 +1061,10 @@ class mrp_procurement(osv.osv):
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
def onchange_product_id(self, cr, uid, ids, product_id, context={}):
""" Finds UoM and UoS of changed product.
@param product_id: Changed id of product.
@return: Dictionary of values.
"""
if product_id:
w=self.pool.get('product.product').browse(cr,uid,product_id, context)
v = {
@ -958,12 +1075,18 @@ class mrp_procurement(osv.osv):
return {}
def check_product(self, cr, uid, ids):
""" Checks product type.
@return: True or False
"""
for procurement in self.browse(cr, uid, ids):
if procurement.product_id.type in ('product', 'consu'):
return True
return False
def check_move_cancel(self, cr, uid, ids, context={}):
""" Checks if move is cancelled or not.
@return: True or False.
"""
res = True
ok = False
for procurement in self.browse(cr, uid, ids, context):
@ -974,6 +1097,9 @@ class mrp_procurement(osv.osv):
return res and ok
def check_move_done(self, cr, uid, ids, context={}):
""" Checks if move is done or not.
@return: True or False.
"""
res = True
for proc in self.browse(cr, uid, ids, context):
if proc.move_id:
@ -986,12 +1112,20 @@ class mrp_procurement(osv.osv):
# for computing their own purpose
#
def _quantity_compute_get(self, cr, uid, proc, context={}):
""" Finds sold quantity of product.
@param proc: Current procurement.
@return: Quantity or False.
"""
if proc.product_id.type=='product':
if proc.move_id.product_uos:
return proc.move_id.product_uos_qty
return False
def _uom_compute_get(self, cr, uid, proc, context={}):
""" Finds UoS if product is Stockable Product.
@param proc: Current procurement.
@return: UoS or False.
"""
if proc.product_id.type=='product':
if proc.move_id.product_uos:
return proc.move_id.product_uos.id
@ -1002,6 +1136,9 @@ class mrp_procurement(osv.osv):
# different from the planned quantity
#
def quantity_get(self, cr, uid, id, context={}):
""" Finds quantity of product used in procurement.
@return: Quantity of product.
"""
proc = self.browse(cr, uid, id, context)
result = self._quantity_compute_get(cr, uid, proc, context)
if not result:
@ -1009,6 +1146,9 @@ class mrp_procurement(osv.osv):
return result
def uom_get(self, cr, uid, id, context=None):
""" Finds UoM of product used in procurement.
@return: UoM of product.
"""
proc = self.browse(cr, uid, id, context)
result = self._uom_compute_get(cr, uid, proc, context)
if not result:
@ -1016,6 +1156,9 @@ class mrp_procurement(osv.osv):
return result
def check_waiting(self, cr, uid, ids, context=[]):
""" Checks state of move.
@return: True or False
"""
for procurement in self.browse(cr, uid, ids, context=context):
if procurement.move_id and procurement.move_id.state=='auto':
return True
@ -1025,6 +1168,10 @@ class mrp_procurement(osv.osv):
return True
def check_produce_product(self, cr, uid, procurement, context=[]):
""" Finds BoM of a product if not found writes exception message.
@param procurement: Current procurement.
@return: True or False.
"""
properties = [x.id for x in procurement.property_ids]
bom_id = self.pool.get('mrp.bom')._bom_find(cr, uid, procurement.product_id.id, procurement.product_uom.id, properties)
if not bom_id:
@ -1033,6 +1180,9 @@ class mrp_procurement(osv.osv):
return True
def check_make_to_stock(self, cr, uid, ids, context={}):
""" Checks product type.
@return: True or False
"""
ok = True
for procurement in self.browse(cr, uid, ids, context=context):
if procurement.product_id.type=='service':
@ -1042,6 +1192,9 @@ class mrp_procurement(osv.osv):
return ok
def check_produce(self, cr, uid, ids, context={}):
""" Checks product type.
@return: True or Product Id.
"""
res = True
user = self.pool.get('res.users').browse(cr, uid, uid)
for procurement in self.browse(cr, uid, ids):
@ -1061,6 +1214,9 @@ class mrp_procurement(osv.osv):
return res
def check_buy(self, cr, uid, ids):
""" Checks product type.
@return: True or Product Id.
"""
user = self.pool.get('res.users').browse(cr, uid, uid)
partner_obj = self.pool.get('res.partner')
for procurement in self.browse(cr, uid, ids):
@ -1080,12 +1236,18 @@ class mrp_procurement(osv.osv):
return True
def test_cancel(self, cr, uid, ids):
""" Tests whether state of move is cancelled or not.
@return: True or False
"""
for record in self.browse(cr, uid, ids):
if record.move_id and record.move_id.state=='cancel':
return True
return False
def action_confirm(self, cr, uid, ids, context={}):
""" Confirms procurement and writes exception message if any.
@return: True
"""
move_obj = self.pool.get('stock.move')
for procurement in self.browse(cr, uid, ids):
if procurement.product_qty <= 0.00:
@ -1115,6 +1277,9 @@ class mrp_procurement(osv.osv):
return True
def action_move_assigned(self, cr, uid, ids, context={}):
""" Changes procurement state to Running and writes message.
@return: True
"""
self.write(cr, uid, ids, {'state':'running','message':_('from stock: products assigned.')})
return True
@ -1122,6 +1287,10 @@ class mrp_procurement(osv.osv):
return True
def _check_make_to_stock_product(self, cr, uid, procurement, context={}):
""" Checks procurement move state.
@param procurement: Current procurement.
@return: True or move id.
"""
ok = True
if procurement.move_id:
id = procurement.move_id.id
@ -1133,24 +1302,24 @@ class mrp_procurement(osv.osv):
return ok
def action_produce_assign_service(self, cr, uid, ids, context={}):
""" Changes procurement state to Running.
@return: True
"""
for procurement in self.browse(cr, uid, ids):
self.write(cr, uid, [procurement.id], {'state':'running'})
return True
def action_produce_assign_product(self, cr, uid, ids, context={}):
"""
This is action which call from workflow to assign production order to procuments
@return : True
""" This is action which call from workflow to assign production order to procurements
@return: True
"""
res = self.make_mo(cr, uid, ids, context=context)
res = res.values()
return len(res) and res[0] or 0 #TO CHECK: why workflow is generated error if return not integer value
def make_mo(self, cr, uid, ids, context={}):
"""
Make Manufecturing(production) order from procurement
@return : New created Production Orders procurement wise
""" Make Manufecturing(production) order from procurement
@return: New created Production Orders procurement wise
"""
res = {}
company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
@ -1186,19 +1355,16 @@ class mrp_procurement(osv.osv):
return res
def action_po_assign(self, cr, uid, ids, context={}):
"""
This is action which call from workflow to assign purchase order to procuments
@return : True
""" This is action which call from workflow to assign purchase order to procuments
@return: True
"""
res = self.make_po(cr, uid, ids, context=context)
res = res.values()
return len(res) and res[0] or 0 #TO CHECK: why workflow is generated error if return not integer value
def make_po(self, cr, uid, ids, context={}):
"""
Make purchase order from procurement
@return : New created Purchase Orders procurement wise
""" Make purchase order from procurement
@return: New created Purchase Orders procurement wise
"""
res = {}
company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
@ -1263,6 +1429,9 @@ class mrp_procurement(osv.osv):
return res
def action_cancel(self, cr, uid, ids):
""" Cancels procurement and writes move state to Assigned.
@return: True
"""
todo = []
todo2 = []
move_obj = self.pool.get('stock.move')
@ -1287,6 +1456,9 @@ class mrp_procurement(osv.osv):
return self.check_move_done(cr, uid, ids)
def action_check(self, cr, uid, ids):
""" Checks procurement move state whether assigned or done.
@return: True
"""
ok = False
for procurement in self.browse(cr, uid, ids):
if procurement.move_id.state=='assigned' or procurement.move_id.state=='done':
@ -1295,10 +1467,16 @@ class mrp_procurement(osv.osv):
return ok
def action_ready(self, cr, uid, ids):
""" Changes procurement state to Ready.
@return: True
"""
res = self.write(cr, uid, ids, {'state':'ready'})
return res
def action_done(self, cr, uid, ids):
""" Changes procurement state to Done and writes Closed date.
@return: True
"""
move_obj = self.pool.get('stock.move')
for procurement in self.browse(cr, uid, ids):
if procurement.move_id:
@ -1311,8 +1489,8 @@ class mrp_procurement(osv.osv):
return res
def run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
'''
use_new_cursor: False or the dbname
''' Runs through scheduler.
@param use_new_cursor: False or the dbname
'''
if not context:
context={}

View File

@ -67,7 +67,6 @@ class product_product(osv.osv):
#TODO : TO Check
res = super(product_product, self).do_change_standard_price(cr, uid, ids, datas, context=context)
bom_obj = self.pool.get('mrp.bom')
def _compute_price(bom):
price = 0.0
if bom.bom_id :
@ -87,7 +86,7 @@ class product_product(osv.osv):
super(product_product, self).do_change_standard_price(cr, uid, [bom.bom_id.product_id.id], datas, context)
_compute_price(bom.bom_id)
return price
bom_ids = bom_obj.search(cr, uid, [('product_id', 'in', ids)])
for bom in bom_obj.browse(cr, uid, bom_ids):

View File

@ -29,6 +29,9 @@ import time
class stock_warehouse_orderpoint(osv.osv):
"""
Defines Minimum stock rules.
"""
_name = "stock.warehouse.orderpoint"
_description = "Orderpoint minimum rule"
_columns = {
@ -59,12 +62,20 @@ class stock_warehouse_orderpoint(osv.osv):
'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={}):
""" Finds location id for changed warehouse.
@param warehouse_id: Changed id of warehouse.
@return: Dictionary of values.
"""
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={}):
""" Finds UoM for changed product.
@param product_id: Changed id of product.
@return: Dictionary of values.
"""
if product_id:
prod=self.pool.get('product.product').browse(cr,uid,product_id)
v = {'product_uom':prod.uom_id.id}
@ -91,6 +102,10 @@ class StockMove(osv.osv):
return super(StockMove, self).copy(cr, uid, id, default, context)
def _action_explode(self, cr, uid, move, context={}):
""" Explodes pickings.
@param move: Stock moves
@return: True
"""
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),
@ -151,7 +166,12 @@ class StockMove(osv.osv):
return True
def action_consume(self, cr, uid, ids, product_qty, location_id=False, context=None):
def action_consume(self, cr, uid, ids, product_qty, location_id=False, context=None):
""" Consumed product with specific quatity from specific source location.
@param product_qty: Consumed product quantity
@param location_id: Source location
@return: Consumed lines
"""
res = []
production_obj = self.pool.get('mrp.production')
wf_service = netsvc.LocalService("workflow")
@ -168,6 +188,11 @@ class StockMove(osv.osv):
return res
def action_scrap(self, cr, uid, ids, product_qty, location_id, context=None):
""" Move the scrap/damaged product into scrap location
@param product_qty: Scraped product quantity
@param location_id: Scrap location
@return: Scraped lines
"""
res = []
production_obj = self.pool.get('mrp.production')
wf_service = netsvc.LocalService("workflow")
@ -202,6 +227,11 @@ class StockPicking(osv.osv):
# Explode picking by replacing phantom BoMs
#
def action_explode(self, cr, uid, picks, *args):
""" Explodes picking by replacing phantom BoMs
@param picks: Picking ids.
@param *args: Arguments
@return: Picking ids.
"""
for move in self.pool.get('stock.move').browse(cr, uid, picks):
self.pool.get('stock.move')._action_explode(cr, uid, move)
return picks
@ -212,6 +242,10 @@ StockPicking()
class spilt_in_production_lot(osv.osv_memory):
_inherit = "stock.move.split"
def split(self, cr, uid, ids, move_ids, context=None):
""" Splits move lines into given quantities.
@param move_ids: Stock moves.
@return: List of new moves.
"""
production_obj = self.pool.get('mrp.production')
move_obj = self.pool.get('stock.move')
res = []

View File

@ -35,17 +35,13 @@ class change_production_qty(osv.osv_memory):
}
def default_get(self, cr, uid, fields, context):
"""
To get default values for the object.
@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.
""" To get default values for the object.
@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.
"""
res = super(change_production_qty, self).default_get(cr, uid, fields, context=context)
prod_obj = self.pool.get('mrp.production')
@ -56,16 +52,13 @@ class change_production_qty(osv.osv_memory):
def change_prod_qty(self, cr, uid, ids, context):
"""
Changes the Quantity of Product.
@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:
Changes the Quantity of Product.
@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:
"""
record_id = context and context.get('active_id',False)
assert record_id, _('Active Id is not found')

View File

@ -29,17 +29,13 @@ class make_procurement(osv.osv_memory):
_description = 'Make Procurements'
def onchange_product_id(self, cr, uid, ids, prod_id):
"""
On Change of Product ID getting the value of related UoM.
@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 prod_id: Changed ID of Product
@return: A dictionary which gives the UoM of the changed Product
""" On Change of Product ID getting the value of related UoM.
@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 prod_id: Changed ID of Product
@return: A dictionary which gives the UoM of the changed Product
"""
product = self.pool.get('product.product').browse(cr, uid, prod_id)
return {'value': {'uom_id': product.uom_id.id}}
@ -58,17 +54,13 @@ class make_procurement(osv.osv_memory):
}
def make_procurement(self, cr, uid, ids, context=None):
"""
Creates procurement order for selected product.
@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: A dictionary which loads Procurement form view.
""" Creates procurement order for selected product.
@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: A dictionary which loads Procurement form view.
"""
user = self.pool.get('res.users').browse(cr, uid, uid, context).login
wh_obj = self.pool.get('stock.warehouse')
@ -109,17 +101,13 @@ class make_procurement(osv.osv_memory):
}
def default_get(self, cr, uid, fields, context=None):
"""
To get default values for the object.
@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.
""" To get default values for the object.
@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.
"""
record_id = context and context.get('active_id', False) or False

View File

@ -29,15 +29,12 @@ class mrp_price(osv.osv_memory):
}
def print_report(self, cr, uid, ids, context=None):
"""
To print the report of Product cost structure
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return : Report
""" To print the report of Product cost structure
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return : Report
"""
datas = {'ids' : context.get('active_ids',[])}
res = self.read(cr, uid, ids, ['number'])

View File

@ -34,15 +34,12 @@ class mrp_product_produce(osv.osv_memory):
}
def _get_product_qty(self, cr, uid, context):
"""
To obtain product quantity
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return: quantity
""" To obtain product quantity
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return: Quantity
"""
prod = self.pool.get('mrp.production').browse(cr, uid,
context['active_id'], context=context)
@ -57,16 +54,13 @@ class mrp_product_produce(osv.osv_memory):
}
def do_produce(self, cr, uid, ids, context={}):
"""
To check the product type
@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 context: A standard dictionary
@return:
""" To check the product type
@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 context: A standard dictionary
@return:
"""
prod_obj = self.pool.get('mrp.production')
move_ids = context['active_ids']

View File

@ -26,8 +26,7 @@ class mrp_track_move(osv.osv_memory):
_description = 'Production Track'
def view_init(self, cr, uid, fields_list, context=None):
"""
Creates view dynamically and adding fields at runtime.
""" Creates view dynamically and adding fields at runtime.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@ -48,8 +47,7 @@ class mrp_track_move(osv.osv_memory):
return res
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
"""
Changes the view dynamically
""" Changes the view dynamically
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@ -88,8 +86,7 @@ class mrp_track_move(osv.osv_memory):
return res
def track_lines(self, cr, uid, ids, context):
"""
Tracks Finished products and splits products to finish lines.
""" Tracks Finished products and splits products to finish lines.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in

View File

@ -31,15 +31,12 @@ class mrp_workcenter_load(osv.osv_memory):
}
def print_report(self, cr, uid, ids, context=None):
"""
To print the report of Work Center Load
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return : Report
""" To print the report of Work Center Load
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return : Report
"""
datas = {'ids' : context.get('active_ids',[])}
res = self.read(cr, uid, ids, ['time_unit','measure_unit'])

View File

@ -41,11 +41,11 @@ class procurement_compute(osv.osv_memory):
def _procure_calculation_orderpoint(self, cr, uid, ids, context):
"""
@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
@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
"""
proc_obj = self.pool.get('mrp.procurement')
for proc in self.browse(cr, uid, ids):
@ -55,12 +55,11 @@ class procurement_compute(osv.osv_memory):
def procure_calculation(self, cr, uid, ids, context):
"""
@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
@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
"""
threaded_calculation = threading.Thread(target=self._procure_calculation_orderpoint, args=(cr, uid, ids, context))
threaded_calculation.start()

View File

@ -37,11 +37,11 @@ class procurement_compute(osv.osv_memory):
def _procure_calculation_all(self, cr, uid, ids, context):
"""
@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
@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
"""
proc_obj = self.pool.get('mrp.procurement')
for proc in self.browse(cr, uid, ids):
@ -51,11 +51,11 @@ class procurement_compute(osv.osv_memory):
def procure_calculation(self, cr, uid, ids, context):
"""
@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
@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
"""
threaded_calculation = threading.Thread(target=self._procure_calculation_all, args=(cr, uid, ids, context))
threaded_calculation.start()

View File

@ -101,7 +101,7 @@ class change_standard_price(osv.osv_memory):
'stock_journal' : res[0].stock_journal.id
}
prod_obj.do_change_standard_price(cr, uid, [rec_id], datas, context)
return {}
return {}
change_standard_price()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: