[IMP]: auction: Converted wizards to osv_memory wizards

bzr revid: rpa@tinyerp.com-20100310134156-965ifa1c3qo9i0a9
This commit is contained in:
ATP (Open ERP) 2010-03-10 19:11:56 +05:30 committed by rpa (Open ERP)
parent 1fe8691588
commit 8233a57725
34 changed files with 1192 additions and 1032 deletions

View File

@ -34,6 +34,16 @@
'init_xml': ['auction_sequence.xml'],
'update_xml': [
'security/ir.model.access.csv',
'wizard/auction_lots_able_view.xml',
'wizard/auction_lots_enable_view.xml',
'wizard/auction_lots_make_invoice_buyer_view.xml',
'wizard/auction_lots_make_invoice_view.xml',
'wizard/auction_taken_view.xml',
'wizard/auction_lots_auction_move_view.xml',
'wizard/auction_pay_buy_view.xml',
'wizard/auction_payer_sel_view.xml',
'wizard/auction_lots_sms_send_view.xml',
'auction_view.xml',
'auction_report.xml',
'auction_wizard.xml'

View File

@ -478,13 +478,15 @@ class auction_lots(osv.osv):
result = [ (r['id'], str(r['obj_num'])+' - '+r['name']) for r in self.read(cr, user, ids, ['name','obj_num'])]
return result
def name_search(self, cr, user, name, args=[], operator='ilike', context={}):
def name_search(self, cr, user, name, args=None, operator='ilike', context={}):
if not args:
args = []
try:
ids = self.search(cr, user, [('obj_num','=',int(name))]+ args)
ids = self.search(cr, user, [('obj_num','=',int(name))] + args)
except:
ids = []
if not ids:
ids = self.search(cr, user, [('name',operator,name)]+ args)
ids = self.search(cr, user, [('name',operator,name)] + args)
return self.name_get(cr, user, ids)
def _sum_taxes_by_type_and_id(self, taxes):

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

@ -19,24 +19,27 @@
#
##############################################################################
import wizard_aie_send
import wizard_aie_send_result
import wizard_lots_buyer_map
import wizard_lots_cancel
import wizard_lots_invoice
import wizard_lots_numerotate
import wizard_lots_pay
import wizard_pay
import wizard_lots_sms
import wizard_lot_date_move
import wizard_auction_journal
import wizard_auction_invoice_buyer
import wizard_transfer_unsold_object
import auction_wizard_enable_taken
import auction_wizard_able_taken
import auction_catalog_flagey
#import wizard_lots_barcode
import wizard_emporte
import wizard_payer
#import wizard_aie_send
#import wizard_aie_send_result
#import wizard_lots_buyer_map
#import wizard_lots_cancel
#import wizard_lots_invoice
#import wizard_lots_numerotate
#import wizard_lots_pay
#import wizard_pay
#import wizard_lot_date_move
#import wizard_transfer_unsold_object
#import auction_catalog_flagey
import auction_lots_able
import auction_lots_enable
import auction_lots_make_invoice_buyer
import auction_lots_make_invoice
import auction_taken
import auction_lots_auction_move
import auction_pay_buy
import auction_payer_sel
import auction_lots_sms_send
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

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

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_lots_able" model="ir.ui.view">
<field name="name">auction.lots.able.form</field>
<field name="model">auction.lots.able</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Confirm">
<group colspan="4" >
<separator string="Confirmation set taken away" colspan="4"/>
<newline/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-goto-last" string="Able Taken away" name="_confirm_able" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_lots_able" model="ir.actions.act_window">
<field name="name">Mark as taken away</field>
<field name="res_model">auction.lots.able</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_lots_able"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_lots_able_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Mark as taken away</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_lots_able'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,84 @@
# -*- 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_auction_move(osv.osv_memory):
_name = "auction.lots.auction.move"
_description = "Auction move "
_columns= {
'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 _auction_move_set(self, cr, uid, ids, context={}):
"""
This Function update auction date on auction lots to given auction date.
erase the auction lots's object adjudication price and its buyer and change state to draft.
create new entry in auction lot history.
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of auction lots auction moves IDs.
"""
for datas in self.read(cr, uid, ids):
if not (datas['auction_id'] and len(context['active_ids'])) :
return {}
refs = self.pool.get('auction.lots')
rec_ids = refs.browse(cr, uid, context['active_ids'])
line_ids = self.pool.get('auction.bid_line').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 = self.pool.get('auction.lot.history').create(cr, uid, {
'auction_id': rec.auction_id.id,
'lot_id': rec.id,
'price': rec.obj_ret
})
up_auction = self.pool.get('auction.lots').write(cr, uid, [rec.id], {
'auction_id':datas['auction_id'],
'obj_ret': None,
'obj_price': None,
'ach_login': None,
'ach_uid': None,
'ach_inv_id': None,
'sel_inv_id': None,
'obj_num': None,
'state': 'draft'})
return {}
auction_lots_auction_move()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_lots_auction_move" model="ir.ui.view">
<field name="name">auction.lots.auction.move.form</field>
<field name="model">auction.lots.auction.move</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Change Auction Date">
<group colspan="4" >
<label string="Warning, this will erase the object adjudication price and its buyer !" colspan="2"/>
<newline/>
<field name="auction_id"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-redo" string="Move to Auction date" name="_auction_move_set" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_lots_auction_move" model="ir.actions.act_window">
<field name="name">Change Auction Date</field>
<field name="res_model">auction.lots.auction.move</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_lots_auction_move"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_lots_auction_move_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Change Auction Date</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_lots_auction_move'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,47 @@
# -*- 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_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

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_lots_enable" model="ir.ui.view">
<field name="name">auction.lots.enable.form</field>
<field name="model">auction.lots.enable</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Confirm">
<group colspan="4" >
<separator string="Confirmation enable taken away" colspan="4"/>
<newline/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-goto-last" string="Enable Taken away" name="_confirm_enable" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_lots_enable" model="ir.actions.act_window">
<field name="name">Unmark as taken away</field>
<field name="res_model">auction.lots.enable</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_lots_enable"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_lots_enable_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Unmark as taken away</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_lots_enable'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,93 @@
# -*- 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_make_invoice(osv.osv_memory):
def _value_amount(self, cr, uid, context={}):
"""
For Amount default value
@return:default auction lots amount value in amount fields.
"""
lots= self.pool.get('auction.lots').browse(cr, uid, context['active_ids'])
amount_total=0.0
for lot in lots:
amount_total+=lot.seller_price
return amount_total
def _value_object(self, cr, uid, context={}):
"""
For object default value.
@return:length of id in Object field.
"""
object = len(context['active_ids'])
return object
def _makeInvoices(self, cr, uid, ids, context):
"""
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
@return: dictionary of account invoice form.
"""
for data in self.read(cr, uid, ids):
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'])
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']
}
_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={
'amount':_value_amount,
'objects':_value_object,
'number':lambda *a: False,
}
auction_lots_make_invoice()

View File

@ -0,0 +1,109 @@
# -*- 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_make_invoice_buyer(osv.osv_memory):
def _value_amount(self, cr, uid, context={}):
"""
For Amount default value
@return:default auction lots amount value in amount fields.
"""
lots= self.pool.get('auction.lots').browse(cr, uid, context['active_ids'])
amount_total=0.0
for lot in lots:
amount_total+=lot.buyer_price
return amount_total
def _value_object(self, cr, uid, context={}):
"""
For object default value.
@return:length of id in Object field.
"""
object = len(context['active_ids'])
return object
def _value_buyer_id(self, cr, uid, context={}):
"""
For default buyer id value
@return:auction lots buyer id in buyer id field.
"""
lots= self.pool.get('auction.lots').browse(cr, uid, context['active_ids'])
for lot in lots:
buyer=lot and lot.ach_uid.id or False
return buyer
def _makeInvoices(self, cr, uid, ids, context):
"""
Create an invoice for selected lots (IDS) to BUYER_ID .
@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 invoice buyers IDs
@return: dictionary of account invoice form.
"""
newinv = []
for data in self.read(cr, uid, ids):
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'])
invoice_number = data['number']
for lot in lots:
up_auction = self.pool.get('auction.lots').write(cr, uid, [lot.id], {'ach_uid':data['buyer_id']})
ids = order_obj.lots_invoice(cr, uid, context['active_ids'], context, data['number'])
cr.commit()
return {
'domain': "[('id','in', ["+','.join(map(str, ids))+"])]",
'name': 'Buyer invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'context': "{'type':'in_refund'}",
'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={
'amount':_value_amount,
'objects':_value_object,
'number':lambda *a: False,
'buyer_id':_value_buyer_id
}
auction_lots_make_invoice_buyer()

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_lots_make_invoice_buyer" model="ir.ui.view">
<field name="name">auction.lots.make.invoice.buyer.form</field>
<field name="model">auction.lots.make.invoice.buyer</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Paid">
<group colspan="4" >
<field name="amount"/>
<field name="objects"/>
<field name="number"/>
<label string="(Keep empty for automatic number)" colspan="2"/>
<field name="buyer_id"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-ok" string="Create invoices" name="_makeInvoices" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_lots_make_invoice_buyer" model="ir.actions.act_window">
<field name="name">Invoice Buyer objects</field>
<field name="res_model">auction.lots.make.invoice.buyer</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_lots_make_invoice_buyer"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_lots_make_invoice_buyer_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Invoice Buyer objects</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_lots_make_invoice_buyer'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_lots_make_invoice" model="ir.ui.view">
<field name="name">auction.lots.make.invoice.form</field>
<field name="model">auction.lots.make.invoice</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Paid">
<group colspan="4" >
<field name="amount"/>
<field name="objects"/>
<field name="number" colspan="3"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-ok" string="Create invoices" name="_makeInvoices" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_lots_make_invoice" model="ir.actions.act_window">
<field name="name">Invoice Seller objects</field>
<field name="res_model">auction.lots.make.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_lots_make_invoice"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_lots_make_invoice_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Invoice Seller objects</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_lots_make_invoice'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,67 @@
# -*- 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_sms_send(osv.osv_memory):
_name = "auction.lots.sms.send"
_description = "Sms send "
_columns= {
'app_id':fields.char('API ID', size=64, required=True),
'user':fields.char('Login', size=64, required=True),
'password':fields.char('Password', size=64, required=True),
'text':fields.text('SMS Message', required=True)
}
def _sms_send(self, cr, uid, ids, context):
for datas in self.read(cr, uid, ids):
lots = self.pool.get('auction.lots').read(cr, uid, context['active_ids'], ['obj_num','obj_price','ach_uid'])
print "lots",lots, [l['ach_uid'][0] for l in lots if l['ach_uid']]
res = self.pool.get('res.partner').read(cr, uid, [l['ach_uid'][0] for l in lots if l['ach_uid']], ['gsm'], context)
nbr = 0
for r in res:
add = self.pool.get('res.partner').address_get(cr, uid, [r['id']])['default']
addr = self.pool.get('res.partner.address').browse(cr, uid, add)
to = addr.mobile
if to:
tools.smssend(data['user'], data['password'], data['app_id'], unicode(data['text'], 'utf-8').encode('latin1'), to)
nbr += 1
return {'sms_sent': nbr}
if to:
tools.smssend(data['user'], data['password'], data['app_id'], unicode(data['text'], 'utf-8').encode('latin1'), to)
nbr += 1
return {'sms_sent': nbr}
#
auction_lots_sms_send()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_lots_sms_send" model="ir.ui.view">
<field name="name">auction.lots.sms.send.form</field>
<field name="model">auction.lots.sms.send</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="SMS - Gateway: clickatell','Bulk SMS send">
<group colspan="4" >
<separator string="SMS - Gateway: clickatell','Bulk SMS send" colspan="4"/>
<field name="app_id"/>
<newline/>
<field name="user"/>
<field name="password"/>
<newline/>
<field name="text" colspan="3"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-go-back" string="Send SMS" name="_sms_send" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_lots_sms_send" model="ir.actions.act_window">
<field name="name">SMS Send</field>
<field name="res_model">auction.lots.sms.send</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_lots_sms_send"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_lots_sms_send_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">SMS Send</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_lots_sms_send'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,105 @@
# -*- 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_pay_buy(osv.osv_memory):
def _start(self, cr, uid, context):
rec = self.pool.get('auction.lots').browse(cr, uid, context['active_ids'], context)
amount1 = 0.0
for r in rec:
amount1+= r.buyer_price
if r.is_ok:
raise osv.except_osv('Error !', 'Some lots of the selection are already paid.')
return amount1
def _value_buyer_id(self, cr, uid, context={}):
"""
For default buyer id value
@return:auction lots buyer id in buyer id field.
"""
lots= self.pool.get('auction.lots').browse(cr, uid, context['active_ids'])
for lot in lots:
buyer=lot and lot.ach_uid.id or False
return buyer
def _pay_and_reconcile(self, cr, uid, ids, context):
for datas in self.read(cr, uid, ids):
if not abs(datas['total'] - (datas['amount'] + datas['amount2'] + datas['amount3'])) <0.01:
rest = datas['total']-(datas['amount'] + datas['amount2'] + datas['amount3'])
raise osv.except_osv('Payment aborted !', 'You should pay all the total: "%.2f" are missing to accomplish the payment.' %(round(rest, 2)))
lots = self.pool.get('auction.lots').browse(cr, uid, context['active_ids'], context)
ref_bk_s = self.pool.get('account.bank.statement.line')
for lot in lots:
if datas['buyer_id']:
self.pool.get('auction.lots').write(cr, uid, [lot.id], {'ach_uid':datas['buyer_id']})
if not lot.auction_id:
raise osv.except_osv('Error !', 'No auction date for "%s": Please set one.'%(lot.name))
self.pool.get('auction.lots').write(cr, uid, [lot.id], {'is_ok':True})
for st, stamount in [('statement_id1', 'amount'), ('statement_id2', 'amount2'), ('statement_id3', 'amount3')]:
if datas[st]:
new_id = ref_bk_s.create(cr, uid, {
'name':'Buyer:'+ str(lot.ach_login or '')+', auction:'+ lots[0].auction_id.name,
'date': time.strftime('%Y-%m-%d'),
'partner_id': datas['buyer_id'] or False,
'type':'customer',
'statement_id': datas[st],
'account_id': lot.auction_id.acc_income.id,
'amount': datas[stamount]
})
for lot in lots:
self.pool.get('auction.lots').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),
}
_defaults={
'amount' : _start,
'total' : _start,
'buyer_id' : _value_buyer_id
}
auction_pay_buy()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_pay_buy" model="ir.ui.view">
<field name="name">auction.pay.buy.form</field>
<field name="model">auction.pay.buy</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Pay objects">
<group colspan="4" >
<field name="amount"/>
<field name="statement_id1" domain="[('state','=','draft')]"/>
<field name="amount2"/>
<field name="statement_id2" domain="[('state','=','draft')]"/>
<field name="amount3"/>
<field name="statement_id3" domain="[('state','=','draft')]"/>
<newline/>
<field name="buyer_id"/>
<field name="total"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-yes" string="Pay" name="_pay_and_reconcile" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_pay_buy" model="ir.actions.act_window">
<field name="name">Pay objects of the buyer</field>
<field name="res_model">auction.pay.buy</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_pay_buy"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_pay_buy_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Pay objects of the buyer</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_pay_buy'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,51 @@
# -*- 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_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),
}
def _pay_and_reconcile(self, cr, uid, ids, context):
lot = self.pool.get('auction.lots').browse(cr, uid, context['active_id'], context)
for datas in self.read(cr, uid, ids):
account_id = datas.get('writeoff_acc_id', False)
period_id = datas.get('period_id', False)
journal_id = datas.get('journal_id', False)
if lot.sel_inv_id:
p = self.pool.get('account.invoice').pay_and_reconcile(['lot.sel_inv_id.id'], datas['amount'], datas['dest_account_id'], journal_id, account_id, period_id, journal_id, context)
# lots.sel_inv_id.pay_and_reconcile(cr,uid,data[id], form['amount'], form['dest_account_id'], journal_id, account_id, period_id, journal_id, context)
return {}
auction_pay_sel()

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_pay_sel" model="ir.ui.view">
<field name="name">auction.pay.sel.form</field>
<field name="model">auction.pay.sel</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Pay invoice">
<group colspan="4" >
<field name="amount"/>
<field name="dest_account_id"/>
<field name="journal_id"/>
<field name="period_id"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-yes" string="Pay" name="_pay_and_reconcile" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_pay_sel" model="ir.actions.act_window">
<field name="name">Pay objects of the seller</field>
<field name="res_model">auction.pay.sel</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_pay_sel"/>
<field name="target">new</field>
</record>
</data>
</openerp>

View File

@ -19,43 +19,42 @@
#
##############################################################################
import wizard
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
take_form = """<?xml version="1.0"?>
<form title="Confirm">
<separator string="Confirmation set taken away" colspan="4"/>
<newline/>
</form>
"""
import time
import tools
import wizard
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')
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

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_payer" model="ir.ui.view">
<field name="name">auction.payer.form</field>
<field name="model">auction.payer</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Check payment for buyer">
<separator string="" colspan="4" />
<group colspan="4" col="2">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon = "gtk-yes" string="Pay" name="_payer" type="object"/>
</group>
</form>
</field>
</record>
<record id="view_auction_payer_sel" model="ir.ui.view">
<field name="name">auction.payer.sel.form</field>
<field name="model">auction.payer.sel</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Check payment for seller">
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-yes" string="Pay" name="_payer_sel" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_payer_sel" model="ir.actions.act_window">
<field name="name">Mark as paid for seller</field>
<field name="res_model">auction.payer.sel</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_payer_sel"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_payer_sel_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Mark as paid for seller</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_payer_sel'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_taken(osv.osv_memory):
"""
Auction lots taken.
"""
_name = "auction.taken"
_description = "Auction taken"
_columns = {
'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;')
def _process(self, cr, uid, ids, context):
"""
Update Auction lots state to taken_away.
@param cr: the current row, from the database cursor.
@param uid: the current users ID for security checks.
@param ids: List of Auction takens IDs
@return: dictionary of lot_ids fields with empty list
"""
for data in self.read(cr, uid, ids):
lot_obj = self.pool.get('auction.lots')
if data['lot_ids']:
lot_obj.write(cr, uid, data['lot_ids'], {'state':'taken_away'})
return {'lot_ids': []}
auction_taken()

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_taken" model="ir.ui.view">
<field name="name">auction.taken.form</field>
<field name="model">auction.taken</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Mark Lots">
<group colspan="4" >
<label string="Select lots which are Sold" colspan="4"/>
<field name="lot_ids" nolabel="1" colspan="4" domain="[('state','=','sold')]"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-ok" string="OK" name="_process" type="object" />
</group>
</form>
</field>
</record>
<record id="action_auction_taken" model="ir.actions.act_window">
<field name="name">Gestion emporte</field>
<field name="res_model">auction.taken</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_taken"/>
<field name="target">new</field>
</record>
<!-- <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"
/> -->
</data>
</openerp>

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,111 +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
invoice_form = '''<?xml version="1.0"?>
<form title="Paid ?">
<field name="amount"/>
<field name="objects"/>
<field name="number"/>
<label string="(Keep empty for automatic number)" colspan="2"/>
<field name="buyer_id"/>
</form>'''
invoice_fields = {
'amount': {'string':'Invoiced Amount', 'type':'float', 'required':True, 'readonly':True},
'objects': {'string':'# of objects', 'type':'integer', 'required':True, 'readonly':True},
'number': {'string':'Invoice Number', 'type':'char'},
'buyer_id':{'string': 'Buyer', 'type': 'many2one', 'relation':'res.partner'}
}
def _values(self,cr,uid, datas,context={}):
pool = pooler.get_pool(cr.dbname)
lots= pool.get('auction.lots').browse(cr,uid,datas['ids'])
# price = 0.0
amount_total=0.0
# pt_tax=pooler.get_pool(cr.dbname).get('account.tax')
for lot in lots:
buyer=lot and lot.ach_uid.id or False
amount_total+=lot.buyer_price
# taxes = lot.product_id.taxes_id
# if lot.author_right:
# taxes.append(lot.author_right)
# if lot.auction_id:
# taxes += lot.auction_id.buyer_costs
# tax=pt_tax.compute(cr,uid,taxes,lot.obj_price,1)
# for t in tax:
# amount_total+=t['amount']
# amount_total+=lot.obj_price
# up_auction=pooler.get_pool(cr.dbname).get('auction.lots').write(cr,uid,[lot.id],{'ach_uid':datas['form']['buyer_id']})
invoice_number = False
return {'objects':len(datas['ids']), 'amount':amount_total, 'number':invoice_number,'buyer_id':buyer}
def _makeInvoices(self, cr, uid, data, context):
newinv = []
pool = pooler.get_pool(cr.dbname)
order_obj = pool.get('auction.lots')
mod_obj = 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,data['ids'])
invoice_number=data['form']['number']
for lot in lots:
up_auction=pooler.get_pool(cr.dbname).get('auction.lots').write(cr,uid,[lot.id],{'ach_uid':data['form']['buyer_id']})
ids = order_obj.lots_invoice(cr, uid, data['ids'],context,data['form']['number'])
# ids = order_obj.lots_invoice(cr, uid, data['ids'],context,invoice_number)
cr.commit()
return {
'domain': "[('id','in', ["+','.join(map(str, ids))+"])]",
'name': 'Buyer invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'context': "{'type':'in_refund'}",
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
return {}
class make_invoice(wizard.interface):
states = {
'init' : {
'actions' : [_values],
'result' : {'type' : 'form',
'arch' : invoice_form,
'fields' : invoice_fields,
'state' : [('end', 'Cancel'),('invoice', 'Create invoices')]}
},
'invoice' : {
'actions' : [],
'result' : {'type' : 'action',
'action' : _makeInvoices}
},
}
make_invoice("auction.lots.make_invoice_buyer")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,105 +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
invoice_form = '''<?xml version="1.0"?>
<form title="Paid ?">
<field name="amount"/>
<field name="objects"/>
<field name="number" colspan="3"/>
</form>'''
invoice_fields = {
'amount': {'string':'Invoiced Amount', 'type':'float', 'required':True, 'readonly':True},
'objects': {'string':'# of objects', 'type':'integer', 'required':True, 'readonly':True},
'number': {'string':'Invoice Number', 'type':'integer'},
}
def _values(self,cr,uid, datas,context={}):
lots= pooler.get_pool(cr.dbname).get('auction.lots').browse(cr,uid,datas['ids'])
# service = netsvc.LocalService("object_proxy")
# lots = service.execute(cr,uid, 'auction.lots', 'read', datas['ids'])
# auction = service.execute(cr,uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0]
price = 0.0
amount_total=0.0
pt_tax=pooler.get_pool(cr.dbname).get('account.tax')
for lot in lots:
# taxes = lot.product_id.taxes_id
# if lot.bord_vnd_id.tax_id:
# taxes.append(lot.bord_vnd_id.tax_id)
# if lot.auction_id:
# taxes += lot.auction_id.seller_costs
# tax=pt_tax.compute(cr,uid,taxes,lot.obj_price,1)
# for t in tax:
# amount_total+=t['amount']
# amount_total+=lot.obj_price
amount_total+=lot.seller_price
#TODO: recuperer id next invoice (de la sequence)???
invoice_number = False
return {'objects':len(datas['ids']), 'amount':amount_total, 'number':invoice_number}
def _makeInvoices(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
order_obj = pool.get('auction.lots')
mod_obj = 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'])
newinv = []
ids = order_obj.seller_trans_create(cr, uid, data['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']
}
return {}
class make_invoice(wizard.interface):
states = {
'init' : {
'actions' : [_values],
'result' : {'type' : 'form',
'arch' : invoice_form,
'fields' : invoice_fields,
'state' : [('end', 'Cancel'),('invoice', 'Create invoices')]}
},
'invoice' : {
'actions' : [_makeInvoices],
'result' : {'type' : 'action',
'action' : _makeInvoices,
'state' : 'end'}
},
}
make_invoice("auction.lots.make_invoice")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,73 +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
from tools.misc import UpdateableStr
# Dossier
_lot_arch = """<?xml version="1.0"?>
<form string="Mark Lots" height="500" width="1000">
<label string="Select lots which are Sold" colspan="4"/>
<field name="lot_ids" nolabel="1" colspan="4" domain="[('state','=','sold')]"/>
</form>
"""
_lot_fields = {
'lot_ids': {'string':'Lots Emportes','relation':'auction.lots','type':'many2many'}
}
def _to_xml(s):
return s.replace('&','&amp;').replace('<','&lt;').replace('>','&gt;')
def _process(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
lot_obj = pool.get('auction.lots')
if data['form']['lot_ids']:
lot_obj.write(cr, uid, data['form']['lot_ids'][0][2], {'state':'taken_away'})
return {'lot_ids': []}
class wizard_reprint(wizard.interface):
states = {
'valid': {
'actions': [_process],
'result': {'type':'state', 'state':'init'}
},
'init': {
'actions': [],
'result': {
'type':'form',
'arch': _lot_arch,
'fields': _lot_fields,
'state': [
('valid',' OK ')
],
}
}
}
wizard_reprint('auction.taken')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,96 +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
import sql_db
auction_move = '''<?xml version="1.0"?>
<form string="Change Auction Date">
<group col="1" colspan="2">
<label string="Warning, this will erase the object adjudication price and its buyer !" colspan="2"/>
</group>
<newline/>
<field name="auction_id"/>
</form>'''
auction_move_fields = {
'auction_id': {'string':'Auction Date', 'type':'many2one', 'required':True, 'relation':'auction.dates'},
}
#def _auction_move_set(self, uid, datas):
# if datas['form']['auction_id']:
# cr = sql_db.db.cursor()
# cr.execute('update auction_lots set auction_id=%s, obj_price=NULL, ach_login=NULL, ach_uid=NULL, ach_pay_id=NULL, ach_inv_id=NULL, state=%s where id in ('+','.join(map(str, datas['ids']))+')', (str(datas['form']['auction_id']), 'draft'))
# cr.execute('delete from auction_bid_line where lot_id in ('+','.join(map(str, datas['ids']))+')')
# cr.commit()
# cr.close()
# return {}
def _top(self,cr,uid,datas,context={}):
refs = pooler.get_pool(cr.dbname).get('auction.lots')
rec_ids = refs.browse(cr,uid,datas['ids'])
for rec in rec_ids:
if not rec.auction_id:
raise wizard.except_wizard('Error !','You can not move a lot that has no auction date')
return {}
def _auction_move_set(self,cr,uid,datas,context={}):
if not (datas['form']['auction_id'] and len(datas['ids'])) :
return {}
refs = pooler.get_pool(cr.dbname).get('auction.lots')
rec_ids = refs.browse(cr,uid,datas['ids'])
line_ids= pooler.get_pool(cr.dbname).get('auction.bid_line').search(cr,uid,[('lot_id','in',datas['ids'])])
# pooler.get_pool(cr.dbname).get('auction.bid_line').unlink(cr, uid, line_ids)
for rec in rec_ids:
new_id=pooler.get_pool(cr.dbname).get('auction.lot.history').create(cr,uid,{
'auction_id':rec.auction_id.id,
'lot_id':rec.id,
'price': rec.obj_ret
})
up_auction=pooler.get_pool(cr.dbname).get('auction.lots').write(cr,uid,[rec.id],{
'auction_id':datas['form']['auction_id'],
'obj_ret':None,
'obj_price':None,
'ach_login':None,
'ach_uid':None,
'ach_inv_id':None,
'sel_inv_id':None,
'obj_num':None,
'state':'draft'})
return {}
class wiz_auc_lots_auction_move(wizard.interface):
states = {
'init': {
'actions': [_top],
'result': {'type': 'form', 'arch':auction_move, 'fields': auction_move_fields, 'state':[('set_date', 'Move to Auction date'),('end','Cancel')]}
},
'set_date': {
'actions': [_auction_move_set],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_auc_lots_auction_move('auction.lots.auction_move')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,103 +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
invoice_form = '''<?xml version="1.0"?>
<form string="Pay invoice">
<field name="amount"/>
<field name="dest_account_id"/>
<field name="journal_id"/>
<field name="period_id"/>
</form>'''
invoice_fields = {
'amount': {'string': 'Amount paid', 'type':'float', 'required':True},
'dest_account_id': {'string':'Payment to Account', 'type':'many2one', 'required':True, 'relation':'account.account', 'domain':[('type','=','cash')]},
'journal_id': {'string': 'Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
'period_id': {'string': 'Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
}
#def pay_n_check(self, cr, uid, data, context):
#
# auction = pool.get('auction.lots').browse(cr,uid,data['id'],context)
# try:
#
# for lot in auction:
#
# if not lot.auction_id :
# raise osv.except_osv("Error","No payment defined for this auction.")
# i=1
# tot= 0
# for payment in auction:
# if not payment.journal_id :
# raise osv.except_osv("Error","No journal defined for the payment line %d" % (i,))
# if not payment.ach_inv_id.amount :
# raise osv.except_osv("Error","No amount defined for the payment line %d." % (i,))
# i+=1
# tot+= payment.ach_inv_id.amount
# if abs(float(tot)) - abs(float(lot.obj_ret)) > 10**-6:
# raise osv.except_osv("Error","The amount paid does not match the total amount")
# else:
# for lot in auction:
# if not lot.journal_id :
# raise osv.except_osv("Error","Please choose a journal for the auction ("+lot.name+").")
# pool.get('auction.lots').create(cr,uid,{
# 'auction_id': lot.auction.id,
# 'journal_id': lot.journal_id,
#
# })
# except osv.except_osv, e:
# raise wizard.except_wizard(e.name, e.name)
# return True
def _pay_and_reconcile(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
lot = pool.get('auction.lots').browse(cr,uid,data['id'],context)
form = data['form']
account_id = form.get('writeoff_acc_id', False)
period_id = form.get('period_id', False)
journal_id = form.get('journal_id', False)
if lot.sel_inv_id:
p=pool.get('account.invoice').pay_and_reconcile(['lot.sel_inv_id.id'], form['amount'], form['dest_account_id'], journal_id, account_id, period_id, journal_id, context)
# lots.sel_inv_id.pay_and_reconcile(cr,uid,data[id], form['amount'], form['dest_account_id'], journal_id, account_id, period_id, journal_id, context)
return {}
class wiz_auc_lots_pay(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':invoice_form, 'fields': invoice_fields, 'state':[ ('pay','Pay'), ('end','Cancel')]}
},
'pay': {
'actions': [_pay_and_reconcile],
'result': {'type': 'state', 'state':'end'}
}}
wiz_auc_lots_pay('auction.pay.sel');
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,150 +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 urllib
sms_send_form = '''<?xml version="1.0"?>
<form title="%s">
<separator string="%s" colspan="4"/>
<field name="app_id"/>
<newline/>
<field name="user"/>
<field name="password"/>
<newline/>
<field name="text" colspan="3"/>
</form>''' % ('SMS - Gateway: clickatell', 'Bulk SMS send')
sms_send_fields = {
'app_id': {'string':'API ID', 'type':'char', 'required':True},
'user': {'string':'Login', 'type':'char', 'required':True},
'password': {'string':'Password', 'type':'char', 'required':True},
'text': {'string':'SMS Message', 'type':'text', 'required':True, 'value':'Les lots [lots] vous ont etes adjuges. -- Rops'}
}
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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 2
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import netsvc
import pooler
sms_send_form = '''<?xml version="1.0"?>
<form string="%s">
<separator string="%s" colspan="4"/>
<field name="app_id"/>
<newline/>
<field name="user"/>
<field name="password"/>
<newline/>
<field name="text" colspan="3"/>
</form>''' % ('SMS - Gateway: clickatell','Bulk SMS send')
sms_send_fields = {
'app_id': {'string':'API ID', 'type':'char', 'required':True},
'user': {'string':'Login', 'type':'char', 'required':True},
'password': {'string':'Password', 'type':'char', 'required':True},
'text': {'string':'SMS Message', 'type':'text', 'required':True}
}
def _sms_send(self, cr, uid, data, context):
service = netsvc.LocalService("object_proxy")
lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', data['ids'], ['obj_num','obj_price','ach_uid'])
res = service.execute(cr.dbname,uid, 'res.partner', 'read', [l['ach_uid'] for l in lots if l['ach_uid']], ['gsm'])
#res = service.execute(cr.dbname, uid, 'res.partner', 'read', data['ids'], ['gsm'])
# service = netsvc.LocalService("object_proxy")
# pool=pooler.get_pool(cr.dbname)
# lots=pool.get('auction.lots').browse(cr,uid,data['id'],context)
# r=lots.ach_uid.id
nbr = 0
for r in res:
to = r['mobile']
if to:
tools.smssend(data['form']['user'], data['form']['password'], data['form']['app_id'], unicode(data['form']['text'], 'utf-8').encode('latin1'), to)
nbr += 1
return {'sms_sent': nbr}
if to:
tools.smssend(data['form']['user'], data['form']['password'], data['form']['app_id'], unicode(data['form']['text'], 'utf-8').encode('latin1'), to)
nbr += 1
return {'sms_sent': nbr}
#
#def _sms_send(self, uid, datas):
# service = netsvc.LocalService("object_proxy")
# pool=pooler.ger_pool(cr.dbname)
# lots=pool.get('auction.lots').browse(cr,uid,datas['ids'],context)
# #lots = service.execute(uid, 'auction.lots', 'read', datas['ids'], ['obj_num','obj_price','ach_uid'])
# #part = service.execute(uid, 'res.partner', 'read', [l['ach_uid'] for l in lots if l['ach_uid']], ['gsm'])
#
# part =ach_uid.id
# part = map(lambda x: (x.id,x.mobile), part)
# for l in lots:
# part.append(str(l.obj_num)+'-%dEUR' % int(l.obj_price))
#
# for p in part.values():
# to = p.mobile
# if to:
# params = urllib.urlencode({'user': datas['form']['user'], 'password': datas['form']['password'], 'api_id': datas['form']['app_id'], 'text':unicode(datas['form']['text'].replace('[lots]',', '.join(p['lots'])), 'utf-8').encode('latin1'), 'to':to})
# f = urllib.urlopen("http://196.7.150.220/http/sendmsg", params)
# nbr+=1
# return {'sms_sent':nbr}
class lots_sms(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':sms_send_form, 'fields': sms_send_fields, 'state':[('send','Send SMS'), ('end','Cancel')]}
},
'send': {
'actions': [_sms_send],
'result': {'type': 'state', 'state':'end'}
}
}
lots_sms('auction.lots.sms_send');
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,109 +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="Pay objects">
<field name="amount"/>
<field name="statement_id1" domain="[('state','=','draft')]"/>
<field name="amount2"/>
<field name="statement_id2" domain="[('state','=','draft')]"/>
<field name="amount3"/>
<field name="statement_id3" domain="[('state','=','draft')]"/>
<newline/>
<field name="buyer_id"/>
<field name="total"/>
</form>'''
def _start(self,cr,uid,data,context):
pool = pooler.get_pool(cr.dbname)
rec=pool.get('auction.lots').browse(cr,uid,data['ids'],context)
amount1=0.0
for r in rec:
amount1+=r.buyer_price
buyer= r and r.ach_uid.id or False
if r.is_ok:
raise wizard.except_wizard('Error !', 'Some lots of the selection are already paid.')
return {'amount':amount1, 'total':amount1,'buyer_id':buyer}
pay_fields = {
'amount': {'string': 'Amount paid', 'type':'float'},
'buyer_id': {'string': 'Buyer', 'type': 'many2one', 'relation':'res.partner'},
'statement_id1': {'string':'Statement', 'type':'many2one', 'required':True, 'relation':'account.bank.statement'},
'amount2': {'string': 'Amount paid', 'type':'float'},
'statement_id2': {'string':'Statement', 'type':'many2one', 'relation':'account.bank.statement'},
'amount3': {'string': 'Amount paid', 'type':'float'},
'statement_id3': {'string':'Statement', 'type':'many2one', 'relation':'account.bank.statement'},
'total': {'string': 'Amount to paid', 'type':'float','readonly':True}
}
def _pay_and_reconcile(self, cr, uid, data, context):
if not abs(data['form']['total'] - (data['form']['amount']+data['form']['amount2']+data['form']['amount3']))<0.01:
rest=data['form']['total']-(data['form']['amount']+data['form']['amount2']+data['form']['amount3'])
raise wizard.except_wizard('Payment aborted !', 'You should pay all the total: "%.2f" are missing to accomplish the payment.' %(round(rest,2)))
pool = pooler.get_pool(cr.dbname)
lots = pool.get('auction.lots').browse(cr,uid,data['ids'],context)
ref_bk_s=pooler.get_pool(cr.dbname).get('account.bank.statement.line')
for lot in lots:
if data['form']['buyer_id']:
pool.get('auction.lots').write(cr,uid,[lot.id],{'ach_uid':data['form']['buyer_id']})
if not lot.auction_id:
raise wizard.except_wizard('Error !', 'No auction date for "%s": Please set one.'%(lot.name))
pool.get('auction.lots').write(cr,uid,[lot.id],{'is_ok':True})
for st,stamount in [('statement_id1','amount'),('statement_id2','amount2'),('statement_id3','amount3')]:
if data['form'][st]:
new_id=ref_bk_s.create(cr,uid,{
'name':'Buyer:'+str(lot.ach_login or '')+', auction:'+ lots[0].auction_id.name,
'date': time.strftime('%Y-%m-%d'),
'partner_id':data['form']['buyer_id'] or False,
'type':'customer',
'statement_id':data['form'][st],
'account_id':lot.auction_id.acc_income.id,
'amount':data['form'][stamount]
})
for lot in lots:
pool.get('auction.lots').write(cr,uid,[lot.id],{'statement_id':[(4,new_id)]})
return {}
class wiz_auc_lots_pay(wizard.interface):
states = {
'init': {
'actions': [_start],
'result': {'type': 'form', 'arch':pay_form, 'fields': pay_fields, 'state':[('end','Cancel'),('pay','Pay')]}
},
'pay': {
'actions': [_pay_and_reconcile],
'result': {'type': 'state', 'state':'end'}
}}
wiz_auc_lots_pay('auction.pay.buy')
# 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: