[MERGE]: merging from the development branch 1

bzr revid: mga@mga-20100328183036-f1uiews49uhntvgc
This commit is contained in:
Mantavya Gajjar
2010-03-29 00:00:36 +05:30
243 changed files with 10440 additions and 5965 deletions
+4 -4
View File
@@ -46,7 +46,7 @@
<field model="ir.model.fields" name="field_id" search="[('model','=','account.move'),('name','=','company_id')]"/>
<field name="operator">child_of</field>
<field name="operand">user.company_id.id</field>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
<field name="rule_group" ref="account_move_comp_rule_group"/>
</record>
@@ -60,7 +60,7 @@
<field model="ir.model.fields" name="field_id" search="[('model','=','account.move.line'),('name','=','company_id')]"/>
<field name="operator">child_of</field>
<field name="operand">user.company_id.id</field>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
<field name="rule_group" ref="account_move_line_comp_rule_group"/>
</record>
<record id="journal_period_comp_rule_group" model="ir.rule.group">
@@ -72,7 +72,7 @@
<field model="ir.model.fields" name="field_id" search="[('model','=','account.journal.period'),('name','=','company_id')]"/>
<field name="operator">child_of</field>
<field name="operand">user.company_id.id</field>
<field name="domain_force">['|','|',('company_id','=',False),('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]</field>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
<field name="rule_group" ref="journal_period_comp_rule_group"/>
</record>
@@ -85,7 +85,7 @@
<field model="ir.model.fields" name="field_id" search="[('model','=','account.journal'),('name','=','company_id')]"/>
<field name="operator">child_of</field>
<field name="operand">user.company_id.id</field>
<field name="domain_force">['|','|',('company_id','=',False),('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]</field>
<field name="domain_force">['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
<field name="rule_group" ref="journal_comp_rule_group"/>
</record>
<record id="analytic_journal_comp_rule_group" model="ir.rule.group">
+13
View File
@@ -38,6 +38,19 @@
'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',
'wizard/auction_catalog_flagey_view.xml',
# 'wizard/auction_aie_send_result_view.xml',
'wizard/auction_lots_buyer_map_view.xml',
'auction_view.xml',
'auction_report.xml',
'auction_wizard.xml'
+6 -6
View File
@@ -478,13 +478,13 @@ 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={}):
try:
ids = self.search(cr, user, [('obj_num','=',int(name))]+ args)
except:
ids = []
def name_search(self, cr, user, name, args=None, operator='ilike', context={}):
if not args:
args = []
ids = self.search(cr, user, [('obj_num','=',int(name))] + args)
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):
+4 -5
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>
+3 -85
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>
@@ -22,3 +22,13 @@
"access_report_object_encoded","report.object.encoded","model_report_object_encoded","base.group_user",1,0,0,0
"access_report_object_encoded_manager","report.object.encoded.manager","model_report_object_encoded_manager","base.group_user",1,0,0,0
"access_report_unclassified_objects","report.unclassified.objects","model_report_unclassified_objects","base.group_user",1,0,0,0
"access_auction_lots_able","auction.lots.able","model_auction_lots_able","base.group_user",1,0,0,0
"access_auction_lots_auction_move","auction.lots.auction.move","model_auction_lots_auction_move","base.group_user",1,0,0,0
"access_auction_lots_enable","auction.lots.enable","model_auction_lots_enable","base.group_user",1,0,0,0
"access_auction_lots_make_invoice_buyer","auction.lots.make.invoice.buyer","model_auction_lots_make_invoice_buyer","base.group_user",1,0,0,0
"access_auction_lots_make_invoice","auction.lots.make.invoice","model_auction_lots_make_invoice","base.group_user",1,0,0,0
"access_auction_lots_sms_send","auction.lots.sms.send","model_auction_lots_sms_send","base.group_user",1,0,0,0
"access_auction_pay_buy","auction.pay.buy","model_auction_pay_buy","base.group_user",1,0,0,0
"acess_auction_payer","auction.payer","model_auction_payer","base.group_user",1,0,0,0
"access_auction_pay_sel","auction.pay.sel","model_auction_payer_sel","base.group_user",1,0,0,0
"acess_auction_taken","auction.taken","model_auction_taken","base.group_user",1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
22 access_report_object_encoded report.object.encoded model_report_object_encoded base.group_user 1 0 0 0
23 access_report_object_encoded_manager report.object.encoded.manager model_report_object_encoded_manager base.group_user 1 0 0 0
24 access_report_unclassified_objects report.unclassified.objects model_report_unclassified_objects base.group_user 1 0 0 0
25 access_auction_lots_able auction.lots.able model_auction_lots_able base.group_user 1 0 0 0
26 access_auction_lots_auction_move auction.lots.auction.move model_auction_lots_auction_move base.group_user 1 0 0 0
27 access_auction_lots_enable auction.lots.enable model_auction_lots_enable base.group_user 1 0 0 0
28 access_auction_lots_make_invoice_buyer auction.lots.make.invoice.buyer model_auction_lots_make_invoice_buyer base.group_user 1 0 0 0
29 access_auction_lots_make_invoice auction.lots.make.invoice model_auction_lots_make_invoice base.group_user 1 0 0 0
30 access_auction_lots_sms_send auction.lots.sms.send model_auction_lots_sms_send base.group_user 1 0 0 0
31 access_auction_pay_buy auction.pay.buy model_auction_pay_buy base.group_user 1 0 0 0
32 acess_auction_payer auction.payer model_auction_payer base.group_user 1 0 0 0
33 access_auction_pay_sel auction.pay.sel model_auction_payer_sel base.group_user 1 0 0 0
34 acess_auction_taken auction.taken model_auction_taken base.group_user 1 0 0 0
+14 -19
View File
@@ -19,24 +19,19 @@
#
##############################################################################
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 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
import auction_catalog_flagey_report
#import auction_aie_send_result
import auction_lots_buyer_map
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
import netsvc
class auction_catalog_flagey(osv.osv_memory):
_name = 'auction.catalog.flagey'
_description = 'Auction Catalog Flagey'
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.
"""
res = super(auction_catalog_flagey, self).default_get(cr, uid, fields, context=context)
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)
for ab in v_ids:
if not ab.auction_id :
raise osv.except_osv('Error!','No Lots belong to this Auction Date')
pass
def print_report(self, cr, uid, ids, context):
"""
Prints auction catalog flagey report.
@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: Report
"""
datas = {'ids': context.get('active_ids',[])}
return {
'type': 'ir.actions.report.xml',
'report_name': 'auction.cat_flagy',
'datas': datas,
}
auction_catalog_flagey()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Auction Catalog Flagey Report -->
<record id="view_auction_catalog_flagey_wizard" model="ir.ui.view">
<field name="name">Auction Catalog Flagey</field>
<field name="model">auction.catalog.flagey</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Catalog Flagey Report">
<label string="Print Auction Catalog Flagey Report..."/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="print_report" string="Ok"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<act_window name="Auction Catalog Flagey"
res_model="auction.catalog.flagey"
src_model="auction.dates"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_auction_catalog_flagey_wizard"/>
</data>
</openerp>
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -15,35 +15,30 @@
# 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 osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
price_form = '''<?xml version="1.0"?>
<form string="Paid ?">
<field name="number"/>
</form>'''
price_fields = {
'number': {'string':'Number of products to produce', 'type':'integer', 'required':True},
}
class wizard_price(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':price_form, 'fields':price_fields, 'state':[('end','Cancel'),('price','Print product price') ]}
},
'price': {
'actions': [],
'result': {'type':'print', 'report':'product.price', 'state':'end'}
}
}
wizard_price('product_price')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
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 user’s ID for security checks,
@param ids: List of auction lots able’s IDs.
"""
self.pool.get('auction.lots').write(cr, uid, context['active_ids'], {'ach_emp':True})
return {}
auction_lots_able()
@@ -0,0 +1,30 @@
<?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>
<act_window name="Mark as taken away"
res_model="auction.lots.able"
src_model="auction.lots"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_auction_lots_able"/>
</data>
</openerp>
@@ -0,0 +1,88 @@
# -*- 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 user’s ID for security checks,
@param ids: List of auction lots auction move’s IDs.
"""
refs = self.pool.get('auction.lots')
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')
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)
for rec in rec_ids:
new_id = auction_lot_history_obj.create(cr, uid, {
'auction_id': rec.auction_id.id,
'lot_id': rec.id,
'price': rec.obj_ret
})
up_auction = auction_lots_obj.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:
@@ -0,0 +1,32 @@
<?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>
<act_window name="Change Auction Date"
res_model="auction.lots.auction.move"
src_model="auction.lots"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_auction_lots_auction_move"/>
</data>
</openerp>
@@ -0,0 +1,127 @@
# -*- 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 netsvc
import sql_db
from osv import osv,fields
class wiz_auc_lots_buyer_map(osv.osv_memory):
_name = 'auction.lots.buyer_map'
_description = 'Map Buyer'
_columns = {
'ach_login': fields.char('Buyer Username', size=64, required=True),
'ach_uid': fields.many2one('res.partner','Buyer', required=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.
"""
ids = context and context.get('active_ids',False) or False
assert ids, _('Active IDs not Found')
res = super(wiz_auc_lots_buyer_map,self).default_get(cr, uid, fields, context)
cr.execute('select id from auction_lots where (ach_uid is null and ach_login is not null) ')
v_ids = [x[0] for x in cr.fetchall()]
for rec in self.pool.get('auction.lots').browse(cr, uid, v_ids, context):
if (not rec.ach_uid or not rec.ach_login):
res.update(self._start(cr, uid, ids, context))
return res
res.update(self._start(cr, uid, ids, context))
return res
def _start(self, cr, uid, ids, context):
"""
Returns login if already there in the selected record.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: List of ids
@param context: A standard dictionary
@return: login field from current record.
"""
lots_obj = self.pool.get('auction.lots')
for rec in lots_obj.browse(cr, uid, ids, context):
if (len(ids)==1) and (not rec.ach_uid and not rec.ach_login):
raise osv.except_osv('Error', 'No buyer is set for this lot.')
if not rec.ach_uid and rec.ach_login:
return {'ach_login': rec.ach_login}
return {}
def buyer_map_set(self, cr, uid, ids, context):
"""
To map the buyer and login name.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: List of ids
@param context: A standard dictionary
@return:
"""
rec_ids = context and context.get('active_ids',False) or False
assert rec_ids, _('Active IDs not Found')
datas = self.read(cr, uid, ids[0],['ach_login','ach_uid'])
lots_obj = self.pool.get('auction.lots')
recs = lots_obj.browse(cr, uid, rec_ids, context)
for rec in recs:
if rec.ach_login==datas['ach_login']:
lots_obj.write(cr, uid, [rec.id], {'ach_uid': datas['ach_uid']}, context=context)
cr.commit()
return {}
def fields_view_get(self, cr, uid, view_id=None, view_type='form',
context=None, toolbar=False, submenu=False):
"""
Changes the view dynamically
@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: New arch of view.
"""
record_ids = context and context.get('active_ids', False) or False
res = super(wiz_auc_lots_buyer_map, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
lots_obj = self.pool.get('auction.lots')
if record_ids:
for lots in lots_obj.browse(cr, uid, record_ids):
if lots.ach_uid:
res['arch'] = """
<form title="Mapping Result">
<group col="2" colspan="2">
<label string="All objects are assigned to buyers !"/>
<newline/>
<button icon='gtk-cancel' special="cancel"
string="Done" />
</group>
</form>
"""
return res
wiz_auc_lots_buyer_map()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Auction lots send result -->
<record id="view_auction_buyer_map" model="ir.ui.view">
<field name="name">Map buyer username to Partners</field>
<field name="model">auction.lots.buyer_map</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Buyer Map" >
<field name="ach_login" colspan="4"/>
<newline/>
<field name="ach_uid" colspan="4"/>
<separator colspan="4"/>
<group col="4" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Exit" />
<button name="buyer_map_set" string="Update"
colspan="2" type="object" icon="gtk-go-forward" />
</group>
</form>
</field>
</record>
<act_window name="Map buyer username to Partners"
res_model="auction.lots.buyer_map"
src_model="auction.lots"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_auction_buyer_map"/>
</data>
</openerp>
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -15,35 +15,33 @@
# 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/>.
#
##############################################################################
import wizard
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
def _wo_check(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
current_auction=pool.get('auction.dates').browse(cr,uid,data['id'])
v_lots=pool.get('auction.lots').search(cr,uid,[('auction_id','=',current_auction.id)])
v_ids=pool.get('auction.lots').browse(cr,uid,v_lots)
for ab in v_ids:
if not ab.auction_id :
raise wizard.except_wizard('Error!','No Lots belong to this Auction Date')
return 'report'
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result' : {'type': 'choice', 'next_state': _wo_check }
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'auction.cat_flagy', 'state':'end'}
}
}
wizard_report('auction.catalog.flagey')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
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 user’s ID for security checks,
@param ids: List of auction lots enable’s IDs.
"""
self.pool.get('auction.lots').write(cr, uid, context['active_id'], {'ach_emp':False})
return {}
auction_lots_enable()
@@ -0,0 +1,34 @@
<?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>
<act_window name="Unmark as taken away"
res_model="auction.lots.enable"
src_model="auction.lots"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_auction_lots_enable"/>
</data>
</openerp>
@@ -0,0 +1,124 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
import netsvc
from tools.translate import _
class auction_lots_invoice(osv.osv_memory):
_name = 'auction.lots.invoice'
_description = "Auction Lots Invoice"
_columns = {
'amount': fields.float('Invoiced Amount', required=True, readonly=True),
'amount_topay': fields.float('Amount to pay', required=True, readonly=True),
'amount_paid': fields.float('Amount paid', readonly=True),
'objects': fields.integer('# of objects', required=True, readonly=True),
'ach_uid': fields.many2one('res.partner','Buyer Name', required=True ),
'number': fields.integer('Invoice Number'),
# 'tax_applied':{'string':'Tax Applied', 'type':'float', '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.
"""
res = super(auction_lots_invoice, self).default_get(cr, uid, fields, context=context)
service = netsvc.LocalService("object_proxy")
lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context.get('active_ids', []))
auction = service.execute(cr.dbname,uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0]
price = 0.0
price_topay = 0.0
price_paid = 0.0
#tax=data['form']['tax_applied']
# uid = False
for lot in lots:
price_lot = lot['obj_price'] or 0.0
costs = service.execute(cr.dbname, uid, 'auction.lots', 'compute_buyer_costs', [lot['id']])
price_lot += costs['amount']
# for cost in costs:
# price_lot += cost['amount']
price += price_lot
if lot['ach_uid']:
if uid and (lot['ach_uid'][0]<>uid):
raise osv.except_osv(_('UserError'), _('Two different buyers for the same invoice !\nPlease correct this problem before invoicing'))
uid = lot['ach_uid'][0]
elif lot['ach_login']:
refs = service.execute(uid, 'res.partner', 'search', [('ref','=',lot['ach_login'])])
if len(refs):
uid = refs[-1]
if 'ach_pay_id' in lot and lot['ach_pay_id']:
price_paid += price_lot
#*tax
else:
price_topay += price_lot
#*tax
#TODO: recuperer id next invoice (de la sequence)???
invoice_number = False
for lot in self.pool.get('auction.lots').browse(cr, uid, context.get('active_ids', [])):
if 'objects' in fields:
res.update({'objects':len(context.get('active_ids', []))})
if 'amount' in fields:
res.update({'amount': price})
if 'ach_uid' in fields:
res.update({'ach_uid': uid})
if 'amount_topay' in fields:
res.update({'amount_topay':price_topay})
if 'amount_paid' in fields:
res.update({'amount_paid':price_paid})
if 'number' in fields:
res.update({'number':invoice_number})
return res
def print_report(self, cr, uid, ids, context={}):
"""
Create an invoice report.
@param cr: the current row, from the database cursor.
@param uid: the current user’s ID for security checks.
@param ids: List of Auction lots make invoice buyer’s IDs
@return: dictionary of account invoice form.
"""
service = netsvc.LocalService("object_proxy")
datas = {'ids' : context.get('active_ids',[])}
res = self.read(cr, uid, ids, ['number','ach_uid'])
res = res and res[0] or {}
datas['form'] = res
# service.execute(cr.dbname, uid, 'auction.lots', 'lots_invoice_and_cancel_old_invoice', datas['ids'], datas['form']['number'], datas['form']['ach_uid'], 'invoice_open')
return {
'type' : 'ir.actions.report.xml',
'report_name':'auction.invoice',
'datas' : datas,
}
auction_lots_invoice()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Auction Lots Invoice Report -->
<record id="view_auction_lots_invoice_wizard" model="ir.ui.view">
<field name="name">auction.lots.invoice.wizard</field>
<field name="model">auction.lots.invoice</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Paid ?">
<field name="amount"/>
<field name="objects"/>
<field name="amount_topay"/>
<field name="amount_paid"/>
<newline/>
<field name="ach_uid"/>
<field name="number"/>
<label string="Let this invoice's number"/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="print_report" string="Ok"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<act_window name="Auction Lots Invoice"
res_model="auction.lots.invoice"
src_model="auction.dates"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_auction_lots_invoice_wizard"/>
</data>
</openerp>
@@ -0,0 +1,96 @@
# -*- 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 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.
"""
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', [])):
if 'amount' in fields:
res.update({'amount': lot.buyer_price})
if 'objects' in fields:
res.update({'objects': len(context['active_ids'])})
return res
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 user’s ID for security checks.
@param ids: List of Auction lots make invoice’s IDs
@return: dictionary of account invoice form.
"""
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']
}
_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()
@@ -0,0 +1,100 @@
# -*- 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 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.
"""
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', [])):
if 'amount' in fields:
res.update({'amount': lot.buyer_price})
if 'buyer_id' in fields:
res.update({'buyer_id': lot.ach_uid and lot.ach_uid.id or False})
if 'objects' in fields:
res.update({'objects': len(context['active_ids'])})
return res
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 user’s ID for security checks.
@param ids: List of Auction lots make invoice buyer’s IDs
@return: dictionary of account invoice form.
"""
newinv = []
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'])
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'])
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={
'number':lambda *a: False,
}
auction_lots_make_invoice_buyer()
@@ -0,0 +1,36 @@
<?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>
<act_window name="Invoice Buyer objects"
res_model="auction.lots.make.invoice.buyer"
src_model="auction.lots"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_auction_lots_make_invoice_buyer"/>
</data>
</openerp>
@@ -0,0 +1,33 @@
<?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>
<act_window name="Invoice Seller objects"
res_model="auction.lots.make.invoice"
src_model="auction.lots"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_auction_lots_make_invoice"/>
</data>
</openerp>
@@ -0,0 +1,78 @@
# -*- 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):
"""
to send sms
@param cr: the current row, from the database cursor.
@param uid: the current user’s ID for security checks.
@param ids: the ID or list of IDs
@param context: A standard dictionary
@return: number indicating the acknowledgement
"""
lot_obj = self.pool.get('auction.lots')
partner_obj = self.pool.get('res.partner')
partner_address_obj = self.pool.get('res.partner.address')
for datas in self.read(cr, uid, ids):
lots = lot_obj.read(cr, uid, context['active_ids'], ['obj_num','obj_price','ach_uid'])
res = partner_obj.read(cr, uid, [l['ach_uid'][0] for l in lots if l['ach_uid']], ['gsm'], context)
nbr = 0
for r in res:
add = partner_obj.address_get(cr, uid, [r['id']])['default']
addr = partner_address_obj.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:
@@ -0,0 +1,35 @@
<?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>
<act_window name="SMS Send"
res_model="auction.lots.sms.send"
src_model="auction.lots"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_auction_lots_sms_send"/>
</data>
</openerp>
+115
View File
@@ -0,0 +1,115 @@
# -*- 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 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.
"""
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', [])):
if 'amount' in fields:
res.update({'amount': lot.buyer_price})
if 'buyer_id' in fields:
res.update({'buyer_id': lot.ach_uid and lot.ach_uid.id or False})
if 'total' in fields:
res.update({'total': lot.buyer_price})
return res
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 user’s 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')
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 = lot_obj.browse(cr, uid, context['active_ids'], context)
ref_bk_s = bank_statement_line_obj
for lot in lots:
if datas['buyer_id']:
lot_obj.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))
lot_obj.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:
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:
@@ -0,0 +1,37 @@
<?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>
<act_window name="Pay objects of the buyer"
res_model="auction.pay.buy"
src_model="auction.lots"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_auction_pay_buy"/>
</data>
</openerp>
+62
View File
@@ -0,0 +1,62 @@
# -*- 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):
"""
Pay and Reconcile
@param cr: the current row, from the database cursor.
@param uid: the current user’s 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')
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 = invoice_obj.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()
@@ -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>
@@ -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 user’s ID for security checks,
@param ids: List of auction payer sel’s 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:
@@ -0,0 +1,43 @@
<?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>
<act_window name="Mark as paid for seller"
res_model="auction.payer.sel"
src_model="auction.lots"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_auction_payer_sel"/>
</data>
</openerp>
+57
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 user’s ID for security checks.
@param ids: List of Auction taken’s IDs
@return: dictionary of lot_ids fields with empty list
"""
lot_obj = self.pool.get('auction.lots')
for data in self.read(cr, uid, ids):
if data['lot_ids']:
lot_obj.write(cr, uid, data['lot_ids'], {'state':'taken_away'})
return {'lot_ids': []}
auction_taken()
@@ -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>
@@ -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:
@@ -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:
-73
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:
@@ -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:
@@ -1,107 +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
buyer_map = '''<?xml version="1.0"?>
<form title="Buyer Map">
<field name="ach_login"/>
<newline/>
<field name="ach_uid"/>
</form>'''
buyer_map_fields = {
'ach_login': {'string':'Buyer Username', 'type':'char', 'size':64, 'required':True},
'ach_uid': {'string':'Buyer', 'type':'many2one', 'required':True, 'relation':'res.partner'},
}
#
# Try to find an object not mapped
#
def _state_check(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
cr.execute('select id from auction_lots where (ach_uid is null and ach_login is not null) ')
v_ids=[x[0] for x in cr.fetchall()]
#ids_not_mapped=pool.get('auction.lots').search(cr,uid,[('rec.ach_uid','=',False)])
for rec in pool.get('auction.lots').browse(cr,uid,v_ids,context):
# if not rec.ach_uid and not rec.ach_login:
# raise wizard.except_wizard ('Error','No username is associated to this lot!')
if (not rec.ach_uid or not rec.ach_login):
return 'check'
return 'done'
def _start(self,cr,uid,datas,context):
pool = pooler.get_pool(cr.dbname)
for rec in pool.get('auction.lots').browse(cr,uid,datas['ids'],context):
if (len(datas['ids'])==1) and (not rec.ach_uid and not rec.ach_login):
raise wizard.except_wizard('Error', 'No buyer setted for this lot')
if not rec.ach_uid and rec.ach_login:
return {'ach_login': rec.ach_login}
for rec in pool.get('auction.lots').browse(cr,uid,datas['ids'],context):
if (not rec.ach_uid and rec.ach_login):
return {'ach_login': rec.ach_login}
return {}
def _buyer_map_set(self,cr, uid, datas,context):
pool = pooler.get_pool(cr.dbname)
recs=pool.get('auction.lots').browse(cr,uid,datas['ids'],context)
for rec in recs:
if rec.ach_login==datas['form']['ach_login']:
pool.get('auction.lots').write(cr, uid, [rec.id], {'ach_uid': datas['form']['ach_uid']}, context=context)
cr.commit()
return {'ach_login':False, 'ach_uid':False}
class wiz_auc_lots_buyer_map(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'choice', 'next_state':_state_check}
},
'check': {
'actions': [_start],
'result': {'type': 'form', 'arch':buyer_map, 'fields': buyer_map_fields, 'state':[('end','Exit'),('set_buyer', 'Update')]}
},
'set_buyer': {
'actions': [_buyer_map_set],
'result': {'type': 'state', 'state':'init'}
},
'done': {
'actions': [_start],
'result': {
'type': 'form',
'arch':'''<?xml version="1.0"?>
<form title="Mapping result">
<label string="All objects are assigned to buyers !"/>
</form>''',
'fields': {},
'state':[('end','Close')]}
}
}
wiz_auc_lots_buyer_map('auction.lots.buyer_map')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,106 +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
invoice_form = '''<?xml version="1.0"?>
<form title="Paid ?">
<field name="amount"/>
<field name="objects"/>
<field name="amount_topay"/>
<field name="amount_paid"/>
<!--field name= "tax_applied"/>-->
<newline/>
<field name="ach_uid" colspan="3"/>
<field name="number" colspan="3"/>
<field label="Let this invoice's number "/>
</form>'''
invoice_fields = {
'amount': {'string':'Invoiced Amount', 'type':'float', 'required':True, 'readonly':True},
'amount_topay': {'string':'Amount to pay', 'type':'float', 'required':True, 'readonly':True},
'amount_paid': {'string':'Amount paid', 'type':'float', 'readonly':True},
'objects': {'string':'# of objects', 'type':'integer', 'required':True, 'readonly':True},
'ach_uid': {'string':'Buyer Name', 'type':'many2one', 'required':True, 'relation':'res.partner'},
'number': {'string':'Invoice Number', 'type':'integer'},
#'tax_applied':{'string':'Tax Applied', 'type':'float', 'readonly':True},
}
def _get_value(self,cr,uid, datas,context={}):
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
price_topay = 0.0
price_paid = 0.0
#tax=data['form']['tax_applied']
uid = False
for lot in lots:
price_lot = lot['obj_price'] or 0.0
costs = service.execute(uid, 'auction.lots', 'compute_buyer_costs', [lot['id']])
for cost in costs:
price_lot += cost['amount']
price += price_lot
if lot['ach_uid']:
if uid and (lot['ach_uid'][0]<>uid):
raise wizard.except_wizard('UserError', ('Two different buyers for the same invoice !\nPlease correct this problem before invoicing', 'init'))
uid = lot['ach_uid'][0]
elif lot['ach_login']:
refs = service.execute(uid, 'res.partner', 'search', [('ref','=',lot['ach_login'])])
if len(refs):
uid = refs[-1]
if lot['ach_pay_id']:
price_paid += price_lot
#*tax
else:
price_topay += price_lot
#*tax
#TODO: recuperer id next invoice (de la sequence)???
invoice_number = False
return {'objects':len(datas['ids']), 'amount':price, 'ach_uid':uid, 'amount_topay':price_topay, 'amount_paid':price_paid, 'number':invoice_number}
def _invoice(self, uid, datas):
service = netsvc.LocalService("object_proxy")
service.execute(uid, 'auction.lots', 'lots_invoice_and_cancel_old_invoice', datas['ids'], datas['form']['number'], datas['form']['ach_uid'], 'invoice_open')
return {}
class wiz_auc_lots_invoice(wizard.interface):
states = {
'init': {
'actions': [_get_value],
'result': {'type': 'form', 'arch':invoice_form, 'fields': invoice_fields, 'state':[('invoice','Create Invoice'), ('end','Cancel')]}
},
'invoice': {
'actions': [_invoice],
'result': {'type': 'print', 'report':'auction.invoice', 'state':'end'}
}
}
wiz_auc_lots_invoice('auction.lots.invoice');
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-103
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:
-150
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:
-109
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:
-79
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:
+3
View File
@@ -64,6 +64,9 @@ class node_calendar(object):
def _get_ttag(self,cr):
return 'calendar-%d' % self.calendar_id
def get_dav_eprop(self,cr,ns,prop):
return None
class Calendar(osv.osv):
_inherit = 'basic.calendar'
+2 -2
View File
@@ -34,8 +34,8 @@
'init_xml': ['delivery_data.xml'],
'update_xml': [
'security/ir.model.access.csv',
'delivery_view.xml',
'delivery_wizard.xml',
'wizard/delivery_sale_order_view.xml',
'delivery_view.xml',
'partner_view.xml'
],
'demo_xml': ['delivery_demo.xml'],
-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard id="wizard_deliver_line_add" keyword="client_action_multi" model="sale.order" name="delivery.sale.order" string="Delivery Costs"/>
</data>
</openerp>
+82 -65
View File
@@ -20,77 +20,94 @@
##############################################################################
import time
import wizard
import ir
import pooler
from tools.translate import _
from tools.misc import UpdateableStr
from osv import osv, fields
delivery_form = UpdateableStr()
class make_delivery(osv.osv_memory):
_name = "delivery.sale.order"
_description = 'Make Delievery'
delivery_fields = {
'carrier_id' : {'string':'Delivery Method', 'type':'many2one', 'relation': 'delivery.carrier','required':True}
}
def _delivery_default(self, cr, uid, data, context):
order_obj = pooler.get_pool(cr.dbname).get('sale.order')
order = order_obj.browse(cr, uid, data['ids'])[0]
delivery_form.string="""<?xml version="1.0"?>
<form string="Create deliveries">
<separator colspan="4" string="Delivery Method" />
<field name="carrier_id" context="{'order_id': %d}"/>
</form>
""" % (data['id'],)
if not order.state in ('draft'):
raise wizard.except_wizard(_('Order not in draft state !'), _('The order state have to be draft to add delivery lines.'))
carrier_id = order.partner_id.property_delivery_carrier.id
return {'carrier_id': carrier_id}
def _delivery_set(self, cr, uid, data, context):
order_obj = pooler.get_pool(cr.dbname).get('sale.order')
line_obj = pooler.get_pool(cr.dbname).get('sale.order.line')
order_objs = order_obj.browse(cr, uid, data['ids'], context)
for order in order_objs:
grid_id = pooler.get_pool(cr.dbname).get('delivery.carrier').grid_get(cr, uid, [data['form']['carrier_id']],order.partner_shipping_id.id)
if not grid_id:
raise wizard.except_wizard(_('No grid avaible !'), _('No grid matching for this carrier !'))
grid_obj=pooler.get_pool(cr.dbname).get('delivery.grid')
grid = grid_obj.browse(cr, uid, [grid_id])[0]
taxes = grid.carrier_id.product_id.taxes_id
fpos = order.fiscal_position or False
taxes_ids = pooler.get_pool(cr.dbname).get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
line_obj.create(cr, uid, {
'order_id': order.id,
'name': grid.carrier_id.name,
'product_uom_qty': 1,
'product_uom': grid.carrier_id.product_id.uom_id.id,
'product_id': grid.carrier_id.product_id.id,
'price_unit': grid_obj.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context),
'tax_id': [(6,0,taxes_ids)],
'type': 'make_to_stock'
})
return {}
class make_delivery(wizard.interface):
states = {
'init' : {
'actions' : [_delivery_default],
'result' : {'type' : 'form', 'arch' : delivery_form, 'fields' : delivery_fields, 'state' : [('end', 'Cancel', 'gtk-cancel'),('delivery', 'Add Delivery Costs', 'gtk-ok') ]}
},
'delivery' : {
'actions' : [_delivery_set],
'result' : {'type' : 'state', 'state' : 'end'}
},
_columns = {
'carrier_id': fields.many2one('delivery.carrier','Delivery Method', required=True),
}
make_delivery("delivery.sale.order")
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.
"""
res = super(make_delivery, self).default_get(cr, uid, fields, context=context)
order_obj = self.pool.get('sale.order')
for order in order_obj.browse(cr, uid, context.get('active_ids', [])):
res.update({'carrier_id': order.partner_id.property_delivery_carrier.id})
return res
def view_init(self, cr , uid , fields, context=None):
order_obj = self.pool.get('sale.order')
for order in order_obj.browse(cr, uid, context.get('active_ids', [])):
if not order.state in ('draft'):
raise osv.except_osv(_('Order not in draft state !'), _('The order state have to be draft to add delivery lines.'))
pass
def delivery_set(self, cr, uid, ids, context):
"""
Adds delivery costs to Sale Order Line.
@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:
"""
rec_ids = context and context.get('active_ids',[])
order_obj = self.pool.get('sale.order')
line_obj = self.pool.get('sale.order.line')
grid_obj = self.pool.get('delivery.grid')
carrier_obj = self.pool.get('delivery.carrier')
acc_fp_obj = self.pool.get('account.fiscal.position')
order_objs = order_obj.browse(cr, uid, rec_ids, context)
for datas in self.browse(cr, uid, ids):
for order in order_objs:
grid_id = carrier_obj.grid_get(cr, uid, [datas.carrier_id.id],order.partner_shipping_id.id)
if not grid_id:
raise osv.except_osv(_('No grid available !'), _('No grid matching for this carrier !'))
if not order.state in ('draft'):
raise osv.except_osv(_('Order not in draft state !'), _('The order state have to be draft to add delivery lines.'))
grid = grid_obj.browse(cr, uid, grid_id)
taxes = grid.carrier_id.product_id.taxes_id
fpos = order.fiscal_position or False
taxes_ids = acc_fp_obj.map_tax(cr, uid, fpos, taxes)
line_obj.create(cr, uid, {
'order_id': order.id,
'name': grid.carrier_id.name,
'product_uom_qty': 1,
'product_uom': grid.carrier_id.product_id.uom_id.id,
'product_id': grid.carrier_id.product_id.id,
'price_unit': grid_obj.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context),
'tax_id': [(6,0,taxes_ids)],
'type': 'make_to_stock'
})
return {}
make_delivery()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Delivery Sale Order -->
<record id="view_make_delivery_wizard" model="ir.ui.view">
<field name="name">Delivery Costs</field>
<field name="model">delivery.sale.order</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create Deliveries">
<separator colspan="4" string="Delivery Method" />
<field name="carrier_id"/>
<newline/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="delivery_set" string="Add Delivery Costs"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<act_window name="Delivery Costs"
res_model="delivery.sale.order"
src_model="sale.order"
view_mode="form"
target="new"
key2="client_action_multi"
id="act_delivery_cost"/>
</data>
</openerp>
+2 -2
View File
@@ -162,7 +162,7 @@
<field name="arch" type="xml">
<tree string="Registration">
<field name="id"/>
<field name="create_date"/>
<field name="date"/>
<field name="event_id"/>
<field name="partner_id"/>
<field name="nb_register"/>
@@ -331,7 +331,7 @@
</record>
<record model="ir.actions.act_window" id="action_event_registration">
<field name="name">Registration by Event</field>
<field name="name">Events On Registrations</field>
<field name="res_model">report.event.registration</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
@@ -308,6 +308,17 @@
</field>
</field>
</record>
<record id="view_attendance_tree_who" model="ir.ui.view">
<field name="name">hr.attendance.tree</field>
<field name="model">hr.attendance</field>
<field name="type">tree</field>
<field name="inherit_id" ref="hr_attendance.view_attendance_who"/>
<field name="arch" type="xml">
<field name="action_desc" position="after">
<field name="sheet_id"/>
</field>
</field>
</record>
<act_window domain="[('sheet_id', '=', active_id)]" id="act_hr_timesheet_sheet_sheet_by_day" name="Timesheet by Account" res_model="hr_timesheet_sheet.sheet.account" src_model="hr_timesheet_sheet.sheet"/>
<!-- <act_window domain="[('sheet_id', '=', active_id)]" id="act_hr_timesheet_sheet_sheet_by_account" name="Timesheet by Day" res_model="hr_timesheet_sheet.sheet.day" src_model="hr_timesheet_sheet.sheet"/> -->
+1 -1
View File
@@ -21,8 +21,8 @@
import mrp
import stock
import product
import installer
import mrp_wizard
import wizard
import report
import company
+7 -1
View File
@@ -60,8 +60,14 @@
'security/ir.model.access.csv',
'mrp_workflow.xml',
'mrp_data.xml',
'mrp_wizard_view.xml',
'wizard/mrp_product_produce_view.xml',
'wizard/make_procurement_view.xml',
'wizard/change_production_qty_view.xml',
'wizard/orderpoint_procurement_view.xml',
'wizard/mrp_price_view.xml',
'wizard/mrp_workcenter_load_view.xml',
'mrp_view.xml',
'wizard/schedulers_all_view.xml',
'mrp_wizard.xml',
'mrp_report.xml',
'company_view.xml',
+140 -71
View File
@@ -134,6 +134,18 @@ class mrp_bom(osv.osv):
_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:
@param arg:
@return: True
"""
result = {}
for bom in self.browse(cr, uid, ids, context=context):
result[bom.id] = map(lambda x: x.id, bom.bom_lines)
@@ -145,6 +157,9 @@ class mrp_bom(osv.osv):
if sids:
bom2 = self.pool.get('mrp.bom').browse(cr, uid, sids[0], context=context)
result[bom.id] += map(lambda x: x.id, bom2.bom_lines)
print "name",name
print "arg",arg
print "result",result
return result
def _compute_type(self, cr, uid, ids, field_name, arg, context):
res = dict(map(lambda x: (x,''), ids))
@@ -189,6 +204,8 @@ class mrp_bom(osv.osv):
'child_ids': fields.function(_child_compute,relation='mrp.bom', method=True, string="BoM Hierarchy", type='many2many'),
'child_complete_ids': fields.function(_child_compute,relation='mrp.bom', method=True, string="BoM Hierarchy", type='many2many'),
'company_id': fields.many2one('res.company','Company',required=True),
'multi_level_bom': fields.boolean('Multi-level BoM'),
}
_defaults = {
'active': lambda *a: 1,
@@ -196,7 +213,8 @@ class mrp_bom(osv.osv):
'product_qty': lambda *a: 1.0,
'product_rounding': lambda *a: 1.0,
'type': lambda *a: 'normal',
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.bom', context=c)
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.bom', context=c),
'multi_level_bom': lambda *a: 0,
}
_order = "sequence"
_sql_constraints = [
@@ -298,11 +316,12 @@ class mrp_bom(osv.osv):
rev_ids = res[0]['revision_ids']
idx = 1
new_idx = []
bom_rev_obj = self.pool.get('mrp.bom.revision')
for rev_id in rev_ids:
if res[0]['revision_type'] == 'numeric':
self.pool.get('mrp.bom.revision').write(cr, uid, [rev_id], {'indice' : idx})
bom_rev_obj.write(cr, uid, [rev_id], {'indice' : idx})
else:
self.pool.get('mrp.bom.revision').write(cr, uid, [rev_id], {'indice' : "%c"%(idx+96,)})
bom_rev_obj.write(cr, uid, [rev_id], {'indice' : "%c"%(idx+96,)})
idx+=1
return True
@@ -375,30 +394,7 @@ class one2many_domain(fields.one2many):
class mrp_production(osv.osv):
_name = 'mrp.production'
_description = 'Production'
_date_name = 'date_planned'
def _get_sale_order(self,cr,uid,ids,field_name=False):
move_obj=self.pool.get('stock.move')
def get_parent_move(move_id):
move = move_obj.browse(cr,uid,move_id)
if move.move_dest_id:
return get_parent_move(move.move_dest_id.id)
return move_id
productions=self.read(cr,uid,ids,['id','move_prod_id'])
res={}
for production in productions:
res[production['id']]=False
if production.get('move_prod_id',False):
parent_move_line=get_parent_move(production['move_prod_id'][0])
if parent_move_line:
move = move_obj.browse(cr,uid,parent_move_line)
#TODO: fix me sale module can not be used here,
#as may be mrp can be installed without sale module
if field_name=='name':
res[production['id']]=move.sale_line_id and move.sale_line_id.order_id.name or False
if field_name=='client_order_ref':
res[production['id']]=move.sale_line_id and move.sale_line_id.order_id.client_order_ref or False
return res
_date_name = 'date_planned'
def _production_calc(self, cr, uid, ids, prop, unknow_none, context={}):
result = {}
@@ -424,11 +420,12 @@ class mrp_production(osv.osv):
result[prod.id] = prod.date_planned[:10]
return result
def _sale_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
return self._get_sale_order(cr,uid,ids,field_name='name')
def _sale_ref_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
return self._get_sale_order(cr,uid,ids,field_name='client_order_ref')
def _ref_calc(self, cr, uid, ids, field_names=None, arg=False, context={}):
res = {}
for f in field_names:
for order_id in ids:
res[order_id] = {f:False}
return res
_columns = {
'name': fields.char('Reference', size=64, required=True),
@@ -470,8 +467,8 @@ class mrp_production(osv.osv):
'hour_total': fields.function(_production_calc, method=True, type='float', string='Total Hours', multi='workorder'),
'cycle_total': fields.function(_production_calc, method=True, type='float', string='Total Cycles', multi='workorder'),
'sale_name': fields.function(_sale_name_calc, method=True, type='char', string='Sale Name', help='Indicate the name of sale order.'),
'sale_ref': fields.function(_sale_ref_calc, method=True, type='char', string='Sale Reference', help='Indicate the Customer Reference from sale order.'),
'sale_name': fields.function(_ref_calc, method=True, multi='sale_name', type='char', string='Sale Name', help='Indicate the name of sale order.'),
'sale_ref': fields.function(_ref_calc, method=True, multi='sale_ref', type='char', string='Sale Reference', help='Indicate the Customer Reference from sale order.'),
'company_id': fields.many2one('res.company','Company',required=True),
}
_defaults = {
@@ -533,15 +530,18 @@ class mrp_production(osv.osv):
def action_compute(self, cr, uid, ids, properties=[]):
results = []
bom_obj = self.pool.get('mrp.bom')
prod_line_obj = self.pool.get('mrp.production.product.line')
workcenter_line_obj = self.pool.get('mrp.production.workcenter.line')
for production in self.browse(cr, uid, ids):
cr.execute('delete from mrp_production_product_line where production_id=%s', (production.id,))
cr.execute('delete from mrp_production_workcenter_line where production_id=%s', (production.id,))
bom_point = production.bom_id
bom_id = production.bom_id.id
if not bom_point:
bom_id = self.pool.get('mrp.bom')._bom_find(cr, uid, production.product_id.id, production.product_uom.id, properties)
bom_id = bom_obj._bom_find(cr, uid, production.product_id.id, production.product_uom.id, properties)
if bom_id:
bom_point = self.pool.get('mrp.bom').browse(cr, uid, bom_id)
bom_point = bom_obj.browse(cr, uid, bom_id)
routing_id = bom_point.routing_id.id or False
self.write(cr, uid, [production.id], {'bom_id': bom_id, 'routing_id': routing_id})
@@ -552,32 +552,34 @@ class mrp_production(osv.osv):
# self.write(cr, uid, [production.id], {'location_src_id': bom_point.routing_id.location_id.id})
factor = production.product_qty * production.product_uom.factor / bom_point.product_uom.factor
res = self.pool.get('mrp.bom')._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, properties)
res = bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, properties)
results = res[0]
results2 = res[1]
for line in results:
line['production_id'] = production.id
self.pool.get('mrp.production.product.line').create(cr, uid, line)
prod_line_obj.create(cr, uid, line)
for line in results2:
line['production_id'] = production.id
self.pool.get('mrp.production.workcenter.line').create(cr, uid, line)
workcenter_line_obj.create(cr, uid, line)
return len(results)
def action_cancel(self, cr, uid, ids):
move_obj = self.pool.get('stock.move')
for production in self.browse(cr, uid, ids):
if production.move_created_ids:
self.pool.get('stock.move').action_cancel(cr, uid, [x.id for x in production.move_created_ids])
self.pool.get('stock.move').action_cancel(cr, uid, [x.id for x in production.move_lines])
move_obj.action_cancel(cr, uid, [x.id for x in production.move_created_ids])
move_obj.action_cancel(cr, uid, [x.id for x in production.move_lines])
self.write(cr, uid, ids, {'state':'cancel'}) #,'move_lines':[(6,0,[])]})
return True
#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):
move_obj = self.pool.get('stock.move')
self.write(cr, uid, ids, {'state':'ready'})
for production in self.browse(cr, uid, ids):
if production.move_prod_id:
self.pool.get('stock.move').write(cr, uid, [production.move_prod_id.id],
move_obj.write(cr, uid, [production.move_prod_id.id],
{'location_id':production.location_dest_id.id})
return True
@@ -596,7 +598,23 @@ class mrp_production(osv.osv):
res = False
return res
def do_produce(self, cr, uid, production_id, production_qty, production_mode, context=None):
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
"""
stock_mov_obj = self.pool.get('stock.move')
production = self.browse(cr, uid, production_id)
@@ -604,6 +622,7 @@ class mrp_production(osv.osv):
final_product_todo = []
if production_mode in ['consume','consume_produce']:
# To consume remaining qty of raw materials
consumed_products = {}
produced_qty = 0
for consumed_product in production.move_lines2:
@@ -628,6 +647,7 @@ class mrp_production(osv.osv):
stock_mov_obj.action_consume(cr, uid, [raw_product.id], rest_qty, production.location_src_id.id, context=context)
if production_mode == 'consume_produce':
# To produce remaining qty of final product
vals = {'state':'confirmed'}
final_product_todo = [x.id for x in production.move_created_ids]
stock_mov_obj.write(cr, uid, final_product_todo, vals)
@@ -663,6 +683,7 @@ class mrp_production(osv.osv):
def _costs_generate(self, cr, uid, production):
amount = 0.0
analytic_line_obj = self.pool.get('account.analytic.line')
for wc_line in production.workcenter_lines:
wc = wc_line.workcenter_id
if wc.costs_journal_id and wc.costs_general_account_id:
@@ -670,7 +691,7 @@ class mrp_production(osv.osv):
account = wc.costs_hour_account_id.id
if value and account:
amount += value
self.pool.get('account.analytic.line').create(cr, uid, {
analytic_line_obj.create(cr, uid, {
'name': wc_line.name+' (H)',
'amount': value,
'account_id': account,
@@ -683,7 +704,7 @@ class mrp_production(osv.osv):
account = wc.costs_cycle_account_id.id
if value and account:
amount += value
self.pool.get('account.analytic.line').create(cr, uid, {
analytic_line_obj.create(cr, uid, {
'name': wc_line.name+' (C)',
'amount': value,
'account_id': account,
@@ -712,6 +733,10 @@ class mrp_production(osv.osv):
def action_confirm(self, cr, uid, ids):
picking_id=False
proc_ids = []
seq_obj = self.pool.get('ir.sequence')
pick_obj = self.pool.get('stock.picking')
move_obj = self.pool.get('stock.move')
proc_obj = self.pool.get('mrp.procurement')
for production in self.browse(cr, uid, ids):
if not production.product_lines:
self.action_compute(cr, uid, [production.id])
@@ -725,7 +750,9 @@ class mrp_production(osv.osv):
pick_type = 'out'
address_id = routing_loc.address_id and routing_loc.address_id.id or False
routing_loc = routing_loc.id
picking_id = self.pool.get('stock.picking').create(cr, uid, {
pick_name = seq_obj.get(cr, uid, 'stock.picking.'+pick_type)
picking_id = pick_obj.create(cr, uid, {
'name': pick_name,
'origin': (production.origin or '').split(':')[0] +':'+production.name,
'type': pick_type,
'move_type': 'one',
@@ -750,7 +777,7 @@ class mrp_production(osv.osv):
'state': 'waiting',
'company_id': production.company_id.id,
}
res_final_id = self.pool.get('stock.move').create(cr, uid, data)
res_final_id = move_obj.create(cr, uid, data)
self.write(cr, uid, [production.id], {'move_created_ids': [(6, 0, [res_final_id])]})
moves = []
@@ -758,7 +785,7 @@ class mrp_production(osv.osv):
move_id=False
newdate = production.date_planned
if line.product_id.type in ('product', 'consu'):
res_dest_id = self.pool.get('stock.move').create(cr, uid, {
res_dest_id = move_obj.create(cr, uid, {
'name':'PROD:'+production.name,
'date_planned': production.date_planned,
'product_id': line.product_id.id,
@@ -773,7 +800,7 @@ class mrp_production(osv.osv):
'company_id': production.company_id.id,
})
moves.append(res_dest_id)
move_id = self.pool.get('stock.move').create(cr, uid, {
move_id = move_obj.create(cr, uid, {
'name':'PROD:'+production.name,
'picking_id':picking_id,
'product_id': line.product_id.id,
@@ -788,7 +815,7 @@ class mrp_production(osv.osv):
'state': 'waiting',
'company_id': production.company_id.id,
})
proc_id = self.pool.get('mrp.procurement').create(cr, uid, {
proc_id = proc_obj.create(cr, uid, {
'name': (production.origin or '').split(':')[0] + ':' + production.name,
'origin': (production.origin or '').split(':')[0] + ':' + production.name,
'date_planned': newdate,
@@ -1038,6 +1065,7 @@ class mrp_procurement(osv.osv):
def check_buy(self, cr, uid, ids):
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):
if procurement.product_id.product_tmpl_id.supply_method<>'buy':
return False
@@ -1048,7 +1076,7 @@ class mrp_procurement(osv.osv):
if user.company_id and user.company_id.partner_id:
if partner.id == user.company_id.partner_id.id:
return False
address_id = self.pool.get('res.partner').address_get(cr, uid, [partner.id], ['delivery'])['delivery']
address_id = partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery']
if not address_id:
cr.execute('update mrp_procurement set message=%s where id=%s', (_('No address defined for the supplier'), procurement.id))
return False
@@ -1061,6 +1089,7 @@ class mrp_procurement(osv.osv):
return False
def action_confirm(self, cr, uid, ids, context={}):
move_obj = self.pool.get('stock.move')
for procurement in self.browse(cr, uid, ids):
if procurement.product_qty <= 0.00:
raise osv.except_osv(_('Data Insufficient !'), _('Please check the Quantity of Requisition Order(s), it should not be less than 1!'))
@@ -1069,7 +1098,7 @@ class mrp_procurement(osv.osv):
source = procurement.location_id.id
if procurement.procure_method=='make_to_order':
source = procurement.product_id.product_tmpl_id.property_stock_procurement.id
id = self.pool.get('stock.move').create(cr, uid, {
id = move_obj.create(cr, uid, {
'name': 'PROC:'+procurement.name,
'location_id': source,
'location_dest_id': procurement.location_id.id,
@@ -1084,7 +1113,7 @@ class mrp_procurement(osv.osv):
else:
# TODO: check this
if procurement.procure_method=='make_to_stock' and procurement.move_id.state in ('waiting',):
id = self.pool.get('stock.move').write(cr, uid, [procurement.move_id.id], {'state':'confirmed'})
id = move_obj.write(cr, uid, [procurement.move_id.id], {'state':'confirmed'})
self.write(cr, uid, ids, {'state':'confirmed','message':''})
return True
@@ -1112,14 +1141,31 @@ class mrp_procurement(osv.osv):
return True
def action_produce_assign_product(self, cr, uid, ids, context={}):
produce_id = False
"""
This is action which call from workflow to assign production order to procuments
@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
"""
res = {}
company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
production_obj = self.pool.get('mrp.production')
move_obj = self.pool.get('stock.move')
wf_service = netsvc.LocalService("workflow")
for procurement in self.browse(cr, uid, ids):
res_id = procurement.move_id.id
loc_id = procurement.location_id.id
newdate = DateTime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - DateTime.RelativeDateTime(days=procurement.product_id.product_tmpl_id.produce_delay or 0.0)
newdate = newdate - DateTime.RelativeDateTime(days=company.manufacturing_lead)
produce_id = self.pool.get('mrp.production').create(cr, uid, {
produce_id = production_obj.create(cr, uid, {
'origin': procurement.origin,
'product_id': procurement.product_id.id,
'product_qty': procurement.product_qty,
@@ -1133,32 +1179,52 @@ class mrp_procurement(osv.osv):
'move_prod_id': res_id,
'company_id': procurement.company_id.id,
})
res[procurement.id] = produce_id
self.write(cr, uid, [procurement.id], {'state':'running'})
bom_result = self.pool.get('mrp.production').action_compute(cr, uid,
bom_result = production_obj.action_compute(cr, uid,
[produce_id], properties=[x.id for x in procurement.property_ids])
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr)
self.pool.get('stock.move').write(cr, uid, [res_id],
move_obj.write(cr, uid, [res_id],
{'location_id':procurement.location_id.id})
return produce_id
return res
def action_po_assign(self, cr, uid, ids, context={}):
purchase_id = False
"""
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
"""
res = {}
company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
partner_obj = self.pool.get('res.partner')
uom_obj = self.pool.get('product.uom')
pricelist_obj = self.pool.get('product.pricelist')
prod_obj = self.pool.get('product.product')
acc_pos_obj = self.pool.get('account.fiscal.position')
po_obj = self.pool.get('purchase.order')
for procurement in self.browse(cr, uid, ids):
res_id = procurement.move_id.id
partner = procurement.product_id.seller_ids[0].name
partner_id = partner.id
address_id = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['delivery'])['delivery']
address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery']
pricelist_id = partner.property_product_pricelist_purchase.id
uom_id = procurement.product_id.uom_po_id.id
qty = self.pool.get('product.uom')._compute_qty(cr, uid, procurement.product_uom.id, procurement.product_qty, uom_id)
qty = uom_obj._compute_qty(cr, uid, procurement.product_uom.id, procurement.product_qty, uom_id)
if procurement.product_id.seller_ids[0].qty:
qty=max(qty,procurement.product_id.seller_ids[0].qty)
price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, False, {'uom': uom_id})[pricelist_id]
price = pricelist_obj.price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, False, {'uom': uom_id})[pricelist_id]
newdate = DateTime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S')
newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead)
@@ -1167,7 +1233,7 @@ class mrp_procurement(osv.osv):
#Passing partner_id to context for purchase order line integrity of Line name
context.update({'lang':partner.lang, 'partner_id':partner_id})
product=self.pool.get('product.product').browse(cr,uid,procurement.product_id.id,context=context)
product = prod_obj.browse(cr,uid,procurement.product_id.id,context=context)
line = {
'name': product.partner_ref,
@@ -1181,11 +1247,11 @@ class mrp_procurement(osv.osv):
}
taxes_ids = procurement.product_id.product_tmpl_id.supplier_taxes_id
taxes = self.pool.get('account.fiscal.position').map_tax(cr, uid, partner.property_account_position, taxes_ids)
taxes = acc_pos_obj.map_tax(cr, uid, partner.property_account_position, taxes_ids)
line.update({
'taxes_id':[(6,0,taxes)]
})
purchase_id = self.pool.get('purchase.order').create(cr, uid, {
purchase_id = po_obj.create(cr, uid, {
'origin': procurement.origin,
'partner_id': partner_id,
'partner_address_id': address_id,
@@ -1195,12 +1261,14 @@ class mrp_procurement(osv.osv):
'company_id': procurement.company_id.id,
'fiscal_position': partner.property_account_position and partner.property_account_position.id or False
})
res[procurement.id] = purchase_id
self.write(cr, uid, [procurement.id], {'state':'running', 'purchase_id':purchase_id})
return purchase_id
return res
def action_cancel(self, cr, uid, ids):
todo = []
todo2 = []
move_obj = self.pool.get('stock.move')
for proc in self.browse(cr, uid, ids):
if proc.close_move:
if proc.move_id.state not in ('done','cancel'):
@@ -1209,9 +1277,9 @@ class mrp_procurement(osv.osv):
if proc.move_id and proc.move_id.state=='waiting':
todo.append(proc.move_id.id)
if len(todo2):
self.pool.get('stock.move').action_cancel(cr, uid, todo2)
move_obj.action_cancel(cr, uid, todo2)
if len(todo):
self.pool.get('stock.move').write(cr, uid, todo, {'state':'assigned'})
move_obj.write(cr, uid, todo, {'state':'assigned'})
self.write(cr, uid, ids, {'state':'cancel'})
wf_service = netsvc.LocalService("workflow")
for id in ids:
@@ -1234,10 +1302,11 @@ class mrp_procurement(osv.osv):
return res
def action_done(self, cr, uid, ids):
move_obj = self.pool.get('stock.move')
for procurement in self.browse(cr, uid, ids):
if procurement.move_id:
if procurement.close_move and (procurement.move_id.state <> 'done'):
self.pool.get('stock.move').action_done(cr, uid, [procurement.move_id.id])
move_obj.action_done(cr, uid, [procurement.move_id.id])
res = self.write(cr, uid, ids, {'state':'done', 'date_close':time.strftime('%Y-%m-%d')})
wf_service = netsvc.LocalService("workflow")
for id in ids:
+46
View File
@@ -165,6 +165,7 @@
<record id="mrp_bom_0" model="mrp.bom">
<field name="name">Regular processor config</field>
<field name="sequence">1</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="routing_id" ref="mrp_routing_2"/>
@@ -174,6 +175,7 @@
<record id="mrp_bom_1" model="mrp.bom">
<field name="name">Assembly Basic+ PC</field>
<field name="sequence">5</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="routing_id" ref="mrp_routing_0"/>
@@ -181,18 +183,21 @@
</record>
<record id="mrp_bom_2" model="mrp.bom">
<field name="name">Assembly Medium PC</field>
<field name="sequence">8</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field model="product.product" name="product_id" search="[('default_code','=','PC3')]"/>
</record>
<record id="mrp_bom_3" model="mrp.bom">
<field name="name">Assembly Customizable PC</field>
<field name="sequence">11</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field model="product.product" name="product_id" search="[('default_code','=','PC4')]"/>
</record>
<record id="mrp_bom_4" model="mrp.bom">
<field name="name">HDD on demand</field>
<field name="sequence">14</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">phantom</field>
@@ -200,6 +205,7 @@
</record>
<record id="mrp_bom_5" model="mrp.bom">
<field name="name">RAM on demand</field>
<field name="sequence">18</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">phantom</field>
@@ -207,6 +213,7 @@
</record>
<record id="mrp_bom_6" model="mrp.bom">
<field name="name">HDD on demand</field>
<field name="sequence">21</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">phantom</field>
@@ -214,6 +221,7 @@
</record>
<record id="mrp_bom_7" model="mrp.bom">
<field name="name">HDD on demand</field>
<field name="sequence">25</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">phantom</field>
@@ -221,6 +229,7 @@
</record>
<record id="mrp_bom_8" model="mrp.bom">
<field name="name">HDD Seagate</field>
<field name="sequence">26</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -228,6 +237,7 @@
</record>
<record id="mrp_bom_9" model="mrp.bom">
<field name="name">Assembly Basic PC</field>
<field name="sequence">29</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="routing_id" ref="mrp_routing_0"/>
@@ -236,12 +246,14 @@
</record>
<record id="mrp_bom_10" model="mrp.bom">
<field name="name">Complete PC with peripherals</field>
<field name="sequence">33</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field model="product.product" name="product_id" search="[('default_code','=','PC0')]"/>
</record>
<record id="mrp_bom_11" model="mrp.bom">
<field name="name">RAM on demand</field>
<field name="sequence">36</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">phantom</field>
@@ -250,6 +262,7 @@
<record id="mrp_bom_13" model="mrp.bom">
<field name="name">High Speed Processor + main board on demand</field>
<field name="sequence">38</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field model="product.product" name="product_id" search="[('default_code','=','CPU2')]"/>
@@ -258,6 +271,7 @@
<record id="mrp_bom_kit" model="mrp.bom">
<field name="code">KIT</field>
<field name="name">Kit Mouse</field>
<field name="sequence">40</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -266,6 +280,7 @@
</record>
<record id="mrp_bom_clavier" model="mrp.bom">
<field name="name">Keyboard</field>
<field name="sequence">42</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_kit"/>
@@ -273,6 +288,7 @@
</record>
<record id="mrp_bom_mouse" model="mrp.bom">
<field name="name">Mouse</field>
<field name="sequence">44</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_kit"/>
@@ -280,6 +296,7 @@
</record>
<record id="mrp_bom_16" model="mrp.bom">
<field name="name">Moon PC</field>
<field name="sequence">45</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_10"/>
@@ -287,6 +304,7 @@
</record>
<record id="mrp_bom_18" model="mrp.bom">
<field name="name">Mainboard ASUStek A7N8X</field>
<field name="sequence">49</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_13"/>
@@ -294,6 +312,7 @@
</record>
<record id="mrp_bom_19" model="mrp.bom">
<field name="name">Processor AMD Athlon 2200+</field>
<field name="sequence">51</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_13"/>
@@ -301,6 +320,7 @@
</record>
<record id="mrp_bom_1900" model="mrp.bom">
<field name="name">Regular Case Fan</field>
<field name="sequence">54</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_13"/>
@@ -308,6 +328,7 @@
</record>
<record id="mrp_bom_23" model="mrp.bom">
<field name="name">DDR 256MB PC333</field>
<field name="sequence">57</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_11"/>
@@ -315,6 +336,7 @@
</record>
<record id="mrp_bom_1901" model="mrp.bom">
<field name="name">DDR 512MB PC400</field>
<field name="sequence">59</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_13"/>
@@ -322,6 +344,7 @@
</record>
<record id="mrp_bom_22" model="mrp.bom">
<field name="name">DDR 1024MB PC400</field>
<field name="sequence">61</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_5"/>
@@ -329,6 +352,7 @@
</record>
<record id="mrp_bom_24" model="mrp.bom">
<field name="name">HDD Seagate 7200.8 80GB</field>
<field name="sequence">64</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_7"/>
@@ -336,6 +360,7 @@
</record>
<record id="mrp_bom_25" model="mrp.bom">
<field name="name">HDD Seagate 7200.8 120GB</field>
<field name="sequence">66</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -344,6 +369,7 @@
</record>
<record id="mrp_bom_26" model="mrp.bom">
<field name="name">RAM on demand</field>
<field name="sequence">69</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_3"/>
@@ -351,6 +377,7 @@
</record>
<record id="mrp_bom_27" model="mrp.bom">
<field name="name">HDD on demand</field>
<field name="sequence">73</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_3"/>
@@ -358,6 +385,7 @@
</record>
<record id="mrp_bom_28" model="mrp.bom">
<field name="name">ATX middle-size case</field>
<field name="sequence">76</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -366,6 +394,7 @@
</record>
<record id="mrp_bom_29" model="mrp.bom">
<field name="name">Processor on demand</field>
<field name="sequence">79</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -374,6 +403,7 @@
</record>
<record id="mrp_bom_30" model="mrp.bom">
<field name="name">ATX Middle-size case</field>
<field name="sequence">81</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -382,6 +412,7 @@
</record>
<record id="mrp_bom_31" model="mrp.bom">
<field name="name">HDD Seagate 7200.8 80GB</field>
<field name="sequence">83</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -390,6 +421,7 @@
</record>
<record id="mrp_bom_32" model="mrp.bom">
<field name="name">High speed processor config</field>
<field name="sequence">85</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -398,6 +430,7 @@
</record>
<record id="mrp_bom_33" model="mrp.bom">
<field name="name">HDD Seagate 7200.8 120GB</field>
<field name="sequence">87</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -406,6 +439,7 @@
</record>
<record id="mrp_bom_34" model="mrp.bom">
<field name="name">Regular processor config</field>
<field name="sequence">89</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -414,6 +448,7 @@
</record>
<record id="mrp_bom_35" model="mrp.bom">
<field name="name">ATX middle-size case</field>
<field name="sequence">92</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -422,6 +457,7 @@
</record>
<record id="mrp_bom_36" model="mrp.bom">
<field name="name">HDD Seagate 7200.8 120GB</field>
<field name="sequence">95</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -430,6 +466,7 @@
</record>
<record id="mrp_bom_processor" model="mrp.bom">
<field name="name">processor</field>
<field name="sequence">98</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -438,6 +475,7 @@
</record>
<record id="mrp_bom_38" model="mrp.bom">
<field name="name">mainboard</field>
<field name="sequence">101</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -446,6 +484,7 @@
</record>
<record id="mrp_bom_fan" model="mrp.bom">
<field name="name">fan</field>
<field name="sequence">105</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -454,6 +493,7 @@
</record>
<record id="mrp_bom_ram" model="mrp.bom">
<field name="name">RAM</field>
<field name="sequence">108</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -462,6 +502,7 @@
</record>
<record id="mrp_bom_41" model="mrp.bom">
<field name="name">Regular processor config</field>
<field name="sequence">111</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -470,6 +511,7 @@
</record>
<record id="mrp_bom_42" model="mrp.bom">
<field name="name">HDD Seagate 7200.8 80GB</field>
<field name="sequence">113</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -478,6 +520,7 @@
</record>
<record id="mrp_bom_43" model="mrp.bom">
<field name="name">ATX Middle-size case</field>
<field name="sequence">115</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
@@ -487,6 +530,7 @@
<record id="mrp_bom_kit2" model="mrp.bom">
<field name="code">KIT</field>
<field name="sequence">118</field>
<field name="name">Kit Keyboard + Mouse</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
@@ -496,6 +540,7 @@
</record>
<record id="mrp_bom_mouse2" model="mrp.bom">
<field name="name">Mouse</field>
<field name="sequence">121</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_kit2"/>
@@ -503,6 +548,7 @@
</record>
<record id="mrp_bom_clavier2" model="mrp.bom">
<field name="name">Keyboard</field>
<field name="sequence">123</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_kit2"/>
+32 -25
View File
@@ -5,10 +5,10 @@
<menuitem icon="terp-mrp" id="base.menu_mrp_root" name="Manufacturing"
groups="group_mrp_user,group_mrp_manager" sequence="3"/>
<menuitem id="menu_mrp_reordering" name="Automatic Procurements" parent="stock.menu_stock_root" sequence="4"/>
<menuitem id="menu_mrp_manufacturing" name="Manufacturing" parent="base.menu_mrp_root" sequence="1"/>
<menuitem id="menu_mrp_manufacturing" name="Manufacturing" parent="base.menu_mrp_root" sequence="1"/>
<menuitem name="Control" id="menu_mrp_control" parent="base.menu_mrp_root" sequence="3" />
<menuitem name="Master Data"
<menuitem name="Master Data"
id="menu_mrp_bom"
parent="base.menu_mrp_root"
sequence="5" />
@@ -242,19 +242,21 @@
<field name="arch" type="xml">
<form string="Bill of Material">
<group colspan="4" col="6">
<field name="product_id" on_change="onchange_product_id(product_id, name)" select="1"/>
<field name="name" select="1"/>
<field name="code" select="1"/>
<field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/>
<field name="product_id" on_change="onchange_product_id(product_id, name)" select="1"/>
<field name="name" select="1"/>
<field name="code" select="1"/>
<field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/>
</group>
<newline/>
<field name="product_uom"/>
<field name="product_qty"/>
<newline/>
<field name="product_uos" groups="product.group_uos"/>
<field name="product_uos_qty" groups="product.group_uos"/>
<field name="routing_id" select="2" groups="base.group_extended"/>
<field name="type" groups="base.group_extended"/>
<group colspan="4" col="6">
<field name="product_uom"/>
<field name="product_qty"/>
<field name="multi_level_bom"/>
</group>
<notebook colspan="4">
<page string="General Information">
<field colspan="4" name="bom_lines" nolabel="1" widget="one2many_list"/>
@@ -274,6 +276,9 @@
<field name="product_efficiency"/>
<field colspan="4" name="property_ids" nolabel="2" groups="base.group_extended"/>
</page>
<page string="Multi-Level BoM" attrs="{'invisible':[('multi_level_bom','=',False)]}">
<field colspan="4" name="child_ids" nolabel="1" string="BoM Hierarchy"/>
</page>
</notebook>
</form>
</field>
@@ -286,6 +291,7 @@
<field name="field_parent">child_complete_ids</field>
<field name="arch" type="xml">
<tree string="BoM Structure" colors="blue:method">
<field name="sequence" invisible="1"/>
<field name="name"/>
<field name="code"/>
<field name="product_id"/>
@@ -438,15 +444,7 @@
<field name="cycle_total" operator="+"/>
</graph>
</field>
</record>
<wizard
string="Change Product Qty."
model="mrp.production"
name="change_production_qty"
id="mrp.wizard_change_production_qty"
keyword="client_action_multi"
multi="True"/>
</record>
<record id="mrp_production_form_view" model="ir.ui.view">
<field name="name">mrp.production.form</field>
@@ -463,7 +461,7 @@
<group colspan="2" col="3">
<field name="product_uom"/>
<button type="action"
name="%(mrp.wizard_change_production_qty)d"
name="%(mrp.action_change_production_qty)d"
string="Change Qty" states="ready,confirmed" />
</group>
<label string="" colspan="2"/>
@@ -489,6 +487,7 @@
<field name="product_qty" string="Qty"/>
<field name="product_uom" string="UOM"/>
<field name="location_id" string="Source Loc."/>
<field name="state" invisible="1"/>
<button name="%(stock.move_consume)d"
string="Consume Products" type="action"
@@ -506,7 +505,7 @@
<tree string="Consumed Products" editable="bottom" colors="red:scraped==True">
<field name="product_id" readonly="1"/>
<field name="product_qty" readonly="1" string="Qty"/>
<field name="product_uom" readonly="1" string="UOM"/>
<field name="product_uom" readonly="1" string="UOM"/>
<field name="location_dest_id" readonly="1" string="Destination Loc."/>
<field name="prodlot_id" />
<field name="state" invisible="1"/>
@@ -940,6 +939,7 @@
<tree string="Minimum Stock Rules">
<field name="name"/>
<field name="warehouse_id"/>
<field name="location_id"/>
<field name="product_id"/>
<field name="product_uom"/>
<field name="product_min_qty"/>
@@ -954,11 +954,18 @@
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Minimum Stock Rules Search">
<field name="name" select="1" />
<field name="warehouse_id" select="1" widget="selection"/>
<field name="location_id" select="1" />
<field name="company_id" select="1" widget="selection"/>
<field name="product_id" select="1"/>
<group col="10" colspan="4">
<field name="name" select="1" />
<field name="warehouse_id" select="1" widget="selection"/>
<field name="location_id" select="1" />
<field name="company_id" select="1" widget="selection"/>
<field name="product_id" select="1"/>
</group>
<newline/>
<group expand="1" string="Group By..." colspan="4" col="10">
<filter string="Warehouse" icon="terp-stock" domain="[]" context="{'group_by':'warehouse_id'}"/>
<filter string="Location" icon="terp-stock" domain="[]" context="{'group_by':'location_id'}"/>
</group>
</search>
</field>
</record>
-28
View File
@@ -1,35 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard id="wiz_mrp_proc0" model="mrp.procurement" string="Compute Schedulers" name="mrp.procurement.compute.all"/>
<menuitem id="menu_mrp_scheduler" name="Schedulers" parent="base.menu_mrp_root" sequence="4"/>
<menuitem action="wiz_mrp_proc0" id="mrp_Sched_all" parent="mrp.menu_mrp_scheduler" type="wizard" sequence="90"/>
<!--
<menuitem action="wiz_mrp_proc1" id="menu_wiz_mrp_proc1" parent="mrp.mrp_Sched_all" type="wizard"/>
-->
<wizard id="wiz_mrp_proc2" model="mrp.procurement" string="Compute Stock Minimum Rules Only" name="mrp.procurement.orderpoint.compute"/>
<!--
<menuitem action="wiz_mrp_proc2" id="menu_wiz_mrp_proc2" parent="mrp.mrp_Sched_all" type="wizard"/>
-->
<wizard id="wizard_workcenter_load" model="mrp.workcenter" name="mrp.workcenter.load" string="Work Center load"/>
<wizard id="wizard_price" menu="False" model="product.product" name="product_price" string="Product Cost Structure"/>
<record id="ir_project_cost_structure" model="ir.values">
<field eval="'client_print_multi'" name="key2"/>
<field eval="'product.product'" name="model"/>
<field name="name">Product Cost Structure</field>
<field eval="'ir.actions.wizard,%d'%wizard_price" name="value"/>
<field eval="True" name="object"/>
</record>
<wizard
string="Requisition Request"
model="product.product"
name="product.product.procurement"
keyword="client_action_multi"
id="product_procurement_wizard"/>
</data>
</openerp>
+70
View File
@@ -0,0 +1,70 @@
# -*- 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 _
class product_product(osv.osv):
_inherit = "product.product"
def do_change_standard_price(self, cr, uid, ids, datas, context={}):
#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
if bom.bom_lines:
for sbom in bom.bom_lines:
price += _compute_price(sbom) * sbom.product_qty
else:
no_child_bom = bom_obj.search(cr, uid, [('product_id', '=', bom.product_id.id), ('bom_id', '=', False)])
if no_child_bom and bom.id not in no_child_bom:
other_bom = bom_obj.browse(cr, uid, no_child_bom)[0]
if not other_bom.product_id.calculate_price:
price += _compute_price(other_bom) * other_bom.product_qty
else:
price += other_bom.product_id.standard_price
else:
price += bom.product_id.standard_price
if bom.routing_id:
for wline in bom.routing_id.workcenter_lines:
wc = wline.workcenter_id
cycle = wline.cycle_nbr
hour = (wc.time_start + wc.time_stop + cycle * wc.time_cycle) * (wc.time_efficiency or 1.0)
price += wc.costs_cycle * cycle + wc.costs_hour * hour
price = product_uom_obj._compute_price(cr, uid, bom.product_uom.id, price, bom.product_id.uom_id.id)
if bom.bom_lines:
self.write(cr, uid, [bom.product_id.id], {'standard_price' : price/bom.product_qty})
if bom.product_uom.id != bom.product_id.uom_id.id:
price = product_uom_obj._compute_price(cr, uid, bom.product_uom.id, price, bom.product_id.uom_id.id)
return price
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()
+6 -6
View File
@@ -134,9 +134,9 @@ class report_custom(report_int):
# select workcenters
cr.execute(
"SELECT id, name FROM mrp_workcenter " \
"WHERE id=ANY(%s)" \
"ORDER BY mrp_workcenter.id" ,(ids,))
"SELECT mw.id, rs.name FROM mrp_workcenter mw, resource_resource rs " \
"WHERE mw.id=ANY(%s) and mw.resource_id=rs.id " \
"ORDER BY mw.id" ,(ids,))
workcenters = cr.dictfetchall()
data = []
@@ -144,13 +144,13 @@ class report_custom(report_int):
vals = []
for workcenter in workcenters:
cr.execute("SELECT SUM(mrp_production_workcenter_line.hour) AS hours, SUM(mrp_production_workcenter_line.cycle) AS cycles, \
mrp_workcenter.name AS name, mrp_workcenter.id AS id \
FROM mrp_production_workcenter_line, mrp_production, mrp_workcenter \
resource_resource.name AS name, mrp_workcenter.id AS id \
FROM mrp_production_workcenter_line, mrp_production, mrp_workcenter, resource_resource \
WHERE (mrp_production_workcenter_line.production_id=mrp_production.id) \
AND (mrp_production_workcenter_line.workcenter_id=mrp_workcenter.id) \
AND (mrp_workcenter.id=%s) \
AND (mrp_production.date_planned BETWEEN %s AND %s) \
GROUP BY mrp_production_workcenter_line.workcenter_id, mrp_workcenter.name, mrp_workcenter.id \
GROUP BY mrp_production_workcenter_line.workcenter_id, resource_resource.name, mrp_workcenter.id \
ORDER BY mrp_workcenter.id", (workcenter['id'], dates[date]['start'] + ' 00:00:00', dates[date]['stop'] + ' 23:59:59'))
res = cr.dictfetchall()
if not res:
+1 -1
View File
@@ -195,7 +195,7 @@ class mrp_procurement(osv.osv):
qty = max(op.product_min_qty, op.product_max_qty)-prods
reste = qty % op.qty_multiple
if reste > 0:
qty += op.qty_multiple - reste
qty += op.qty_multiple - reste
newdate = DateTime.now() + DateTime.RelativeDateTime(
days=int(op.product_id.seller_delay))
if op.product_id.supply_method == 'buy':
+6
View File
@@ -32,6 +32,12 @@
"access_mrp_production_stock_worker","mrp.production stock_worker","model_mrp_production","stock.group_stock_user",1,0,0,0
"access_mrp_installer","mrp.installer","model_mrp_installer","mrp.group_mrp_user",1,0,0,0
"access_mrp_product_produce","mrp.product.produce","model_mrp_product_produce","mrp.group_mrp_user",1,0,0,0
"access_mrp_make_procurement","make.procurement","model_make_procurement","mrp.group_mrp_user",1,0,0,0
"access_mrp_change_production_qty","change.production.qty","model_change_production_qty","mrp.group_mrp_user",1,0,0,0
"access_mrp_procurement_compute_all","mrp.procurement.compute.all","model_mrp_procurement_compute_all","mrp.group_mrp_user",1,0,0,0
"access_mrp_procurement_orderpoint_compute","mrp.procurement.orderpoint.compute","model_mrp_procurement_orderpoint_compute","mrp.group_mrp_user",1,0,0,0
"access_mrp_production_order","mrp.production.order","model_mrp_production_order","mrp.group_mrp_user",1,0,0,0
"access_report_workcenter_load","report.workcenter.load","model_report_workcenter_load","mrp.group_mrp_manager",1,0,0,0
"access_report_mrp_inout","report.mrp.inout","model_report_mrp_inout","mrp.group_mrp_manager",1,0,0,0
"access_mrp_product_price","mrp.product_price","model_mrp_product_price","mrp.group_mrp_manager",1,0,0,0
"access_mrp_workcenter_load","mrp.workcenter.load","model_mrp_workcenter_load","mrp.group_mrp_manager",1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
32 access_mrp_production_stock_worker mrp.production stock_worker model_mrp_production stock.group_stock_user 1 0 0 0
33 access_mrp_installer mrp.installer model_mrp_installer mrp.group_mrp_user 1 0 0 0
34 access_mrp_product_produce mrp.product.produce model_mrp_product_produce mrp.group_mrp_user 1 0 0 0
35 access_mrp_make_procurement make.procurement model_make_procurement mrp.group_mrp_user 1 0 0 0
36 access_mrp_change_production_qty change.production.qty model_change_production_qty mrp.group_mrp_user 1 0 0 0
37 access_mrp_procurement_compute_all mrp.procurement.compute.all model_mrp_procurement_compute_all mrp.group_mrp_user 1 0 0 0
38 access_mrp_procurement_orderpoint_compute mrp.procurement.orderpoint.compute model_mrp_procurement_orderpoint_compute mrp.group_mrp_user 1 0 0 0
39 access_mrp_production_order mrp.production.order model_mrp_production_order mrp.group_mrp_user 1 0 0 0
40 access_report_workcenter_load report.workcenter.load model_report_workcenter_load mrp.group_mrp_manager 1 0 0 0
41 access_report_mrp_inout report.mrp.inout model_report_mrp_inout mrp.group_mrp_manager 1 0 0 0
42 access_mrp_product_price mrp.product_price model_mrp_product_price mrp.group_mrp_manager 1 0 0 0
43 access_mrp_workcenter_load mrp.workcenter.load model_mrp_workcenter_load mrp.group_mrp_manager 1 0 0 0
+7 -6
View File
@@ -19,14 +19,15 @@
#
##############################################################################
import wizard_orderpoint_procurement
import mrp_product_produce
import orderpoint_procurement
import wizard_procurement
import wizard_schedulers_all
import wizard_price
import wizard_workcenter_load
import schedulers_all
import mrp_price
import mrp_workcenter_load
import wizard_track_prod
import wizard_change_production_qty
import make_procurement
import change_production_qty
import make_procurement_product
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+106
View File
@@ -0,0 +1,106 @@
# -*- 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 time
import ir
from osv.osv import except_osv
from osv import fields, osv
import netsvc
from tools.translate import _
class change_production_qty(osv.osv_memory):
_name = 'change.production.qty'
_description = 'Change Quantity of Products'
_columns = {
'product_qty': fields.float('Product Qty', required=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.
"""
res = super(change_production_qty, self).default_get(cr, uid, fields, context=context)
prod_obj = self.pool.get('mrp.production')
prod = prod_obj.browse(cr, uid, context.get('active_id'))
if 'product_qty' in fields:
res.update({'product_qty': prod.product_qty})
return res
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:
"""
record_id = context and context.get('active_id',False)
assert record_id, _('Active Id is not found')
prod_obj = self.pool.get('mrp.production')
product_lines_obj = self.pool.get('mrp.production.product.line')
bom_obj = self.pool.get('mrp.bom')
for wiz_qty in self.browse(cr, uid, ids):
prod = prod_obj.browse(cr, uid,record_id)
prod_obj.write(cr, uid,prod.id, {'product_qty': wiz_qty.product_qty})
prod_obj.action_compute(cr, uid, [prod.id])
move_lines_obj = self.pool.get('stock.move')
for move in prod.move_lines:
bom_point = prod.bom_id
bom_id = prod.bom_id.id
if not bom_point:
bom_id = bom_obj._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id)
if not bom_id:
raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
prod_obj.write(cr, uid, [prod.id], {'bom_id': bom_id})
bom_point = sbom_obj.browse(cr, uid, [bom_id])[0]
if not bom_id:
raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor
res = bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, [])
for r in res[0]:
if r['product_id']== move.product_id.id:
move_lines_obj.write(cr, uid,move.id, {'product_qty' : r['product_qty']})
for m in prod.move_created_ids:
move_lines_obj.write(cr, uid,m.id, {'product_qty': wiz_qty.product_qty})
return {}
change_production_qty()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Change Product Quantity -->
<record id="view_change_production_qty_wizard" model="ir.ui.view">
<field name="name">Change Product Qty</field>
<field name="model">change.production.qty</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Change Product Qty">
<field name="product_qty"/>
<newline/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="change_prod_qty" string="Validate"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<record id="action_change_production_qty" model="ir.actions.act_window">
<field name="name">Change Product Qty</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">change.production.qty</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
-102
View File
@@ -1,102 +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 pooler
import netsvc
import time
def _get_default(obj, cr, uid, data, context=None):
pool = pooler.get_pool(cr.dbname)
product = pool.get('product.product').browse(cr, uid, data['id'], context)
return {'product_id': product.id, 'uom_id':product.uom_id.id, 'qty':1.0}
def make_procurement(obj, cr, uid, data, context=None):
'''Create procurement'''
pool = pooler.get_pool(cr.dbname)
wh = pool.get('stock.warehouse').browse(cr, uid, data['form']['warehouse_id'], context)
user = pool.get('res.users').browse(cr, uid, uid, context)
procure_id = pool.get('mrp.procurement').create(cr, uid, {
'name':'INT:'+str(user.login),
'date_planned':data['form']['date_planned'],
'product_id':data['form']['product_id'],
'product_qty':data['form']['qty'],
'product_uom':data['form']['uom_id'],
'location_id':wh.lot_stock_id.id,
'procure_method':'make_to_order',
}, context=context)
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr)
return {}
class MakeProcurement(wizard.interface):
'''Wizard that create a procurement from a product form'''
done_form = """<?xml version="1.0"?>
<form string="Make Requisition">
<label string="Your procurement request has been sent !"/>
</form>"""
procurement_form = """<?xml version="1.0"?>
<form string="Internal Requisition Request">
<label string="This wizard will plan the procurement for this product. This procurement may generate task, production orders or purchase orders." align="0.0" colspan="4"/>
<field name="product_id"/>
<field name="warehouse_id"/>
<field name="qty"/>
<field name="uom_id"/>
<field name="date_planned"/>
</form>"""
procurement_fields = {
'qty': {'string': 'Quantity', 'type': 'float', 'digits':(16,2), 'required': True},
'product_id': {'string': 'product', 'type': 'many2one', 'relation': 'product.product', 'required': True, 'readonly':1},
'uom_id': {'string': 'Unit of Measure', 'type': 'many2one', 'relation': 'product.uom', 'required':True},
'warehouse_id': {'string': 'Warehouse', 'type': 'many2one', 'relation':'stock.warehouse', 'required':True},
'date_planned': {'string': 'Planned Date', 'type': 'date', 'required':True, 'default': lambda *args: time.strftime('%Y-%m-%d')}
}
states = {
'init': {
'actions': [_get_default],
'result': {'type': 'form', 'arch': procurement_form, 'fields': procurement_fields,
'state': [
('end', 'Cancel'),
('create', 'Ask New Products')
]
}
},
'done': {
'actions': [],
'result': {'type': 'form', 'arch': done_form, 'fields': {},
'state': [
('end', 'Close'),
]
}
},
'create': {
'actions': [],
'result': {'type': 'action', 'action': make_procurement, 'state': 'done'}
}
}
MakeProcurement('product.product.procurement')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,134 @@
# -*- 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 netsvc
import time
from osv import fields, osv
class make_procurement(osv.osv_memory):
_name = 'make.procurement'
_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
"""
product = self.pool.get('product.product').browse(cr, uid, prod_id)
return {'value': {'uom_id': product.uom_id.id}}
_columns = {
'qty': fields.float('Quantity', digits=(16,2), required=True),
'product_id': fields.many2one('product.product', 'Product', required=True, readonly=1),
'uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True),
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
'date_planned': fields.date('Planned Date', required=True),
}
_defaults = {
'date_planned': lambda *args: time.strftime('%Y-%m-%d'),
'qty': lambda *args: 1.0,
}
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.
"""
user = self.pool.get('res.users').browse(cr, uid, uid, context).login
wh_obj = self.pool.get('stock.warehouse')
procurement_obj = self.pool.get('mrp.procurement')
wf_service = netsvc.LocalService("workflow")
data_obj = self.pool.get('ir.model.data')
for proc in self.browse(cr, uid, ids):
wh = wh_obj.browse(cr, uid, proc.warehouse_id.id, context)
procure_id = procurement_obj.create(cr, uid, {
'name':'INT: '+str(user),
'date_planned': proc.date_planned,
'product_id': proc.product_id.id,
'product_qty': proc.qty,
'product_uom': proc.uom_id.id,
'location_id': wh.lot_stock_id.id,
'procure_method':'make_to_order',
})
wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr)
id2 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_tree_view')
id3 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_form_view')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
if id3:
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
return {
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'mrp.procurement',
'res_id' : procure_id,
'views': [(id3,'form'),(id2,'tree')],
'type': 'ir.actions.act_window',
}
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.
"""
record_id = context and context.get('active_id', False) or False
res = super(make_procurement, self).default_get(cr, uid, fields, context=context)
product_id = self.pool.get('product.product').browse(cr, uid, record_id, context=context).id
if 'product_id' in fields:
res.update({'product_id':product_id})
return res
make_procurement()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Make Procurement -->
<record id="view_make_procurment_wizard" model="ir.ui.view">
<field name="name">Requisition Request</field>
<field name="model">make.procurement</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Requisition Request">
<label string="This wizard will plan the procurement for this product. This procurement may generate task, production orders or purchase orders." colspan="4"/>
<field name="product_id" on_change="onchange_product_id(product_id)"/>
<field name="qty"/>
<field name="uom_id"/>
<field name="date_planned"/>
<field name="warehouse_id" colspan="4"/>
<newline/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="make_procurement" string="Ask New Products"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<act_window name="Requisition Request"
res_model="make.procurement"
src_model="product.product"
view_mode="form"
target="new"
key2="client_action_multi"
id="act_make_procurement"/>
</data>
</openerp>
@@ -19,34 +19,37 @@
#
##############################################################################
import wizard
from osv import fields, osv
_time_unit_form = '''<?xml version="1.0"?>
<form string="Select time unit">
<field name="time_unit"/>
<newline/>
<field name="measure_unit"/>
</form>'''
_time_unit_fields = {
'time_unit': {'string':'Type of period', 'type':'selection', 'selection':[('day', 'Day by day'),('week', 'Per week'),('month', 'Per month')], 'required':True},
'measure_unit': {'string':'Amount measuring unit', 'type':'selection', 'selection':[('hours', 'Amount in hours'),('cycles', 'Amount in cycles')], 'required':True},
}
class wizard_mrp_workcenter(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':_time_unit_form, 'fields':_time_unit_fields, 'state':[('end','Cancel'),('report','Print') ]},
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'mrp.workcenter.load', 'state':'end'},
},
class mrp_price(osv.osv_memory):
_name = 'mrp.product_price'
_description = 'Product Price'
_columns = {
'number': fields.integer('Number of products to produce', required=True),
}
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
"""
datas = {'ids' : context.get('active_ids',[])}
res = self.read(cr, uid, ids, ['number'])
res = res and res[0] or {}
datas['form'] = res
return {
'type' : 'ir.actions.report.xml',
'report_name':'product.price',
'datas' : datas,
}
wizard_mrp_workcenter('mrp.workcenter.load')
mrp_price()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+33
View File
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Product Cost Structure Report -->
<record id="view_mrp_product_price_wizard" model="ir.ui.view">
<field name="name">Product Cost Structure</field>
<field name="model">mrp.product_price</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Paid ?">
<field name="number"/>
<newline/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="print_report" string="Print"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<act_window name="Product Cost Structure"
res_model="mrp.product_price"
src_model="product.product"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_mrp_product_price_wizard"/>
</data>
</openerp>
@@ -34,6 +34,16 @@ 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
"""
prod = self.pool.get('mrp.production').browse(cr, uid,
context['active_id'], context=context)
done = 0.0
@@ -47,11 +57,22 @@ 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:
"""
prod_obj = self.pool.get('mrp.production')
move_ids = context['active_ids']
for data in self.read(cr, uid, ids):
for move_id in move_ids:
prod_obj.do_produce(cr, uid, move_id,
prod_obj.action_produce(cr, uid, move_id,
data['product_qty'], data['mode'], context=context)
return {}
+57
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
class mrp_workcenter_load(osv.osv_memory):
_name = 'mrp.workcenter.load'
_description = 'Workcenter Load'
_columns = {
'time_unit': fields.selection([('day', 'Day by day'),('week', 'Per week'),('month', 'Per month')],'Type of period', required=True),
'measure_unit': fields.selection([('hours', 'Amount in hours'),('cycles', 'Amount in cycles')],'Amount measuring unit', required=True),
}
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
"""
datas = {'ids' : context.get('active_ids',[])}
res = self.read(cr, uid, ids, ['time_unit','measure_unit'])
res = res and res[0] or {}
datas['form'] = res
return {
'type' : 'ir.actions.report.xml',
'report_name':'mrp.workcenter.load',
'datas' : datas,
}
mrp_workcenter_load()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Work Center Load Report -->
<record id="view_mrp_workcenter_load_wizard" model="ir.ui.view">
<field name="name">Work Center Load</field>
<field name="model">mrp.workcenter.load</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select time unit">
<field name="time_unit"/>
<newline/>
<field name="measure_unit"/>
<newline/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="print_report" string="Print"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<act_window name="Work Center Load"
res_model="mrp.workcenter.load"
src_model="mrp.workcenter"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_mrp_workcenter_load_wizard"/>
</data>
</openerp>
@@ -0,0 +1,71 @@
# -*- 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/>.
#
##############################################################################
#
# Order Point Method:
# - Order if the virtual stock of today is bellow the min of the defined order point
#
import threading
from osv import fields,osv
class procurement_compute(osv.osv_memory):
_name = 'mrp.procurement.orderpoint.compute'
_description = 'Automatic Order Point'
_columns = {
'automatic': fields.boolean('Automatic Orderpoint', help='If the stock of a product is under 0, it will act like an orderpoint'),
}
_defaults = {
'automatic' : lambda *a: False,
}
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
"""
proc_obj = self.pool.get('mrp.procurement')
for proc in self.browse(cr, uid, ids):
proc_obj._procure_orderpoint_confirm(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname, context=context)
return {}
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
"""
threaded_calculation = threading.Thread(target=self._procure_calculation_orderpoint, args=(cr, uid, ids, context))
threaded_calculation.start()
return {}
procurement_compute()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Compute Stock Minimum Rules Only -->
<record id="view_procurement_compute_wizard" model="ir.ui.view">
<field name="name">Compute Stock Minimum Rules Only</field>
<field name="model">mrp.procurement.orderpoint.compute</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Parameters">
<field name="automatic"/>
<separator colspan="4"/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="procure_calculation" string="Compute Stock"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<act_window name="Compute Stock Minimum Rules Only"
res_model="mrp.procurement.orderpoint.compute"
src_model="mrp.procurement"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_procurement_compute"/>
</data>
</openerp>
+68
View File
@@ -0,0 +1,68 @@
# -*- 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 threading
from osv import osv, fields
class procurement_compute(osv.osv_memory):
_name = 'mrp.procurement.compute.all'
_description = 'Compute all schedulers'
_columns = {
'automatic': fields.boolean('Automatic orderpoint',help='Triggers an automatic procurement for all products that have a virtual stock under 0. You should probably not use this option, we suggest using a MTO configuration on products.'),
}
_defaults ={
'automatic': lambda *a: False,
}
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
"""
proc_obj = self.pool.get('mrp.procurement')
for proc in self.browse(cr, uid, ids):
proc_obj.run_scheduler(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname,\
context=context)
return {}
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
"""
threaded_calculation = threading.Thread(target=self._procure_calculation_all, args=(cr, uid, ids, context))
threaded_calculation.start()
return {}
procurement_compute()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+37
View File
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Compute Schedulers -->
<record id="view_compute_schedulers_wizard" model="ir.ui.view">
<field name="name">Compute Schedulers</field>
<field name="model">mrp.procurement.compute.all</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Scheduler Parameters">
<field name="automatic"/>
<separator colspan="4"/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="procure_calculation" string="Compute Schedulers"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<act_window name="Compute Schedulers"
res_model="mrp.procurement.compute.all"
src_model="mrp.procurement"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_compute_schedulers"/>
<menuitem id="menu_mrp_scheduler" name="Schedulers" parent="base.menu_mrp_root" sequence="4"/>
<menuitem action="action_compute_schedulers" id="mrp_Sched_all" parent="mrp.menu_mrp_scheduler" sequence="90"/>
</data>
</openerp>
@@ -1,117 +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 time
import wizard
import ir
import pooler
from osv.osv import except_osv
from osv import fields,osv
import netsvc
from tools.translate import _
form1 = '''<?xml version="1.0"?>
<form string="Change Product Qty">
<field name="product_qty"/>
</form>'''
form1_fields={
'product_qty': {'string': 'Product Qty', 'type':'float', 'required':True},
}
def _get_qty(self,cr,uid, data, state):
prod_obj = pooler.get_pool(cr.dbname).get('mrp.production')
prod = prod_obj.browse(cr, uid,data['ids'])[0]
form1_fields['product_qty']['default']=prod.product_qty
return {}
def _get_states(self, cr, uid, data, context):
prod_obj = pooler.get_pool(cr.dbname).get('mrp.production')
prod = prod_obj.browse(cr, uid,data['ids'])[0]
if prod.state in ('cancel', 'done'):
raise wizard.except_wizard(_('Warning !'), _('The production is in "%s" state. You can not change the production quantity anymore') % (prod.state).upper() )
return 'end'
if prod.state in ('draft'):
#raise wizard.except_wizard('Warning !', 'The production is in "%s" state. You can change the production quantity directly...!!!' % (prod.state).upper() )
return 'end'
else:
return 'confirm'
def _change_prod_qty(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
prod_obj = pool.get('mrp.production')
prod = prod_obj.browse(cr, uid,data['ids'])[0]
prod_obj.write(cr, uid,prod.id, {'product_qty' : data['form']['product_qty']})
prod_obj.action_compute(cr, uid, [prod.id])
move_lines_obj = pool.get('stock.move')
for move in prod.move_lines:
bom_point = prod.bom_id
bom_id = prod.bom_id.id
if not bom_point:
bom_id = pool.get('mrp.bom')._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id)
if not bom_id:
raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
self.write(cr, uid, [prod.id], {'bom_id': bom_id})
bom_point = pool.get('mrp.bom').browse(cr, uid, [bom_id])[0]
if not bom_id:
raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor
res = pool.get('mrp.bom')._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, [])
for r in res[0]:
if r['product_id']== move.product_id.id:
move_lines_obj.write(cr, uid,move.id, {'product_qty' : r['product_qty']})
product_lines_obj = pool.get('mrp.production.product.line')
for m in prod.move_created_ids:
move_lines_obj.write(cr, uid,m.id, {'product_qty' : data['form']['product_qty']})
return {}
class change_production_qty(wizard.interface):
states = {
'init' : {
'actions' : [],
'result' : {'type' : 'choice', 'next_state' : _get_states}
},
'confirm' : {
'actions' : [_get_qty],
'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state':[('end','Cancel'),('validate','Validate')]}
},
'validate': {
'actions': [],
'result': {'type':'action', 'action':_change_prod_qty, 'state':'end'}
},
'end' : {
'actions' : [],
'result': {'type': 'state', 'state': 'end'},
},
}
change_production_qty('change_production_qty')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -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/>.
#
##############################################################################
#
# Order Point Method:
# - Order if the virtual stock of today is bellow the min of the defined order point
#
import wizard
import threading
import pooler
parameter_form = '''<?xml version="1.0"?>
<form string="Parameters" colspan="4">
<field name="automatic" />
</form>'''
parameter_fields = {
'automatic': {'string': 'Automatic orderpoint', 'type': 'boolean', 'help': 'If the stock of a product is under 0, it will act like an orderpoint', 'default': lambda *a: False},
}
def _procure_calculation_orderpoint(self, db_name, uid, data, context):
db, pool = pooler.get_db_and_pool(db_name)
cr = db.cursor()
try:
proc_obj = pool.get('mrp.procurement')
automatic = data['form']['automatic']
proc_obj._procure_orderpoint_confirm(cr, uid, automatic=automatic,\
use_new_cursor=cr.dbname, context=context)
finally:
cr.close()
return {}
def _procure_calculation(self, cr, uid, data, context):
threaded_calculation = threading.Thread(target=_procure_calculation_orderpoint, args=(self, cr.dbname, uid, data, context))
threaded_calculation.start()
return {}
class procurement_compute(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':parameter_form, 'fields': parameter_fields, 'state':[('end','Cancel'),('compute','Compute Stock')]}
},
'compute': {
'actions': [_procure_calculation],
'result': {'type': 'state', 'state':'end'}
},
}
procurement_compute('mrp.procurement.orderpoint.compute')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,64 +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 threading
import pooler
parameter_form = '''<?xml version="1.0"?>
<form string="Scheduler Parameters" colspan="4">
<field name="automatic" />
</form>'''
parameter_fields = {
'automatic': {'string': 'Automatic orderpoint', 'type': 'boolean', 'help': 'Triggers an automatic procurement for all products that have a virtual stock under 0. You should probably not use this option, we suggest using a MTO configuration on products.', 'default': lambda *a: False},
}
def _procure_calculation_all(self, db_name, uid, data, context):
db, pool = pooler.get_db_and_pool(db_name)
cr = db.cursor()
proc_obj = pool.get('mrp.procurement')
automatic = data['form']['automatic']
proc_obj.run_scheduler(cr, uid, automatic=automatic, use_new_cursor=cr.dbname,\
context=context)
cr.close()
return {}
def _procure_calculation(self, cr, uid, data, context):
threaded_calculation = threading.Thread(target=_procure_calculation_all, args=(self, cr.dbname, uid, data, context))
threaded_calculation.start()
return {}
class procurement_compute(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':parameter_form, 'fields': parameter_fields, 'state':[('end','Cancel'),('compute','Compute Stock') ]}
},
'compute': {
'actions': [_procure_calculation],
'result': {'type': 'state', 'state':'end'}
},
}
procurement_compute('mrp.procurement.compute.all')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+4 -3
View File
@@ -37,11 +37,12 @@
'depends': ['base', 'sale', 'account'],
'update_xml': [
'security/ir.model.access.csv',
'mrp_repair_sequence.xml',
'mrp_repair_wizard.xml',
'mrp_repair_sequence.xml',
'wizard/mrp_repair_cancel_view.xml',
'wizard/mrp_repair_make_invoice_view.xml',
'mrp_repair_view.xml',
'mrp_repair_workflow.xml',
'mrp_repair_report.xml'
'mrp_repair_report.xml',
],
'demo_xml': [],
'installable': True,
+5 -3
View File
@@ -95,7 +95,7 @@ class mrp_repair(osv.osv):
\n* The \'To be Invoiced\' state is used to generate the invoice before or after repairing done. \
\n* The \'Done\' state is set when repairing is completed.\
\n* The \'Cancelled\' state is used when user cancel repair order.'),
'location_id': fields.many2one('stock.location', 'Current Location', required=True, select=True, readonly=True, states={'draft':[('readonly',False)]}),
'location_id': fields.many2one('stock.location', 'Current Location', select=True, readonly=True, states={'draft':[('readonly',False)]}),
'location_dest_id': fields.many2one('stock.location', 'Delivery Location', readonly=True, states={'draft':[('readonly',False)]}),
'move_id': fields.many2one('stock.move', 'Move',required=True, domain="[('product_id','=',product_id)]", readonly=True, states={'draft':[('readonly',False)]}),
'guarantee_limit': fields.date('Guarantee limit', help="The guarantee limit is computed as: last move date + warranty defined on selected product. If the current date is below the guarantee limit, each operation and fee you will add will be set as 'not to invoiced' by default. Note that you can change manually afterwards."),
@@ -261,12 +261,12 @@ class mrp_repair(osv.osv):
def action_invoice_create(self, cr, uid, ids, group=False, context=None):
res={}
invoices_group = {}
for repair in self.browse(cr, uid, ids, context=context):
for repair in self.browse(cr, uid, ids, context=context):
res[repair.id]=False
if repair.state in ('draft','cancel') or repair.invoice_id:
continue
if not (repair.partner_id.id and repair.partner_invoice_id.id):
raise osv.except_osv(_('No partner !'),_('You have to select a partner in the repair form !'))
raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !'))
comment=repair.quotation_notes
if (repair.invoice_method != 'none'):
if group and repair.partner_invoice_id.id in invoices_group:
@@ -398,7 +398,9 @@ class mrp_repair(osv.osv):
self.pool.get('mrp.repair.line').write(cr, uid, [move.id], {'move_id': move_id})
if repair.deliver_bool:
pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out')
picking = self.pool.get('stock.picking').create(cr, uid, {
'name': pick_name,
'origin': repair.name,
'state': 'draft',
'move_type': 'one',
-22
View File
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard
id="action_cancel_repair"
model="mrp.repair"
name="mrp.repair.cancel"
string="Cancel Repair"
menu = "False"
multi = "True"
/>
<wizard
id="wizard_mrp_repair_make_invoice"
keyword="client_action_multi"
model="mrp.repair"
name="mrp.repair.make_invoice"
multi="True"
string="Make invoices"/>
</data>
</openerp>
+1 -1
View File
@@ -397,7 +397,7 @@
<blockTable colWidths="534.0" style="Table8">
<tr>
<td>
<para style="P3">[[ format(o.quotation_notes) or '' ]]</para>
<para style="P3">[[ format(o.quotation_notes) or removeParentNode('blockTable') ]]</para>
</td>
</tr>
</blockTable>
@@ -5,3 +5,7 @@
"access_mrp_repair_line_manager","MRP Repair Line manager","model_mrp_repair_line","stock.group_stock_manager",1,1,1,1
"access_mrp_repair_fee_user","MRP Repair Fee user","model_mrp_repair_fee","stock.group_stock_user",1,0,0,0
"access_mrp_repair_fee_manager","MRP Repair Fee manager","model_mrp_repair_fee","stock.group_stock_manager",1,1,1,1
"access_mrp_repair_cancel_user","mrp.repair.cancel user","model_mrp_repair_cancel","stock.group_stock_user",1,0,0,0
"access_mrp_repair_cancel_manager","mrp.repair.cancel manager","model_mrp_repair_cancel","stock.group_stock_manager",1,1,1,1
"access_mrp_repair_make_invoice_user","mrp.repair.make_invoice user","model_mrp_repair_make_invoice","stock.group_stock_user",1,0,0,0
"access_mrp_repair_make_invoice_manager","mrp.repair.make_invoice manager","model_mrp_repair_make_invoice","stock.group_stock_manager",1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
5 access_mrp_repair_line_manager MRP Repair Line manager model_mrp_repair_line stock.group_stock_manager 1 1 1 1
6 access_mrp_repair_fee_user MRP Repair Fee user model_mrp_repair_fee stock.group_stock_user 1 0 0 0
7 access_mrp_repair_fee_manager MRP Repair Fee manager model_mrp_repair_fee stock.group_stock_manager 1 1 1 1
8 access_mrp_repair_cancel_user mrp.repair.cancel user model_mrp_repair_cancel stock.group_stock_user 1 0 0 0
9 access_mrp_repair_cancel_manager mrp.repair.cancel manager model_mrp_repair_cancel stock.group_stock_manager 1 1 1 1
10 access_mrp_repair_make_invoice_user mrp.repair.make_invoice user model_mrp_repair_make_invoice stock.group_stock_user 1 0 0 0
11 access_mrp_repair_make_invoice_manager mrp.repair.make_invoice manager model_mrp_repair_make_invoice stock.group_stock_manager 1 1 1 1
+2 -2
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:
+87
View File
@@ -0,0 +1,87 @@
# -*- 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 netsvc
from osv import osv,fields
from tools.translate import _
class repair_cancel(osv.osv_memory):
_name = 'mrp.repair.cancel'
_description = 'Cancel Repair'
def cancel_repair(self, cr, uid, ids, context):
"""
Cancels the repair
@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) or False
assert record_id, _('Active ID is not Found')
repair_order_obj = self.pool.get('mrp.repair')
repair_line_obj = self.pool.get('mrp.repair.line')
repair_order = repair_order_obj.browse(cr, uid, record_id)
if repair_order.invoiced or repair_order.invoice_method == 'none':
repair_order_obj.action_cancel(cr, uid, [record_id], context=context)
else:
raise osv.except_osv(_('Warning!'),_('Repair is not cancelled. It is not invoiced.'))
return {}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
"""
Changes the view dynamically
@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: New arch of view.
"""
record_id = context and context.get('active_id', False) or False
res = super(repair_cancel, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
if record_id:
repair_order = self.pool.get('mrp.repair').browse(cr, uid, record_id)
if not repair_order.invoiced:
res['arch'] = """ <form string="Cancel Repair" colspan="4">
<group col="2" colspan="2">
<label string="Do you want to continue?" colspan="4"/>
<separator colspan="4"/>
<button icon="gtk-cancel" special="cancel" string="No" readonly="0"/>
<button name="cancel_repair" string="Yes" type="object" icon="gtk-ok"/>
</group>
</form>
"""
return res
repair_cancel()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+64
View File
@@ -0,0 +1,64 @@
# -*- 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 netsvc
from osv import osv, fields
class make_invoice(osv.osv_memory):
_name = 'mrp.repair.make_invoice'
_description = 'Make Invoice'
_columns = {
'group': fields.boolean('Group by partner invoice address'),
}
def make_invoices(self, cr, uid, ids, context):
"""
Generates invoice(s) of selected records.
@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: Loads the view of new invoice(s).
"""
inv = self.browse(cr, uid, ids[0])
order_obj = self.pool.get('mrp.repair')
newinv = order_obj.action_invoice_create(cr, uid, context['active_ids'], group=inv.group,context=context)
return {
'domain': [('id','in', newinv.values())],
'name': 'Invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'context': "{'type':'out_invoice'}",
'type': 'ir.actions.act_window'
}
make_invoice()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Cancel Repair -->
<record id="view_cancel_repair" model="ir.ui.view">
<field name="name">Cancel Repair</field>
<field name="model">mrp.repair.cancel</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Cancel Repair Order">
<label string="This operation will cancel the Repair process, but will not cancel it's Invoice. Do you want to continue?" colspan="4"/>
<newline/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="No" />
<button name="cancel_repair" string="Yes"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<record id="action_cancel_repair" model="ir.actions.act_window">
<field name="name">Cancel Repair Order</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.repair.cancel</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Make Invoice -->
<record id="view_make_invoice" model="ir.ui.view">
<field name="name">Make Invoice</field>
<field name="model">mrp.repair.make_invoice</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create invoices">
<separator colspan="4" string="Do you really want to create the invoices ?" />
<field name="group"/>
<newline/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="make_invoices" string="Create Invoice"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<act_window name="Make Invoice"
res_model="mrp.repair.make_invoice"
src_model="mrp.repair"
view_mode="form"
target="new"
key2="client_action_multi"
id="act_mrp_repair_invoice"/>
</data>
</openerp>
@@ -1,81 +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
cancel_form = """<?xml version="1.0"?>
<form string="Cancel Repair...??">
<label colspan="4" string="This operation will cancel the Repair process, but will not cancel it's Invoice.\nDo you want to continue?" />
</form>
"""
cancel_fields = {}
def check_state(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
repair_obj = pool.get('mrp.repair').browse(cr, uid, data['ids'])[0]
if repair_obj.invoice_id:
return 'display'
else:
pool.get('mrp.repair').write(cr,uid,data['ids'],{'state':'cancel'})
return 'end'
def _cancel_repair(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
repair_obj = pool.get('mrp.repair').browse(cr, uid, data['ids'])
pool.get('mrp.repair').write(cr,uid,data['ids'],{'state':'cancel'})
mrp_line_obj = pool.get('mrp.repair.line')
for line in repair_obj:
mrp_line_obj.write(cr, uid, [l.id for l in line.operations], {'state': 'cancel'})
return {}
class repair_cancel(wizard.interface):
states = {
'init' : {
'actions' : [],
'result' : {'type' : 'choice', 'next_state' : check_state}
},
'display' : {
'actions' : [],
'result' : {'type' : 'form',
'arch' : cancel_form,
'fields' : cancel_fields,
'state' : [('end', 'No'),('yes', 'Yes') ]}
},
'yes' : {
'actions' : [],
'result' : {'type' : 'action',
'action' : _cancel_repair,
'state' : 'end'}
},
'end' : {
'actions' : [],
'result': {'type': 'state', 'state': 'end'},
},
}
repair_cancel("mrp.repair.cancel")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,81 +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 string="Create invoices">
<separator colspan="4" string="Do you really want to create the invoices ?" />
<field name="group"/>
</form>
"""
invoice_fields = {
'group': {
'string': 'Group by partner invoice address',
'type':'boolean'
},
}
ack_form = """<?xml version="1.0"?>
<form string="Create invoices">
<separator string="Invoices created" />
</form>"""
ack_fields = {}
def _makeInvoices(self, cr, uid, data, context):
order_obj = pooler.get_pool(cr.dbname).get('mrp.repair')
newinv = order_obj.action_invoice_create(cr, uid, data['ids'],group=data['form']['group'],context=context)
return {
'domain': [('id','in', newinv.values())],
'name': 'Invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'context': "{'type':'out_refund'}",
'type': 'ir.actions.act_window'
}
class make_invoice(wizard.interface):
states = {
'init' : {
'actions' : [],
'result' : {'type' : 'form',
'arch' : invoice_form,
'fields' : invoice_fields,
'state' : [('end', 'Cancel'),('invoice', 'Create invoices') ]}
},
'invoice' : {
'actions' : [],
'result' : {'type' : 'action',
'action' : _makeInvoices,
'state' : 'end'}
},
}
make_invoice("mrp.repair.make_invoice")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+24 -14
View File
@@ -38,9 +38,30 @@ Main features :
'author': 'Tiny',
'depends': ['sale', 'delivery'],
# 'depends': ['sale', 'purchase', 'account', 'account_tax_include','board','mrp','board_manufacturing','delivery','profile_manufacturing','account','multi_company'],
'init_xml': [
'security/point_of_sale_security.xml',
'init_xml': [],
'update_xml': [
'security/point_of_sale_security.xml',
'security/ir.model.access.csv',
'wizard/pos_details.xml',
'wizard/pos_add_product.xml',
'wizard/pos_confirm.xml',
'wizard/pos_discount.xml',
'wizard/pos_get_sale.xml',
'wizard/pos_open_statement.xml',
'wizard/pos_close_statement.xml',
'wizard/pos_box_entries.xml',
'wizard/pos_payment_report_user_view.xml',
'wizard/pos_payment_report_date_view.xml',
'wizard/pos_box_out.xml',
'wizard/pos_sales_user.xml',
'wizard/all_closed_cashbox_of_the_day.xml',
'wizard/pos_sales_user_current_user.xml',
'wizard/pos_sale_user_today.xml',
'wizard/pos_receipt_view.xml',
'wizard/pos_payment_report_user.xml',
'wizard/pos_payment_report.xml',
'wizard/pos_payment.xml',
'pos_report.xml',
'pos_wizard.xml',
'pos_view.xml',
@@ -51,18 +72,7 @@ Main features :
'statement_view.xml',
'statement_report.xml',
'statement_data.xml',
'statement_wizard.xml'
],
'update_xml': [
'security/point_of_sale_security.xml',
'security/ir.model.access.csv',
'pos_report.xml',
'pos_wizard.xml',
'pos_view.xml',
'pos_sequence.xml',
'posrule_data.xml',
'pos_data.xml',
'pos_workflow.xml'
'statement_wizard.xml',
],
'demo_xml': ['pos_demo.xml','singer_statement_demo.xml','multi_company_stock_data.xml'],
'installable': True,
+11 -8
View File
@@ -125,14 +125,17 @@ class account_bank_statement(osv.osv):
}
def create(self, cr, uid, vals, context=None):
open_jrnl = self.search(cr, uid, [('company_id', '=', vals['company_id']), ('journal_id', '=', vals['journal_id']), ('state', '=', 'open')])
if open_jrnl:
raise osv.except_osv('Error', u'Une caisse de type espèce est déjà ouverte')
if 'starting_details_ids' in vals:
vals['starting_details_ids'] = starting_details_ids = map(list, vals['starting_details_ids'])
for i in starting_details_ids:
if i and i[0] and i[1]:
i[0], i[1] = 0, 0
company_id = vals and vals.get('company_id',False)
if company_id:
open_jrnl = self.search(cr, uid, [('company_id', '=', vals['company_id']), ('journal_id', '=', vals['journal_id']), ('state', '=', 'open')])
if open_jrnl:
raise osv.except_osv('Error', u'Une caisse de type espèce est déjà ouverte')
if 'starting_details_ids' in vals:
vals['starting_details_ids'] = starting_details_ids = map(list, vals['starting_details_ids'])
for i in starting_details_ids:
if i and i[0] and i[1]:
i[0], i[1] = 0, 0
res = super(account_bank_statement, self).create(cr, uid, vals, context=context)
return res
+31 -24
View File
@@ -43,7 +43,7 @@
<group colspan="4" col="7">
<field name="amount_tax"/>
<field name="amount_total"/>
<button name="%(pos_discount)d" string="D_iscount" type="action" states="draft"/>
<button name="%(action_pos_discount)d" string="D_iscount" type="action" states="draft"/>
<button name="dummy_button" string="Compute" type="object" />
</group>
@@ -68,8 +68,8 @@
<button name="%(pos_add_product)d" string="_Add product" type="action" states="draft"/>
-->
<button name="%(pos_payment)d" string="Ma_ke Payment" icon="gtk-ok" type="action" states="draft,advance"/>
<button name="%(o_rec)d" string="_Reprint" icon="gtk-print" type="action" states="paid,done,invoiced"/>
<button name="%(action_pos_payment)d" string="Ma_ke Payment" icon="gtk-ok" type="action" states="draft,advance" context="{'record_id':'active_id'}" />
<button name="%(action_report_pos_receipt)d" string="_Reprint" icon="gtk-print" type="action" states="paid,done,invoiced"/>
<!--
@@ -830,31 +830,31 @@ invoiced
action="action_product_output"
id="products_for_output_operations"/>
<wizard
<!-- <wizard
string="Refloat Box entries"
model="account.bank.statement"
name="pos.entry"
menu="False"
id="pos_entries"/>
id="pos_entries"/>-->
<menuitem name="Register Management" parent="menu_point_root"
id="menu_point_config" sequence="3"/>
<menuitem
name="Input Operations" parent="menu_point_config"
string="Refloat"
action="pos_entries"
type="wizard"
id="menu_wizard_enter_jrnl" sequence="2" />
<wizard
action="action_box_entries"
id="menu_wizard_enter_jrnl" sequence="3" />
<!-- <wizard
string="Enter negative operations"
model="account.bank.statement"
name="pos.out"
menu="False"
id="pos_entries2"/>
id="pos_entries2"/>-->
<menuitem
name="Output Operations" parent="menu_point_config"
string="Refloat"
action="pos_entries2"
type="wizard"
action="action_box_out"
id="menu_wizard_enter_jrnl2" sequence="3" />
<!-- <menuitem name="Sales Waiting Validation" parent="menu_point_config" id="menu_point_ofsale_date_payment"-->
@@ -981,22 +981,29 @@ invoiced
<!-- <menuitem icon="STOCK_PRINT" action="wizard_pos_payment_report"
id="menu_pos_payment_report" parent="menu_cashboxes_by_day" type="wizard" sequence="4"/-->
<menuitem icon="STOCK_PRINT" action="wizard_pos_sales_user"
id="menu_pos_sales_user" parent="menu_trans_pos_tree" type="wizard" sequence="3" groups="base.group_extended" />
<menuitem icon="STOCK_PRINT" action="action_report_pos_sale_user"
id="menu_pos_sales_user" parent="menu_trans_pos_tree" sequence="3" groups="base.group_extended" />
<menuitem icon="STOCK_PRINT" action="wizard_pos_sales_user_today"
id="menu_pos_sales_user_today" parent="menu_trans_pos_tree_today" type="wizard" sequence="2" groups="base.group_extended"/>
<menuitem icon="STOCK_PRINT" action="action_report_pos_payment_repport_date"
id="menu_pos_payment_report_date" parent="menu_trans_pos_tree" sequence="5" groups="base.group_extended"/>
<menuitem icon="STOCK_PRINT" action="action_report_pos_payment_report_user"
id="menu_pos_payment_report_user" parent="menu_trans_pos_tree_today" sequence="6" groups="base.group_extended"/>
<menuitem icon="STOCK_PRINT" action="action_pos_sales_user_today"
id="menu_pos_sales_user_today" parent="menu_trans_pos_tree_today" sequence="2" groups="base.group_extended"/>
<menuitem icon="STOCK_PRINT" action="wizard_pos_payment_report_date"
id="menu_pos_payment_report_date" parent="menu_trans_pos_tree" type="wizard" sequence="5" groups="base.group_extended"/>
<menuitem icon="STOCK_PRINT" action="action_report_pos_payment_repport_date"
id="menu_pos_payment_report_date" parent="menu_trans_pos_tree" sequence="5" groups="base.group_extended"/>
<menuitem icon="STOCK_PRINT" action="wizard_pos_payment_report_user"
id="menu_pos_payment_report_user" parent="menu_trans_pos_tree_today" type="wizard" sequence="6" groups="base.group_extended"/>
<menuitem icon="STOCK_PRINT" action="wizard_pos_sales_user_today_current_user"
id="menu_pos_sales_user_today_current_user" parent="menu_cashboxes_by_day" type="wizard" sequence="7"/>
<menuitem icon="STOCK_PRINT" action="wizard_pos_details"
id="menu_pos_details" parent="menu_cashboxes_by_day" type="wizard" />
<menuitem icon="STOCK_PRINT" action="action_report_pos_payment_report_user"
id="menu_pos_payment_report_user" parent="menu_trans_pos_tree_today" sequence="6" groups="base.group_extended"/>
<menuitem icon="STOCK_PRINT" action="action_report_pos_sales_user_today_current_user"
id="menu_pos_sales_user_today_current_user" parent="menu_cashboxes_by_day" sequence="7"/>
<menuitem icon="STOCK_PRINT" action="action_report_pos_details"
id="menu_pos_details" parent="menu_cashboxes_by_day" />
</data>
+17 -36
View File
@@ -9,17 +9,13 @@
string="Return Goods"/>
<wizard string="Receipt" model="pos.order"
name="ord.receipt" id="o_rec"
keyword="client_print_multi"
menu="False"
/>
<!-- <wizard string="Box Entries" model="account.bank.statement"
name="pos.entry" id="pos_entry" menu="False"/>-->
<wizard string="Payment" model="pos.order"
name="pos.payment" id="pos_payment" menu="False"/>
<!-- <wizard string="Payment" model="pos.order"
name="pos.payment" id="pos_payment" menu="False"/>-->
<!--<wizard string="Create Invoices" model="pos.order"
name="pos.create_invoice" id="pos_invoice" multi="True"/>-->
@@ -30,64 +26,49 @@
<!--<wizard string="Cancel" model="pos.order"
name="pos.cancel" id="pos_cancel" multi="True"/>-->
<wizard
string="Confirm"
model="pos.order"
name="pos.confirm"
id="pos_confirm"
multi="True"
menu="True"
/>
<!--
<wizard string="Discount" model="pos.order"
name="pos.discount" id="pos_discount" menu="False"/>
name="pos.discount" id="pos_discount" menu="False"/>-->
<!-- <wizard id="wizard_pos_payment_report" menu="False"
model="pos.order" name="pos.payment.report" string="All paid lines for the current User"/-->
<!--
<wizard id="wizard_pos_sales_user" menu="False"
model="pos.order" name="pos.sales.user" string="Sales Report"/>
<wizard id="wizard_pos_sales_user_today" menu="False"
model="pos.order" name="pos.sales.user.today" string="Sales by Users"/>
model="pos.order" name="pos.sales.user" string="Sales Report"/>-->
<!--
<wizard id="wizard_pos_payment_report_date" menu="False"
model="pos.order" name="pos.payment.report.date" string="Sales lines Report"/>
<wizard id="wizard_pos_payment_report_user" menu="False"
model="pos.order" name="pos.payment.report.user" string="Sales lines by Users"/>
-->
<wizard id="wizard_pos_sales_user_today_current_user" menu="False"
model="pos.order" name="pos.sales.user.today.current.user" string="Sales for Current User"/>
<wizard id="wizard_pos_details" menu="False"
model="pos.order" name="pos.details" string="Sales Details"/>
<!-- <wizard id="wizard_pos_details" menu="False"
model="pos.order" name="pos.details" string="Sales Details"/>-->
<!-- <wizard string="Get From Order" model="pos.order"
name="pos.sale.get" id="pos_sale_get"/>
<wizard string="Scan Product" model="pos.order"
name="pos.scan_product" id="pos_scan_product"/-->
<wizard
<!-- <wizard
id="close_statement"
model="account.bank.statement"
menu="False"
menu="True"
name="statement.close"
string="Close Statements"/>
<wizard
id="open_statement"
model="account.bank.statement"
menu="False"
name="statement.open"
string="Open Statements"/>
string="Close Statements"/>-->
<wizard
<!--wizard
id="wizard_all_closed_cashbox_of_the_day"
model="account.bank.statement"
menu="False"
name="all.closed.cashbox.of.the.day"
string="All Cashboxes Of the day"/>
string="All Cashboxes Of the day"/-->
</data>
@@ -138,4 +138,6 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
res = self.cr.dictfetchall()
return res[0]['net_total'] or 0.0
report_sxw.report_sxw('report.all.closed.cashbox.of.the.day', 'account.bank.statement', 'addons/statement/report/all_closed_cashbox_of_the_day.rml', parser=all_closed_cashbox_of_the_day)
report_sxw.report_sxw('report.all.closed.cashbox.of.the.day', 'account.bank.statement', 'addons/point_of_sale/report/all_closed_cashbox_of_the_day.rml', parser=all_closed_cashbox_of_the_day)
@@ -43,7 +43,7 @@ class pos_payment_report_date(report_sxw.rml_parse):
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \
"and po.state in ('paid','invoiced') and po.date_order >= %s and po.date_order <= %s and po.user_id in %s " \
,(dt1,dt2,tuple(form['user_id'][0][-1])))
,(dt1,dt2,tuple(form['user_id'])))
data=self.cr.dictfetchall()
return data
@@ -55,7 +55,7 @@ class pos_payment_report_date(report_sxw.rml_parse):
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \
"and po.state in ('paid','invoiced') and po.date_order >= %s and po.date_order <= %s and po.user_id in %s " \
,(dt1,dt2,tuple(form['user_id'][0][-1])))
,(dt1,dt2,tuple(form['user_id'])))
res=self.cr.fetchone()[0]
return res
@@ -35,7 +35,7 @@ class pos_payment_report_user(report_sxw.rml_parse):
def __pos_payment_user__(self,form):
data={}
ids = form['user_id'][0][-1]
ids = form['user_id']
idss = map(str, ids)
sql = "select pt.name,pol.qty,pol.discount,pol.price_unit, " \
"(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) as total " \
+3 -1
View File
@@ -104,7 +104,9 @@
<para style="terp_default_Centre_9">E-mail : [[ address and address.email ]]</para>
<para style="terp_default_Centre_9">Shop : [[ o.shop_id.name ]]</para>
<para style="terp_default_Centre_9">Vendeur : [[ o.user_id1.name ]]</para>
<para style="terp_default_Centre_9">Date : [[ o.date_order ]]</para>
<para style="terp_default_Centre_9">Date : [[ formatLang(o.date_order,date = True) ]]</para>
<para style="P4">
<font color="white"> </font>
</para>
@@ -71,7 +71,7 @@
<para style="terp_default_Centre_9">Tel : [[ address and address.phone ]]</para>
<para style="terp_default_Centre_9">E-mail : [[ address and address.email ]]</para>
<para style="terp_default_Centre_9">Salesman : [[ o.user_id.name ]]</para>
<para style="terp_default_Centre_9">Sale Date : [[ o.date_order ]]</para>
<para style="terp_default_Centre_9">Sale Date : [[ str(o.date_order) ]]</para>
<para style="P5">Purchase Voucher : [[o.name]]</para>
<para style="P4">
<font color="white"> </font>

Some files were not shown because too many files have changed in this diff Show More