bzr revid: fp@tinyerp.com-20100406163210-baxw860xradvzmqf
This commit is contained in:
Fabien Pinckaers 2010-04-06 18:32:10 +02:00
commit b3f8b9e9cc
85 changed files with 1582 additions and 1497 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

@ -3,7 +3,8 @@
<data>
<menuitem name="Auction Management" id="auction_menu_root" icon="terp-purchase"/>
<menuitem name="Configuration" parent="auction_menu_root" id="auction_config_menu" sequence="7"/>
<menuitem name="Tools Bar Codes" id="auction_outils_menu" parent="auction_menu_root" sequence="5" />
<menuitem name="Deliveries Management" action="action_auction_taken" id="menu_wizard_emporte" parent="auction_outils_menu"/>
=======================================================
Auction Management/Configuration/artist
=======================================================
@ -203,6 +204,7 @@
<field name="lot_est2"/>
<field name="product_id"/>
<field name="state" readonly="1"/>
</form>
</field>
</record>
@ -277,7 +279,7 @@
<separator string="Description" colspan="4"/>
<field name="obj_desc" colspan="4" nolabel="1" select="2"/>
<field name="state" colspan="1" select="2"/>
<group col="4" colspan="2">
<group col="8" colspan="2">
<button name="button_bought" string="Sold" states="draft" type="object" icon="gtk-jump-to"/>
<button name="button_not_bought" string="Not sold" states="draft" type="object" icon="gtk-undo"/>
<button name="button_taken_away" string="Taken away" states="sold" type="object" icon="gtk-goto-last"/>
@ -330,7 +332,6 @@
<field name="date"/>
</tree>
</field>
</page>
<page string="Bids">
<field name="bid_lines" colspan="4" nolabel="1" editable="top">
@ -340,9 +341,7 @@
<field name="call"/>
</tree>
</field>
</page>
</notebook>
</form>
</field>

View File

@ -1,8 +1,8 @@
<?xml version="1.0"?>
<openerp>
<data>
<!--<delete model="ir.actions.wizard" search="[('wiz_name','like','auction.lots.')]"/>-->
<!-- Following wizard is remaining to implement in osv_memory-->
<!--
<wizard string="Send to website"
model="auction.lots"
name="auction.lots.send.aie"
@ -20,45 +20,6 @@
multi="1"
id="wizard_map_user"/>
<wizard string="Change Auction Date"
model="auction.lots"
name="auction.lots.auction_move"
multi="1"
id="wizard_change_auction"/>
<!--wizard string="Pay objects of the seller"
model="auction.lots"
name="auction.pay.sel"
id="wizard_lots_pay"/-->
<wizard string="Pay objects of the buyer"
model="auction.lots"
name="auction.pay.buy"
id="wizard_pay"/>
<wizard
string="Gestion emporte"
model="auction.dates"
name="auction.taken"
multi="1"
id="wizard_emporte"/>
<menuitem name="Tools Bar Codes"
id="auction_outils_menu"
parent="auction_menu_root" sequence="5"
/>
<menuitem name="Deliveries Management"
action="wizard_emporte"
type="wizard"
id="menu_wizard_emporte"
parent="auction_outils_menu"
/>
<!--wizard string="Cancel payment"
model="auction.lots"
name="auction.lots.cancel"
multi="1"
id="wizard_cancel_pay"/-->
<wizard string="Numerotation (per lot)"
model="auction.lots"
@ -72,56 +33,13 @@
multi="1"
id="wizard_numerotate_automatic"/>
<wizard string="SMS Send"
model="auction.lots"
name="auction.lots.sms_send"
multi="1"
id="wizard_sms"/>
<!--wizard string="Invoice"
model="auction.lots"
name="auction.lots.invoice"
multi="1"
id="wizard_invoicing"/-->
<wizard string="Invoice Seller objects"
model="auction.lots"
name="auction.lots.make_invoice"
multi="1"
id="wizard_invoice"/>
<wizard string="Invoice Buyer objects"
model="auction.lots"
name="auction.lots.make_invoice_buyer"
id="wizard_invoice_buyer1"/>
<wizard string="Unmark as taken away"
model="auction.lots"
name="auction.lots.enable"
multi="1"
id="auction_wizard_enable_taken"/>
<wizard string="Mark as taken away"
model="auction.lots"
name="auction.lots.able"
multi="1"
id="auction_wizard_able_taken"/>
<wizard
id="auction_catalog_flagy"
string="Auction Catalog Flagey"
model="auction.dates"
name="auction.catalog.flagey"
keyword="client_print_multi"/>
<wizard string="Mark as paid for seller"
model="auction.lots"
name="auction.payer.sel"
multi="1"
id="auction_wizard_payer_sel"/>
-->
</data>
</openerp>

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

@ -0,0 +1,44 @@
# -*- 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 fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_lots_able(osv.osv_memory):
_name = "auction.lots.able"
_description = "Lots able"
def confirm_able(self, cr, uid, ids, context={}):
"""
This function Update auction lots object and set taken away field true.
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of auction lots ables IDs.
"""
self.pool.get('auction.lots').write(cr, uid, context['active_ids'], {'ach_emp':True})
return {}
auction_lots_able()

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

@ -0,0 +1,41 @@
# -*- 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 fields, osv
class auction_lots_enable(osv.osv_memory):
_name = "auction.lots.enable"
_description = "Lots Enable"
_columns= {
'confirm_en':fields.integer('Catalog Number')
}
def confirm_enable(self, cr, uid, ids, context={}):
"""
This function Update auction lots object and set taken away field False.
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of auction lots enables IDs.
"""
self.pool.get('auction.lots').write(cr, uid, context['active_id'], {'ach_emp':False})
return {}
auction_lots_enable()

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

@ -19,43 +19,35 @@
#
##############################################################################
import wizard
import netsvc
import pooler
take_form = """<?xml version="1.0"?>
<form title="Confirm">
<separator string="Confirmation set taken away" colspan="4"/>
<newline/>
</form>
"""
take_fields = {
# 'confirm_en': {'string':'Catalog Number', 'type':'integer'},
}
def _confirm_able(self,cr,uid,data,context={}):
res={}
pool = pooler.get_pool(cr.dbname)
pool.get('auction.lots').write(cr,uid,data['ids'],{'ach_emp':True})
return {}
class able_take_away(wizard.interface):
states = {
'init' : {
'actions' : [],
'result' : {
'type' : 'form',
'arch' : take_form,
'fields' : take_fields,
'state' : [('end', 'Cancel'),('go', 'Able Taken away')]}
},
'go' : {
'actions' : [_confirm_able],
'result' : {'type' : 'state', 'state' : 'end'}
},
}
able_take_away('auction.lots.able')
from osv import fields, osv
class auction_payer(osv.osv_memory):
_name = "auction.payer"
_description = "Auction payer"
def payer(self, cr, uid, ids, context):
self.pool.get('auction.lots').write(cr, uid, context['active_ids'], {'is_ok':True, 'state':'paid'})
return {}
auction_payer()
class auction_payer_sel(osv.osv_memory):
"""
For Mark as payment for seller
"""
_name = "auction.payer.sel"
_description = "Auction payment for seller"
def payer_sel(self, cr, uid, ids, context):
"""
This function Update auction lots object and seller paid true.
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of auction payer sels IDs.
"""
self.pool.get('auction.lots').write(cr, uid, context['active_ids'], {'paid_vnd':True})
return {}
auction_payer_sel()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

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

@ -1,61 +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
#field name="confirm_en"/>
take_form = """<?xml version="1.0"?>
<form title="Confirm">
<separator string="Confirmation enable taken away" colspan="4"/>
<newline/>
</form>
"""
take_fields = {
'confirm_en': {'string':'Catalog Number', 'type':'integer'},
}
def _confirm_enable(self,cr,uid,data,context={}):
pool = pooler.get_pool(cr.dbname)
pool.get('auction.lots').write(cr,uid,data['ids'],{'ach_emp':False})
return {}
class enable_take_away(wizard.interface):
states = {
'init' : {
'actions' : [],
'result' : {
'type' : 'form',
'arch' : take_form,
'fields' : take_fields,
'state' : [ ('end', 'Cancel'),('go', 'Enable Taken away')]}
},
'go' : {
'actions' : [_confirm_enable],
'result' : {'type' : 'state', 'state' : 'end'}
},
}
enable_take_away('auction.lots.enable')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,79 +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 netsvc
import osv
import time
import pooler
pay_form = '''<?xml version="1.0"?>
<form string="Check payment for buyer">
</form>'''
pay_fields = {
}
pay_form1 = '''<?xml version="1.0"?>
<form string="Check payment for seller">
</form>'''
pay_fields1 = {
}
def _payer(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
pool.get('auction.lots').write(cr,uid,data['ids'],{'is_ok':True, 'state':'paid'})
return {}
def _payer_sel(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
pool.get('auction.lots').write(cr,uid,data['ids'],{'paid_vnd':True})
return {}
class wiz_auc_pay(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':pay_form, 'fields': pay_fields, 'state':[('end','Cancel'),('pay','Pay')]}
},
'pay': {
'actions': [_payer],
'result': {'type': 'state', 'state':'end'}
}}
wiz_auc_pay('auction.payer')
class wiz_auc_pay_sel(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':pay_form1, 'fields': pay_fields1, 'state':[('end','Cancel'),('pay2','Pay')]}
},
'pay2': {
'actions': [_payer_sel],
'result': {'type': 'state', 'state':'end'}
}}
wiz_auc_pay_sel('auction.payer.sel')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -31,18 +31,24 @@ import time
import tools
months = {
1: "January", 2: "February", 3: "March", 4: "April", \
5: "May", 6: "June", 7: "July", 8: "August", 9: "September", \
10: "October", 11: "November", 12: "December"}
1: "January", 2: "February", 3: "March", 4: "April", \
5: "May", 6: "June", 7: "July", 8: "August", 9: "September", \
10: "October", 11: "November", 12: "December"
}
def get_recurrent_dates(rrulestring, exdate, startdate=None):
"""
Get recurrent dates
Get recurrent dates based on Rule string considering exdate and start date
@param rrulestring: Rulestring
@param exdate: List of exception dates for rrule
@param startdate: Startdate for computing recurrent dates
@return: List of Recurrent dates
"""
def todate(date):
val = parser.parse(''.join((re.compile('\d')).findall(date)))
return val
if not startdate:
startdate = datetime.now()
rset1 = rrule.rrulestr(rrulestring, dtstart=startdate, forceset=True)
@ -55,12 +61,14 @@ def get_recurrent_dates(rrulestring, exdate, startdate=None):
def base_calendar_id2real_id(base_calendar_id=None, with_date=False):
"""
Convert base calendar id into real id.
@return: base calendar id
This function converts virtual event id into real id of actual event
@param base_calendar_id: Id of calendar
@param with_date: If value passed to this param it will return dates based on value of withdate + base_calendar_id
"""
if base_calendar_id and isinstance(base_calendar_id, (str, unicode)):
res = base_calendar_id.split('-')
if len(res) >= 2:
real_id = res[0]
if with_date:
@ -70,11 +78,14 @@ def base_calendar_id2real_id(base_calendar_id=None, with_date=False):
end = start + timedelta(hours=with_date)
return (int(real_id), real_date, end.strftime("%Y-%m-%d %H:%M:%S"))
return int(real_id)
return base_calendar_id and int(base_calendar_id) or base_calendar_id
def real_id2base_calendar_id(real_id, recurrent_date):
"""
Convert real id into base_calendar_id.
Convert real id of record into virtual id using recurrent_date
e.g. real id is 1 and recurrent_date is 01-12-2009 10:00:00 then it will return
1-20091201100000
@return: real id with recurrent date.
"""
@ -84,7 +95,6 @@ def real_id2base_calendar_id(real_id, recurrent_date):
return '%d-%s' % (real_id, recurrent_date)
return real_id
def _links_get(self, cr, uid, context={}):
"""
Get request link.
@ -375,9 +385,11 @@ request was delegated to"),
response_re = re.compile("Are you coming\?.*\n*.*(YES|NO|MAYBE).*", re.UNICODE)
def msg_new(self, cr, uid, msg):
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, """
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
"""
return False
def msg_act_get(self, msg):
@ -436,25 +448,25 @@ request was delegated to"),
(att2.partner_id and att2.partner_id.name) or \
att2.email) + ' - Status: ' + att2.state.title())
body_vals = {'name': res_obj.name,
'start_date': res_obj.date,
'end_date': res_obj.date_deadline or False,
'description': res_obj.description or '-',
'location': res_obj.location or '-',
'attendees': '<br>'.join(att_infos),
'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User',
'sign': sign,
'company': company
'start_date': res_obj.date,
'end_date': res_obj.date_deadline or False,
'description': res_obj.description or '-',
'location': res_obj.location or '-',
'attendees': '<br>'.join(att_infos),
'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User',
'sign': sign,
'company': company
}
body = html_invitation % body_vals
if mail_to and email_from:
tools.email_send(
email_from,
mail_to,
sub,
body,
subtype='html',
reply_to=email_from
)
email_from,
mail_to,
sub,
body,
subtype='html',
reply_to=email_from
)
return True
def onchange_user_id(self, cr, uid, ids, user_id, *args, **argv):
"""
@ -497,7 +509,6 @@ request was delegated to"),
for vals in self.browse(cr, uid, ids, context=context):
user = vals.user_id
if user:
mod_obj = self.pool.get(vals.ref._name)
if vals.ref:
if vals.ref.user_id.id != user.id:
@ -552,9 +563,7 @@ class res_alarm(osv.osv):
are both optional, but if one occurs, so MUST the other"""),
'repeat': fields.integer('Repeat'),
'active': fields.boolean('Active', help="If the active field is set to \
true, it will allow you to hide the event alarm information without removing it."),
true, it will allow you to hide the event alarm information without removing it.")
}
_defaults = {
'trigger_interval': lambda *x: 'minutes',
@ -580,10 +589,10 @@ are both optional, but if one occurs, so MUST the other"""),
model_id = ir_obj.search(cr, uid, [('model', '=', model)])[0]
model_obj = self.pool.get(model)
for data in model_obj.browse(cr, uid, ids):
for data in model_obj.browse(cr, uid, ids, context):
basic_alarm = data.alarm_id
if not context.get('alarm_id'):
if not context.get('alarm_id', False):
self.do_alarm_unlink(cr, uid, [data.id], model)
return True
self.do_alarm_unlink(cr, uid, [data.id], model)
@ -609,6 +618,7 @@ are both optional, but if one occurs, so MUST the other"""),
cr.execute('Update %s set base_calendar_alarm_id=%s, alarm_id=%s \
where id=%s' % (model_obj._table, \
alarm_id, basic_alarm.id, data.id))
cr.commit()
return True
def do_alarm_unlink(self, cr, uid, ids, model, context={}):
@ -625,7 +635,7 @@ are both optional, but if one occurs, so MUST the other"""),
ir_obj = self.pool.get('ir.model')
model_id = ir_obj.search(cr, uid, [('model', '=', model)])[0]
model_obj = self.pool.get(model)
for datas in model_obj.browse(cr, uid, ids):
for datas in model_obj.browse(cr, uid, ids, context):
alarm_ids = alarm_obj.search(cr, uid, [('model_id', '=', model_id), ('res_id', '=', datas.id)])
if alarm_ids:
alarm_obj.unlink(cr, uid, alarm_ids)
@ -643,35 +653,35 @@ class calendar_alarm(osv.osv):
__attribute__ = {}
_columns = {
'alarm_id': fields.many2one('res.alarm', 'Basic Alarm', ondelete='cascade'),
'name': fields.char('Summary', size=124, help="""Contains the text to be \
used as the message subject for email \
or contains the text to be used for display"""),
'action': fields.selection([('audio', 'Audio'), ('display', 'Display'), \
('procedure', 'Procedure'), ('email', 'Email') ], 'Action', \
required=True, help="Defines the action to be invoked when an alarm is triggered"),
'description': fields.text('Description', help='Provides a more complete \
description of the calendar component, than that \
provided by the "SUMMARY" property'),
'attendee_ids': fields.many2many('calendar.attendee', 'alarm_attendee_rel', \
'alarm_id', 'attendee_id', 'Attendees', readonly=True),
'attach': fields.binary('Attachment', help="""* Points to a sound resource,\
which is rendered when the alarm is triggered for audio,
* File which is intended to be sent as message attachments for email,
* Points to a procedure resource, which is invoked when\
the alarm is triggered for procedure."""),
'res_id': fields.integer('Resource ID'),
'model_id': fields.many2one('ir.model', 'Model'),
'user_id': fields.many2one('res.users', 'Owner'),
'event_date': fields.datetime('Event Date'),
'event_end_date': fields.datetime('Event End Date'),
'trigger_date': fields.datetime('Trigger Date', readonly="True"),
'state':fields.selection([
('draft', 'Draft'),
('run', 'Run'),
('stop', 'Stop'),
('done', 'Done'),
], 'State', select=True, readonly=True),
'alarm_id': fields.many2one('res.alarm', 'Basic Alarm', ondelete='cascade'),
'name': fields.char('Summary', size=124, help="""Contains the text to be \
used as the message subject for email \
or contains the text to be used for display"""),
'action': fields.selection([('audio', 'Audio'), ('display', 'Display'), \
('procedure', 'Procedure'), ('email', 'Email') ], 'Action', \
required=True, help="Defines the action to be invoked when an alarm is triggered"),
'description': fields.text('Description', help='Provides a more complete \
description of the calendar component, than that \
provided by the "SUMMARY" property'),
'attendee_ids': fields.many2many('calendar.attendee', 'alarm_attendee_rel', \
'alarm_id', 'attendee_id', 'Attendees', readonly=True),
'attach': fields.binary('Attachment', help="""* Points to a sound resource,\
which is rendered when the alarm is triggered for audio,
* File which is intended to be sent as message attachments for email,
* Points to a procedure resource, which is invoked when\
the alarm is triggered for procedure."""),
'res_id': fields.integer('Resource ID'),
'model_id': fields.many2one('ir.model', 'Model'),
'user_id': fields.many2one('res.users', 'Owner'),
'event_date': fields.datetime('Event Date'),
'event_end_date': fields.datetime('Event End Date'),
'trigger_date': fields.datetime('Trigger Date', readonly="True"),
'state':fields.selection([
('draft', 'Draft'),
('run', 'Run'),
('stop', 'Stop'),
('done', 'Done'),
], 'State', select=True, readonly=True),
}
_defaults = {
@ -706,15 +716,14 @@ class calendar_alarm(osv.osv):
def do_run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, \
context=None):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of calendar alarms IDs.
@param use_new_cursor: False or the dbname
@param context: A standard dictionary for contextual values
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of calendar alarms IDs.
@param use_new_cursor: False or the dbname
@param context: A standard dictionary for contextual values
"""
if not context:
context = {}
current_datetime = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
@ -782,7 +791,6 @@ class calendar_event(osv.osv):
def _tz_get(self, cr, uid, context={}):
return [(x.lower(), x) for x in pytz.all_timezones]
def onchange_dates(self, cr, uid, ids, start_date, duration=False, end_date=False, context={}):
"""
@param self: The object pointer
@ -812,6 +820,82 @@ class calendar_event(osv.osv):
value['date_deadline'] = end.strftime("%Y-%m-%d %H:%M:%S")
return {'value': value}
def _set_rrulestring(self, cr, uid, id, name, value, arg, context):
"""
Set rule string.
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param id: List of calendar event's ids.
@param context: A standard dictionary for contextual values
@return: dictionary of rrule value.
"""
cr.execute("UPDATE %s set freq='',interval=0,count=0,end_date=Null,\
mo=False,tu=False,we=False,th=False,fr=False,sa=False,su=False,\
day=0,select1=False,month_list=0 ,byday=False where id=%s" % (self._table, id))
if not value:
return True
val = {}
for part in value.split(';'):
if part.lower().__contains__('freq') and len(value.split(';')) <=2:
rrule_type = part.lower()[5:]
break
else:
rrule_type = 'custom'
break
ans = value.split(';')
for i in ans:
val[i.split('=')[0].lower()] = i.split('=')[1].lower()
if int(val.get('interval')) > 1: #If interval is other than 1 rule is custom
rrule_type = 'custom'
qry = "UPDATE %(table)s set rrule_type=\'%(rule_type)s\' "
if rrule_type == 'custom':
new_val = val.copy()
for k, v in val.items():
if val['freq'] == 'weekly' and val.get('byday'):
for day in val['byday'].split(','):
new_val[day] = True
val.pop('byday')
if val.get('until'):
until = parser.parse(''.join((re.compile('\d')).findall(val.get('until'))))
new_val['end_date'] = until.strftime('%Y-%m-%d')
val.pop('until')
new_val.pop('until')
if val.get('bymonthday'):
new_val['day'] = val.get('bymonthday')
val.pop('bymonthday')
new_val['select1'] = 'date'
new_val.pop('bymonthday')
if val.get('byday'):
d = val.get('byday')
new_val['byday'] = d[:1]
new_val['week_list'] = d[1:].upper()
new_val['select1'] = 'day'
if val.get('bymonth'):
new_val['month_list'] = val.get('bymonth')
val.pop('bymonth')
new_val.pop('bymonth')
for k, v in new_val.items():
temp = ", %s='%s'" % (k, v)
qry += temp
whr = " where id=%(id)s"
qry = qry + whr
val.update({
'table': self._table,
'rule_type': rrule_type,
'id': id,
})
cr.execute(qry % val)
return True
def _get_rulestring(self, cr, uid, ids, name, arg, context=None):
"""
Get rule string.
@ -822,9 +906,7 @@ class calendar_event(osv.osv):
@return: dictionary of rrule value.
"""
result = {}
for event in ids:
datas = self.read(cr, uid, event)
for datas in self.read(cr, uid, ids):
if datas.get('rrule_type'):
if datas.get('rrule_type') == 'none':
result[event] = False
@ -848,21 +930,20 @@ class calendar_event(osv.osv):
'duration': fields.float('Duration'),
'description': fields.text('Your action'),
'class': fields.selection([('public', 'Public'), ('private', 'Private'), \
('confidential', 'Confidential')], 'Mark as'),
('confidential', 'Confidential')], 'Mark as'),
'location': fields.char('Location', size=264, help="Location of Event"),
'show_as': fields.selection([('free', 'Free'), \
('busy', 'Busy')],
'Show as'),
('busy', 'Busy')], 'Show as'),
'base_calendar_url': fields.char('Caldav URL', size=264),
'exdate': fields.text('Exception Date/Times', help="This property \
defines the list of date/time exceptions for arecurring calendar component."),
'exrule': fields.char('Exception Rule', size=352, help="defines a \
rule or repeating pattern for anexception to a recurrence set"),
'rrule': fields.function(_get_rulestring, type='char', size=124, method=True,\
string='Recurrent Rule', store=True),
string='Recurrent Rule', store=True, fnct_inv=_set_rrulestring),
'rrule_type': fields.selection([('none', ''), ('daily', 'Daily'), \
('weekly', 'Weekly'), ('monthly', 'Monthly'), \
('yearly', 'Yearly'), ('custom', 'Custom')], 'Recurrency'),
('weekly', 'Weekly'), ('monthly', 'Monthly'), \
('yearly', 'Yearly'), ('custom', 'Custom')], 'Recurrency'),
'alarm_id': fields.many2one('res.alarm', 'Alarm'),
'base_calendar_alarm_id': fields.many2one('calendar.alarm', 'Alarm'),
'recurrent_uid': fields.integer('Recurrent ID'),
@ -871,13 +952,13 @@ class calendar_event(osv.osv):
string='Timezone', store=True),
'user_id': fields.many2one('res.users', 'Responsible'),
'freq': fields.selection([('None', 'No Repeat'), \
('secondly', 'Secondly'), \
('minutely', 'Minutely'), \
('hourly', 'Hourly'), \
('daily', 'Daily'), \
('weekly', 'Weekly'), \
('monthly', 'Monthly'), \
('yearly', 'Yearly')], 'Frequency'),
('secondly', 'Secondly'), \
('minutely', 'Minutely'), \
('hourly', 'Hourly'), \
('daily', 'Daily'), \
('weekly', 'Weekly'), \
('monthly', 'Monthly'), \
('yearly', 'Yearly')], 'Frequency'),
'interval': fields.integer('Interval'),
'count': fields.integer('Count'),
'mo': fields.boolean('Mon'),
@ -888,19 +969,18 @@ class calendar_event(osv.osv):
'sa': fields.boolean('Sat'),
'su': fields.boolean('Sun'),
'select1': fields.selection([('date', 'Date of month'), \
('day', 'Day of month')], 'Option'),
('day', 'Day of month')], 'Option'),
'day': fields.integer('Date of month'),
'week_list': fields.selection([('MO', 'Monday'), ('TU', 'Tuesday'), \
('WE', 'Wednesday'), ('TH', 'Thursday'), \
('FR', 'Friday'), ('SA', 'Saturday'), \
('SU', 'Sunday')], 'Weekday'),
('WE', 'Wednesday'), ('TH', 'Thursday'), \
('FR', 'Friday'), ('SA', 'Saturday'), \
('SU', 'Sunday')], 'Weekday'),
'byday': fields.selection([('1', 'First'), ('2', 'Second'), \
('3', 'Third'), ('4', 'Fourth'), \
('5', 'Fifth'), ('-1', 'Last')], 'By day'),
('3', 'Third'), ('4', 'Fourth'), \
('5', 'Fifth'), ('-1', 'Last')], 'By day'),
'month_list': fields.selection(months.items(), 'Month'),
'end_date': fields.date('Repeat Until')
}
_defaults = {
'class': lambda *a: 'public',
'show_as': lambda *a: 'busy',
@ -924,11 +1004,11 @@ class calendar_event(osv.osv):
event_id = base_calendar_id2real_id(event_id)
datas = self.read(cr, uid, event_id, context=context)
defaults.update({
'recurrent_uid': base_calendar_id2real_id(datas['id']),
'recurrent_id': defaults.get('date') or real_date,
'rrule_type': 'none',
'rrule': ''
})
'recurrent_uid': base_calendar_id2real_id(datas['id']),
'recurrent_id': defaults.get('date') or real_date,
'rrule_type': 'none',
'rrule': ''
})
exdate = datas['exdate'] and datas['exdate'].split(',') or []
if real_date and defaults.get('date'):
exdate.append(real_date)
@ -944,7 +1024,7 @@ class calendar_event(osv.osv):
@param event_ids: List of crm meetings IDs.
@return: True
"""
#start Loop
for event_id in event_ids:
event_id = base_calendar_id2real_id(event_id)
@ -959,7 +1039,7 @@ class calendar_event(osv.osv):
qry += ", location = '%(location)s'"
qry += "WHERE id = %s" % (event_id)
cr.execute(qry %(defaults))
#End Loop
return True
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100):
@ -1056,13 +1136,16 @@ class calendar_event(osv.osv):
weekstring = ''
monthstring = ''
yearstring = ''
# logic for computing rrule string
freq = datas.get('freq')
if freq == 'None':
return ''
if datas.get('interval') < 1:
raise osv.except_osv(_('Error!'), ("Please select proper Interval"))
if freq == 'weekly':
byday = map(lambda x: x.upper(), filter(lambda x: datas.get(x) and x in weekdays, datas))
if byday:
weekstring = ';BYDAY=' + ','.join(byday)
@ -1093,9 +1176,9 @@ class calendar_event(osv.osv):
rrule_string = 'FREQ=' + freq.upper() + weekstring + ';INTERVAL=' + \
str(datas.get('interval')) + enddate + monthstring + yearstring
# End logic
return rrule_string
def search(self, cr, uid, args, offset=0, limit=100, order=None,
context=None, count=False):
"""
@ -1285,13 +1368,14 @@ class calendar_todo(osv.osv):
_description = "Calendar Task"
def _get_date(self, cr, uid, ids, name, arg, context):
""" Get Date
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of calendar todo's IDs.
@param args: list of tuples of form [(name_of_the_field, operator, value), ...].
@param context: A standard dictionary for contextual values
"""
Get Date
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of calendar todo's IDs.
@param args: list of tuples of form [(name_of_the_field, operator, value), ...].
@param context: A standard dictionary for contextual values
"""
res = {}
@ -1300,14 +1384,15 @@ class calendar_todo(osv.osv):
return res
def _set_date(self, cr, uid, id, name, value, arg, context):
""" Set Date
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param id: calendar's ID.
@param value: Get Value
@param args: list of tuples of form [(name_of_the_field, operator, value), ...].
@param context: A standard dictionary for contextual values
"""
Set Date
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param id: calendar's ID.
@param value: Get Value
@param args: list of tuples of form [(name_of_the_field, operator, value), ...].
@param context: A standard dictionary for contextual values
"""
event = self.browse(cr, uid, id, context=context)
@ -1331,11 +1416,12 @@ class ir_attachment(osv.osv):
_inherit = 'ir.attachment'
def search_count(self, cr, user, args, context=None):
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param user: the current users ID for security checks,
@param args: list of tuples of form [(name_of_the_field, operator, value), ...].
@param context: A standard dictionary for contextual values
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param user: the current users ID for security checks,
@param args: list of tuples of form [(name_of_the_field, operator, value), ...].
@param context: A standard dictionary for contextual values
"""
args1 = []
@ -1345,14 +1431,14 @@ class ir_attachment(osv.osv):
def search(self, cr, uid, args, offset=0, limit=None, order=None,
context=None, count=False):
""" @param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param args: list of tuples of form [(name_of_the_field, operator, value), ...].
@param offset: The Number of Results to pass,
@param limit: The Number of Results to Return,
@param context: A standard dictionary for contextual values
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param args: list of tuples of form [(name_of_the_field, operator, value), ...].
@param offset: The Number of Results to pass,
@param limit: The Number of Results to Return,
@param context: A standard dictionary for contextual values
"""
new_args = args
@ -1369,12 +1455,13 @@ class ir_values(osv.osv):
def set(self, cr, uid, key, key2, name, models, value, replace=True, \
isobject=False, meta=False, preserve_user=False, company=False):
""" set IR Values
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param model: Get The Model """
"""
Set IR Values
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param model: Get The Model
"""
new_model = []
for data in models:
@ -1387,12 +1474,13 @@ class ir_values(osv.osv):
def get(self, cr, uid, key, key2, models, meta=False, context={}, \
res_id_req=False, without_user=True, key2_req=True):
""" Get IR Values
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param model: Get The Model """
"""
Get IR Values
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param model: Get The Model
"""
new_model = []
for data in models:
@ -1411,14 +1499,14 @@ class ir_model(osv.osv):
def read(self, cr, uid, ids, fields=None, context={},
load='_classic_read'):
""" Read IR Model
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of IR Models IDs.
@param context: A standard dictionary for contextual values """
"""
Read IR Model
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of IR Models IDs.
@param context: A standard dictionary for contextual values
"""
data = super(ir_model, self).read(cr, uid, ids, fields=fields, \
context=context, load=load)
@ -1432,13 +1520,13 @@ ir_model()
class virtual_report_spool(web_services.report_spool):
def exp_report(self, db, uid, object, ids, datas=None, context=None):
""" Export Report
@param self: The object pointer
@param db: get the current database,
@param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values """
"""
Export Report
@param self: The object pointer
@param db: get the current database,
@param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values
"""
if object == 'printscreen.list':
return super(virtual_report_spool, self).exp_report(db, uid, \
@ -1446,10 +1534,8 @@ class virtual_report_spool(web_services.report_spool):
new_ids = []
for id in ids:
new_ids.append(base_calendar_id2real_id(id))
if datas is None:
datas = {}
if datas.get('id',False):
datas['id'] = base_calendar_id2real_id(datas['id'])
if datas.get('id', False):
datas['id'] = base_calendar_id2real_id(datas['id'])
return super(virtual_report_spool, self).exp_report(db, uid, object, new_ids, datas, context)
virtual_report_spool()
@ -1458,13 +1544,14 @@ class res_users(osv.osv):
_inherit = 'res.users'
def _get_user_avail(self, cr, uid, ids, context=None):
""" Get USer Availability
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of res users IDs.
@param context: A standard dictionary for contextual values """
"""
Get USer Availability
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of res users IDs.
@param context: A standard dictionary for contextual values
"""
current_datetime = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
res = {}
@ -1488,13 +1575,14 @@ class res_users(osv.osv):
return res
def _get_user_avail_fun(self, cr, uid, ids, name, args, context=None):
""" Get USer Availability Function
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of res users IDs.
@param context: A standard dictionary for contextual values """
"""
Get USer Availability Function
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of res users IDs.
@param context: A standard dictionary for contextual values
"""
return self._get_user_avail(cr, uid, ids, context=context)
@ -1506,4 +1594,3 @@ class res_users(osv.osv):
res_users()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -14,7 +14,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-04-04 03:52+0000\n"
"X-Launchpad-Export-Date: 2010-04-05 03:53+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: base_contact

View File

@ -48,6 +48,7 @@ between mails and Open ERP.""",
'process',
'mail_gateway',
'base_calendar',
'resource',
],
'init_xml': ['crm_data.xml',
'crm_meeting_data.xml',
@ -73,7 +74,6 @@ between mails and Open ERP.""",
'wizard/crm_send_email_view.xml',
'wizard/crm_email_add_cc_view.xml',
'crm_wizard.xml',
'crm_view.xml',
'crm_action_rule_view.xml',

View File

@ -63,6 +63,7 @@ class crm_case_section(osv.osv):
in the 'Reply-To' of all emails sent by Open ERP about cases in this sales team"),
'parent_id': fields.many2one('crm.case.section', 'Parent Section'),
'child_ids': fields.one2many('crm.case.section', 'parent_id', 'Child Sections'),
'resource_calendar_id': fields.many2one('resource.calendar', "Resource's Calendar"),
}
_defaults = {
@ -130,7 +131,6 @@ class crm_case_categ(osv.osv):
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'object_id': fields.many2one('ir.model', 'Object Name'),
}
def _find_object_id(self, cr, uid, context=None):
"""
@ -143,8 +143,8 @@ class crm_case_categ(osv.osv):
object_id = context and context.get('object_id', False) or False
ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', object_id)])
return ids and ids[0]
_defaults = {
_defaults = {
'object_id' : _find_object_id
}
#
@ -163,7 +163,6 @@ class crm_case_resource_type(osv.osv):
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'object_id': fields.many2one('ir.model', 'Object Name'),
}
def _find_object_id(self, cr, uid, context=None):
"""
@param self: The object pointer
@ -203,7 +202,6 @@ class crm_case_stage(osv.osv):
help="Change Probability on next and previous stages."),
'requirements': fields.text('Requirements')
}
def _find_object_id(self, cr, uid, context=None):
"""
@ -352,7 +350,6 @@ class crm_case(osv.osv):
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
'company_id': fields.many2one('res.company', 'Company'),
}
def _get_default_partner_address(self, cr, uid, context):
"""
@ -502,8 +499,8 @@ class crm_case(osv.osv):
s[section] = dict([(v, k) for (k, v) in s[section].iteritems()])
if st in s[section]:
self.write(cr, uid, [case.id], {'stage_id': s[section][st]})
return True
return True
def history(self, cr, uid, ids, keyword, history=False, email=False, details=None, context={}):
"""
@param self: The object pointer
@ -551,7 +548,7 @@ class crm_case(osv.osv):
(case.section_id and case.section_id.reply_to) or \
(case.user_id and case.user_id.address_id and \
case.user_id.address_id.email) or tools.config.get('email_from',False)
res = obj.create(cr, uid, data, context)
res = obj.create(cr, uid, data, context)
return True
_history = __history
@ -630,7 +627,7 @@ class crm_case(osv.osv):
self.__history(cr, uid, cases, _('Send'), history=True, email=False)
for case in cases:
self.write(cr, uid, [case.id], {
'description': False,
'description': False,
})
emails = [case.email_from] + (case.email_cc or '').split(',')
emails = filter(None, emails)
@ -644,11 +641,11 @@ class crm_case(osv.osv):
_("No E-Mail ID Found for your Company address!"))
tools.email_send(
emailfrom,
emails,
'[' + str(case.id) + '] ' + case.name,
self.format_body(body),
reply_to = case.section_id.reply_to,
emailfrom,
emails,
'[' + str(case.id) + '] ' + case.name,
self.format_body(body),
reply_to = case.section_id.reply_to,
openobject_id = str(case.id)
)
self.__history(cr, uid, [case], _('Send'), history=True, email=emails, details=body, email_from=emailfrom)
@ -687,7 +684,6 @@ class crm_case(osv.osv):
return {'value': data}
def case_close(self, cr, uid, ids, *args):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@ -707,7 +703,6 @@ class crm_case(osv.osv):
return True
def case_escalate(self, cr, uid, ids, *args):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@ -734,7 +729,6 @@ class crm_case(osv.osv):
def case_open(self, cr, uid, ids, *args):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@ -755,7 +749,6 @@ class crm_case(osv.osv):
def case_cancel(self, cr, uid, ids, *args):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@ -816,11 +809,11 @@ class crm_case_log(osv.osv):
_order = "id desc"
_columns = {
'name': fields.char('Status', size=64),
'date': fields.datetime('Date'),
'section_id': fields.many2one('crm.case.section', 'Section'),
'user_id': fields.many2one('res.users', 'User Responsible', readonly=True),
'model_id': fields.many2one('ir.model', "Model"),
'res_id': fields.integer('Resource ID'),
'date': fields.datetime('Date'),
'section_id': fields.many2one('crm.case.section', 'Section'),
'user_id': fields.many2one('res.users', 'User Responsible', readonly=True),
'model_id': fields.many2one('ir.model', "Model"),
'res_id': fields.integer('Resource ID'),
}
_defaults = {

View File

@ -23,6 +23,8 @@ from osv import fields, osv, orm
from datetime import datetime, timedelta
import crm
import math
import time
from mx import DateTime
from tools.translate import _
class crm_lead(osv.osv):
@ -33,8 +35,26 @@ class crm_lead(osv.osv):
_order = "priority desc, id desc"
_inherit = ['res.partner.address', 'crm.case']
def _compute_openday(self, cr, uid, ids, name, args, context={}):
def case_open(self, cr, uid, ids, *args):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of case's Ids
@param *args: Give Tuple Value
"""
cases = self.browse(cr, uid, ids)
for case in cases:
data = {'state': 'open', 'active': True}
if not case.user_id:
data['user_id'] = uid
data.update({'date_open': time.strftime('%Y-%m-%d %H:%M:%S')})
self.write(cr, uid, ids, data)
self._action(cr, uid, cases, 'open')
return True
def _compute_day(self, cr, uid, ids, fields, args, context={}):
"""
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@ -42,77 +62,68 @@ class crm_lead(osv.osv):
@return: difference between current date and log date
@param context: A standard dictionary for contextual values
"""
log_obj = self.pool.get('crm.case.log')
model_obj = self.pool.get('ir.model')
cal_obj = self.pool.get('resource.calendar')
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'crm.lead')])
log_obj = self.pool.get('crm.case.log')
hist_id = log_obj.search(cr, uid, [('model_id', '=', model_id[0]), \
('res_id', '=', r.id), \
('name', '=', 'Open')])
model_ids = model_obj.search(cr, uid, [('model', '=', self._name)])
model_id = False
if len(model_ids):
model_id = model_ids[0]
if hist_id:
# Considering last log for opening case
log = log_obj.browse(cr, uid, hist_id[-1])
date_lead_open = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
date_log_open = datetime.strptime(log.date, "%Y-%m-%d %H:%M:%S")
ans = date_lead_open - date_log_open
duration = float(ans.days) + (float(ans.seconds) / 86400)
result[r.id] = abs(int(duration))
return result
res = {}
for lead in self.browse(cr, uid, ids , context):
for field in fields:
res[lead.id] = {}
duration = 0
if field == 'day_open':
if lead.date_open:
date_create = datetime.strptime(lead.create_date, "%Y-%m-%d %H:%M:%S")
date_open = datetime.strptime(lead.date_open, "%Y-%m-%d %H:%M:%S")
def _compute_closeday(self, cr, uid, ids, name, args, context={}):
ans = date_open - date_create
duration = float(ans.days) + (float(ans.seconds) / 86400)
"""
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of closedays IDs
@param context: A standard dictionary for contextual values
@return: difference between current date and closed date
"""
elif field == 'day_close':
if lead.date_closed:
date_create = datetime.strptime(lead.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(lead.date_closed, "%Y-%m-%d %H:%M:%S")
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
if r.date_closed:
date_create = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(r.date_closed, "%Y-%m-%d %H:%M:%S")
ans = date_close - date_create
duration = float(ans.days) + (float(ans.seconds) / 86400)
result[r.id] = abs(int(duration))
return result
ans = date_close - date_create
duration = float(ans.days) + (float(ans.seconds) / 86400)
res[lead.id][field] = abs(int(duration))
return res
_columns = {
'categ_id': fields.many2one('crm.case.categ', 'Lead Source', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.opportunity')]"),
('object_id.model', '=', 'crm.opportunity')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Lead Type', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.lead')]"),
'partner_name': fields.char("Contact Name", size=64),
('object_id.model', '=', 'crm.lead')]"),
'partner_name': fields.char("Contact Name", size=64),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'date_closed': fields.datetime('Closed', readonly=True),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'date_closed': fields.datetime('Closed', readonly=True),
'stage_id': fields.many2one('crm.case.stage', 'Stage', \
domain="[('section_id','=',section_id),\
('object_id.model', '=', 'crm.lead')]"),
'opportunity_id': fields.many2one('crm.opportunity', 'Opportunity'),
('object_id.model', '=', 'crm.lead')]"),
'opportunity_id': fields.many2one('crm.opportunity', 'Opportunity'),
'user_id': fields.many2one('res.users', 'Salesman'),
'referred': fields.char('Referred By', size=32),
'day_open': fields.function(_compute_openday, string='Days to Open', \
method=True, type="integer", store=True),
'day_close': fields.function(_compute_closeday, string='Days to Close', \
method=True, type="integer", store=True),
'function_name' : fields.char('Function', size=64),
'user_id': fields.many2one('res.users', 'Salesman'),
'referred': fields.char('Referred By', size=32),
'date_open': fields.datetime('Opened', readonly=True),
'day_open': fields.function(_compute_day, string='Days to Open', \
method=True, multi='day_open', type="integer", store=True),
'day_close': fields.function(_compute_day, string='Days to Close', \
method=True, multi='day_close', type="integer", store=True),
'function_name': fields.char('Function', size=64),
}
_defaults = {
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
}
@ -144,29 +155,29 @@ class crm_lead(osv.osv):
if data_id:
view_id1 = data_obj.browse(cr, uid, data_id, context=context).res_id
value = {
'name': _('Create Partner'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'crm.lead2opportunity.partner',
'view_id': False,
'context': context,
'views': [(view_id1, 'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'name': _('Create Partner'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'crm.lead2opportunity.partner',
'view_id': False,
'context': context,
'views': [(view_id1, 'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'nodestroy': True
}
break
else:
value = {
'name': _('Create Opportunity'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'crm.lead2opportunity',
'view_id': False,
'context': context,
'views': [(view_id, 'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'name': _('Create Opportunity'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'crm.lead2opportunity',
'view_id': False,
'context': context,
'views': [(view_id, 'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'nodestroy': True
}
return value

View File

@ -13,13 +13,12 @@
<field eval="'Luc Latour'" name="name"/>
<field eval="'open'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'Michel Lafont'" name="partner_name2"/>
<field eval="'(726) 782-0636'" name="partner_mobile"/>
<field eval="'(726) 782-0636'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor6"/>
<field name="stage_id" ref="crm.stage_lead1"/>
<field eval="'The Oil Company'" name="partner_name"/>
<field eval="'(769) 703-274'" name="partner_phone"/>
<field eval="'(769) 703-274'" name="phone"/>
</record>
<record id="crm_case_electonicgoodsdealer0" model="crm.lead">
<field name="type_id" ref="crm.type_lead7"/>
@ -28,13 +27,12 @@
<field eval="'Marc Dufour'" name="name"/>
<field eval="'open'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'Luc Latour'" name="partner_name2"/>
<field eval="'(392) 895-7917'" name="partner_mobile"/>
<field eval="'(392) 895-7917'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor2"/>
<field name="stage_id" ref="crm.stage_lead2"/>
<field eval="'Le Club SARL'" name="partner_name"/>
<field eval="'(956) 293-2595'" name="partner_phone"/>
<field eval="'(956) 293-2595'" name="phone"/>
</record>
<record id="crm_case_developingwebapplications0" model="crm.lead">
<field name="type_id" ref="crm.type_lead5"/>
@ -43,13 +41,12 @@
<field eval="'Fabien Pinckaers'" name="name"/>
<field eval="'done'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'Mike Gardner'" name="partner_name2"/>
<field eval="'(820) 167-3208'" name="partner_mobile"/>
<field eval="'(820) 167-3208'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor4"/>
<field name="stage_id" ref="crm.stage_lead4"/>
<field eval="'TheKompany'" name="partner_name"/>
<field eval="'(079) 681-2139'" name="partner_phone"/>
<field eval="'(079) 681-2139'" name="phone"/>
<field eval="'contact@tecsas.fr'" name="email_from"/>
</record>
<record id="crm_case_qrecorp0" model="crm.lead">
@ -59,12 +56,12 @@
<field eval="'Henry Mc Coy'" name="name"/>
<field eval="'draft'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'(077) 582-4035'" name="partner_mobile"/>
<field eval="'(077) 582-4035'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor1"/>
<field name="stage_id" ref="crm.stage_lead1"/>
<field eval="'The Gas Company'" name="partner_name"/>
<field eval="'(514) 698-4118'" name="partner_phone"/>
<field eval="'(514) 698-4118'" name="phone"/>
</record>
<record id="crm_case_itdeveloper0" model="crm.lead">
<field name="type_id" ref="crm.type_lead4"/>
@ -73,13 +70,12 @@
<field eval="'Carrie Helle'" name="name"/>
<field eval="'pending'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'Sam Stone'" name="partner_name2"/>
<field eval="'(333) 715-1450'" name="partner_mobile"/>
<field eval="'(333) 715-1450'" name="mobile"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="crm.categ_oppor6"/>
<field name="stage_id" ref="crm.stage_lead3"/>
<field eval="'Stonage IT'" name="partner_name"/>
<field eval="'(855) 924-4364'" name="partner_phone"/>
<field eval="'(855) 924-4364'" name="phone"/>
</record>
<record id="crm_case_mgroperations0" model="crm.lead">
<field name="partner_address_id" ref="base.res_partner_address_1"/>
@ -91,12 +87,11 @@
<field eval="'Tina Pinero'" name="name"/>
<field eval="'cancel'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'Benoit Mortier'" name="partner_name2"/>
<field eval="'(468) 017-2684'" name="partner_mobile"/>
<field eval="'(468) 017-2684'" name="mobile"/>
<field name="categ_id" ref="crm.categ_oppor8"/>
<field name="stage_id" ref="crm.stage_lead6"/>
<field eval="'Opensides SPRL'" name="partner_name"/>
<field eval="'(373) 907-1009'" name="partner_phone"/>
<field eval="'(373) 907-1009'" name="phone"/>
<field eval="'info@opensides.be'" name="email_from"/>
</record>
<record id="crm_case_vpoperations0" model="crm.lead">
@ -107,12 +102,11 @@
<field eval="'Wendi Baltz'" name="name"/>
<field eval="'done'" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="'Will Smith'" name="partner_name2"/>
<field eval="'(463) 014-1208'" name="partner_mobile"/>
<field eval="'(463) 014-1208'" name="mobile"/>
<field name="categ_id" ref="crm.categ_oppor4"/>
<field name="stage_id" ref="crm.stage_lead4"/>
<field eval="'Gardner Group'" name="partner_name"/>
<field eval="'(282) 603-7489'" name="partner_phone"/>
<field eval="'(282) 603-7489'" name="phone"/>
</record>
</data>
</openerp>

View File

@ -55,10 +55,8 @@
<group col="8" colspan="4">
<field name="freq" />
<field name="interval" />
<field name="count"
attrs="{'required' : [('end_date','=',False)]}" />
<field name="end_date"
attrs="{'required' : [('count','&lt;=',0), ('freq', '!=', 'None')]}" />
<field name="count" />
<field name="end_date" />
</group>
<group col="14" colspan="4" name="Select weekdays"
attrs="{'invisible' : [('freq','!=','weekly')]}">

View File

@ -23,6 +23,7 @@ from datetime import datetime
from osv import fields,osv,orm
from tools.translate import _
import crm
import time
AVAILABLE_STATES = [
('draft','New'),
@ -40,8 +41,26 @@ class crm_opportunity(osv.osv):
_order = "id desc"
_inherit = 'crm.case'
def _compute_openday(self, cr, uid, ids, name, args, context={}):
def case_open(self, cr, uid, ids, *args):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of case's Ids
@param *args: Give Tuple Value
"""
cases = self.browse(cr, uid, ids)
for case in cases:
data = {'state': 'open', 'active': True}
if not case.user_id:
data['user_id'] = uid
data.update({'date_open': time.strftime('%Y-%m-%d %H:%M:%S')})
self.write(cr, uid, ids, data)
self._action(cr, uid, cases, 'open')
return True
def _compute_day(self, cr, uid, ids, fields, args, context={}):
"""
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@ -49,45 +68,37 @@ class crm_opportunity(osv.osv):
@return: difference between current date and log date
@param context: A standard dictionary for contextual values
"""
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'crm.opportunity')])
log_obj = self.pool.get('crm.case.log')
hist_id = log_obj.search(cr, uid, [('model_id', '=', model_id[0]), \
('res_id', '=', r.id), \
('name', '=', 'Open')])
log_obj = self.pool.get('crm.case.log')
model_obj = self.pool.get('ir.model')
cal_obj = self.pool.get('resource.calendar')
if hist_id:
# Considering last log for opening case
log = log_obj.browse(cr, uid, hist_id[-1])
date_lead_open = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
date_log_open = datetime.strptime(log.date, "%Y-%m-%d %H:%M:%S")
ans = date_lead_open - date_log_open
duration = float(ans.days) + (float(ans.seconds) / 86400)
result[r.id] = abs(int(duration))
return result
model_ids = model_obj.search(cr, uid, [('model', '=', self._name)])
model_id = False
if len(model_ids):
model_id = model_ids[0]
def _compute_closeday(self, cr, uid, ids, name, args, context={}):
res = {}
for opportunity in self.browse(cr, uid, ids , context):
for field in fields:
res[opportunity.id] = {}
duration = 0
if field == 'day_open':
if opportunity.date_open:
date_create = datetime.strptime(opportunity.create_date, "%Y-%m-%d %H:%M:%S")
date_open = datetime.strptime(opportunity.date_open, "%Y-%m-%d %H:%M:%S")
"""
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of closedays IDs
@return: difference between current date and closed date
@param context: A standard dictionary for contextual values
"""
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
ans = date_open - date_create
duration = float(ans.days) + (float(ans.seconds) / 86400)
if r.date_closed:
date_create = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(r.date_closed, "%Y-%m-%d %H:%M:%S")
ans = date_close - date_create
duration = float(ans.days) + (float(ans.seconds) / 86400)
result[r.id] = abs(int(duration))
return result
elif field == 'day_close':
if opportunity.date_closed:
date_create = datetime.strptime(opportunity.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(opportunity.date_closed, "%Y-%m-%d %H:%M:%S")
ans = date_close - date_create
duration = float(ans.days) + (float(ans.seconds) / 86400)
res[opportunity.id][field] = abs(int(duration))
return res
_columns = {
'stage_id': fields.many2one ('crm.case.stage', 'Stage', \
@ -113,11 +124,12 @@ class crm_opportunity(osv.osv):
\nWhen the case is over, the state is set to \'Done\'.\
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
'day_open': fields.function(_compute_openday, string='Days to Open', \
method=True, type="integer", store=True),
'day_close': fields.function(_compute_closeday, string='Days to Close', \
method=True, type="integer", store=True),
}
'date_open': fields.datetime('Opened', readonly=True),
'day_open': fields.function(_compute_day, string='Days to Open', \
method=True, multi='day_open', type="integer", store=True),
'day_close': fields.function(_compute_day, string='Days to Close', \
method=True, multi='day_close', type="integer", store=True),
}
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}):

View File

@ -11,13 +11,11 @@
<field eval="60" name="probability"/>
<field name="partner_address_id" ref="base.res_partner_address_zen"/>
<field eval="1" name="active"/>
<field eval="17.0" name="duration"/>
<field name="type_id" ref="crm.type_oppor1"/>
<field name="partner_id" ref="base.res_partner_3"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="&quot;open&quot;" name="state"/>
<field eval="75000.0" name="planned_cost"/>
<field eval="85000.0" name="planned_revenue"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="time.strftime('%Y-%m-07 10:05:15')" name="date"/>
@ -33,10 +31,8 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="&quot;draft&quot;" name="state"/>
<field eval="30000.0" name="planned_cost"/>
<field eval="45000.0" name="planned_revenue"/>
<field eval="50" name="probability"/>
<field eval="8.0" name="duration"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="time.strftime('%Y-%m-05 12:25:15')" name="date"/>
<field name="categ_id" ref="crm.categ_oppor5"/>
@ -52,10 +48,8 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="&quot;pending&quot;" name="state"/>
<field eval="50000.0" name="planned_cost"/>
<field eval="55000.0" name="planned_revenue"/>
<field eval="70" name="probability"/>
<field eval="10.0" name="duration"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="time.strftime('%Y-%m-14 13:55:10')" name="date"/>
<field name="categ_id" ref="crm.categ_oppor7"/>
@ -72,9 +66,7 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field eval="&quot;open&quot;" name="state"/>
<field eval="50000.0" name="planned_cost"/>
<field eval="45000.0" name="planned_revenue"/>
<field eval="24.0" name="duration"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="time.strftime('%Y-%m-23 16:32:23')" name="date"/>
<field name="categ_id" ref="crm.categ_oppor5"/>
@ -86,12 +78,10 @@
<field eval="80" name="probability"/>
<field name="partner_address_id" ref="base.res_partner_address_wong"/>
<field eval="1" name="active"/>
<field eval="2.25" name="duration"/>
<field name="partner_id" ref="base.res_partner_maxtor"/>
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field eval="&quot;done&quot;" name="state"/>
<field eval="25000.0" name="planned_cost"/>
<field eval="42000.0" name="planned_revenue"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="time.strftime('%Y-%m-25 16:05:15')" name="date"/>

View File

@ -47,7 +47,6 @@
id="menu_crm_opportunity_resource_act"
parent="crm.menu_crm_case_resource_type" />
<!-- Opportunities Form View -->
<record model="ir.ui.view" id="crm_case_form_view_oppor">
@ -138,6 +137,7 @@
<field name="create_date"/>
<field name="write_date"/>
<field name="date_closed"/>
<field name="date_open"/>
</group>
<group col="2" colspan="2">
<separator string="Misc" colspan="2"/>
@ -246,7 +246,7 @@
<field name="arch" type="xml">
<graph string="Opportunity by Categories" type="bar" orientation="horizontal">
<field name="categ_id"/>
<field name="planned_cost" operator="+"/>
<field name="planned_revenue" operator="+"/>
<field name="state" group="True"/>
</graph>
</field>
@ -308,18 +308,14 @@
<filter string="Campaign" icon="terp-crm"
domain="[]" context="{'group_by':'type_id'}" />
<separator orientation="vertical" />
<filter string="Partner" icon="terp-crm" domain="[]"
context="{'group_by':'partner_id'}" />
<filter string="Salesman" icon="terp-crm"
domain="[]" context="{'group_by':'user_id'}" />
<separator orientation="vertical" />
<filter string="Creation" icon="terp-project"
domain="[]" context="{'group_by':'create_date'}" />
<filter string="Exp.Closing" icon="terp-project"
domain="[]" context="{'group_by':'date_deadline'}" />
</group>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
</data>
</openerp>

View File

@ -8,13 +8,13 @@ msgstr ""
"Project-Id-Version: openobject-addons\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2010-01-05 05:59+0000\n"
"PO-Revision-Date: 2010-04-03 13:35+0000\n"
"PO-Revision-Date: 2010-04-04 12:10+0000\n"
"Last-Translator: smii <Unknown>\n"
"Language-Team: Finnish <fi@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-04-04 03:52+0000\n"
"X-Launchpad-Export-Date: 2010-04-05 03:53+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: crm
@ -3315,7 +3315,7 @@ msgstr ""
#. module: crm
#: model:ir.ui.menu,name:crm.next_id_64
msgid "Reporting"
msgstr ""
msgstr "Raportointi"
#. module: crm
#: code:addons/crm/crm.py:0
@ -3336,7 +3336,7 @@ msgstr ""
#: selection:report.crm.case.section.stage,state:0
#, python-format
msgid "Pending"
msgstr ""
msgstr "Odottaa"
#. module: crm
#: model:process.transition,name:crm.process_transition_leadopportunity0
@ -3346,12 +3346,12 @@ msgstr ""
#. module: crm
#: view:crm.job:0
msgid "Expected Salary"
msgstr ""
msgstr "Oletettu palkka"
#. module: crm
#: model:ir.ui.menu,name:crm.menu_crm_configuration
msgid "Configuration"
msgstr ""
msgstr "Asetukset"
#. module: crm
#: model:ir.actions.wizard,name:crm.wizard_crm_new_send_mail
@ -3361,7 +3361,7 @@ msgstr ""
#. module: crm
#: constraint:ir.cron:0
msgid "Invalid arguments"
msgstr ""
msgstr "Virheelliset argumentit"
#. module: crm
#: field:crm.meeting,transparent:0
@ -3377,43 +3377,43 @@ msgstr ""
#: model:crm.case.categ,name:crm.categ_lead7
#: model:crm.case.categ,name:crm.categ_oppor7
msgid "Word of mouth"
msgstr ""
msgstr "Suusanallinen"
#. module: crm
#: view:crm.lead:0
msgid "Lead Subject"
msgstr ""
msgstr "Ohjausaihe"
#. module: crm
#: view:crm.lead:0
#: view:crm.phonecall:0
msgid "Convert to Opportunity"
msgstr ""
msgstr "Muunna mahdollisuudeksi"
#. module: crm
#: model:crm.case.stage,name:crm.stage_phone1
msgid "Planned"
msgstr ""
msgstr "Suunniteltu"
#. module: crm
#: model:crm.case.category2,name:crm.category_meet3
msgid "Customer Office"
msgstr ""
msgstr "Asiakkaan toimisto"
#. module: crm
#: view:crm.job:0
msgid "Candidate Email"
msgstr ""
msgstr "Ehdokkaan sähköposti"
#. module: crm
#: view:crm.opportunity:0
msgid "Sales Stage: "
msgstr ""
msgstr "Myyntien vaihe: "
#. module: crm
#: view:crm.claim:0
msgid "Type of Action"
msgstr ""
msgstr "Toiminnon tyyppi"
#. module: crm
#: field:crm.case.rule,act_user_id:0
@ -3423,7 +3423,7 @@ msgstr "Aseta vastaava"
#. module: crm
#: view:crm.job:0
msgid "Meeting With Candidates"
msgstr ""
msgstr "Ehdokkaiden tapaaminen"
#. module: crm
#: help:crm.segmentation,som_interval:0
@ -3447,7 +3447,7 @@ msgstr ""
#: selection:report.crm.case.section.categ2,month:0
#: selection:report.crm.case.section.stage,month:0
msgid "December"
msgstr ""
msgstr "Joulukuu"
#. module: crm
#: view:report.crm.case.section.categ.categ2:0
@ -3467,7 +3467,7 @@ msgstr "Lähetä sähköpostia"
#. module: crm
#: view:crm.fundraising:0
msgid "Funds Tree"
msgstr ""
msgstr "Varojen puu"
#. module: crm
#: field:crm.case.rule,act_method:0
@ -3477,24 +3477,24 @@ msgstr "Kutsu objektia"
#. module: crm
#: model:ir.actions.act_window,name:crm.crm_case_category_act_fund_all1
msgid "All Funds"
msgstr ""
msgstr "Kaikki varat"
#. module: crm
#: field:crm.case.section,calendar:0
#: view:crm.meeting:0
#: model:ir.ui.menu,name:crm.menu_crm_case_category_act_meetings
msgid "Calendar"
msgstr ""
msgstr "Kalenteri"
#. module: crm
#: model:crm.case.categ,name:crm.categ_job1
msgid "Salesman"
msgstr ""
msgstr "Myyjä"
#. module: crm
#: model:crm.case.section,name:crm.section_support_help
msgid "HelpDesk"
msgstr ""
msgstr "HelpDesk"
#. module: crm
#: field:crm.case,ref2:0
@ -3511,12 +3511,12 @@ msgstr "Ostomyynti"
#: model:ir.actions.wizard,name:crm.wizard_crm_job_meeting_set
#: model:ir.actions.wizard,name:crm.wizard_crm_phonecall_meeting_set
msgid "Schedule Meeting"
msgstr ""
msgstr "Ajoita tapaaminen"
#. module: crm
#: model:crm.case.categ,name:crm.categ_fund4
msgid "Arts And Culture"
msgstr ""
msgstr "Taide ja Kulttuuri"
#. module: crm
#: model:crm.case.categ,name:crm.categ_phone2
@ -3524,7 +3524,7 @@ msgstr ""
#: model:ir.actions.act_window,name:crm.crm_case_categ_phone_outgoing0
#: model:ir.ui.menu,name:crm.menu_crm_case_phone_outbound
msgid "Outbound"
msgstr ""
msgstr "Lähtevä"
#. module: crm
#: code:addons/crm/crm.py:0
@ -3535,7 +3535,7 @@ msgstr "Historioi"
#. module: crm
#: view:crm.meeting:0
msgid "Confirmed"
msgstr ""
msgstr "Vahvistettu"
#. module: crm
#: selection:crm.segmentation,state:0
@ -3547,7 +3547,7 @@ msgstr "Ei toiminnassa"
#: wizard_field:crm.lead.opportunity_set,opportunity,probability:0
#: wizard_field:crm.phonecall.opportunity_set,opportunity,probability:0
msgid "Success Probability"
msgstr ""
msgstr "Onnistunut mahdollisuus"
#. module: crm
#: code:addons/crm/crm.py:0
@ -3585,7 +3585,7 @@ msgstr "Aseta osio"
#: selection:crm.case.rule,trg_priority_from:0
#: selection:crm.case.rule,trg_priority_to:0
msgid "Normal"
msgstr ""
msgstr "Normaali"
#. module: crm
#: code:addons/crm/crm.py:0
@ -3594,6 +3594,7 @@ msgstr ""
#, python-format
msgid "You must put a Partner eMail to use this action!"
msgstr ""
"Sinun täytyy laittaa kumppanin sähköpostiosoite käyttääksesi tätä toimintoa!"
#. module: crm
#: wizard_view:crm.job.partner_create,init:0
@ -3602,7 +3603,7 @@ msgstr ""
#: wizard_view:crm.phonecall.opportunity_set,create_partner:0
#: wizard_view:crm.phonecall.partner_create,init:0
msgid "You may have to verify that this partner does not exist already."
msgstr ""
msgstr "Sinun täytyy varmistaa ettei tämä kumppani ole jo olemassa."
#. module: crm
#: view:crm.job:0
@ -3622,14 +3623,14 @@ msgstr ""
#: field:report.crm.case.section.categ2,user_id:0
#: field:report.crm.case.section.stage,user_id:0
msgid "User"
msgstr ""
msgstr "Käyttäjä"
#. module: crm
#: model:ir.ui.menu,name:crm.menu_action_report_crm_case_lead_categ_categ2
#: model:ir.ui.menu,name:crm.menu_crm_case_section_categ_categ2_tree
#: view:report.crm.case.section.categ.categ2:0
msgid "Cases by Section, Category and Type"
msgstr ""
msgstr "Tapahtumat osion, kategorian ja tyypin mukaan"
#. module: crm
#: selection:report.crm.case.section.categ.categ2,month:0
@ -3637,12 +3638,12 @@ msgstr ""
#: selection:report.crm.case.section.categ2,month:0
#: selection:report.crm.case.section.stage,month:0
msgid "November"
msgstr ""
msgstr "Marraskuu"
#. module: crm
#: model:crm.case.category2,name:crm.category_job2
msgid "Licenced"
msgstr ""
msgstr "Lisensöity"
#. module: crm
#: field:crm.case.section,parent_id:0
@ -3658,7 +3659,7 @@ msgstr "Yläosio"
#: model:ir.actions.wizard,name:crm.wizard_crm_job_reschedule_phone_call
#: model:ir.actions.wizard,name:crm.wizard_crm_opportunity_reschedule_phone_call
msgid "Schedule Phone Call"
msgstr ""
msgstr "Ajoita puhelinsoitto"
#. module: crm
#: code:addons/crm/crm.py:0
@ -3666,6 +3667,8 @@ msgstr ""
msgid ""
"Can not send mail with empty body,you should have description in the body"
msgstr ""
"Sähköpostia ei voi lähettää tyhjällä viesti -kentällä. Sinulla tulisi olla "
"kuvaus viesti -kentässä"
#. module: crm
#: selection:report.crm.case.section.categ.categ2,month:0
@ -3673,7 +3676,7 @@ msgstr ""
#: selection:report.crm.case.section.categ2,month:0
#: selection:report.crm.case.section.stage,month:0
msgid "January"
msgstr ""
msgstr "Tammikuu"
#. module: crm
#: model:process.process,name:crm.process_process_contractprocess0
@ -3693,7 +3696,7 @@ msgstr "Suunniteltu tuotto"
#. module: crm
#: model:crm.case.categ,name:crm.categ_fund3
msgid "Healthcare"
msgstr ""
msgstr "Terveydenhoito"
#. module: crm
#: view:crm.case:0
@ -3717,7 +3720,7 @@ msgstr "Kumppanin Yhteystiedot"
#. module: crm
#: model:crm.case.category2,name:crm.category_meet1
msgid "Office"
msgstr ""
msgstr "Toimisto"
#. module: crm
#: model:ir.model,name:crm.model_crm_fundraising
@ -3727,7 +3730,7 @@ msgstr ""
#. module: crm
#: model:ir.model,name:crm.model_crm_case_stage
msgid "Stage of case"
msgstr ""
msgstr "Tapahtuman vaihe"
#. module: crm
#: view:crm.case:0

View File

@ -25,7 +25,7 @@ class res_company(osv.osv):
_description = 'res.company'
def _get_default_ad(self, addresses):
city = post_code = address = ""
city = post_code = address = country_code = ""
for ads in addresses:
if ads.type == 'default':
city = ads.city or ""
@ -34,7 +34,9 @@ class res_company(osv.osv):
address = ads.street or ""
if ads.street2:
address += " " + ads.street2
return city, post_code, address
if ads.country_id:
country_code = ads.country_id and ads.country_id.code or ""
return city, post_code, address, country_code
res_company()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -32,6 +32,9 @@ class l10n_be_vat_declaration(osv.osv_memory):
'period_id': fields.many2one('account.period','Period', required=True),
'msg': fields.text('File created', size=64, readonly=True),
'file_save': fields.binary('Save File'),
'ask_resitution': {'type': 'boolean', 'string': 'Ask Restitution',},
'ask_payment': {'type': 'boolean', 'string': 'Ask Payment',},
'client_nihil': {'type': 'boolean', 'string': 'Last Declaration of Entreprise', 'help': 'Thick this case only if it concerns only the last statement on the civil or cessation of activity'},
}
_defaults = {
@ -46,7 +49,7 @@ class l10n_be_vat_declaration(osv.osv_memory):
obj_comp = self.pool.get('res.company')
obj_data = self.pool.get('ir.model.data')
list_of_tags=['00','01','02','03','45','46','47','48','49','54','55','56','57','59','61','62','63','64','71','81','82','83','84','85','86','87','91']
list_of_tags=['00','01','02','03','44','45','46','47','48','49','54','55','56','57','59','61','62','63','64','71','81','82','83','84','85','86','87','88','91']
obj_company = obj_user.browse(cr, uid, uid, context=context).company_id
user_cmpny = obj_company.name
vat_no=obj_company.partner_id.vat
@ -59,26 +62,19 @@ class l10n_be_vat_declaration(osv.osv_memory):
ctx['period_id'] = data['period_id'] #added context here
tax_info = obj_tax_code.read(cr, uid, tax_code_ids, ['code','sum_period'], context=ctx)
address = post_code = city = ''
if not obj_company.partner_id.address:
address = post_code = city = ''
city, post_code, address = obj_comp._get_default_ad(obj_company.partner_id.address)
address = post_code = city = country_code = ''
city, post_code, address, country_code = obj_comp._get_default_ad(obj_company.partner_id.address)
year_id = obj_fyear.find(cr, uid)
account_period = obj_acc_period.browse(cr, uid, data['period_id'], context=context)
current_year = account_period.fiscalyear_id.name
period_code = account_period.code
send_ref = user_cmpny
if period_code:
send_ref = send_ref + period_code
send_ref = str(obj_company.partner_id.id) + str(account_period.date_start[5:7]) + str(account_period.date_stop[:4])
data_of_file='<?xml version="1.0"?>\n<VATSENDING xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MultiDeclarationTVA-NoSignature-14.xml">'
data_of_file +='\n\t<DECLARER>\n\t\t<VATNUMBER>'+str(vat_no)+'</VATNUMBER>\n\t\t<NAME>'+str(obj_company.name)+'</NAME>\n\t\t<ADDRESS>'+address+'</ADDRESS>'
data_of_file +='\n\t\t<POSTCODE>'+post_code+'</POSTCODE>\n\t\t<CITY>'+city+'</CITY>\n\t\t<SENDINGREFERENCE>'+send_ref+'</SENDINGREFERENCE>\n\t</DECLARER>'
data_of_file +='\n\t<VATRECORD>\n\t\t<RECNUM>1</RECNUM>\n\t\t<VATNUMBER>'+str(vat_no)+'</VATNUMBER>\n\t\t<DPERIODE>\n\t\t\t'
data_of_file +='\n\t\t<POSTCODE>'+post_code+'</POSTCODE>\n\t\t<CITY>'+city+'</CITY>\n\t\t<COUNTRY>'+country_code+'</COUNTRY>\n\t\t<SENDINGREFERENCE>'+send_ref+'</SENDINGREFERENCE>\n\t</DECLARER>'
data_of_file +='\n\t<VATRECORD>\n\t\t<RECNUM>1</RECNUM>\n\t\t<VATNUMBER>'+str(vat_no[2:])+'</VATNUMBER>\n\t\t<DPERIODE>\n\t\t\t'
starting_month = account_period.date_start[5:7]
ending_month = account_period.date_stop[5:7]
if starting_month != ending_month:
@ -89,14 +85,16 @@ class l10n_be_vat_declaration(osv.osv_memory):
else:
data_of_file += '<MONTH>' + starting_month + '</MONTH>\n\t\t\t'
data_of_file += '<YEAR>' + str(account_period.date_stop[:4]) + '</YEAR>\n\t\t</DPERIODE>\n\t\t<ASK RESTITUTION="NO" PAYMENT="NO"/>'
data_of_file += '\n\t\t<ClientListingNihil>'+ (data['form']['client_nihil'] and 'YES' or 'NO') +'</ClientListingNihil>'
data_of_file +='\n\t\t<DATA>\n\t\t\t<DATA_ELEM>'
for item in tax_info:
if item['code']:
if item['code'] == '71-72':
item['code'] = '71'
if item['code'] in list_of_tags:
data_of_file +='\n\t\t\t\t<D' + str(int(item['code'])) +'>' + str(int(item['sum_period']*100)) + '</D'+str(int(item['code'])) +'>'
data_of_file +='\n\t\t\t\t<D'+str(int(item['code'])) +'>' + str(abs(int(item['sum_period']*100))) + '</D'+str(int(item['code'])) +'>'
data_of_file +='\n\t\t\t</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>'
data['file_save'] = base64.encodestring(data_of_file)
@ -105,4 +103,4 @@ class l10n_be_vat_declaration(osv.osv_memory):
l10n_be_vat_declaration()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -15,6 +15,9 @@
<form string="Select Period">
<group colspan="4" >
<field name="period_id" select="1" default_focus="1"/>
<field name="ask_resitution"/>
<field name="ask_payment"/>
<field name="client_nihil"/>
<button colspan="1" name="create_xml" string="Create XML" type="object" icon="gtk-execute"/>
</group>
<separator string="XML Flie has been Created." colspan="4"/>
@ -44,4 +47,4 @@
id="l10_be_vat_declaration"/>
</data>
</openerp>
</openerp>

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,20 +143,23 @@ 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):
result[bom.id] = map(lambda x: x.id, bom.bom_lines)
@ -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),
@ -233,6 +255,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}
@ -242,6 +269,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,))
@ -259,6 +292,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:
@ -306,6 +348,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'])
@ -388,11 +433,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] = {
@ -405,18 +458,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:
@ -498,6 +566,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:
@ -505,6 +578,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]
@ -513,6 +590,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]
@ -521,10 +602,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')
@ -560,6 +648,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:
@ -571,6 +662,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):
@ -580,11 +674,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:
@ -595,21 +695,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)
@ -678,6 +771,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:
@ -711,11 +808,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:
@ -727,6 +830,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')
@ -834,6 +940,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
@ -881,6 +991,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'
@ -947,6 +1060,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 = {
@ -957,12 +1074,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):
@ -973,6 +1096,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:
@ -985,12 +1111,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
@ -1001,6 +1135,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:
@ -1008,6 +1145,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:
@ -1015,6 +1155,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
@ -1024,6 +1167,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:
@ -1032,6 +1179,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':
@ -1041,6 +1191,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):
@ -1060,6 +1213,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):
@ -1079,12 +1235,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:
@ -1114,6 +1276,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
@ -1121,6 +1286,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
@ -1132,24 +1301,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
@ -1185,19 +1354,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
@ -1262,6 +1428,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')
@ -1286,6 +1455,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':
@ -1294,10 +1466,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:
@ -1310,8 +1488,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

@ -26,52 +26,70 @@ from tools.translate import _
class product_product(osv.osv):
_inherit = "product.product"
def get_product_accounts(self, cr, uid, product_id, context={}):
"""
To get the stock input account, stock output account and stock journal related to product.
@param product_id : product id
@return: dictionary which contains information regarding stock input account, stock output account and stock journal
"""
product_obj = self.pool.get('product.product').browse(cr, uid, product_id, False)
stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False
if not stock_input_acc:
stock_input_acc = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id or False
stock_output_acc = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id or False
if not stock_output_acc:
stock_output_acc = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id or False
journal_id = product_obj.categ_id.property_stock_journal and product_obj.categ_id.property_stock_journal.id or False
res = {}
res.update({'stock_account_input': stock_input_acc})
res.update({'stock_account_output': stock_output_acc})
res.update({'stock_journal': journal_id})
return res
def do_change_standard_price(self, cr, uid, ids, datas, context={}):
"""
Changes the Standard Price of Product and parent products and creates an account move accordingly.
@param datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal
@param context: A standard dictionary
@return:
"""
#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')
product_uom_obj = self.pool.get('product.uom')
def _compute_price(bom):
price = 0.0
if bom.bom_id :
if bom.bom_id.bom_lines :
for bom_line in bom.bom_id.bom_lines :
prod_price = self.read(cr, uid, bom_line.product_id.id, ['standard_price'])['standard_price']
price += bom_line.product_qty * prod_price
def _compute_price(bom):
print bom.product_id
price = 0
# 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
# 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
accounts = self.get_product_accounts(cr, uid, bom.bom_id.product_id.id , context)
datas = {
'new_price' : price,
'stock_output_account' : accounts['stock_account_output'],
'stock_input_account' : accounts['stock_account_input'],
'stock_journal' : accounts['stock_journal']
}
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):
_compute_price(bom)
return res
product_product()

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

@ -19,7 +19,7 @@
#
##############################################################################
import wizard_cancel_repair
import wizard_make_invoice
import cancel_repair
import make_invoice
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -35,6 +35,14 @@ class pos_discount(osv.osv_memory):
'discount': lambda *a: 5,
}
def view_init(self, cr, uid, fields_list, context=None):
res = super(pos_discount, self).view_init(cr, uid, fields_list, context=context)
record_id = context and context.get('active_id', False) or False
order = self.pool.get('pos.order').browse(cr, uid, record_id)
if not order.lines:
raise osv.except_osv('Error!','No Order Lines ')
True
def apply_discount(self, cr, uid, ids, context):
"""
To give the discount of product and check the.
@ -52,7 +60,7 @@ class pos_discount(osv.osv_memory):
order_ref = self.pool.get('pos.order')
order_line_ref = self.pool.get('pos.order.line')
for order in order_ref.browse(cr, uid, record_id, context=context):
for line in order.lines:

View File

@ -84,7 +84,7 @@ class pos_make_payment(osv.osv_memory):
record_id = context and context.get('active_id', False) or False
order = self.pool.get('pos.order').browse(cr, uid, record_id)
if not order.lines:
raise osv.except_osv('Error!','No Order Lines ')
raise osv.except_osv('Error!','No order lines defined for this sale ')
True
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):

View File

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_pos_scan_product" model="ir.ui.view">
<field name="name">Scan product</field>
<field name="model">pos.scan.product</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Scan product">
<group col="2" colspan="4">
<label string="Scan Barcode" colspan="4"/>
<field name="gencod" colspan="4" nolabel="1"/>
<button icon='gtk-cancel' special="cancel"
string="Close" />
<button name="scan" string="Add"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<record id="action_pos_scan_product" model="ir.actions.act_window">
<field name="name">Scan product</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">pos.scan.product</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>

View File

@ -136,6 +136,8 @@ class product_pricelist(osv.osv):
'date': Date of the pricelist (%Y-%m-%d),
}
'''
price=False
item_id=0
context = context or {}
currency_obj = self.pool.get('res.currency')
product_obj = self.pool.get('product.product')

View File

@ -40,7 +40,8 @@ works done on tasks, eso. It is able to render planning, order tasks, eso.
"project_report.xml",
"process/task_process.xml",
"project_installer.xml",
"report/project_report_view.xml"
"report/project_report_view.xml",
"wizard/project_close_task_view.xml",
],
'demo_xml': [
'project_demo.xml'

View File

@ -190,10 +190,11 @@ class project(osv.osv):
def duplicate_template(self, cr, uid, ids, context={}):
project_obj = self.pool.get('project.project')
data_obj = self.pool.get('ir.model.data')
task_obj = self.pool.get('project.task')
result = []
for proj in self.browse(cr, uid, ids, context=context):
parent_id = context.get('parent_id',False)
parent_id = context.get('parent_id',False) # check me where to pass context for parent id ??
new_id = project_obj.copy(cr, uid, proj.id, default = {
'name': proj.name +_(' (copy)'),
'state':'open',
@ -208,7 +209,28 @@ class project(osv.osv):
child_ids = self.search(cr, uid, [('parent_id','=', proj.id)], context=context)
if child_ids:
self.duplicate_template(cr, uid, child_ids, context={'parent_id': new_id})
return result
if result and len(result):
res_id = result[0]
form_view_id = data_obj._get_id(cr, uid, 'project', 'edit_project')
form_view = data_obj.read(cr, uid, form_view_id, ['res_id'])
tree_view_id = data_obj._get_id(cr, uid, 'project', 'view_project_list')
tree_view = data_obj.read(cr, uid, tree_view_id, ['res_id'])
search_view_id = data_obj._get_id(cr, uid, 'project', 'view_project_project_filter')
search_view = data_obj.read(cr, uid, search_view_id, ['res_id'])
return {
'name': _('Projects'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'project.project',
'view_id': False,
'res_id' : res_id,
'views': [(form_view['res_id'],'form'),(tree_view['res_id'],'tree')],
'type': 'ir.actions.act_window',
'search_view_id': search_view['res_id'],
'nodestroy': True
}
# return result
# set active value for a project, its sub projects and its tasks
def setActive(self, cr, uid, ids, value=True, context={}):
@ -358,6 +380,8 @@ class task(osv.osv):
return res
def do_close(self, cr, uid, ids, *args):
mail_send = False
mod_obj = self.pool.get('ir.model.data')
request = self.pool.get('res.request')
tasks = self.browse(cr, uid, ids)
for task in tasks:
@ -373,6 +397,9 @@ class task(osv.osv):
'ref_doc1': 'project.task,%d'% (task.id,),
'ref_doc2': 'project.project,%d'% (project.id,),
})
elif project.warn_manager:
task_id = ids[0]
mail_send = True
self.write(cr, uid, [task.id], {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
for parent_id in task.parent_ids:
if parent_id.state in ('pending','draft'):
@ -382,6 +409,21 @@ class task(osv.osv):
reopen = False
if reopen:
self.do_reopen(cr, uid, [parent_id.id])
if mail_send:
model_data_ids = mod_obj.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_project_close_task')])
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id']
args[0].update({'task_id': task_id})
return {
'name': _('Email Send to Customer'),
'view_type': 'form',
'context': args[0], # improve me
'view_mode': 'tree,form',
'res_model': 'close.task',
'views': [(resource_id,'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'nodestroy': True
}
return True
def do_reopen(self, cr, uid, ids, *args):

View File

@ -49,9 +49,9 @@
<button name="set_cancel" string="Cancel" type="object" states="open,pending" icon="gtk-cancel"/>
<button name="set_done" string="Done" type="object" states="open,pending" icon="gtk-jump-to"/>
<button name="reset_project" string="Reset as Project" type="object" states="template" icon="gtk-convert"/>
<button
<button
string="New Project Based on Template"
name="%(wizard_duplicate_template)d" type="action"
name="duplicate_template" type="object"
states="template" icon="gtk-new"/>
</group>
</page>
@ -270,7 +270,7 @@
<button name="%(action_config_compute_remaining)d" states="done,cancelled" string="Reactivate" type="action" icon="gtk-convert" context="{'button_reactivate':True}" />
<button name="do_pending" states="open" string="Pending" type="object" icon="gtk-media-pause"/>
<button groups="base.group_extended" name="%(wizard_delegate_task)d" states="pending,open" string="Delegate" type="action" icon="gtk-sort-descending"/>
<button name="%(wizard_close_task)d" states="pending,open" string="Done" type="action" icon="gtk-jump-to"/>
<button name="do_close" states="pending,open" string="Done" type="object" icon="gtk-jump-to"/>
<button name="do_cancel" states="draft,open,pending" string="Cancel" type="object" icon="gtk-cancel"/>
</group>
</page>
@ -349,7 +349,7 @@
<field name="state" invisible="context.get('set_visible',False)"/>
<button name="do_open" states="pending,draft,done,cancel" string="Start Task" type="object" icon="gtk-execute" help="For changing to open state" invisible="context.get('set_visible',False)"/>
<button groups="base.group_extended" name="%(wizard_delegate_task)d" states="pending,open,draft" string="Delegate" type="action" icon="gtk-execute" help="For changing to delegate state"/>
<button name="%(wizard_close_task)d" states="draft,pending,open" string="Done" type="action" icon="gtk-jump-to" help="For changing to done state"/>
<button name="do_close" states="draft,pending,open" string="Done" type="object" icon="gtk-jump-to" help="For changing to done state"/>
<button name="do_cancel" states="draft,open,pending" string="Cancel" type="object" icon="gtk-cancel" help="For cancelling the task"/>
</tree>
</field>

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard id="wizard_close_task" menu="False" model="project.task" name="project.task.close" string="Close Task"/>
<!--<wizard id="wizard_close_task" menu="False" model="project.task" name="project.task.close" string="Close Task"/>-->
<wizard id="wizard_delegate_task" menu="False" model="project.task" name="project.task.delegate" string="Delegate Task"/>
<wizard
<!--<wizard
id="wizard_duplicate_template"
menu="False"
model="project.project"
name="project.duplicate.template" string="Duplicate Template"/>
-->
</data>
</openerp>

View File

@ -19,9 +19,8 @@
#
##############################################################################
import close_task
import project_close_task
import task_delegate
import duplicate_template_wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,114 +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
from tools import email_send as email
import pooler
from osv import osv
from tools.translate import _
mail_form = """<?xml version="1.0" ?>
<form string="Send mail to customer">
<field name="email" colspan="4"/>
<field name="description" colspan="4"/>
</form>"""
mail_fields = {
'email': {'string': 'E-Mails', 'type': 'char', 'required': 'True', 'size':64},
'description': {'string':'Description', 'type':'text', 'required':'True'},
}
def email_send(cr, uid, ids, to_adr, description, context={}):
pool = pooler.get_pool(cr.dbname)
for task in pool.get('project.task').browse(cr, uid, ids, context=context):
project = task.project_id
subject = "Task '%s' closed" % task.name
if task.user_id and task.user_id.address_id and task.user_id.address_id.email:
from_adr = task.user_id.address_id.email
signature = task.user_id.signature
else:
raise wizard.except_wizard(_('Error'), _("Couldn't send mail because your email address is not configured!"))
if to_adr:
val = {
'name': task.name,
'user_id': task.user_id.name,
'task_id': "%d/%d" % (project.id, task.id),
'date_start': task.date_start,
'date_close': task.date_close,
'state': task.state
}
header = (project.warn_header or '') % val
footer = (project.warn_footer or '') % val
body = u'%s\n%s\n%s\n\n-- \n%s' % (header, description, footer, signature)
email(from_adr, [to_adr], subject, body.encode('utf-8'), email_bcc=[from_adr])
else:
raise wizard.except_wizard(_('Error'), _("Couldn't send mail because the contact for this task (%s) has no email address!") % contact.name)
class wizard_close(wizard.interface):
def _check_complete(self, cr, uid, data, context):
task = pooler.get_pool(cr.dbname).get('project.task').browse(cr, uid, data['ids'])[0]
if not (task.project_id and task.project_id.warn_customer):
return 'close'
return 'mail_ask'
def _get_data(self, cr, uid, data, context):
email = ''
task = pooler.get_pool(cr.dbname).get('project.task').browse(cr, uid, data['ids'][0])
partner_id = task.partner_id or task.project_id.partner_id
if partner_id and partner_id.address[0].email:
email = partner_id.address[0].email
return {'description': task.description or task.name, 'email':email}
def _data_send(self, cr, uid, data, context):
task_obj = pooler.get_pool(cr.dbname).get('project.task')
if data['form']['email']:
description = data['form'].get('description', False)
email_send(cr, uid, data['ids'], data['form']['email'], data['form']['description'])
return {}
def _do_close(self, cr, uid, data, context):
task_obj = pooler.get_pool(cr.dbname).get('project.task')
task_obj.do_close(cr, uid, data['ids'], context)
return {}
states = {
'init': {
'actions': [],
'result': {'type':'choice', 'next_state':_check_complete}
},
'mail_ask': {
'actions': [_get_data],
'result': {'type':'form', 'arch':mail_form, 'fields':mail_fields, 'state':[('end', 'Cancel'), ('close', 'Quiet close'), ('mail_send', 'Send Message')]},
},
'mail_send': {
'actions': [_data_send],
'result': {'type':'state', 'state':'close'},
},
'close': {
'actions': [_do_close],
'result': {'type':'state', 'state':'end'},
},
}
wizard_close('project.task.close')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,71 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from mx.DateTime import now
import wizard
import netsvc
import ir
import pooler
import time
from tools.translate import _
class project_duplicate_template(wizard.interface):
def duplicate_template(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
project_obj = pool.get('project.project')
res = project_obj.duplicate_template(cr, uid, data['ids'])
if res and len(res):
res_id = res[0]
data_obj = pool.get('ir.model.data')
form_view_id = data_obj._get_id(cr, uid, 'project', 'edit_project')
form_view = data_obj.read(cr, uid, form_view_id, ['res_id'])
tree_view_id = data_obj._get_id(cr, uid, 'project', 'view_project_list')
tree_view = data_obj.read(cr, uid, tree_view_id, ['res_id'])
search_view_id = data_obj._get_id(cr, uid, 'project', 'view_project_project_filter')
search_view = data_obj.read(cr, uid, search_view_id, ['res_id'])
return {
'name': _('Projects'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'project.project',
'view_id': False,
'res_id' : res_id,
'views': [(form_view['res_id'],'form'),(tree_view['res_id'],'tree')],
'type': 'ir.actions.act_window',
'search_view_id': search_view['res_id']
}
return {}
states = {
'init': {
'actions': [],
'result': {'type': 'action', 'action': duplicate_template, 'state': 'order'}
},
'order': {
'actions': [],
'result': {'type': 'state', 'state': 'end'}
}
}
project_duplicate_template('project.duplicate.template')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,91 @@
# -*- 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 fields, osv
from tools.translate import _
from tools import email_send as email
class project_close_task(osv.osv_memory):
"""
Close Task
"""
_name = "close.task"
_description = "Project Close Task"
_columns = {
'email': fields.char('E-Mails', size=64,),
'description': fields.text('Description',),
}
def _get_email(self, cr, uid, context={}):
email = ''
if 'task_id' in context:
task = self.pool.get('project.task').browse(cr, uid, context['task_id'])
partner_id = task.partner_id or task.project_id.partner_id
if partner_id and partner_id.address[0].email:
email = partner_id.address[0].email
return email
def _get_desc(self, cr, uid, context={}):
if 'task_id' in context:
task = self.pool.get('project.task').browse(cr, uid, context['task_id'])
return task.description or task.name
return ''
_defaults={
'email': _get_email,
'description': _get_desc,
}
def confirm(self, cr, uid, ids, context={}):
if not 'task_id' in context:
return {}
close_task = self.read(cr, uid, ids[0], [])
to_adr = close_task['email']
description = close_task['description']
if 'task_id' in context:
for task in self.pool.get('project.task').browse(cr, uid, [context['task_id']], context=context):
project = task.project_id
subject = "Task '%s' closed" % task.name
if task.user_id and task.user_id.address_id and task.user_id.address_id.email:
from_adr = task.user_id.address_id.email
signature = task.user_id.signature
else:
raise osv.except_osv(_('Error'), _("Couldn't send mail because your email address is not configured!"))
if to_adr:
val = {
'name': task.name,
'user_id': task.user_id.name,
'task_id': "%d/%d" % (project.id, task.id),
'date_start': task.date_start,
'date_end': task.date_end,
'state': task.state
}
header = (project.warn_header or '') % val
footer = (project.warn_footer or '') % val
body = u'%s\n%s\n%s\n\n-- \n%s' % (header, description, footer, signature)
email(from_adr, [to_adr], subject, body.encode('utf-8'), email_bcc=[from_adr])
else:
raise osv.except_osv(_('Error'), _("Couldn't send mail because the contact for this task (%s) has no email address!") % contact.name)
return {}
project_close_task()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_project_close_task" model="ir.ui.view">
<field name="name">Project Close Task</field>
<field name="model">close.task</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Project Close Task">
<field name="email" />
<newline/>
<field name="description" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="_Cancel"/>
<button icon="gtk-ok" name="confirm" string="Send Mail" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_project_close_task" model="ir.actions.act_window">
<field name="name">Project Close Task</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">close.task</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_project_close_task"/>
<field name="context">{'record_id' : active_id}</field>
<field name="target">new</field>
</record>
</data>
</openerp>

View File

@ -37,37 +37,64 @@ class project_issue(osv.osv):
_order = "priority, id desc"
_inherit = 'crm.case'
def _compute_openday(self, cr, uid, ids, name, args, context={}):
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'project.issue')])
log_obj = self.pool.get('crm.case.log')
hist_id = log_obj.search(cr, uid, [('model_id', '=', model_id[0]), \
('res_id', '=', r.id), \
('name', '=', 'Open')])
def case_open(self, cr, uid, ids, *args):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of case's Ids
@param *args: Give Tuple Value
"""
if hist_id:
# Considering last log for opening case
log = log_obj.browse(cr, uid, hist_id[-1])
date_lead_open = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
date_log_open = datetime.strptime(log.date, "%Y-%m-%d %H:%M:%S")
ans = date_lead_open - date_log_open
duration = float(ans.days) + (float(ans.seconds) / 86400)
result[r.id] = abs(int(duration))
return result
cases = self.browse(cr, uid, ids)
for case in cases:
data = {'state': 'open', 'active': True}
if not case.user_id:
data['user_id'] = uid
data.update({'date_open': time.strftime('%Y-%m-%d %H:%M:%S')})
self.write(cr, uid, ids, data)
self._action(cr, uid, cases, 'open')
return True
def _compute_closeday(self, cr, uid, ids, name, args, context={}):
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
if r.date_closed:
date_create = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(r.date_closed, "%Y-%m-%d %H:%M:%S")
ans = date_close - date_create
duration = float(ans.days) + (float(ans.seconds) / 86400)
result[r.id] = abs(int(duration))
return result
def _compute_day(self, cr, uid, ids, fields, args, context={}):
"""
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of Opendays IDs
@return: difference between current date and log date
@param context: A standard dictionary for contextual values
"""
log_obj = self.pool.get('crm.case.log')
model_obj = self.pool.get('ir.model')
cal_obj = self.pool.get('resource.calendar')
model_ids = model_obj.search(cr, uid, [('model', '=', self._name)])
model_id = False
if len(model_ids):
model_id = model_ids[0]
res = {}
for project in self.browse(cr, uid, ids , context):
for field in fields:
res[project.id] = {}
duration = 0
if field == 'day_open':
if project.date_open:
date_create = datetime.strptime(project.create_date, "%Y-%m-%d %H:%M:%S")
date_open = datetime.strptime(project.date_open, "%Y-%m-%d %H:%M:%S")
ans = date_open - date_create
duration = float(ans.days) + (float(ans.seconds) / 86400)
elif field == 'day_close':
if project.date_closed:
date_create = datetime.strptime(project.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(project.date_closed, "%Y-%m-%d %H:%M:%S")
ans = date_close - date_create
duration = float(ans.days) + (float(ans.seconds) / 86400)
res[project.id][field] = abs(int(duration))
return res
_columns = {
'date_closed': fields.datetime('Closed', readonly=True),
@ -84,14 +111,16 @@ class project_issue(osv.osv):
'project_id':fields.many2one('project.project', 'Project'),
'duration': fields.float('Duration'),
'task_id': fields.many2one('project.task', 'Task', domain="[('project_id','=',project_id)]"),
'day_open': fields.function(_compute_openday, string='Days to Open', \
method=True, type="integer", store=True),
'day_close': fields.function(_compute_closeday, string='Days to Close', \
method=True, type="integer", store=True),
'assigned_to' : fields.many2one('res.users', 'Assigned to'),
'date_open': fields.datetime('Opened', readonly=True),
'day_open': fields.function(_compute_day, string='Days to Open', \
method=True, multi='day_open', type="integer", store=True),
'day_close': fields.function(_compute_day, string='Days to Close', \
method=True, multi='day_close', type="integer", store=True),
'assigned_to' : fields.many2one('res.users', 'Assigned to'),
'timesheet_ids' : fields.one2many('hr.analytic.timesheet', 'issue_id', 'Timesheets'),
'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account',
domain="[('partner_id', '=', partner_id)]"),
domain="[('partner_id', '=', partner_id)]",
required=True),
}
def _get_project(self, cr, uid, context):

View File

@ -77,7 +77,13 @@
<field name="create_date"/>
<field name="write_date" />
<field name="date_closed"/>
<field name="date_open"/>
</group>
<group colspan="2" col="2">
<separator string="Statistics" colspan="2" col="2"/>
<field name="day_open"/>
<field name="day_close"/>
</group>
<group col="2" colspan="2">
<separator string="References" colspan="2"/>
<field name="id"/>
@ -88,7 +94,7 @@
<separator string="Action Information" colspan="4"/>
<field name="name" colspan="4"/>
<field name="date" />
<field name="user_id" />
<field name="user_id" />
</form>
</field>
</page>

View File

@ -14,7 +14,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-04-04 03:52+0000\n"
"X-Launchpad-Export-Date: 2010-04-05 03:53+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: report_purchase

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@ -15,13 +15,12 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from make_invoice import make_invoice
#remaining make_invoice
import sale_line_invoice
import sale_make_invoice_advance
import wizard_sale_line_invoice
import make_invoice_advance
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -14,7 +14,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-04-04 03:52+0000\n"
"X-Launchpad-Export-Date: 2010-04-05 03:53+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: scrum

View File

@ -28,13 +28,8 @@ class product_product(osv.osv):
def do_change_standard_price(self, cr, uid, ids, datas, context={}):
"""
Changes the Standard Price of Product.
And creates an account move accordingly.
Changes the Standard Price of Product and creates an account move accordingly.
@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 datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal
@param context: A standard dictionary

View File

@ -1629,6 +1629,7 @@ class stock_move(osv.osv):
prodlot_obj.write(cr, uid, [prodlot_id], {'ref': ref})
return prodlot_id
def action_scrap(self, cr, uid, ids, quantity, location_id, context=None):
'''
Move the scrap/damaged product into scrap location

View File

@ -29,73 +29,66 @@ class change_standard_price(osv.osv_memory):
'new_price': fields.float('Price', required=True),
'stock_account_input':fields.many2one('account.account', 'Stock Input Account'),
'stock_account_output':fields.many2one('account.account', 'Stock Output Account'),
'stock_journal':fields.many2one('account.journal', 'Stock journal', required=True),
'stock_journal':fields.many2one('account.journal', 'Stock journal', required=True),
'enable_stock_in_out_acc':fields.boolean('Enable Related Account',),
}
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.
"""
product_obj = self.pool.get('product.product').browse(cr, uid, context.get('active_id', False))
res = super(change_standard_price, self).default_get(cr, uid, fields, context=context)
stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False
if not stock_input_acc:
stock_input_acc = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id or False
stock_output_acc = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id or False
if not stock_output_acc:
stock_output_acc = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id or False
@param fields: List of fields for which we want default values
@param context: A standard dictionary
@return: A dictionary which of fields with values.
"""
product_pool = self.pool.get('product.product')
product_obj = product_pool.browse(cr, uid, context.get('active_id', False))
res = super(change_standard_price, self).default_get(cr, uid, fields, context=context)
accounts = product_pool.get_product_accounts(cr, uid, context.get('active_id', False), context={})
price = product_obj.standard_price
journal_id = product_obj.categ_id.property_stock_journal and product_obj.categ_id.property_stock_journal.id or False
if 'new_price' in fields:
res.update({'new_price': price})
if 'stock_account_input' in fields:
res.update({'stock_account_input': stock_input_acc})
res.update({'stock_account_input': accounts['stock_account_input']})
if 'stock_account_output' in fields:
res.update({'stock_account_output': stock_output_acc})
res.update({'stock_account_output': accounts['stock_account_output']})
if 'stock_journal' in fields:
res.update({'stock_journal': journal_id})
res.update({'stock_journal': accounts['stock_journal']})
if 'enable_stock_in_out_acc' in fields:
res.update({'enable_stock_in_out_acc': True})
res.update({'enable_stock_in_out_acc': True})
return res
def onchange_price(self, cr, uid, ids, new_price, context = {}):
product_obj = self.pool.get('product.product').browse(cr, uid, context.get('active_id', False))
price = product_obj.standard_price
diff = price - new_price
if diff > 0 :
if diff > 0 :
return {'value' : {'enable_stock_in_out_acc':True}}
else :
return {'value' : {'enable_stock_in_out_acc':False}}
def change_price(self, cr, uid, ids, context):
"""
Changes the Standard Price of Product.
"""
Changes the Standard Price of Product.
And creates an account move accordingly.
@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:
@param ids: List of IDs selected
@param context: A standard dictionary
@return:
"""
rec_id = context and context.get('active_id', False)
prod_obj = self.pool.get('product.template')
@ -104,13 +97,13 @@ class change_standard_price(osv.osv_memory):
move_obj = self.pool.get('account.move')
move_line_obj = self.pool.get('account.move.line')
data_obj = self.pool.get('ir.model.data')
res = self.read(cr, uid, ids[0], ['new_price'])
new_price = res.get('new_price',[])
data = prod_obj.browse(cr, uid, rec_id)
diff = data.standard_price - new_price
prod_obj.write(cr, uid, rec_id, {'standard_price': new_price})
loc_ids = location_obj.search(cr, uid, [('account_id','<>',False),('usage','=','internal')])
lot_ids = lot_obj.search(cr, uid, [('location_id', 'in', loc_ids),('product_id','=',rec_id)])
qty = 0
@ -118,10 +111,10 @@ class change_standard_price(osv.osv_memory):
credit = 0.0
stock_input_acc = data.property_stock_account_input.id or data.categ_id.property_stock_account_input_categ.id
stock_output_acc = data.property_stock_account_output.id or data.categ_id.property_stock_account_output_categ.id
for lots in lot_obj.browse(cr, uid, lot_ids):
qty += lots.name
if stock_input_acc and stock_output_acc and lot_ids:
move_id = move_obj.create(cr, uid, {'journal_id': data.categ_id.property_stock_journal.id})
if diff > 0:
@ -163,5 +156,3 @@ class change_standard_price(osv.osv_memory):
return {}
change_standard_price()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -95,7 +95,7 @@ class survey_analysis(report_rml):
</stylesheet>
<images/>
<story>
<para style="Title"><u>Response Summary</u></para>
<para style="Title"><u>Answer Summary</u></para>
<para style="Standard"><font></font></para>
<para style="P2">
<font color="white"> </font>
@ -158,7 +158,7 @@ class survey_analysis(report_rml):
rml += """<blockTable colWidths=" """ + colWidths + """ " style="Table1"><tr>"""
for mat_col in range(0, len(matrix_ans)):
rml+="""<td><para style="response">""" + to_xml(tools.ustr(matrix_ans[mat_col][1])) + """</para></td>"""
rml += """<td><para style="response-bold">Response Count</para></td>
rml += """<td><para style="response-bold">Answer Count</para></td>
</tr>"""
last_col = cols_widhts[-1]
@ -194,8 +194,8 @@ class survey_analysis(report_rml):
rml += """<blockTable colWidths="240.0,210,50.0" style="Table1">"""
rml += """ <tr>
<td> <para style="Standard"> </para></td>
<td> <para style="terp_default_Center_heading">Response Percentage</para></td>
<td> <para style="response-bold">Response Count</para></td>
<td> <para style="terp_default_Center_heading">Answer Percentage</para></td>
<td> <para style="response-bold">Answer Count</para></td>
</tr>"""
for ans in que.answer_choice_ids:
@ -238,7 +238,7 @@ class survey_analysis(report_rml):
rml += """<blockTable colWidths="400.0,100.0" style="Table1">
<tr>
<td> <para style="Standard"> </para></td>
<td> <para style="response-bold">Response Count</para></td>
<td> <para style="response-bold">Answer Count</para></td>
</tr>
<tr><td><para style="answer"></para></td>
<td><para style="answer_right">""" + tools.ustr(cr.fetchone()[0]) + """ </para></td></tr>
@ -249,7 +249,7 @@ class survey_analysis(report_rml):
rml += """<blockTable colWidths="400.0,100.0" style="Table1">
<tr>
<td> <para style="Standard"> </para></td>
<td> <para style="response-bold">Response Count</para></td>
<td> <para style="response-bold">Answer Count</para></td>
</tr>
<tr><td><para style="answer"></para></td>
<td><para style="answer_right">""" + tools.ustr(cr.fetchone()[0]) + """ </para></td></tr>
@ -269,7 +269,7 @@ class survey_analysis(report_rml):
for mat_col in range(0,len(matrix_ans)):
rml += """<td><para style="response">""" + to_xml(tools.ustr(matrix_ans[mat_col][1])) + """</para></td>"""
rml += """<td><para style="response-bold">Rating Average</para></td>
<td><para style="response-bold">Response Count</para></td>
<td><para style="response-bold">Answer Count</para></td>
</tr>"""
for ans in que.answer_choice_ids:
@ -325,7 +325,7 @@ class survey_analysis(report_rml):
for menu in menu_choices:
rml += """<td><para style="response">""" + to_xml(tools.ustr(menu)) + """</para></td>"""
rml += """<td><para style="response-bold">Response Count</para></td></tr>"""
rml += """<td><para style="response-bold">Answer Count</para></td></tr>"""
cr.execute("select count(id), sra.answer_id from survey_response_answer sra \
where sra.column_id='%s' group by sra.answer_id " % (column.id))
res_count = cr.dictfetchall()
@ -363,9 +363,9 @@ class survey_analysis(report_rml):
<tr>
<td> <para style="Standard"> </para></td>
<td> <para style="Standard"> </para></td>
<td> <para style="response">Response Average</para></td>
<td> <para style="response">Response Total</para></td>
<td> <para style="response-bold">Response Count</para></td>
<td> <para style="response">Answer Average</para></td>
<td> <para style="response">Answer Total</para></td>
<td> <para style="response-bold">Answer Count</para></td>
</tr>"""
for ans in que.answer_choice_ids:
cr.execute("select answer from survey_response_answer where answer_id=%d group by answer" % ans.id)

View File

@ -51,8 +51,8 @@ class survey_browse_response(report_rml):
_frame_width = tools.ustr(_pageSize[0])
_frame_height = tools.ustr(float(_pageSize[1].replace('cm','')) - float(1.90))+'cm'
_tbl_widths = tools.ustr(float(_pageSize[0].replace('cm','')) - float(2.10))+'cm'
rml ="""<document filename="Survey Response Report.pdf">
<template pageSize="("""+_pageSize[0]+""","""+_pageSize[1]+""")" title='Survey Response.pdf' author="Martin Simon" allowSplitting="20" >
rml ="""<document filename="Survey Answer Report.pdf">
<template pageSize="("""+_pageSize[0]+""","""+_pageSize[1]+""")" title='Survey Answer.pdf' author="Martin Simon" allowSplitting="20" >
<pageTemplate id="first">
<frame id="first" x1="0.0cm" y1="1.0cm" width='"""+_frame_width+"""' height='"""+_frame_height+"""'/>
<pageGraphics>
@ -203,10 +203,10 @@ class survey_browse_response(report_rml):
colwidth = "4.6cm,5cm," + str(tbl_width - 16.4) +"cm,4cm,3cm"
rml += """<blockTable colWidths='""" + colwidth + """' style="Table_heading">
<tr>
<td><para style="terp_tblheader_General_Centre">Response Create Date:- </para></td>
<td><para style="terp_tblheader_General_Centre">Answer Create Date:- </para></td>
<td><para style="terp_tblheader_General_Centre_simple">""" + to_xml(time.strftime('%d-%m-%Y %I:%M:%S %p', time.strptime(response.date_create.split('.')[0], '%Y-%m-%d %H:%M:%S'))) + """</para></td>
<td><para style="terp_tblheader_General_Centre"></para></td>
<td><para style="terp_tblheader_General_right">Response By:- </para></td>
<td><para style="terp_tblheader_General_right">Answer By:- </para></td>
<td><para style="terp_tblheader_General_right_simple">""" + to_xml(response.user_id.login) + """</para></td>
</tr>
</blockTable><para style="P2"></para>"""
@ -289,7 +289,7 @@ class survey_browse_response(report_rml):
else:
rml +="""<blockTable colWidths='""" + str(_tbl_widths) + """' style="simple_table">
<tr><td> <para style="response">No Response</para></td> </tr>
<tr><td> <para style="response">No Answer</para></td> </tr>
</blockTable>"""
elif que.type in ['multiple_choice_only_one_ans','multiple_choice_multiple_ans']:
@ -363,7 +363,7 @@ class survey_browse_response(report_rml):
<td><para style="answer">""" + to_xml(tools.ustr(answer[0].comment)) + """</para></td></tr></blockTable>"""
else:
rml += """<blockTable colWidths='""" + str(_tbl_widths) + """' style="simple_table">
<tr><td> <para style="response">No Response</para></td> </tr>
<tr><td> <para style="response">No Answer</para></td> </tr>
</blockTable>"""
elif que.type in ['multiple_textboxes_diff_type','multiple_textboxes','date','date_and_time','numerical_textboxes','multiple_textboxes_diff_type']:
@ -390,7 +390,7 @@ class survey_browse_response(report_rml):
</blockTable>"""
else:
rml += """<blockTable colWidths='""" + str(_tbl_widths) + """' style="simple_table">
<tr> <td> <para style="response">No Response</para></td> </tr>
<tr> <td> <para style="response">No Answer</para></td> </tr>
</blockTable>"""
elif que.type in ['single_textbox']:
@ -400,7 +400,7 @@ class survey_browse_response(report_rml):
</blockTable>"""
else:
rml += """<blockTable colWidths='""" + str(_tbl_widths) + """' style="simple_table">
<tr> <td> <para style="response">No Response</para></td> </tr>
<tr> <td> <para style="response">No Answer</para></td> </tr>
</blockTable>"""
elif que.type in ['comment']:
@ -410,7 +410,7 @@ class survey_browse_response(report_rml):
</blockTable>"""
else:
rml += """<blockTable colWidths='""" + str(_tbl_widths) + """' style="simple_table">
<tr> <td> <para style="response">No Response</para></td> </tr>
<tr> <td> <para style="response">No Answer</para></td> </tr>
</blockTable>"""
elif que.type in ['matrix_of_choices_only_one_ans','matrix_of_choices_only_multi_ans', 'rating_scale', 'matrix_of_drop_down_menus']:
@ -507,7 +507,7 @@ class survey_browse_response(report_rml):
<td><para style="answer">""" + to_xml(tools.ustr(answer[0].comment or '')) + """</para></td></tr></blockTable>"""
else:
rml += """<blockTable colWidths='""" + str(_tbl_widths) + """' style="simple_table">
<tr><td> <para style="response">No Response</para></td> </tr>
<tr><td> <para style="response">No Answer</para></td> </tr>
</blockTable>"""
if datas.has_key('form') and not datas['form']['without_pagebreak']:

View File

@ -55,9 +55,9 @@ class survey(osv.osv):
'page_ids': fields.one2many('survey.page', 'survey_id', 'Page'),
'date_open': fields.datetime('Survey Open Date', readonly=1),
'date_close': fields.datetime('Survey Close Date', readonly=1),
'max_response_limit': fields.integer('Maximum Response Limit'),
'response_user': fields.integer('Maximum Response per User',
help="Set to one if you require only one response per user"),
'max_response_limit': fields.integer('Maximum Answer Limit'),
'response_user': fields.integer('Maximum Answer per User',
help="Set to one if you require only one Answer per user"),
'state': fields.selection([('draft', 'Draft'), ('open', 'Open'), ('close', 'Closed'), ('cancel', 'Cancelled')], 'Status', readonly=True),
'responsible_id': fields.many2one('res.users', 'Responsible'),
'tot_start_survey': fields.integer("Total Started Survey", readonly=1),
@ -65,7 +65,7 @@ class survey(osv.osv):
'note': fields.text('Description', size=128),
'history': fields.one2many('survey.history', 'survey_id', 'History Lines', readonly=True),
'users': fields.many2many('res.users', 'survey_users_rel', 'sid', 'uid', 'Users'),
'send_response': fields.boolean('E-mail Notification on Response'),
'send_response': fields.boolean('E-mail Notification on Answer'),
'type': fields.many2one('survey.type', 'Type'),
}
_defaults = {
@ -97,7 +97,6 @@ class survey(osv.osv):
survey()
class survey_history(osv.osv):
_name = 'survey.history'
_description = 'Survey History'
@ -110,7 +109,6 @@ class survey_history(osv.osv):
_defaults = {
'date': lambda * a: datetime.datetime.now()
}
survey_history()
class survey_page(osv.osv):
@ -144,14 +142,14 @@ class survey_page(osv.osv):
surv_name_wiz = self.pool.get('survey.name.wiz')
surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'transfer':True, 'page_no' : context.get('page_number',0) })
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'survey.question.wiz',
'type': 'ir.actions.act_window',
'target': 'new',
'search_view_id': search_id[0],
'context': context
}
'view_type': 'form',
'view_mode': 'form',
'res_model': 'survey.question.wiz',
'type': 'ir.actions.act_window',
'target': 'new',
'search_view_id': search_id[0],
'context': context
}
def copy(self, cr, uid, id, default=None, context={}):
raise osv.except_osv(_('Warning !'),_('You cannot duplicate the resource!'))
@ -183,7 +181,6 @@ class survey_question(osv.osv):
'page_id': fields.many2one('survey.page', 'Survey Page', ondelete='cascade', required=1),
'question': fields.char('Question', size=128, required=1),
'answer_choice_ids': fields.one2many('survey.answer', 'question_id', 'Answer'),
'response_ids': fields.one2many('survey.response.line', 'question_id', 'Response', readonly=1),
'is_require_answer': fields.boolean('Require Answer to Question (optional)'),
'required_type': fields.selection([('all','All'), ('at least','At Least'), ('at most','At Most'), ('exactly','Exactly'), ('a range','A Range')], 'Respondent must answer'),
'req_ans': fields.integer('#Required Answer'),
@ -192,33 +189,33 @@ class survey_question(osv.osv):
'req_error_msg': fields.text('Error Message'),
'allow_comment': fields.boolean('Allow Comment Field'),
'sequence': fields.integer('Sequence'),
'tot_resp': fields.function(_calc_response, method=True, string="Total Response"),
'tot_resp': fields.function(_calc_response, method=True, string="Total Answer"),
'survey': fields.related('page_id', 'survey_id', type='many2one', relation='survey', string='Survey'),
'descriptive_text': fields.text('Descriptive Text', size=255),
'column_heading_ids': fields.one2many('survey.question.column.heading', 'question_id',' Column heading'),
'type': fields.selection([('multiple_choice_only_one_ans','Multiple Choice (Only One Answer)'),
('multiple_choice_multiple_ans','Multiple Choice (Multiple Answer)'),
('matrix_of_choices_only_one_ans','Matrix of Choices (Only One Answers Per Row)'),
('matrix_of_choices_only_multi_ans','Matrix of Choices (Multiple Answers Per Row)'),
('matrix_of_drop_down_menus','Matrix of Drop-down Menus'),
('rating_scale','Rating Scale'),('single_textbox','Single Textbox'),
('multiple_textboxes','Multiple Textboxes'),
('multiple_textboxes_diff_type','Multiple Textboxes With Different Type'),
('comment','Comment/Essay Box'),
('numerical_textboxes','Numerical Textboxes'),('date','Date'),
('date_and_time','Date and Time'),('descriptive_text','Descriptive Text'),
('table','Table'),
], 'Question Type', required=1,),
('multiple_choice_multiple_ans','Multiple Choice (Multiple Answer)'),
('matrix_of_choices_only_one_ans','Matrix of Choices (Only One Answers Per Row)'),
('matrix_of_choices_only_multi_ans','Matrix of Choices (Multiple Answers Per Row)'),
('matrix_of_drop_down_menus','Matrix of Drop-down Menus'),
('rating_scale','Rating Scale'),('single_textbox','Single Textbox'),
('multiple_textboxes','Multiple Textboxes'),
('multiple_textboxes_diff_type','Multiple Textboxes With Different Type'),
('comment','Comment/Essay Box'),
('numerical_textboxes','Numerical Textboxes'),('date','Date'),
('date_and_time','Date and Time'),('descriptive_text','Descriptive Text'),
('table','Table'),
], 'Question Type', required=1,),
'is_comment_require': fields.boolean('Add Comment Field (optional)'),
'comment_label': fields.char('Field Label', size = 255),
'comment_field_type': fields.selection([('char', 'Single Line Of Text'), ('text', 'Paragraph of Text')], 'Comment Field Type'),
'comment_valid_type': fields.selection([('do_not_validate', '''Don't Validate Comment Text.'''),
('must_be_specific_length', 'Must Be Specific Length'),
('must_be_whole_number', 'Must Be A Whole Number'),
('must_be_decimal_number', 'Must Be A Decimal Number'),
('must_be_date', 'Must Be A Date'),
('must_be_email_address', 'Must Be An Email Address'),
], 'Text Validation'),
('must_be_specific_length', 'Must Be Specific Length'),
('must_be_whole_number', 'Must Be A Whole Number'),
('must_be_decimal_number', 'Must Be A Decimal Number'),
('must_be_date', 'Must Be A Date'),
('must_be_email_address', 'Must Be An Email Address'),
], 'Text Validation'),
'comment_minimum_no': fields.integer('Minimum number'),
'comment_maximum_no': fields.integer('Maximum number'),
'comment_minimum_float': fields.float('Minimum decimal number'),
@ -230,12 +227,12 @@ class survey_question(osv.osv):
'make_comment_field_err_msg': fields.text('Error message'),
'is_validation_require': fields.boolean('Validate Text (optional)'),
'validation_type': fields.selection([('do_not_validate', '''Don't Validate Comment Text.'''),\
('must_be_specific_length', 'Must Be Specific Length'),\
('must_be_whole_number', 'Must Be A Whole Number'),\
('must_be_decimal_number', 'Must Be A Decimal Number'),\
('must_be_date', 'Must Be A Date'),\
('must_be_email_address', 'Must Be An Email Address')\
], 'Text Validation'),
('must_be_specific_length', 'Must Be Specific Length'),\
('must_be_whole_number', 'Must Be A Whole Number'),\
('must_be_decimal_number', 'Must Be A Decimal Number'),\
('must_be_date', 'Must Be A Date'),\
('must_be_email_address', 'Must Be An Email Address')\
], 'Text Validation'),
'validation_minimum_no': fields.integer('Minimum number'),
'validation_maximum_no': fields.integer('Maximum number'),
'validation_minimum_float': fields.float('Minimum decimal number'),
@ -245,7 +242,7 @@ class survey_question(osv.osv):
'validation_valid_err_msg': fields.text('Error message'),
'numeric_required_sum': fields.integer('Sum of all choices'),
'numeric_required_sum_err_msg': fields.text('Error message'),
'rating_allow_one_column_require': fields.boolean('Allow Only One Response per Column (Forced Ranking)'),
'rating_allow_one_column_require': fields.boolean('Allow Only One Answer per Column (Forced Ranking)'),
'in_visible_rating_weight': fields.boolean('Is Rating Scale Invisible?'),
'in_visible_menu_choice': fields.boolean('Is Menu Choice Invisible?'),
'in_visible_answer_type': fields.boolean('Is Answer Type Invisible?'),
@ -438,14 +435,14 @@ class survey_question(osv.osv):
surv_name_wiz = self.pool.get('survey.name.wiz')
surv_name_wiz.write(cr, uid, [context.get('sur_name_id',False)], {'transfer':True, 'page_no' : context.get('page_number',False) })
return {
'view_type': 'form',
"view_mode": 'form',
'res_model': 'survey.question.wiz',
'type': 'ir.actions.act_window',
'target': 'new',
'search_view_id': search_id[0],
'context': context
}
'view_type': 'form',
'view_mode': 'form',
'res_model': 'survey.question.wiz',
'type': 'ir.actions.act_window',
'target': 'new',
'search_view_id': search_id[0],
'context': context
}
def default_get(self, cr, uid, fields, context={}):
data = super(survey_question, self).default_get(cr, uid, fields, context)
@ -454,7 +451,7 @@ class survey_question(osv.osv):
data['sequence'] = context['line_order'][-1][2]['sequence'] + 1
if context.has_key('page_id'):
data['page_id']= context.get('page_id',False)
data['page_id']= context.get('page_id', False)
return data
survey_question()
@ -466,11 +463,11 @@ class survey_question_column_heading(osv.osv):
_rec_name = 'title'
def _get_in_visible_rating_weight(self,cr, uid, context={}):
if context.get('in_visible_rating_weight',False):
if context.get('in_visible_rating_weight', False):
return context['in_visible_rating_weight']
return False
def _get_in_visible_menu_choice(self,cr, uid, context={}):
if context.get('in_visible_menu_choice',False):
if context.get('in_visible_menu_choice', False):
return context['in_visible_menu_choice']
return False
@ -486,7 +483,6 @@ class survey_question_column_heading(osv.osv):
'in_visible_rating_weight': _get_in_visible_rating_weight,
'in_visible_menu_choice': _get_in_visible_menu_choice,
}
survey_question_column_heading()
class survey_answer(osv.osv):
@ -497,7 +493,7 @@ class survey_answer(osv.osv):
def _calc_response_avg(self, cr, uid, ids, field_name, arg, context):
val = {}
for rec in self.browse(cr, uid, ids):
for rec in self.browse(cr, uid, ids, context):
cr.execute("select count(question_id) ,(select count(answer_id) \
from survey_response_answer sra, survey_response_line sa \
where sra.response_id = sa.id and sra.answer_id = %d \
@ -516,19 +512,17 @@ class survey_answer(osv.osv):
return val
def _get_in_visible_answer_type(self,cr, uid, context={}):
if context.get('in_visible_answer_type',False):
return context.get('in_visible_answer_type',False)
return False
return context.get('in_visible_answer_type', False)
_columns = {
'question_id': fields.many2one('survey.question', 'Question', ondelete='cascade'),
'answer': fields.char('Answer', size=128, required=1),
'sequence': fields.integer('Sequence'),
'response': fields.function(_calc_response_avg, method=True, string="#Response", multi='sums'),
'response': fields.function(_calc_response_avg, method=True, string="#Answer", multi='sums'),
'average': fields.function(_calc_response_avg, method=True, string="#Avg", multi='sums'),
'type': fields.selection([('char','Character'),('date','Date'),('datetime','Date & Time'),\
('integer','Integer'),('float','Float'),('selection','Selection'),\
('email','Email')], "Type of Answer",required=1),
('integer','Integer'),('float','Float'),('selection','Selection'),\
('email','Email')], "Type of Answer",required=1),
'menu_choice': fields.text('Menu Choices'),
'in_visible_answer_type': fields.boolean('Is Answer Type Invisible??')
}
@ -540,7 +534,7 @@ class survey_answer(osv.osv):
def default_get(self, cr, uid, fields, context={}):
data = super(survey_answer, self).default_get(cr, uid, fields, context)
if context.get('line_order',False):
if context.get('line_order', False):
if len(context['line_order'][-1]) > 2 and type(context['line_order'][-1][2]) == type({}) and context['line_order'][-1][2].has_key('sequence'):
data['sequence'] = context['line_order'][-1][2]['sequence'] + 1
return data
@ -555,8 +549,8 @@ class survey_response(osv.osv):
'date_create' : fields.datetime('Create Date', required=1),
'user_id' : fields.many2one('res.users', 'User'),
'response_type' : fields.selection([('manually', 'Manually'), ('link', 'Link')], \
'Response Type', required=1, readonly=1),
'question_ids' : fields.one2many('survey.response.line', 'response_id', 'Response Answer'),
'Answer Type', required=1, readonly=1),
'question_ids' : fields.one2many('survey.response.line', 'response_id', 'Answer'),
'state' : fields.selection([('done', 'Finished '),('skip', 'Not Finished')], \
'Status', readonly=True),
}
@ -585,16 +579,16 @@ class survey_response_line(osv.osv):
_description = 'Survey Response Line'
_rec_name = 'date_create'
_columns = {
'response_id': fields.many2one('survey.response', 'Response', ondelete='cascade'),
'response_id': fields.many2one('survey.response', 'Answer', ondelete='cascade'),
'date_create': fields.datetime('Create Date', required=1),
'state': fields.selection([('draft', 'Draft'), ('done', 'Answered'),('skip', 'Skiped')],\
'Status', readonly=True),
'question_id': fields.many2one('survey.question', 'Question'),
'page_id': fields.related('question_id', 'page_id', type='many2one', \
relation='survey.page', string='Page'),
'response_answer_ids': fields.one2many('survey.response.answer', 'response_id', 'Response Answer'),
'response_answer_ids': fields.one2many('survey.response.answer', 'response_id', 'Answer'),
'response_table_ids': fields.one2many('survey.tbl.column.heading', \
'response_table_id', 'Response Answer'),
'response_table_id', 'Answer'),
'comment': fields.text('Notes'),
'single_text': fields.char('Text', size=255),
}
@ -611,17 +605,17 @@ class survey_tbl_column_heading(osv.osv):
'name': fields.integer('Row Number'),
'column_id': fields.many2one('survey.question.column.heading', 'Column'),
'value': fields.char('Value', size = 255),
'response_table_id': fields.many2one('survey.response.line', 'Response', ondelete='cascade'),
'response_table_id': fields.many2one('survey.response.line', 'Answer', ondelete='cascade'),
}
survey_tbl_column_heading()
class survey_response_answer(osv.osv):
_name = 'survey.response.answer'
_description = 'Survey Response Answer'
_description = 'Survey Answer'
_rec_name = 'response_id'
_columns = {
'response_id': fields.many2one('survey.response.line', 'Response', ondelete='cascade'),
'response_id': fields.many2one('survey.response.line', 'Answer', ondelete='cascade'),
'answer_id': fields.many2one('survey.answer', 'Answer', required=1, ondelete='cascade'),
'column_id': fields.many2one('survey.question.column.heading','Column'),
'answer': fields.char('Value', size =255),

View File

@ -113,7 +113,7 @@ class survey_question_wiz(osv.osv_memory):
user_limit = survey_obj.browse(cr, uid, survey_id)
user_limit = user_limit.response_user
if user_limit and res >= user_limit:
raise osv.except_osv(_('Warning !'),_("You can not give response for this survey more than %s times") % (user_limit))
raise osv.except_osv(_('Warning !'),_("You can not give answer for this survey more than %s times") % (user_limit))
if sur_rec.max_response_limit and sur_rec.max_response_limit <= sur_rec.tot_start_survey and not sur_name_rec.page_no + 1:
survey_obj.write(cr, uid, survey_id, {'state':'close', 'date_close':strftime("%Y-%m-%d %H:%M:%S")})
@ -411,11 +411,11 @@ class survey_question_wiz(osv.osv_memory):
if user_email and resp_email:
user_name = user_obj.browse(cr, uid, uid).name
mail = "Hello " + survey_data.responsible_id.name + ",\n\n " + str(user_name) + " Give Response Of " + survey_data.title + " Survey.\n\n Thanks,"
tools.email_send(user_email, [resp_email], "Survey Response Of " + str(user_name) , mail, attach = attachments)
tools.email_send(user_email, [resp_email], "Survey Answer Of " + str(user_name) , mail, attach = attachments)
xml_form = etree.Element('form', {'string': _('Complete Survey Response')})
xml_form = etree.Element('form', {'string': _('Complete Survey Answer')})
etree.SubElement(xml_form, 'separator', {'string': 'Complete Survey', 'colspan': "4"})
etree.SubElement(xml_form, 'label', {'string': 'Thanks for your response'})
etree.SubElement(xml_form, 'label', {'string': 'Thanks for your Answer'})
etree.SubElement(xml_form, 'newline')
etree.SubElement(xml_form, 'button', {'icon': "gtk-go-forward", 'special':"cancel",'string':"OK",'colspan':"2"})
root = xml_form.getroottree()
@ -426,7 +426,7 @@ class survey_question_wiz(osv.osv_memory):
def create_report(self, cr, uid, res_ids, report_name=False, file_name=False, context=None):
"""
If any user give answer of survey then last create report of this answer and if 'E-mail Notification on Response' set True in survey then send mail on responsible person of this survey and attach survey answer report in pdf format.
If any user give answer of survey then last create report of this answer and if 'E-mail Notification on Answer' set True in survey then send mail on responsible person of this survey and attach survey answer report in pdf format.
@param self: The object pointer
@param cr: the current row, from the database cursor,

View File

@ -46,7 +46,7 @@ class survey_browse_answer(osv.osv_memory):
_columns = {
'survey_id': fields.selection(_get_survey, "Survey", required="1"),
'response_id': fields.many2one("survey.response", "Survey Response"),
'response_id': fields.many2one("survey.response", "Survey Answer"),
}
def action_next(self, cr, uid, ids, context=None):

View File

@ -12,7 +12,7 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Survey">
<separator colspan="4" string = "Select Survey and related response"/>
<separator colspan="4" string = "Select Survey and related answer"/>
<field name="survey_id" width="250"/>
<field name="response_id" domain="[('survey_id','=', survey_id)]"/>
<separator colspan="4" />

View File

@ -28,7 +28,7 @@ class survey_print_answer(osv.osv_memory):
_name = 'survey.print.answer'
_columns = {
'response_ids': fields.many2many('survey.response','survey_print_response',\
'response_id','print_id', "Response", required="1"),
'response_id','print_id', "Answer", required="1"),
'orientation': fields.selection([('vertical','Portrait(Vertical)'),\
('horizontal','Landscape(Horizontal)')], 'Orientation'),
'paper_size': fields.selection([('letter','Letter (8.5" x 11")'),\

View File

@ -80,7 +80,7 @@ class survey_name_wiz(osv.osv_memory):
'page': fields.char('Page Position',size = 12),
'transfer': fields.boolean('Page Transfer'),
'store_ans': fields.text('Store Answer'),
'response': fields.char('Response',size=16)
'response': fields.char('Answer',size=16)
}
_defaults = {
'page_no': lambda * a: - 1,

View File

@ -34,7 +34,7 @@
<record id="action_view_survey_name"
model="ir.actions.act_window">
<field name="name">Give Survey Response</field>
<field name="name">Give Survey Answer</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">survey.name.wiz</field>
<field name="view_type">form</field>

View File

@ -38,7 +38,7 @@ class survey_send_invitation(osv.osv_memory):
_name = 'survey.send.invitation'
_columns = {
'partner_ids': fields.many2many('res.partner','survey_res_partner','partner_id',\
'survey_id', "Response", required=1),
'survey_id', "Answer", required=1),
'send_mail': fields.boolean('Send mail for new user'),
'send_mail_existing': fields.boolean('Send reminder for existing user'),
'mail_subject': fields.char('Subject', size=256, required=1),