bzr revid: fp@tinyerp.com-20100404184930-kw83bg1j3r7xtiu8
This commit is contained in:
Fabien Pinckaers
2010-04-04 20:49:30 +02:00
52 changed files with 1152 additions and 905 deletions
+2
View File
@@ -38,6 +38,8 @@
'init_xml': ['auction_sequence.xml'],
'update_xml': [
'security/ir.model.access.csv',
# 'wizard/auction_lots_cancel_view.xml',
# 'wizard/auction_transfer_unsold_object_view.xml',
'wizard/auction_lots_able_view.xml',
'wizard/auction_lots_enable_view.xml',
'wizard/auction_lots_make_invoice_buyer_view.xml',
+1
View File
@@ -95,6 +95,7 @@ class auction_dates(osv.osv):
RETURN: True
"""
# objects vendus mais non factures
#TODO: convert this query to tiny API
cr.execute('select count(*) as c from auction_lots where auction_id =ANY(%s) and state=%s and obj_price>0', (ids,'draft',))
nbr = cr.fetchone()[0]
ach_uids = {}
+2 -1
View File
@@ -29,7 +29,8 @@ import auction_pay_buy
import auction_payer_sel
import auction_lots_sms_send
import auction_catalog_flagey_report
#import auction_lots_cancel
#import auction_transfer_unsold_object
#import auction_aie_send_result
import auction_lots_buyer_map
+15 -12
View File
@@ -107,18 +107,21 @@ class wiz_auc_lots_buyer_map(osv.osv_memory):
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>
"""
try:
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>
"""
except:
return res
return res
wiz_auc_lots_buyer_map()
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv
from osv import fields
class auction_lots_cancel(osv.osv):
'''
Open ERP Model
'''
_name = 'auction.lots.cancel'
_description = 'To cancel auction lots.'
def cancel(self, cr, uid, ids, context):
"""
To cancel the auction lot
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: List of IDs selected
@param context: A standard dictionary
@return:
"""
lots_obj = self.pool.get('auction.lots')
invoice_obj = self.pool.get('account.invoice')
lot = lots_obj.browse(cr,uid,context['active_id'],context)
if lot.ach_inv_id:
supplier_refund_inv_id = invoice_obj.refund(cr, uid,[lot.ach_inv_id.id])
if lot.sel_inv_id:
customer_refund_inv_id = invoice_obj.refund(cr, uid,[lot.sel_inv_id.id])
return {}
_columns = {
}
auction_lots_cancel()
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="name_form" model="ir.ui.view">
<field name="name">auction.lots.cancel.form</field>
<field name="model">auction.lots.cancel</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Cancel Payment">
<label string="Are you sure you want to refund this invoice ?"/>
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="cancel" string="Cancel Payment"
colspan="1" type="object" icon="gtk-ok" />
</form>
</field>
</record>
<act_window name="Cancel ittttttt"
res_model="auction.lots.cancel"
src_model="auction.lots"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_auction_lots_cancel"/>
</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 osv
from osv import fields
class auction_transfer_unsold_object(osv.osv):
'''
Open ERP Model
'''
_name = 'auction.transfer.unsold.object'
_description = 'To transfer unsold objects'
def _start(self, cr, uid, context):
"""
To initialize auction_id_from
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: List of IDs selected
@param context: A standard dictionary
@return: auction_id_from
"""
lots_obj = self.pool.get('auction.lots')
rec = lots_obj.browse(cr, uid, context['active_id'], context)
auction_from = rec and rec.auction_id.id or False
return auction_from
def transfer_unsold_object(self, cr, uid, ids, context):
"""
To Transfer the unsold object
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: List of IDs selected
@param context: A standard dictionary
@return:
"""
bid_line_obj = self.pool.get('auction.bid_line')
lots_obj = self.pool.get('auction.lots')
lot_history_obj = self.pool.get('auction.lot.history')
line_ids= bid_line_obj.search(cr,uid,[('lot_id','in',context['active_ids'])])
bid_line_obj.unlink(cr, uid, line_ids)
res = self.browse(cr, uid, ids)
unsold_ids = lots_obj.search(cr,uid,[('auction_id','=',res[0].auction_id_from.id),('state','=','unsold')])
for rec in lots_obj.browse(cr, uid, unsold_ids, context):
new_id = lot_history_obj.create(cr,uid,{'auction_id':rec.auction_id.id,'lot_id':rec.id,'price': rec.obj_ret, 'name': rec.auction_id.auction1})
up_auction = lots_obj.write(cr,uid,[rec.id],{'auction_id': res[0].auction_id_to.id,
'obj_ret':None,
'obj_price':None,
'ach_login':None,
'ach_uid':None,
'ach_inv_id':None,
'sel_inv_id':None,
'state':'draft'})
return {}
_columns = {
'auction_id_from':fields.many2one('auction.dates', 'From Auction Date', required=True),
'auction_id_to':fields.many2one('auction.dates', 'To Auction Date', required=True),
}
_defaults = {
'auction_id_from': _start,
}
auction_transfer_unsold_object()
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="name_form" model="ir.ui.view">
<field name="name">auction.transfer.unsold.object.form</field>
<field name="model">auction.transfer.unsold.object</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Draft To Posted">
<group col="1" colspan="2">
<separator colspan="4" string="Transfer unsold Object: Current auction date to another " />
</group>
<newline/>
<field name="auction_id_from" select="1"/>
<newline/>
<field name="auction_id_to" select="1"/>
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="transfer_unsold_object" string="Transfer"
colspan="1" type="object" icon="gtk-ok" />
</form>
</field>
</record>
</data>
</openerp>
@@ -1,91 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
import pooler
paid_form = '''<?xml version="1.0"?>
<form string="Cancel Payment">
<label string="Are you sure you want to refund this invoice ?"/>
</form>'''
fields_ask = {
}
#
#def _get_value(self,cr,uid, datas,context={}):
## service = netsvc.LocalService("object_proxy")
# lots=pool.get('auction.lots').browse(cr,uid,data['id'],context)
#
#
## lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', datas['ids'])
#
# ids = []
# pay_ids = {}
# price = 0.0
# price_paid = 0.0
# uid = False
#
##TODO: refuse if several payments?
# for lot in lots:
# price += lot['obj_price']
#
# # add all the buyer costs
# costs = service.execute(cr.dbname,uid, 'auction.lots', 'compute_buyer_costs', [lot['id']])
# for cost in costs:
# price += cost['amount']
#
##TODO: pr bien faire, faudrait leur poser la question: continue anyway?
# if len(ids)<len(datas['ids']):
# raise wizard.except_wizard('UserError', ('Some object(s) are not paid !', 'init'))
#
# return {'objects':len(ids), 'amount_total':price, 'amount_paid':price_paid}
#
#def _cancel(self, uid, datas):
# service = netsvc.LocalService("object_proxy")
# lots = service.execute(cr.dbname,uid, 'auction.lots', 'lots_cancel_payment', datas['ids'])
# return {}
#
def _cancel(self,cr,uid,data,context):
pool = pooler.get_pool(cr.dbname)
lot = pool.get('auction.lots').browse(cr,uid,data['id'],context)
if lot.ach_inv_id:
p=pool.get('account.invoice').refund(['lot.ach_inv_id.id'],context)
if lot.vnd_inv_id:
p=pool.get('account.invoice').refund(['lot.vnd_inv_id.id'],context)
return {}
class wiz_auc_lots_cancel(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':paid_form, 'fields': fields_ask, 'state':[('make_cancel','Cancel Payment'), ('end','Cancel')]}
},
'make_cancel': {
'actions': [_cancel],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_auc_lots_cancel('auction.lots.cancel');
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,92 +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 netsvc
import pooler
from osv.orm import browse_record
import sql_db
transfer_unsold_object_form = """<?xml version="1.0"?>
<form string="Draft To Posted">
<group col="1" colspan="2">
<separator colspan="4" string="Transfer unsold Object: Current auction date to another " />
</group>
<newline/>
<field name="auction_id_from"/>
<newline/>
<field name="auction_id_to"/>
</form>
"""
transfer_unsold_object_fields = {
'auction_id_from': {'string':'From Auction Date', 'type':'many2one', 'required':True, 'relation':'auction.dates'},
'auction_id_to': {'string':'To Auction Date', 'type':'many2one', 'required':True, 'relation':'auction.dates'},
}
def _start(self,cr,uid,data,context):
pool = pooler.get_pool(cr.dbname)
rec=pool.get('auction.lots').browse(cr,uid,data['id'],context)
auction_from= rec and rec.auction_id.id or False
return {'auction_id_from':auction_from}
def _transfer_unsold_object(self, cr, uid, data, context):
#if not (data['form']['auction_id_to']) :
# return {}
#Historique de l objet + changement de l auction date + supp des bid line
line_ids= pooler.get_pool(cr.dbname).get('auction.bid_line').search(cr,uid,[('lot_id','in',data['ids'])])
pooler.get_pool(cr.dbname).get('auction.bid_line').unlink(cr, uid, line_ids)
obj_pool = pooler.get_pool(cr.dbname).get('auction.lots')
ids= obj_pool.search(cr,uid,[('auction_id','=',data['form']['auction_id_from']),('state','=','unsold')])
for rec in obj_pool.browse(cr, uid, ids, context):
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, 'name': 'reasons'+rec.auction_id.auction1})
up_auction=pooler.get_pool(cr.dbname).get('auction.lots').write(cr,uid,[rec.id],{'auction_id':data['form']['auction_id_to'],
'obj_ret':None,
'obj_price':None,
'ach_login':None,
'ach_uid':None,
'ach_inv_id':None,
'sel_inv_id':None,
'state':'draft'})
# new_id = self.pool.get('auction.lot.history').copy(cr, uid, m.id, {'price': recs.obj_ret, 'name': 'reasons'+recs.auction_id.name})
# new_id=pooler.get_pool(cr.dbname).get('auction.lot.history').create(cr,uid,{'auction_id':rec.auction_id,'lot_id':rec.name,'price': rec.obj_ret, 'name': 'reasons'+rec.auction_id.auction1})
return {}
class transfer_object(wizard.interface):
states = {
'init' : {
'actions' : [_start],
'result' : {'type' : 'form',
'arch' : transfer_unsold_object_form,
'fields' :transfer_unsold_object_fields,
'state' : [('transfer', 'Transfer'),('end', 'Cancel') ]}
},
'transfer' : {
'actions' : [_transfer_unsold_object],
'result' : {'type' : 'state','state' : 'end'}
},
}
transfer_object('auction.lots.transfer.unsold.object')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+2
View File
@@ -62,10 +62,12 @@
'mrp_data.xml',
'wizard/mrp_product_produce_view.xml',
'wizard/make_procurement_view.xml',
'wizard/mrp_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',
# 'wizard/mrp_track_prod_view.xml',
'mrp_view.xml',
'wizard/schedulers_all_view.xml',
'mrp_wizard.xml',
+3 -2
View File
@@ -139,8 +139,8 @@ class mrp_bom(osv.osv):
@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:
@param name: name of the field
@param arg: user defined argument
@return: True
@@ -156,6 +156,7 @@ 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)
return result
def _compute_type(self, cr, uid, ids, field_name, arg, context):
res = dict(map(lambda x: (x,''), ids))
+34 -27
View File
@@ -32,35 +32,42 @@ class product_product(osv.osv):
bom_obj = self.pool.get('mrp.bom')
product_uom_obj = self.pool.get('product.uom')
def _compute_price(bom):
def _compute_price(bom):
print bom.product_id
price = 0
if bom.bom_lines:
for sbom in bom.bom_lines:
price += _compute_price(sbom) * sbom.product_qty
else:
# if bom.bom_lines:
# for sbom in bom.bom_lines:
# print "--->>>" , sbom.name
# price += _compute_price(sbom) * sbom.product_qty
# else:
parent_bom = bom_obj.search(cr, uid, [('bom_id', '=', False)])
print "========", bom.product_id.name
for p in parent_bom:
test_obj = bom_obj.browse(cr, uid, p)
print test_obj
print "XXXXXXXXXXXXX", p, test_obj.child_ids
no_child_bom = bom_obj.search(cr, uid, [('product_id', '=', bom.product_id.id), ('bom_id', '=', False)])
if no_child_bom and bom.id not in no_child_bom:
other_bom = bom_obj.browse(cr, uid, no_child_bom)[0]
if not other_bom.product_id.calculate_price:
price += _compute_price(other_bom) * other_bom.product_qty
else:
price += other_bom.product_id.standard_price
else:
price += bom.product_id.standard_price
if bom.routing_id:
for wline in bom.routing_id.workcenter_lines:
wc = wline.workcenter_id
cycle = wline.cycle_nbr
hour = (wc.time_start + wc.time_stop + cycle * wc.time_cycle) * (wc.time_efficiency or 1.0)
price += wc.costs_cycle * cycle + wc.costs_hour * hour
price = product_uom_obj._compute_price(cr, uid, bom.product_uom.id, price, bom.product_id.uom_id.id)
if bom.bom_lines:
self.write(cr, uid, [bom.product_id.id], {'standard_price' : price/bom.product_qty})
if bom.product_uom.id != bom.product_id.uom_id.id:
price = product_uom_obj._compute_price(cr, uid, bom.product_uom.id, price, bom.product_id.uom_id.id)
return price
# if no_child_bom and bom.id not in no_child_bom:
# other_bom = bom_obj.browse(cr, uid, no_child_bom)[0]
# if not other_bom.product_id.calculate_price:
# price += _compute_price(other_bom) * other_bom.product_qty
# else:
# price += other_bom.product_id.standard_price
# else:
# price += bom.product_id.standard_price
#
# if bom.routing_id:
# for wline in bom.routing_id.workcenter_lines:
# wc = wline.workcenter_id
# cycle = wline.cycle_nbr
# hour = (wc.time_start + wc.time_stop + cycle * wc.time_cycle) * (wc.time_efficiency or 1.0)
# price += wc.costs_cycle * cycle + wc.costs_hour * hour
# price = product_uom_obj._compute_price(cr, uid, bom.product_uom.id, price, bom.product_id.uom_id.id)
# if bom.bom_lines:
# self.write(cr, uid, [bom.product_id.id], {'standard_price' : price/bom.product_qty})
# if bom.product_uom.id != bom.product_id.uom_id.id:
# price = product_uom_obj._compute_price(cr, uid, bom.product_uom.id, price, bom.product_id.uom_id.id)
# return price
bom_ids = bom_obj.search(cr, uid, [('product_id', 'in', ids)])
+2 -2
View File
@@ -21,11 +21,11 @@
import mrp_product_produce
import orderpoint_procurement
import wizard_procurement
import mrp_procurement
import schedulers_all
import mrp_price
import mrp_workcenter_load
import wizard_track_prod
#import mrp_track_prod
import change_production_qty
import make_procurement_product
+52
View File
@@ -0,0 +1,52 @@
# -*- 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'
_description = 'Compute Procurement'
def _procure_calculation_procure(self, cr, uid, ids, context):
try:
proc_obj = self.pool.get('mrp.procurement')
proc_obj._procure_confirm(cr, uid, use_new_cursor=cr.dbname, context=context)
finally:
cr.close()
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_procure, 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 Procurement -->
<record id="view_compute_procurment_wizard" model="ir.ui.view">
<field name="name">Compute Procurements</field>
<field name="model">mrp.procurement.compute</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Parameters">
<label string="This wizard will schedule procurements." colspan="4" align="0.0"/>
<newline/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="procure_calculation" string="Compute Requisitions"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<!-- <act_window name="Compute Procurements" -->
<!-- res_model="mrp.procurement.compute"-->
<!-- src_model="mrp.procurement"-->
<!-- view_mode="form"-->
<!-- target="new" -->
<!-- key2="client_action_multi" -->
<!-- id="act_compute_procurement"/> -->
</data>
</openerp>
+126
View File
@@ -0,0 +1,126 @@
# -*- 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
class mrp_track_move(osv.osv_memory):
_name = 'mrp.production.track'
_description = 'Production Track'
def view_init(self, cr, uid, fields_list, context=None):
"""
Creates view dynamically and adding fields at runtime.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return: New arch of view with new columns.
"""
res = super(mrp_track_move, self).view_init(cr, uid, fields_list, context=context)
record_id = context and context.get('active_id', False) or False
if record_id:
prod_obj = self.pool.get('mrp.production')
try:
prod = prod_obj.browse(cr, uid, record_id)
for m in [line for line in prod.move_created_ids]:
if 'track%s'%(m.id) not in self._columns:
self._columns['track%s'%(m.id)] = fields.boolean(string=m.product_id.name)
except:
return res
return res
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
"""
Changes the view dynamically
@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.
"""
res = super(mrp_track_move, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
record_id = context and context.get('active_id', False) or False
if record_id:
prod_obj = self.pool.get('mrp.production')
prod = prod_obj.browse(cr, uid, record_id)
try:
if prod.state != 'done':
res['arch'] = '''<form string="Track lines">
<label colspan="4" string="You can not split an unfinished production Output." />
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Exit" />
</group>
</form>
'''
else:
arch_lst = ['<form string="Track lines">', '<label colspan="4" string="The field on each line says whether this lot should be tracked or not." />']
for m in [line for line in prod.move_created_ids]:
quantity = m.product_qty
res['fields']['track%s' %m.id] = {'string' : m.product_id.name, 'type' : 'boolean', 'default' : lambda x,y,z: False}
arch_lst.append('<field name="track%s" />\n<newline />' %m.id)
arch_lst.append('<group col="2" colspan="4">')
arch_lst.append('<button icon=\'gtk-cancel\' special="cancel" string="Cancel" />')
arch_lst.append('<button name="track_lines" string="Track" colspan="1" type="object" icon="gtk-ok" />')
arch_lst.append('</group>')
arch_lst.append('</form>')
res['arch'] = '\n'.join(arch_lst)
except Exception,e:
return res
return res
def track_lines(self, cr, uid, ids, context):
"""
Tracks Finished products and splits products to finish lines.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@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 not found'
data = self.read(cr, uid, ids[0])
prod_obj = self.pool.get('mrp.production')
prod = prod_obj.browse(cr, uid, record_id)
if not prod.move_created_ids and prod.state != 'done':
return {}
prodlot_obj = self.pool.get('stock.production.lot')
move_obj = self.pool.get('stock.move')
move_ids = [m.id for m in [line for line in prod.move_created_ids]]
for idx, move in enumerate(move_obj.browse(cr, uid, move_ids)):
if data['track%s' %move.id]:
for idx in range(int(move.product_qty)):
update_val = {'product_qty': 1}
if idx:
current_move = move_obj.copy(cr, uid, move.id, {'state': move.state, 'production_id': move.production_id.id})
else:
current_move = move.id
new_prodlot = prodlot_obj.create(cr, uid, {'name': 'PRODUCTION:%d:LOT:%d' % (record_id, idx+1), 'product_id': move.product_id.id})
update_val['prodlot_id'] = new_prodlot
move_obj.write(cr, uid, [current_move], update_val)
return {}
mrp_track_move()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Track Production -->
<act_window name="Track Production"
res_model="mrp.production.track"
src_model="mrp.production"
view_mode="form"
target="new"
key2="client_action_multi"
id="act_production_track"/>
</data>
</openerp>
-64
View File
@@ -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="Parameters" colspan="4">
<label string="This wizard will schedule procurements." colspan="4" align="0.0"/>
</form>'''
parameter_fields = {
}
def _procure_calculation_procure(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')
proc_obj._procure_confirm(cr, uid, 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_procure, 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 Requisitions') ]}
},
'compute': {
'actions': [_procure_calculation],
'result': {'type': 'state', 'state':'end'}
},
}
procurement_compute('mrp.procurement.compute')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-104
View File
@@ -1,104 +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 time
from osv import osv
from tools.misc import UpdateableStr
arch = UpdateableStr()
fields = {}
def _get_moves(self, cr, uid, data, context):
prod_obj = pooler.get_pool(cr.dbname).get('mrp.production')
prod = prod_obj.browse(cr, uid, [data['id']])[0]
res = {}
fields.clear()
if prod.state != 'done':
arch.string = '''<?xml version="1.0"?><form string="Track lines"><label colspan="4" string="You can not split an unfinished production output" /></form>'''
res['moves'] = []
else:
arch_lst = ['<?xml version="1.0"?>', '<form string="Track lines">', '<label colspan="4" string="The field on each line says if this lot should be tracked or not." />']
for m in [line for line in prod.move_created_ids]:
quantity = m.product_qty
arch_lst.append('<field name="track%s" />\n<newline />' % m.id)
fields['track%s' % m.id] = {'string' : m.product_id.name, 'type' : 'boolean', 'default' : lambda x,y,z: False}
res.setdefault('moves', []).append(m.id)
arch_lst.append('</form>')
arch.string = '\n'.join(arch_lst)
return res
def _track_lines(self, cr, uid, data, context):
if not data['form']['moves']:
return {}
prodlot_obj = pooler.get_pool(cr.dbname).get('stock.production.lot')
lot_obj = pooler.get_pool(cr.dbname).get('stock.lot')
move_obj = pooler.get_pool(cr.dbname).get('stock.move')
new_lot = lot_obj.create(cr, uid, {'name': 'PRODUCTION:%d' % data['id']})
for idx, move in enumerate(move_obj.browse(cr, uid, data['form']['moves'])):
if data['form']['track%s' % move.id]:
for idx in range(move.product_qty):
update_val = {'product_qty': 1, 'lot_id': new_lot}
if idx:
current_move = move_obj.copy(cr, uid, move.id, {'state': move.state, 'production_id': move.production_id.id})
else:
current_move = move.id
new_prodlot = prodlot_obj.create(cr, uid, {'name': 'PRODUCTION:%d:LOT:%d' % (data['id'], idx+1)})
update_val['prodlot_id'] = new_prodlot
move_obj.write(cr, uid, [current_move], update_val)
return {}
class wizard_track_move(wizard.interface):
def _next(self, cr, uid, data, context):
prod_obj = pooler.get_pool(cr.dbname).get('mrp.production')
prod = prod_obj.browse(cr, uid, [data['id']])[0]
if prod.state != 'done':
return 'notrack'
else:
return 'track'
states = {
'init': {
'actions': [],
'result': {'type':'choice', 'next_state': _next}
},
'notrack':{
'actions':[_get_moves],
'result':{'type':'form', 'arch':arch, 'fields':fields, 'state':[('end', 'Cancel')]}
},
'track':{
'actions':[_get_moves],
'result': {'type':'form', 'arch':arch, 'fields':fields, 'state':[('end','Cancel'),('split','Track')]}
},
'split': {
'actions': [_track_lines],
'result': {'type':'state', 'state':'end'}
}
}
wizard_track_move('mrp.production.track')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+14 -11
View File
@@ -68,17 +68,20 @@ class repair_cancel(osv.osv_memory):
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>
"""
try:
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>
"""
except:
return res
return res
repair_cancel()
+2 -2
View File
@@ -41,7 +41,7 @@ Main features :
'init_xml': [],
'update_xml': [
'security/point_of_sale_security.xml',
'security/point_of_sale_security.xml',
'security/ir.model.access.csv',
'wizard/pos_details.xml',
'wizard/pos_add_product.xml',
@@ -73,7 +73,7 @@ Main features :
'statement_view.xml',
'statement_report.xml',
'statement_data.xml',
'statement_wizard.xml',
'statement_wizard.xml',
],
'demo_xml': ['pos_demo.xml','singer_statement_demo.xml','multi_company_stock_data.xml'],
'installable': True,
+2 -3
View File
@@ -10,7 +10,6 @@
<!-- <wizard string="Box Entries" model="account.bank.statement"
name="pos.entry" id="pos_entry" menu="False"/>-->
@@ -63,12 +62,12 @@
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,6 +138,4 @@ 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/point_of_sale/report/all_closed_cashbox_of_the_day.rml', parser=all_closed_cashbox_of_the_day)
@@ -104,9 +104,7 @@
<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 : [[ formatLang(o.date_order,date = True) ]]</para>
<para style="P4">
<font color="white"> </font>
</para>
@@ -28,7 +28,6 @@
"acess_pos_box_entries ","pos.box.entries ","model_pos_box_entries","point_of_sale.group_pos_user",1,0,0,0
"access_pos_box_out","pos.box.out","model_pos_box_out","point_of_sale.group_pos_user",1,0,0,0
"access_pos_details ","pos.details ","model_pos_details","point_of_sale.group_pos_user",1,0,0,0
"access_pos_details ","pos.details ","model_pos_details","point_of_sale.group_pos_user",1,0,0,0
"access_pos_sale_user","pos.sale.user","model_pos_sale_user","point_of_sale.group_pos_user",1,0,0,0
"access_pos_sale_user","pos.sales.user.today","model_pos_sales_user_today","point_of_sale.group_pos_user",1,0,0,0
"access_pos_sales_user_today_current_user","pos.sales.user.today.current_user","model_pos_sales_user_today_current_user","point_of_sale.group_pos_user",1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
28 acess_pos_box_entries pos.box.entries model_pos_box_entries point_of_sale.group_pos_user 1 0 0 0
29 access_pos_box_out pos.box.out model_pos_box_out point_of_sale.group_pos_user 1 0 0 0
30 access_pos_details pos.details model_pos_details point_of_sale.group_pos_user 1 0 0 0
access_pos_details pos.details model_pos_details point_of_sale.group_pos_user 1 0 0 0
31 access_pos_sale_user pos.sale.user model_pos_sale_user point_of_sale.group_pos_user 1 0 0 0
32 access_pos_sale_user pos.sales.user.today model_pos_sales_user_today point_of_sale.group_pos_user 1 0 0 0
33 access_pos_sales_user_today_current_user pos.sales.user.today.current_user model_pos_sales_user_today_current_user point_of_sale.group_pos_user 1 0 0 0
+13 -1
View File
@@ -22,6 +22,18 @@
rml="point_of_sale/report/account_statement.rml"
/>
<report
id="all_closed_cashbox_of_the_day"
string="All Cloded CashBOx"
model="account.bank.statement"
name="all.closed.cashbox.of.the.day"
auto="False"
multi="True"
menu = 'False'
rml="point_of_sale/report/all_closed_cashbox_of_the_day.rml"
/>
<report
id="pos_users_product_re"
string="User's Product"
@@ -44,7 +56,7 @@
<report
id="all_closed_cashbox_of_the_day"
string="All Closed CashBOx"
string="All Cloded CashBOx"
model="account.bank.statement"
name="all.closed.cashbox.of.the.day"
auto="False"
+1 -4
View File
@@ -427,10 +427,7 @@
<menuitem icon="STOCK_PRINT"
action="action_report_all_closed_cashbox_of_the_day"
id="menu_all_closed_cashbox_of_the_day"
parent="menu_statement_tree_all"
/>
parent="menu_statement_tree_all"/>
<menuitem
name="Close Register" parent="point_of_sale.menu_point_config"
+2 -13
View File
@@ -16,21 +16,10 @@
-->
<!-- <wizard
id="action_report_all_closed_cashbox_of_the_day2"
model="account.bank.statement"
menu="False"
name="all.closed.cashbox.of.the.day"
string="All Cashboxes Of the day"/>-->
<menuitem icon="STOCK_PRINT"
action="action_report_all_closed_cashbox_of_the_day"
id="menu_all_closed_cashbox_of_the_day"
parent="menu_point_report_register"
/>
parent="menu_point_report_register"/>
</data>
</openerp>
-2
View File
@@ -19,9 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard_return
import pos_add_product
import pos_confirm
import pos_discount
+1 -7
View File
@@ -31,13 +31,7 @@
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<!-- <act_window name="POS Details"
res_model="pos.details"
src_model="pos.order"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_report_pos_details"/> -->
</data>
</openerp>
+76 -75
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -15,98 +15,96 @@
# 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 netsvc
from osv import osv, fields
from osv import osv,fields
from tools.translate import _
import pos_box_entries
import time
from decimal import Decimal
from tools.translate import _
import pos_receipt
class pos_make_payment(osv.osv_memory):
_name = 'pos.make.payment'
_description = 'Point of Sale Payment'
def default_get(self, cr, uid, fields, context=None):
"""
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.
@param fields: List of fields for which we want default values
@param context: A standard dictionary
@return: A dictionary which of fields with values.
"""
if context is None:
context = {}
res = super(pos_make_payment, self).default_get(cr, uid, fields, context=context)
record_id = context and context.get('active_id', False)
record_id = context and context.get('active_id',False)
j_obj = self.pool.get('account.journal')
company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
company_id = self.pool.get('res.users').browse(cr,uid,uid).company_id.id
journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', company_id)])
if journal:
journal = journal[0]
else:
journal = None
wf_service = netsvc.LocalService("workflow")
order_obj=self.pool.get('pos.order')
order = order_obj.browse(cr, uid, record_id, context)
#get amount to pay
amount = order.amount_total - order.amount_paid
if amount <= 0.0:
context.update({'flag': True})
order_obj.action_paid(cr, uid, [record_id], context)
elif order.amount_paid > 0.0:
order_obj.write(cr, uid, [record_id], {'state': 'advance'})
invoice_wanted_checked = False
current_date = time.strftime('%Y-%m-%d')
if 'journal' in fields:
res.update({'journal': journal})
res.update({'journal':journal})
if 'amount' in fields:
res.update({'amount': amount})
res.update({'amount':amount})
if 'invoice_wanted' in fields:
res.update({'invoice_wanted': invoice_wanted_checked})
res.update({'invoice_wanted':invoice_wanted_checked})
if 'payment_date' in fields:
res.update({'payment_date': current_date})
if 'payment_name' in fields:
res.update({'payment_name': 'Payment'})
res.update({'payment_date':current_date})
if 'payment_name' in fields:
res.update({'payment_name':'Payment'})
return res
def view_init(self, cr, uid, fields_list, context=None):
res = super(pos_make_payment, self).view_init(cr, uid, fields_list, context=context)
record_id = context and context.get('active_id', False) or False
record_id = context and context.get('active_id', False) or False
order = self.pool.get('pos.order').browse(cr, uid, record_id)
if not order.lines:
raise osv.except_osv('Error!', 'No Order Lines ')
raise osv.except_osv('Error!','No Order Lines ')
True
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
@param context: A standard dictionary
@return: New arch of view.
"""
record_id = context and context.get('record_id', False) or False
res = super(pos_make_payment, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
record_id = context and context.get('record_id', False) or False
res = super(pos_make_payment, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
if record_id:
order = self.pool.get('pos.order').browse(cr, uid, record_id)
amount = order.amount_total - order.amount_paid
if amount == 0.0:
if amount==0.0:
res['arch'] = """ <form string="Make Payment" colspan="4">
<group col="2" colspan="2">
<label string="Do you want to print the Receipt?" colspan="4"/>
@@ -119,30 +117,33 @@ class pos_make_payment(osv.osv_memory):
return res
def check(self, cr, uid, ids, context=None):
"""Check the order:
if the order is not paid: continue payment,
if the order is paid print invoice (if wanted) or ticket.
"""
record_id = context and context.get('active_id', False)
record_id = context and context.get('active_id',False)
order_obj = self.pool.get('pos.order')
jrnl_obj = self.pool.get('account.journal')
jrnl_obj = self.pool.get('account.journal')
order = order_obj.browse(cr, uid, record_id, context)
amount = order.amount_total - order.amount_paid
data = self.read(cr, uid, ids)[0]
data = self.read(cr, uid, ids)[0]
# Todo need to check ...
if amount != 0.0:
if amount !=0.0:
invoice_wanted = data['invoice_wanted']
jrnl_used=False
if data.get('journal',False):
jrnl_used=jrnl_obj.browse(cr,uid,data['journal'])
order_obj.write(cr, uid, [record_id], {'invoice_wanted': invoice_wanted})
order_obj.add_payment(cr, uid, record_id, data, context=context)
if amount <= 0.0:
context.update({'flag': True})
order_obj.action_paid(cr, uid, [record_id], context)
order_obj.add_payment(cr, uid, record_id, data, context=context)
if amount<=0.0:
context.update({'flag':True})
order_obj.action_paid(cr,uid,[record_id],context)
if order_obj.test_paid(cr, uid, [record_id]):
if order.partner_id and order.invoice_wanted:
return self.create_invoice(cr, uid, ids, context)
return self.create_invoice(cr,uid,ids,context)
else:
order_obj.write(cr, uid, [record_id],{'state':'paid'})
return self.print_report(cr, uid, ids, context)
@@ -151,33 +152,34 @@ class pos_make_payment(osv.osv_memory):
return self.print_report(cr, uid, ids, context)
return {}
def create_invoice(self, cr, uid, ids, context):
wf_service = netsvc.LocalService("workflow")
record_ids = context and context.get('active_ids', False)
record_ids = context and context.get('active_ids',False)
for i in record_ids:
wf_service.trg_validate(uid, 'pos.order', i, 'invoice', cr)
datas = {'ids': context.get('active_ids', [])}
return {
'type': 'ir.actions.report.xml',
'report_name': 'pos.invoice',
'datas': datas,
}
datas = {'ids' : context.get('active_ids', [])}
return {
'type' : 'ir.actions.report.xml',
'report_name':'pos.invoice',
'datas' : datas,
}
def print_report(self, cr, uid, ids, context=None):
"""
@summary: To get the date and print the report
@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 : retrun report
"""
if context is None:
context = {}
datas = {'ids': context.get('active_ids', [])}
res = {}
if not context:
context={}
"""
@summary: To get the date and print the report
@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 : retrun report
"""
datas = {'ids' : context.get('active_ids',[])}
res = {}
datas['form'] = res
return {
'type': 'ir.actions.report.xml',
'report_name': 'pos.receipt',
@@ -185,17 +187,16 @@ class pos_make_payment(osv.osv_memory):
}
_columns = {
'journal': fields.selection(pos_box_entries.get_journal, "Journal", required=True),
'journal':fields.selection(pos_box_entries.get_journal, "Journal",required=True),
'product_id': fields.many2one('product.product', "Acompte"),
'amount': fields.float('Amount', digits=(16, 2), required= True),
'amount':fields.float('Amount', digits=(16,2) ,required= True),
'payment_name': fields.char('Payment name', size=32, required=True),
'payment_date': fields.date('Payment date', required=True),
'is_acc': fields.boolean('Accompte'),
'invoice_wanted': fields.boolean('Invoice'),
'num_sale': fields.char('Num.File', size=32),
'num_sale':fields.char('Num.File', size=32),
}
pos_make_payment()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -23,7 +23,6 @@
from osv import osv
from tools.translate import _
class pos_receipt(osv.osv_memory):
_name = 'pos.receipt'
_description = 'Point of sale receipt'
@@ -60,4 +59,3 @@ class pos_receipt(osv.osv_memory):
}
pos_receipt()
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- pos.details -->
<!-- pos sales user -->
<record id="view_pos_sale_user" model="ir.ui.view">
<field name="name">Sale By User</field>
<field name="model">pos.sale.user</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="POS Details :">
<form string="Sale By User">
<group col="2" colspan="4">
<field name="date_start"/>
<field name="date_end"/>
@@ -28,13 +28,7 @@
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<!-- <act_window name="POS Details"
res_model="pos.details"
src_model="pos.order"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_report_pos_details"/> -->
</data>
</openerp>
@@ -42,6 +42,6 @@ class pos_scan_product(osv.osv_memory):
record_id = context and context.get('active_id',False)
result =self. pool.get('pos.order.line')._scan_product(cr, uid, data['gencod'], 1, record_id)
return {'gencod': False}
pos_scan_product()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_pos_scan_product" model="ir.ui.view">
<field name="name">Scan product</field>
<field name="model">pos.scan.product</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Scan product">
<group col="2" colspan="4">
<label string="Scan Barcode" colspan="4"/>
<field name="gencod" colspan="4" nolabel="1"/>
<button icon='gtk-cancel' special="cancel"
string="Close" />
<button name="scan" string="Add"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<record id="action_pos_scan_product" model="ir.actions.act_window">
<field name="name">Scan product</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">pos.scan.product</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
-69
View File
@@ -1,69 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields
from osv import osv
import time
import ir
from mx import DateTime
import datetime
import pooler
from tools import config
import wizard
import netsvc
sale_forecast_res_form= """<?xml version="1.0"?>
<form string="Sale by User">
<field name="date_start" />
<field name="date_end" />
<field name="user_id" />
</form>
"""
sale_forecast_res_field= {
'date_start': {'string':'Start Date','type':'date','required': True,'default': lambda *a: time.strftime('%Y-%m-%d')},
'date_end': {'string':'End Date','type':'date','required': True,'default': lambda *a: time.strftime('%Y-%m-%d')},
'user_id': {'string': 'Salesman', 'type': 'many2many', 'relation': 'res.users', 'required': True},
}
class wizard_pos_sales_user(wizard.interface):
states = {
'init' : {
'actions' : [],
'result' : {'type' : 'form',
'arch' : sale_forecast_res_form,
'fields' : sale_forecast_res_field,
'state' : [('end', 'Cancel','gtk-cancel'),('print_report', 'Print Report','gtk-print') ]}
},
'print_report' : {
'actions' : [],
'result' : {'type' : 'print',
'report':'pos.sales.user',
'state' : 'end'}
},
}
wizard_pos_sales_user('pos.sales.user')
+1 -1
View File
@@ -11,7 +11,7 @@
<field name="grouped" />
<separator string="" colspan="6" />
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="makeInvoices" string="Create Invoices" type="object" icon="gtk-ok"/>
<button name="make_invoices" string="Create Invoices" type="object" icon="gtk-ok"/>
</form>
</field>
</record>
+3
View File
@@ -54,6 +54,9 @@ Thanks to the double entry management, the inventory controlling is powerful and
"wizard/stock_change_standard_price_view.xml",
"wizard/stock_picking_make_view.xml",
"wizard/stock_traceability_view.xml",
"wizard/stock_picking_make_view.xml",
"wizard/stock_return_picking_view.xml",
"wizard/stock_split_move_view.xml",
"stock_workflow.xml",
"stock_incoterms.xml",
"stock_wizard.xml",
+13 -1
View File
@@ -22,7 +22,8 @@
"access_stock_move_consume","stock.move.consume","model_stock_move_consume","stock.group_stock_user",1,0,0,0
"access_stock_move_scrap","stock.move.scrap","model_stock_move_scrap","stock.group_stock_user",1,0,0,0
"access_stock_move_split","stock.move.split","model_stock_move_split","stock.group_stock_user",1,0,0,0
"access_stock_move_split_lines","stock.move.split.lines","model_stock_move_split_lines","stock.group_stock_user",1,0,0,0"access_report_products_to_received_planned","report.products.to.received.planned","model_report_products_to_received_planned","stock.group_stock_user",1,0,0,0
"access_stock_move_split_lines","stock.move.split.lines","model_stock_move_split_lines","stock.group_stock_user",1,0,0,0
"access_report_products_to_received_planned","report.products.to.received.planned","model_report_products_to_received_planned","stock.group_stock_user",1,0,0,0
"access_report_delivery_products_planned","report.delivery.products.planned","model_report_delivery_products_planned","stock.group_stock_user",1,0,0,0
"access_stock_move_track","stock.move.track","model_stock_move_track","stock.group_stock_user",1,0,0,0
"access_stock_move_consume","stock.move.consume","model_stock_move_consume","stock.group_stock_user",1,0,0,0
@@ -35,3 +36,14 @@
"access_stock_invoice_onshipping","stock.invoice.onshipping","model_stock_invoice_onshipping","stock.group_stock_user",1,0,0,0
"access_stock_location_product","stock.location.product","model_stock_location_product","stock.group_stock_user",1,0,0,0
"access_report_stock_picking","report.stock.picking","model_report_stock_picking","stock.group_stock_user",1,0,0,0
"access_stock_delivery","stock.delivery","model_stock_delivery","stock.group_stock_user",1,0,0,0
"access_stock_traceability_upstream","stock.traceability.upstream","model_stock_traceability_upstream","stock.group_stock_user",1,0,0,0
"access_stock_traceability_downstream","stock.traceability.downstream","model_stock_traceability_downstream","stock.group_stock_user",1,0,0,0
"access_stock_traceability_lot_upstream","stock.traceability.lot.upstream","model_stock_traceability_lot_upstream","stock.group_stock_user",1,0,0,0
"access_stock_traceability_lot_downstream","stock.traceability.lot.downstream","model_stock_traceability_lot_downstream","stock.group_stock_user",1,0,0,0
"access_stock_partial_picking",stock.partial.picking","model_stock_partial_picking","stock.group_stock_user",1,0,0,0
"access_stock_partial_move","stock.partial.move","model_stock_partial_move","stock.group_stock_user",1,0,0,0
"access_stock_picking_make","stock.picking.make","model_stock_picking_make","stock.group_stock_user",1,0,0,0
"access_stock_inventory_merge","stock.inventory.merge","model_stock_inventory_merge","stock.group_stock_user",1,0,0,0
"access_stock_change_standard_price","stock.change.standard.price","model_stock_change_standard_price","stock.group_stock_user",1,0,0,0
Can't render this file because it contains an unexpected character in line 25 and column 121.
+7 -7
View File
@@ -591,7 +591,7 @@
type="action"
icon="gtk-go-forward"
help="Make Picking" colspan="2"/>
<button name="%(return_picking)d"
<button name="%(act_stock_return_picking)d"
states="done"
string="Return Picking"
type="action"
@@ -664,7 +664,7 @@
</field>
<group col="7" colspan="4">
<label colspan="6"/>
<button name="%(move_split)d" string="Split Entry Lines in two" type="action" icon="gtk-justify-fill"/>
<button name="%(act_split_moves)d" string="Split Entry Lines in two" type="action" icon="gtk-justify-fill"/>
</group>
<group col="10" colspan="4">
<field name="state" readonly="1"/>
@@ -758,7 +758,7 @@
type="action"
icon="gtk-go-forward"
help="Make Picking" colspan="2"/>
<button name="%(return_picking)d"
<button name="%(act_stock_return_picking)d"
states="done"
string="Return Picking"
type="action"
@@ -825,7 +825,7 @@
</field>
<group col="7" colspan="4">
<label colspan="6"/>
<button name="%(move_split)d" string="Split in Two" type="action" states="assigned,confirmed,draft,auto" icon="gtk-justify-fill"/>
<button name="%(act_split_moves)d" string="Split in Two" type="action" states="assigned,confirmed,draft,auto" icon="gtk-justify-fill"/>
</group>
<group col="10" colspan="4">
<field name="state" readonly="1"/>
@@ -952,7 +952,7 @@
type="action"
icon="gtk-go-forward"
help="Make Picking" colspan="2"/>
<button name="%(return_picking)d"
<button name="%(act_stock_return_picking)d"
states="done"
string="Return Picking"
type="action"
@@ -1022,7 +1022,7 @@
</field>
<group col="7" colspan="4">
<label colspan="6"/>
<button name="%(move_split)d" string="Split in Two" type="action" icon="gtk-justify-fill"/>
<button name="%(act_split_moves)d" string="Split in Two" type="action" icon="gtk-justify-fill"/>
</group>
<group col="10" colspan="4">
<field name="state" readonly="1"/>
@@ -1147,7 +1147,7 @@
type="action"
icon="gtk-go-forward"
help="Make Picking" colspan="2"/>
<button name="%(return_picking)d"
<button name="%(act_stock_return_picking)d"
states="done"
string="Return Picking"
type="action"
+6 -24
View File
@@ -6,29 +6,11 @@
<wizard string="UPS xml file" model="stock.move.lot" name="stock.ups_xml" />
-->
<wizard
id="move_split"
model="stock.picking"
multi="True"
name="stock.move.split"
string="Split move line"/>
<wizard
id="return_picking"
model="stock.picking"
menu="False"
keyword="client_action_multi"
name="stock.return.picking"
string="Return picking"/>
<wizard
id="split_inventory_lots"
model="stock.inventory.line"
multi="True"
name="stock.inventory.line.split"
string="Split inventory lines"/>
<wizard
id="split_inventory_lots"
model="stock.inventory.line"
multi="True"
name="stock.inventory.line.split"
string="Split inventory lines"/>
</data>
</openerp>
+2 -2
View File
@@ -25,8 +25,8 @@ import stock_partial_picking
import stock_partial_move
import stock_picking_make
import wizard_replacement
import wizard_return
import wizard_split_lot_line
import stock_return_picking
import stock_split_move
import wizard_ups
import stock_inventory_merge
import stock_inventory_set_stock_zero
@@ -98,14 +98,85 @@ class change_standard_price(osv.osv_memory):
"""
rec_id = context and context.get('active_id', False)
assert rec_id, _('Active ID is not set in Context')
prod_obj = self.pool.get('product.product')
res = self.browse(cr, uid, ids)
datas = {
'new_price' : res[0].new_price,
'stock_output_account' : res[0].stock_account_output.id,
'stock_input_account' : res[0].stock_account_input.id,
'stock_journal' : res[0].stock_journal.id
prod_obj = self.pool.get('product.template')
location_obj = self.pool.get('stock.location')
lot_obj = self.pool.get('stock.report.prodlots')
move_obj = self.pool.get('account.move')
move_line_obj = self.pool.get('account.move.line')
data_obj = self.pool.get('ir.model.data')
res = self.read(cr, uid, ids[0], ['new_price'])
new_price = res.get('new_price',[])
data = prod_obj.browse(cr, uid, rec_id)
diff = data.standard_price - new_price
prod_obj.write(cr, uid, rec_id, {'standard_price': new_price})
loc_ids = location_obj.search(cr, uid, [('account_id','<>',False),('usage','=','internal')])
lot_ids = lot_obj.search(cr, uid, [('location_id', 'in', loc_ids),('product_id','=',rec_id)])
qty = 0
debit = 0.0
credit = 0.0
stock_input_acc = data.property_stock_account_input.id or data.categ_id.property_stock_account_input_categ.id
stock_output_acc = data.property_stock_account_output.id or data.categ_id.property_stock_account_output_categ.id
for lots in lot_obj.browse(cr, uid, lot_ids):
qty += lots.name
if stock_input_acc and stock_output_acc and lot_ids:
move_id = move_obj.create(cr, uid, {'journal_id': data.categ_id.property_stock_journal.id})
if diff > 0:
credit = qty * diff
move_line_obj.create(cr, uid, {
'name': data.name,
'account_id': stock_input_acc,
'credit': credit,
'move_id': move_id
})
for lots in lot_obj.browse(cr, uid, lot_ids):
credit = lots.name * diff
move_line_obj.create(cr, uid, {
'name': 'Expense',
'account_id': lots.location_id.account_id.id,
'debit': credit,
'move_id': move_id
})
elif diff < 0:
debit = qty * -diff
move_line_obj.create(cr, uid, {
'name': data.name,
'account_id': stock_output_acc,
'debit': debit,
'move_id': move_id
})
for lots in lot_obj.browse(cr, uid, lot_ids):
debit = lots.name * -diff
move_line_obj.create(cr, uid, {
'name': 'Income',
'account_id': lots.location_id.account_id.id,
'credit': debit,
'move_id': move_id
})
else:
raise osv.except_osv(_('Warning!'),_('No Change in Price.'))
else:
raise osv.except_osv(_('Warning!'),_('No Accounts are defined for '
'this product on its location.\nCan\'t create Move.'))
id2 = data_obj._get_id(cr, uid, 'account', 'view_move_tree')
id3 = data_obj._get_id(cr, uid, 'account', 'view_move_form')
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': 'account.move',
'res_id' : move_id,
'views': [(id3,'form'),(id2,'tree')],
'type': 'ir.actions.act_window',
}
prod_obj.do_change_standard_price(cr, uid, [rec_id], datas, context)
return {}
+27 -27
View File
@@ -68,35 +68,35 @@ class stock_fill_inventory(osv.osv_memory):
res = location_obj._product_get(cr, uid,
fill_inventory.location_id.id, context=context)
res_location[fill_inventory.location_id.id] = res
product_ids = []
for location in res_location.keys():
res = res_location[location]
for product_id in res.keys():
prod = product_obj.browse(cr, uid, [product_id])[0]
uom = prod.uom_id.id
context.update({'uom': uom})
amount = stock_location_obj._product_get(cr, uid,
location, [product_id], context=context)[product_id]
product_ids = []
for location in res_location.keys():
res = res_location[location]
for product_id in res.keys():
prod = product_obj.browse(cr, uid, [product_id])[0]
uom = prod.uom_id.id
context.update({'uom': uom})
amount = stock_location_obj._product_get(cr, uid,
location, [product_id], context=context)[product_id]
if(amount):
line_ids=inventory_line_obj.search(cr, uid,
[('inventory_id', '=', context['active_ids']),
('location_id', '=', location),
('product_id', '=', product_id),
('product_uom', '=', uom),
('product_qty', '=', amount)])
if not len(line_ids):
inventory_line = {'inventory_id': context['active_ids'][0],
'location_id': location,
'product_id': product_id,
'product_uom': uom,
'product_qty': amount}
inventory_line_obj.create(cr, uid, inventory_line)
product_ids.append(product_id)
if(amount):
line_ids=inventory_line_obj.search(cr, uid,
[('inventory_id', '=', context['active_ids']),
('location_id', '=', location),
('product_id', '=', product_id),
('product_uom', '=', uom),
('product_qty', '=', amount)])
if not len(line_ids):
inventory_line = {'inventory_id': context['active_ids'][0],
'location_id': location,
'product_id': product_id,
'product_uom': uom,
'product_qty': amount}
inventory_line_obj.create(cr, uid, inventory_line)
product_ids.append(product_id)
if(len(product_ids) == 0):
raise osv.except_osv(_('Message !'), _('No product in this location.'))
if(len(product_ids) == 0):
raise osv.except_osv(_('Message !'), _('No product in this location.'))
return {}
stock_fill_inventory()
+221
View File
@@ -0,0 +1,221 @@
# -*- 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 osv,fields
from tools.translate import _
class stock_return_picking(osv.osv_memory):
_name = 'stock.return.picking'
_description = 'Return Picking'
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(stock_return_picking, self).default_get(cr, uid, fields, context=context)
record_id = context and context.get('active_id', False) or False
pick_obj = self.pool.get('stock.picking')
pick = pick_obj.browse(cr, uid, record_id)
for m in [line for line in pick.move_lines]:
res['return%s'%(m.id)] = m.product_qty
if pick.invoice_state=='invoiced':
res['invoice_state'] = '2binvoiced'
else:
res['invoice_state'] = 'none'
return res
def view_init(self, cr, uid, fields_list, context=None):
"""
Creates view dynamically and adding fields at runtime.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return: New arch of view with new columns.
"""
res = super(stock_return_picking, self).view_init(cr, uid, fields_list, context=context)
record_id = context and context.get('active_id', False) or False
if record_id:
pick_obj = self.pool.get('stock.picking')
try:
pick = pick_obj.browse(cr, uid, record_id)
for m in [line for line in pick.move_lines]:
if 'return%s'%(m.id) not in self._columns:
self._columns['return%s'%(m.id)] = fields.float(string=m.name, required=True)
if 'invoice_state' not in self._columns:
self._columns['invoice_state'] = fields.selection([('2binvoiced', 'To be Invoiced'), ('none', 'None')], string='Invoice State', required=True)
except Exception, e:
return res
return res
def fields_view_get(self, cr, uid, view_id=None, view_type='form',
context=None, toolbar=False, submenu=False):
"""
Changes the view dynamically
@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.
"""
res = super(stock_return_picking, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
record_id = context and context.get('active_id', False) or False
assert record_id,'Active ID not found'
if record_id:
pick_obj = self.pool.get('stock.picking')
pick = pick_obj.browse(cr, uid, record_id)
try:
if pick.state != 'done':
raise osv.except_osv(_('Warning !'), _("The Picking is not completed yet!\nYou cannot return picking which is not in 'Done' state!"))
return_history = {}
for m_line in pick.move_lines:
return_history[m_line.id] = 0
for rec in m_line.move_stock_return_history:
return_history[m_line.id] += rec.product_qty
res['fields'].clear()
arch_lst=['<?xml version="1.0"?>', '<form string="%s">' % _('Return lines'), '<label string="%s" colspan="4"/>' % _('Provide the quantities of the returned products.')]
for m in [line for line in pick.move_lines]:
quantity = m.product_qty
if quantity > return_history[m.id] and (quantity - return_history[m.id])>0:
arch_lst.append('<field name="return%s"/>\n<newline/>' % (m.id,))
res['fields']['return%s' % m.id]={'string':m.name, 'type':'float', 'required':True}
res.setdefault('returns', []).append(m.id)
if not res.get('returns',False):
raise osv.except_osv(_('Warning!'),_('There is no product to return!'))
arch_lst.append('<field name="invoice_state"/>\n<newline/>')
if pick.invoice_state=='invoiced':
new_invoice_state='2binvoiced'
else:
new_invoice_state=pick.invoice_state
res['fields']['invoice_state']={'string':_('Invoice state'), 'type':'selection','required':True, 'selection':[('2binvoiced', _('To Be Invoiced')), ('none', _('None'))]}
arch_lst.append('<group col="2" colspan="4">')
arch_lst.append('<button icon="gtk-cancel" special="cancel" string="Cancel" />')
arch_lst.append('<button name="action_open_window" string="Return" colspan="1" type="object" icon="gtk-apply" />')
arch_lst.append('</group>')
arch_lst.append('</form>')
res['arch'] = '\n'.join(arch_lst)
except Exception,e:
return res
return res
def _create_returns(self, cr, uid, ids, context):
"""
Creates return picking.
@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 of fields with values.
"""
record_id = context and context.get('active_id', False) or False
move_obj = self.pool.get('stock.move')
pick_obj = self.pool.get('stock.picking')
uom_obj = self.pool.get('product.uom')
wf_service = netsvc.LocalService("workflow")
pick = pick_obj.browse(cr, uid, record_id)
data = self.read(cr, uid, ids[0])
new_picking = None
date_cur = time.strftime('%Y-%m-%d %H:%M:%S')
move_ids = [m.id for m in [line for line in pick.move_lines]]
set_invoice_state_to_none = True
for move in move_obj.browse(cr, uid, move_ids):
if not new_picking:
if pick.type=='out':
new_type = 'in'
elif pick.type=='in':
new_type = 'out'
else:
new_type = 'internal'
new_picking = pick_obj.copy(cr, uid, pick.id, {'name':'%s (return)' % pick.name,
'move_lines':[], 'state':'draft', 'type':new_type,
'date':date_cur, 'invoice_state':data['invoice_state'],})
new_location=move.location_dest_id.id
new_qty = data['return%s' % move.id]
returned_qty = move.product_qty
for rec in move.move_stock_return_history:
returned_qty -= rec.product_qty
if returned_qty != new_qty:
set_invoice_state_to_none = False
new_move=move_obj.copy(cr, uid, move.id, {
'product_qty': new_qty,
'product_uos_qty': uom_obj._compute_qty(cr, uid, move.product_uom.id,
new_qty, move.product_uos.id),
'picking_id':new_picking, 'state':'draft',
'location_id':new_location, 'location_dest_id':move.location_id.id,
'date':date_cur, 'date_planned':date_cur,})
move_obj.write(cr, uid, [move.id], {'move_stock_return_history':[(4,new_move)]})
if set_invoice_state_to_none:
pick_obj.write(cr, uid, [pick.id], {'invoice_state':'none'})
if new_picking:
if new_picking:
wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr)
pick_obj.force_assign(cr, uid, [new_picking], context)
return new_picking
def action_open_window(self, cr, uid, ids, context):
"""
Opens return picking list.
@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 of fields with values.
"""
res = self._create_returns(cr, uid, ids, context)
if not res:
return {}
return {
'domain': "[('id', 'in', ["+str(res)+"])]",
'name': 'Picking List',
'view_type':'form',
'view_mode':'tree,form',
'res_model':'stock.picking',
'view_id':False,
'type':'ir.actions.act_window',
}
stock_return_picking()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Return Picking -->
<record id="act_stock_return_picking" model="ir.actions.act_window">
<field name="name">Return Picking</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.return.picking</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
+125
View File
@@ -0,0 +1,125 @@
# -*- 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
class stock_split_move_line(osv.osv_memory):
_name = 'stock.move.line.split'
_description = "Split Moves"
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(stock_split_move_line, self).default_get(cr, uid, fields, context=context)
record_id = context and context.get('active_id', False) or False
pick_obj = self.pool.get('stock.picking')
pick = pick_obj.browse(cr, uid, record_id)
for m in [line for line in pick.move_lines]:
res['move%s'%(m.id)] = m.product_qty
return res
def view_init(self, cr, uid, fields_list, context=None):
"""
Creates view dynamically and adding fields at runtime.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return: New arch of view with new columns.
"""
res = super(stock_split_move_line, self).view_init(cr, uid, fields_list, context=context)
record_id = context and context.get('active_id', False) or False
if record_id:
pick_obj = self.pool.get('stock.picking')
try:
pick = pick_obj.browse(cr, uid, record_id)
for m in [line for line in pick.move_lines]:
if 'move%s' % m.id not in self._columns:
self._columns['move%s' % m.id] = fields.float(string=m.product_id.name)
except:
return res
return res
def fields_view_get(self, cr, uid, view_id=None, view_type='form',
context=None, toolbar=False, submenu=False):
"""
Changes the view dynamically
@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.
"""
res = super(stock_split_move_line, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
record_id = context and context.get('active_id', False) or False
assert record_id,'Active ID not found'
pick_obj = self.pool.get('stock.picking')
pick = pick_obj.browse(cr, uid, record_id)
arch_lst = ['<?xml version="1.0"?>', '<form string="Split lines">', '<label string="Indicate here the quantity of the new line. A quantity of zero will not split the line." colspan="4"/>']
for m in [line for line in pick.move_lines]:
quantity = m.product_qty
arch_lst.append('<field name="move%s" />\n<newline />' % (m.id,))
res['fields']['move%s' % m.id] = {'string' : m.product_id.name, 'type' : 'float', 'required' : True}
arch_lst.append('<group col="2" colspan="4">')
arch_lst.append('<button icon="gtk-cancel" special="cancel" string="Cancel" />')
arch_lst.append('<button name="split_lines" string="Split" colspan="1" type="object" icon="gtk-apply" />')
arch_lst.append('</group>')
arch_lst.append('</form>')
res['arch'] = '\n'.join(arch_lst)
return res
def split_lines(self, cr, uid, ids, context):
"""
Splits moves in quantity given in the wizard.
@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 of fields with values.
"""
move_obj = self.pool.get('stock.move')
record_id = context and context.get('active_id', False) or False
pick_obj = self.pool.get('stock.picking')
pick = pick_obj.browse(cr, uid, record_id)
data = self.read(cr, uid, ids[0])
move_ids = [m.id for m in [line for line in pick.move_lines]]
for move in move_obj.browse(cr, uid, move_ids):
quantity = data['move%s' % move.id]
if 0 < quantity < move.product_qty:
new_qty = move.product_qty - quantity
new_uos_qty = new_qty / move.product_qty * move.product_uos_qty
new_obj = move_obj.copy(cr, uid, move.id, {'product_qty' : new_qty, 'product_uos_qty': new_uos_qty, 'state':move.state})
uos_qty = quantity / move.product_qty * move.product_uos_qty
move_obj.write(cr, uid, [move.id], {'product_qty' : quantity, 'product_uos_qty': uos_qty})
return {}
stock_split_move_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Split Moves -->
<record id="act_split_moves" model="ir.actions.act_window">
<field name="name">Split Moves</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.move.line.split</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
-156
View File
@@ -1,156 +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
from tools.misc import UpdateableStr
import netsvc
import time
from tools.translate import _
arch=UpdateableStr()
fields={}
def make_default(val):
def fct(obj, cr, uid):
return val
return fct
def _get_returns(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
pick_obj = pool.get('stock.picking')
pick = pick_obj.browse(cr, uid, [data['id']])[0]
if pick.state != 'done':
raise wizard.except_wizard(_('Warning !'), _("The Picking is not completed yet!\nYou cannot return picking which is not in 'Done' state!"))
res = {}
return_history = {}
for m_line in pick.move_lines:
return_history[m_line.id] = 0
for rec in m_line.move_stock_return_history:
return_history[m_line.id] += rec.product_qty
fields.clear()
arch_lst=['<?xml version="1.0"?>', '<form string="%s">' % _('Return lines'), '<label string="%s" colspan="4"/>' % _('Provide the quantities of the returned products.')]
for m in [line for line in pick.move_lines]:
quantity = m.product_qty
if quantity > return_history[m.id] and (quantity - return_history[m.id])>0:
arch_lst.append('<field name="return%s"/>\n<newline/>' % (m.id,))
fields['return%s' % m.id]={'string':m.name, 'type':'float', 'required':True, 'default':make_default(quantity - return_history[m.id])}
res.setdefault('returns', []).append(m.id)
if not res.get('returns',False):
raise wizard.except_wizard(_('Warning!'),_('There is no product to return!'))
arch_lst.append('<field name="invoice_state"/>\n<newline/>')
if pick.invoice_state=='invoiced':
new_invoice_state='2binvoiced'
else:
new_invoice_state=pick.invoice_state
fields['invoice_state']={'string':_('Invoice state'), 'type':'selection', 'default':make_default(new_invoice_state), 'required':True, 'selection':[('2binvoiced', _('to be invoiced')), ('none', _('None'))]}
arch_lst.append('</form>')
arch.string='\n'.join(arch_lst)
return res
def _create_returns(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
move_obj = pool.get('stock.move')
pick_obj = pool.get('stock.picking')
uom_obj = pool.get('product.uom')
pick=pick_obj.browse(cr, uid, [data['id']])[0]
new_picking=None
date_cur=time.strftime('%Y-%m-%d %H:%M:%S')
set_invoice_state_to_none = True
for move in move_obj.browse(cr, uid, data['form'].get('returns',[])):
if not new_picking:
if pick.type=='out':
new_type='in'
elif pick.type=='in':
new_type='out'
else:
new_type='internal'
new_picking=pick_obj.copy(cr, uid, pick.id, {'name':'%s (return)' % pick.name,
'move_lines':[], 'state':'draft', 'type':new_type,
'date':date_cur, 'invoice_state':data['form']['invoice_state'],})
new_location=move.location_dest_id.id
new_qty = data['form']['return%s' % move.id]
returned_qty = move.product_qty
for rec in move.move_stock_return_history:
returned_qty -= rec.product_qty
if returned_qty != new_qty:
set_invoice_state_to_none = False
new_move=move_obj.copy(cr, uid, move.id, {
'product_qty': new_qty,
'product_uos_qty': uom_obj._compute_qty(cr, uid, move.product_uom.id,
new_qty, move.product_uos.id),
'picking_id':new_picking, 'state':'draft',
'location_id':new_location, 'location_dest_id':move.location_id.id,
'date':date_cur, 'date_planned':date_cur,})
move_obj.write(cr, uid, [move.id], {'move_stock_return_history':[(4,new_move)]})
if set_invoice_state_to_none:
pick_obj.write(cr, uid, [pick.id], {'invoice_state':'none'})
if new_picking:
wf_service = netsvc.LocalService("workflow")
if new_picking:
wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr)
pick_obj.force_assign(cr, uid, [new_picking], context)
return new_picking
def _action_open_window(self, cr, uid, data, context):
res=_create_returns(self, cr, uid, data, context)
if not res:
return {}
return {
'domain': "[('id', 'in', ["+str(res)+"])]",
'name': 'Picking List',
'view_type':'form',
'view_mode':'tree,form',
'res_model':'stock.picking',
'view_id':False,
'type':'ir.actions.act_window',
}
class wizard_return_picking(wizard.interface):
states={
'init':{
'actions':[_get_returns],
'result':{'type':'form', 'arch':arch, 'fields':fields, 'state':[('end','Cancel','gtk-cancel'),('return','Return','gtk-apply',True)]}
},
'return':{
'actions':[],
'result':{'type':'action', 'action':_action_open_window, 'state':'end'}
}
}
wizard_return_picking('stock.return.picking')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,80 +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 time
from osv import osv
from tools.misc import UpdateableStr
arch = UpdateableStr()
fields = {}
def make_default(val):
def fct(obj, cr, uid):
return val
return fct
def _get_moves(self, cr, uid, data, context):
pick_obj = pooler.get_pool(cr.dbname).get('stock.picking')
pick = pick_obj.browse(cr, uid, [data['id']])[0]
res = {}
fields.clear()
arch_lst = ['<?xml version="1.0"?>', '<form string="Split lines">', '<label string="Indicate here the quantity of the new line. A quantity of zero will not split the line." colspan="4"/>']
for m in [line for line in pick.move_lines]:
quantity = m.product_qty
arch_lst.append('<field name="move%s" />\n<newline />' % (m.id,))
fields['move%s' % m.id] = {'string' : m.product_id.name, 'type' : 'float', 'required' : True, 'default' : make_default(quantity)}
res.setdefault('moves', []).append(m.id)
arch_lst.append('</form>')
arch.string = '\n'.join(arch_lst)
return res
def _split_lines(self, cr, uid, data, context):
move_obj = pooler.get_pool(cr.dbname).get('stock.move')
for move in move_obj.browse(cr, uid, data['form']['moves']):
quantity = data['form']['move%s' % move.id]
if 0 < quantity < move.product_qty:
new_qty = move.product_qty - quantity
new_uos_qty = new_qty / move.product_qty * move.product_uos_qty
new_obj = move_obj.copy(cr, uid, move.id, {'product_qty' : new_qty, 'product_uos_qty': new_uos_qty, 'state':move.state})
uos_qty = quantity / move.product_qty * move.product_uos_qty
move_obj.write(cr, uid, [move.id], {'product_qty' : quantity, 'product_uos_qty': uos_qty})
return {}
class wizard_split_move(wizard.interface):
states = {
'init': {
'actions': [_get_moves],
'result': {'type':'form', 'arch':arch, 'fields':fields, 'state':[('end','Cancel','gtk-cancel'),('split','Split','gtk-apply',True)]}
},
'split': {
'actions': [_split_lines],
'result': {'type':'state', 'state':'end'}
}
}
wizard_split_move('stock.move.split')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: