diff --git a/addons/account/security/account_security.xml b/addons/account/security/account_security.xml
index f551d77ccaa..cd9727d5903 100644
--- a/addons/account/security/account_security.xml
+++ b/addons/account/security/account_security.xml
@@ -46,7 +46,7 @@
child_ofuser.company_id.id
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
@@ -60,7 +60,7 @@
child_ofuser.company_id.id
- ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
@@ -72,7 +72,7 @@
child_ofuser.company_id.id
- ['|','|',('company_id','=',False),('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]
+ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
@@ -85,7 +85,7 @@
child_ofuser.company_id.id
- ['|','|',('company_id','=',False),('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]
+ ['|','|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
diff --git a/addons/auction/__terp__.py b/addons/auction/__terp__.py
index ecc91f4e2d2..61e91802f44 100644
--- a/addons/auction/__terp__.py
+++ b/addons/auction/__terp__.py
@@ -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'
diff --git a/addons/auction/auction.py b/addons/auction/auction.py
index 0ece4690d9f..1687980c029 100644
--- a/addons/auction/auction.py
+++ b/addons/auction/auction.py
@@ -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):
diff --git a/addons/auction/auction_view.xml b/addons/auction/auction_view.xml
index 2189253f3ce..ee1004ab0f3 100644
--- a/addons/auction/auction_view.xml
+++ b/addons/auction/auction_view.xml
@@ -3,7 +3,8 @@
-
+
+
=======================================================
Auction Management/Configuration/artist
=======================================================
@@ -203,6 +204,7 @@
+
@@ -277,7 +279,7 @@
-
+
@@ -330,7 +332,6 @@
-
@@ -340,9 +341,7 @@
-
-
diff --git a/addons/auction/auction_wizard.xml b/addons/auction/auction_wizard.xml
index 0a93799cc20..ab1b051add5 100644
--- a/addons/auction/auction_wizard.xml
+++ b/addons/auction/auction_wizard.xml
@@ -1,8 +1,8 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ -->
diff --git a/addons/auction/security/ir.model.access.csv b/addons/auction/security/ir.model.access.csv
index 642209edd05..1c1df0828ca 100644
--- a/addons/auction/security/ir.model.access.csv
+++ b/addons/auction/security/ir.model.access.csv
@@ -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
diff --git a/addons/auction/wizard/__init__.py b/addons/auction/wizard/__init__.py
index ec07ef6e04f..bcd2de8b301 100644
--- a/addons/auction/wizard/__init__.py
+++ b/addons/auction/wizard/__init__.py
@@ -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:
diff --git a/addons/auction/wizard/auction_catalog_flagey_report.py b/addons/auction/wizard/auction_catalog_flagey_report.py
new file mode 100644
index 00000000000..119c3273ee0
--- /dev/null
+++ b/addons/auction/wizard/auction_catalog_flagey_report.py
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+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:
+
diff --git a/addons/auction/wizard/auction_catalog_flagey_view.xml b/addons/auction/wizard/auction_catalog_flagey_view.xml
new file mode 100644
index 00000000000..ca87771cc37
--- /dev/null
+++ b/addons/auction/wizard/auction_catalog_flagey_view.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+ Auction Catalog Flagey
+ auction.catalog.flagey
+ form
+
+
+
+
+
+
+
+
diff --git a/addons/mrp/wizard/wizard_price.py b/addons/auction/wizard/auction_lots_able.py
similarity index 57%
rename from addons/mrp/wizard/wizard_price.py
rename to addons/auction/wizard/auction_lots_able.py
index dd84ad23be2..8ddeeca8055 100644
--- a/addons/mrp/wizard/wizard_price.py
+++ b/addons/auction/wizard/auction_lots_able.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -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 .
+# along with this program. If not, see .
#
##############################################################################
-
+from osv import fields, osv
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import tools
import wizard
-price_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()
diff --git a/addons/auction/wizard/auction_lots_able_view.xml b/addons/auction/wizard/auction_lots_able_view.xml
new file mode 100644
index 00000000000..96135460c72
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_able_view.xml
@@ -0,0 +1,30 @@
+
+
+
+
+ auction.lots.able.form
+ auction.lots.able
+ form
+
+
+
+
+
+
+
diff --git a/addons/auction/wizard/auction_lots_auction_move.py b/addons/auction/wizard/auction_lots_auction_move.py
new file mode 100644
index 00000000000..24b2604d1d7
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_auction_move.py
@@ -0,0 +1,88 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+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:
+
diff --git a/addons/auction/wizard/auction_lots_auction_move_view.xml b/addons/auction/wizard/auction_lots_auction_move_view.xml
new file mode 100644
index 00000000000..dd116a8bc6c
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_auction_move_view.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ auction.lots.auction.move.form
+ auction.lots.auction.move
+ form
+
+
+
+
+
+
+
+
diff --git a/addons/auction/wizard/auction_lots_buyer_map.py b/addons/auction/wizard/auction_lots_buyer_map.py
new file mode 100644
index 00000000000..db80a2ab3f3
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_buyer_map.py
@@ -0,0 +1,127 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+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'] = """
+
+ """
+ return res
+
+wiz_auc_lots_buyer_map()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/auction/wizard/auction_lots_buyer_map_view.xml b/addons/auction/wizard/auction_lots_buyer_map_view.xml
new file mode 100644
index 00000000000..c76c74983d2
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_buyer_map_view.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+ Map buyer username to Partners
+ auction.lots.buyer_map
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/auction/wizard/auction_catalog_flagey.py b/addons/auction/wizard/auction_lots_enable.py
similarity index 52%
rename from addons/auction/wizard/auction_catalog_flagey.py
rename to addons/auction/wizard/auction_lots_enable.py
index fd73e7dadc4..e8aa5edadf5 100644
--- a/addons/auction/wizard/auction_catalog_flagey.py
+++ b/addons/auction/wizard/auction_lots_enable.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -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 .
+# along with this program. If not, see .
#
##############################################################################
-
-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()
diff --git a/addons/auction/wizard/auction_lots_enable_view.xml b/addons/auction/wizard/auction_lots_enable_view.xml
new file mode 100644
index 00000000000..8384524dad2
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_enable_view.xml
@@ -0,0 +1,34 @@
+
+
+
+
+ auction.lots.enable.form
+ auction.lots.enable
+ form
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/auction/wizard/auction_lots_invoice.py b/addons/auction/wizard/auction_lots_invoice.py
new file mode 100644
index 00000000000..9581941266f
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_invoice.py
@@ -0,0 +1,124 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+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:
diff --git a/addons/auction/wizard/auction_lots_invoice_view.xml b/addons/auction/wizard/auction_lots_invoice_view.xml
new file mode 100644
index 00000000000..4adc7098789
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_invoice_view.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+ auction.lots.invoice.wizard
+ auction.lots.invoice
+ form
+
+
+
+
+
+
+
+
diff --git a/addons/auction/wizard/auction_lots_make_invoice.py b/addons/auction/wizard/auction_lots_make_invoice.py
new file mode 100644
index 00000000000..6be49f7336a
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_make_invoice.py
@@ -0,0 +1,96 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+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()
diff --git a/addons/auction/wizard/auction_lots_make_invoice_buyer.py b/addons/auction/wizard/auction_lots_make_invoice_buyer.py
new file mode 100644
index 00000000000..53c3519d225
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_make_invoice_buyer.py
@@ -0,0 +1,100 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+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()
diff --git a/addons/auction/wizard/auction_lots_make_invoice_buyer_view.xml b/addons/auction/wizard/auction_lots_make_invoice_buyer_view.xml
new file mode 100644
index 00000000000..ba4aac79ca6
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_make_invoice_buyer_view.xml
@@ -0,0 +1,36 @@
+
+
+
+
+ auction.lots.make.invoice.buyer.form
+ auction.lots.make.invoice.buyer
+ form
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/auction/wizard/auction_lots_make_invoice_view.xml b/addons/auction/wizard/auction_lots_make_invoice_view.xml
new file mode 100644
index 00000000000..29ef3e09348
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_make_invoice_view.xml
@@ -0,0 +1,33 @@
+
+
+
+
+ auction.lots.make.invoice.form
+ auction.lots.make.invoice
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/auction/wizard/auction_lots_sms_send.py b/addons/auction/wizard/auction_lots_sms_send.py
new file mode 100644
index 00000000000..a5736ce4990
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_sms_send.py
@@ -0,0 +1,78 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+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:
+
diff --git a/addons/auction/wizard/auction_lots_sms_send_view.xml b/addons/auction/wizard/auction_lots_sms_send_view.xml
new file mode 100644
index 00000000000..22aa9d681ac
--- /dev/null
+++ b/addons/auction/wizard/auction_lots_sms_send_view.xml
@@ -0,0 +1,35 @@
+
+
+
+
+ auction.lots.sms.send.form
+ auction.lots.sms.send
+ form
+
+
+
+
+
+
+
diff --git a/addons/auction/wizard/auction_pay_buy.py b/addons/auction/wizard/auction_pay_buy.py
new file mode 100644
index 00000000000..8f16ea9e7de
--- /dev/null
+++ b/addons/auction/wizard/auction_pay_buy.py
@@ -0,0 +1,115 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+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:
+
diff --git a/addons/auction/wizard/auction_pay_buy_view.xml b/addons/auction/wizard/auction_pay_buy_view.xml
new file mode 100644
index 00000000000..0a9a3a6dcee
--- /dev/null
+++ b/addons/auction/wizard/auction_pay_buy_view.xml
@@ -0,0 +1,37 @@
+
+
+
+
+ auction.pay.buy.form
+ auction.pay.buy
+ form
+
+
+
+
+
+
+
diff --git a/addons/auction/wizard/auction_pay_sel.py b/addons/auction/wizard/auction_pay_sel.py
new file mode 100644
index 00000000000..df7b4a794f3
--- /dev/null
+++ b/addons/auction/wizard/auction_pay_sel.py
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+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()
diff --git a/addons/auction/wizard/auction_pay_sel_view.xml b/addons/auction/wizard/auction_pay_sel_view.xml
new file mode 100644
index 00000000000..2570b7a7a0a
--- /dev/null
+++ b/addons/auction/wizard/auction_pay_sel_view.xml
@@ -0,0 +1,35 @@
+
+
+
+
+ auction.pay.sel.form
+ auction.pay.sel
+ form
+
+
+
+
+
+
+ Pay objects of the seller
+ auction.pay.sel
+ form
+ tree,form
+
+ new
+
+
+
+
diff --git a/addons/auction/wizard/auction_wizard_able_taken.py b/addons/auction/wizard/auction_payer_sel.py
similarity index 51%
rename from addons/auction/wizard/auction_wizard_able_taken.py
rename to addons/auction/wizard/auction_payer_sel.py
index 261cc47c48b..349f10d4dec 100644
--- a/addons/auction/wizard/auction_wizard_able_taken.py
+++ b/addons/auction/wizard/auction_payer_sel.py
@@ -19,43 +19,42 @@
#
##############################################################################
-import wizard
+from osv import fields, osv
+from tools.translate import _
import netsvc
import pooler
-take_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:
diff --git a/addons/auction/wizard/auction_payer_sel_view.xml b/addons/auction/wizard/auction_payer_sel_view.xml
new file mode 100644
index 00000000000..57c43df8fe4
--- /dev/null
+++ b/addons/auction/wizard/auction_payer_sel_view.xml
@@ -0,0 +1,43 @@
+
+
+
+
+ auction.payer.form
+ auction.payer
+ form
+
+
+
+
+
+
+ auction.payer.sel.form
+ auction.payer.sel
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/auction/wizard/auction_taken.py b/addons/auction/wizard/auction_taken.py
new file mode 100644
index 00000000000..63c3db7583c
--- /dev/null
+++ b/addons/auction/wizard/auction_taken.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+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('&','&').replace('<','<').replace('>','>')
+
+ 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()
diff --git a/addons/auction/wizard/auction_taken_view.xml b/addons/auction/wizard/auction_taken_view.xml
new file mode 100644
index 00000000000..626caa473ad
--- /dev/null
+++ b/addons/auction/wizard/auction_taken_view.xml
@@ -0,0 +1,42 @@
+
+
+
+
+ auction.taken.form
+ auction.taken
+ form
+
+
+
+
+
+
+ Gestion emporte
+ auction.taken
+ form
+ tree,form
+
+ new
+
+
+
+
+
+
diff --git a/addons/auction/wizard/wizard_auction_invoice_buyer.py b/addons/auction/wizard/wizard_auction_invoice_buyer.py
deleted file mode 100644
index 6cf12b5da22..00000000000
--- a/addons/auction/wizard/wizard_auction_invoice_buyer.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import pooler
-
-invoice_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:
-
diff --git a/addons/auction/wizard/wizard_auction_journal.py b/addons/auction/wizard/wizard_auction_journal.py
deleted file mode 100644
index 79329592165..00000000000
--- a/addons/auction/wizard/wizard_auction_journal.py
+++ /dev/null
@@ -1,105 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import pooler
-
-
-
-invoice_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:
-
diff --git a/addons/auction/wizard/wizard_emporte.py b/addons/auction/wizard/wizard_emporte.py
deleted file mode 100644
index 1172404e218..00000000000
--- a/addons/auction/wizard/wizard_emporte.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-
-import pooler
-from tools.misc import UpdateableStr
-
-
-# Dossier
-
-_lot_arch = """
-
-"""
-_lot_fields = {
- 'lot_ids': {'string':'Lots Emportes','relation':'auction.lots','type':'many2many'}
-}
-
-def _to_xml(s):
- return s.replace('&','&').replace('<','<').replace('>','>')
-
-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:
-
diff --git a/addons/auction/wizard/wizard_lot_date_move.py b/addons/auction/wizard/wizard_lot_date_move.py
deleted file mode 100644
index e6e13ea0ab2..00000000000
--- a/addons/auction/wizard/wizard_lot_date_move.py
+++ /dev/null
@@ -1,96 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import pooler
-import sql_db
-
-auction_move = '''
-'''
-
-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:
-
diff --git a/addons/auction/wizard/wizard_lots_buyer_map.py b/addons/auction/wizard/wizard_lots_buyer_map.py
deleted file mode 100644
index 42c5f80a530..00000000000
--- a/addons/auction/wizard/wizard_lots_buyer_map.py
+++ /dev/null
@@ -1,107 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import pooler
-import sql_db
-
-buyer_map = '''
-'''
-
-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':'''
- ''',
- 'fields': {},
- 'state':[('end','Close')]}
- }
- }
-
-wiz_auc_lots_buyer_map('auction.lots.buyer_map')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/auction/wizard/wizard_lots_invoice.py b/addons/auction/wizard/wizard_lots_invoice.py
deleted file mode 100644
index 636b12cc2ff..00000000000
--- a/addons/auction/wizard/wizard_lots_invoice.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-
-invoice_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:
-
diff --git a/addons/auction/wizard/wizard_lots_pay.py b/addons/auction/wizard/wizard_lots_pay.py
deleted file mode 100644
index a6b8f635ba4..00000000000
--- a/addons/auction/wizard/wizard_lots_pay.py
+++ /dev/null
@@ -1,103 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import netsvc
-import osv
-import time
-import pooler
-
-invoice_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:
-
diff --git a/addons/auction/wizard/wizard_lots_sms.py b/addons/auction/wizard/wizard_lots_sms.py
deleted file mode 100644
index dc60a9bd24d..00000000000
--- a/addons/auction/wizard/wizard_lots_sms.py
+++ /dev/null
@@ -1,150 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-
-import urllib
-
-sms_send_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
-#
-# 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 = '''
-''' % ('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:
-
diff --git a/addons/auction/wizard/wizard_pay.py b/addons/auction/wizard/wizard_pay.py
deleted file mode 100644
index ff68c2b5b8d..00000000000
--- a/addons/auction/wizard/wizard_pay.py
+++ /dev/null
@@ -1,109 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import netsvc
-import osv
-import time
-import pooler
-pay_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:
-
diff --git a/addons/auction/wizard/wizard_payer.py b/addons/auction/wizard/wizard_payer.py
deleted file mode 100644
index 6e224fbadad..00000000000
--- a/addons/auction/wizard/wizard_payer.py
+++ /dev/null
@@ -1,79 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import netsvc
-import osv
-import time
-import pooler
-
-pay_form = '''
-'''
-pay_fields = {
-}
-
-
-pay_form1 = '''
-'''
-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:
-
diff --git a/addons/caldav/caldav_node.py b/addons/caldav/caldav_node.py
index 1f5a2352b5f..64ee27b751a 100644
--- a/addons/caldav/caldav_node.py
+++ b/addons/caldav/caldav_node.py
@@ -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'
diff --git a/addons/delivery/__terp__.py b/addons/delivery/__terp__.py
index 1ce00a0cd26..9b0949e07e1 100644
--- a/addons/delivery/__terp__.py
+++ b/addons/delivery/__terp__.py
@@ -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'],
diff --git a/addons/delivery/delivery_wizard.xml b/addons/delivery/delivery_wizard.xml
deleted file mode 100644
index b497e6144d9..00000000000
--- a/addons/delivery/delivery_wizard.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/addons/delivery/wizard/delivery_sale_order.py b/addons/delivery/wizard/delivery_sale_order.py
index c7870e43d85..efc82ae4141 100644
--- a/addons/delivery/wizard/delivery_sale_order.py
+++ b/addons/delivery/wizard/delivery_sale_order.py
@@ -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="""
-
- """ % (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:
diff --git a/addons/delivery/wizard/delivery_sale_order_view.xml b/addons/delivery/wizard/delivery_sale_order_view.xml
new file mode 100644
index 00000000000..c2609bc3923
--- /dev/null
+++ b/addons/delivery/wizard/delivery_sale_order_view.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+ Delivery Costs
+ delivery.sale.order
+ form
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml
index 55dea914ac5..f257c8df6e4 100644
--- a/addons/event/event_view.xml
+++ b/addons/event/event_view.xml
@@ -162,7 +162,7 @@
-
+
@@ -331,7 +331,7 @@
- Registration by Event
+ Events On Registrationsreport.event.registrationformtree,graph
diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml
index 24008e64843..3702bcb0f1d 100644
--- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml
+++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml
@@ -308,6 +308,17 @@
+
+ hr.attendance.tree
+ hr.attendance
+ tree
+
+
+
+
+
+
+
diff --git a/addons/mrp/__init__.py b/addons/mrp/__init__.py
index b1b92e8514e..39d97d0ba11 100644
--- a/addons/mrp/__init__.py
+++ b/addons/mrp/__init__.py
@@ -21,8 +21,8 @@
import mrp
import stock
+import product
import installer
-import mrp_wizard
import wizard
import report
import company
diff --git a/addons/mrp/__terp__.py b/addons/mrp/__terp__.py
index feabb8cc123..acf25b160e0 100644
--- a/addons/mrp/__terp__.py
+++ b/addons/mrp/__terp__.py
@@ -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',
diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py
index 716b19164e9..6864b542396 100644
--- a/addons/mrp/mrp.py
+++ b/addons/mrp/mrp.py
@@ -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:
diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml
index f0c1cfa5483..8962eb6e1c8 100644
--- a/addons/mrp/mrp_demo.xml
+++ b/addons/mrp/mrp_demo.xml
@@ -165,6 +165,7 @@
Regular processor config
+ 11.0
@@ -174,6 +175,7 @@
Assembly Basic+ PC
+ 51.0
@@ -181,18 +183,21 @@
Assembly Medium PC
+ 81.0Assembly Customizable PC
+ 111.0HDD on demand
+ 141.0phantom
@@ -200,6 +205,7 @@
RAM on demand
+ 181.0phantom
@@ -207,6 +213,7 @@
HDD on demand
+ 211.0phantom
@@ -214,6 +221,7 @@
HDD on demand
+ 251.0phantom
@@ -221,6 +229,7 @@
HDD Seagate
+ 261.0normal
@@ -228,6 +237,7 @@
Assembly Basic PC
+ 291.0
@@ -236,12 +246,14 @@
Complete PC with peripherals
+ 331.0RAM on demand
+ 361.0phantom
@@ -250,6 +262,7 @@
High Speed Processor + main board on demand
+ 381.0
@@ -258,6 +271,7 @@
KITKit Mouse
+ 401.0normal
@@ -266,6 +280,7 @@
Keyboard
+ 421.0
@@ -273,6 +288,7 @@
Mouse
+ 441.0
@@ -280,6 +296,7 @@
Moon PC
+ 451.0
@@ -287,6 +304,7 @@
Mainboard ASUStek A7N8X
+ 491.0
@@ -294,6 +312,7 @@
Processor AMD Athlon 2200+
+ 511.0
@@ -301,6 +320,7 @@
Regular Case Fan
+ 541.0
@@ -308,6 +328,7 @@
DDR 256MB PC333
+ 571.0
@@ -315,6 +336,7 @@
DDR 512MB PC400
+ 591.0
@@ -322,6 +344,7 @@
DDR 1024MB PC400
+ 611.0
@@ -329,6 +352,7 @@
HDD Seagate 7200.8 80GB
+ 641.0
@@ -336,6 +360,7 @@
HDD Seagate 7200.8 120GB
+ 661.0normal
@@ -344,6 +369,7 @@
RAM on demand
+ 691.0
@@ -351,6 +377,7 @@
HDD on demand
+ 731.0
@@ -358,6 +385,7 @@
ATX middle-size case
+ 761.0normal
@@ -366,6 +394,7 @@
Processor on demand
+ 791.0normal
@@ -374,6 +403,7 @@
ATX Middle-size case
+ 811.0normal
@@ -382,6 +412,7 @@
HDD Seagate 7200.8 80GB
+ 831.0normal
@@ -390,6 +421,7 @@
High speed processor config
+ 851.0normal
@@ -398,6 +430,7 @@
HDD Seagate 7200.8 120GB
+ 871.0normal
@@ -406,6 +439,7 @@
Regular processor config
+ 891.0normal
@@ -414,6 +448,7 @@
ATX middle-size case
+ 921.0normal
@@ -422,6 +457,7 @@
HDD Seagate 7200.8 120GB
+ 951.0normal
@@ -430,6 +466,7 @@
processor
+ 981.0normal
@@ -438,6 +475,7 @@
mainboard
+ 1011.0normal
@@ -446,6 +484,7 @@
fan
+ 1051.0normal
@@ -454,6 +493,7 @@
RAM
+ 1081.0normal
@@ -462,6 +502,7 @@
Regular processor config
+ 1111.0normal
@@ -470,6 +511,7 @@
HDD Seagate 7200.8 80GB
+ 1131.0normal
@@ -478,6 +520,7 @@
ATX Middle-size case
+ 1151.0normal
@@ -487,6 +530,7 @@
KIT
+ 118Kit Keyboard + Mouse1.0
@@ -496,6 +540,7 @@
Mouse
+ 1211.0
@@ -503,6 +548,7 @@
Keyboard
+ 1231.0
diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml
index e3071185725..15729a8c985 100644
--- a/addons/mrp/mrp_view.xml
+++ b/addons/mrp/mrp_view.xml
@@ -5,10 +5,10 @@
-
+
-
@@ -242,19 +242,21 @@
@@ -286,6 +291,7 @@
child_complete_ids
+
@@ -438,15 +444,7 @@
-
-
-
+ mrp.production.form
@@ -463,7 +461,7 @@
@@ -489,6 +487,7 @@
+
diff --git a/addons/mrp/mrp_wizard.xml b/addons/mrp/mrp_wizard.xml
index 74001494c77..f7bfdcd7395 100644
--- a/addons/mrp/mrp_wizard.xml
+++ b/addons/mrp/mrp_wizard.xml
@@ -1,35 +1,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- Product Cost Structure
-
-
-
-
-
diff --git a/addons/mrp/product.py b/addons/mrp/product.py
new file mode 100644
index 00000000000..375bd0c9f46
--- /dev/null
+++ b/addons/mrp/product.py
@@ -0,0 +1,70 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+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()
diff --git a/addons/mrp/report/workcenter_load.py b/addons/mrp/report/workcenter_load.py
index a65a51d03f7..248e9e5707e 100644
--- a/addons/mrp/report/workcenter_load.py
+++ b/addons/mrp/report/workcenter_load.py
@@ -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:
diff --git a/addons/mrp/schedulers.py b/addons/mrp/schedulers.py
index fb9b1edf6a8..097f81f7529 100644
--- a/addons/mrp/schedulers.py
+++ b/addons/mrp/schedulers.py
@@ -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':
diff --git a/addons/mrp/security/ir.model.access.csv b/addons/mrp/security/ir.model.access.csv
index 9913071038c..48f27679435 100644
--- a/addons/mrp/security/ir.model.access.csv
+++ b/addons/mrp/security/ir.model.access.csv
@@ -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
diff --git a/addons/mrp/wizard/__init__.py b/addons/mrp/wizard/__init__.py
index 240f25daa9d..043cdc94465 100644
--- a/addons/mrp/wizard/__init__.py
+++ b/addons/mrp/wizard/__init__.py
@@ -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:
diff --git a/addons/mrp/wizard/change_production_qty.py b/addons/mrp/wizard/change_production_qty.py
new file mode 100644
index 00000000000..fbbbc356c7c
--- /dev/null
+++ b/addons/mrp/wizard/change_production_qty.py
@@ -0,0 +1,106 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+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:
diff --git a/addons/mrp/wizard/change_production_qty_view.xml b/addons/mrp/wizard/change_production_qty_view.xml
new file mode 100644
index 00000000000..34520a71721
--- /dev/null
+++ b/addons/mrp/wizard/change_production_qty_view.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+ Change Product Qty
+ change.production.qty
+ form
+
+
+
+
+
+
+ Change Product Qty
+ ir.actions.act_window
+ change.production.qty
+ form
+ form
+ new
+
+
+
+
diff --git a/addons/mrp/wizard/make_procurement.py b/addons/mrp/wizard/make_procurement.py
deleted file mode 100644
index 0cf12107181..00000000000
--- a/addons/mrp/wizard/make_procurement.py
+++ /dev/null
@@ -1,102 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-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 = """
-"""
- procurement_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:
-
diff --git a/addons/mrp/wizard/make_procurement_product.py b/addons/mrp/wizard/make_procurement_product.py
new file mode 100644
index 00000000000..a549d9f24b2
--- /dev/null
+++ b/addons/mrp/wizard/make_procurement_product.py
@@ -0,0 +1,134 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+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:
+
diff --git a/addons/mrp/wizard/make_procurement_view.xml b/addons/mrp/wizard/make_procurement_view.xml
new file mode 100644
index 00000000000..08c4b2cabf5
--- /dev/null
+++ b/addons/mrp/wizard/make_procurement_view.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+ Requisition Request
+ make.procurement
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/mrp/wizard/wizard_workcenter_load.py b/addons/mrp/wizard/mrp_price.py
similarity index 51%
rename from addons/mrp/wizard/wizard_workcenter_load.py
rename to addons/mrp/wizard/mrp_price.py
index 6465622c421..5d3c16cbaa5 100644
--- a/addons/mrp/wizard/wizard_workcenter_load.py
+++ b/addons/mrp/wizard/mrp_price.py
@@ -19,34 +19,37 @@
#
##############################################################################
-import wizard
+from osv import fields, osv
-_time_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:
-
diff --git a/addons/mrp/wizard/mrp_price_view.xml b/addons/mrp/wizard/mrp_price_view.xml
new file mode 100644
index 00000000000..e2e294c5739
--- /dev/null
+++ b/addons/mrp/wizard/mrp_price_view.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+ Product Cost Structure
+ mrp.product_price
+ form
+
+
+
+
+
+
+
+
diff --git a/addons/mrp/mrp_wizard.py b/addons/mrp/wizard/mrp_product_produce.py
similarity index 74%
rename from addons/mrp/mrp_wizard.py
rename to addons/mrp/wizard/mrp_product_produce.py
index 40d9f2ed1ab..7c77dfdee94 100644
--- a/addons/mrp/mrp_wizard.py
+++ b/addons/mrp/wizard/mrp_product_produce.py
@@ -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 {}
diff --git a/addons/mrp/mrp_wizard_view.xml b/addons/mrp/wizard/mrp_product_produce_view.xml
similarity index 100%
rename from addons/mrp/mrp_wizard_view.xml
rename to addons/mrp/wizard/mrp_product_produce_view.xml
diff --git a/addons/mrp/wizard/mrp_workcenter_load.py b/addons/mrp/wizard/mrp_workcenter_load.py
new file mode 100644
index 00000000000..1b5478dcbeb
--- /dev/null
+++ b/addons/mrp/wizard/mrp_workcenter_load.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+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:
diff --git a/addons/mrp/wizard/mrp_workcenter_load_view.xml b/addons/mrp/wizard/mrp_workcenter_load_view.xml
new file mode 100644
index 00000000000..a6b7a4f987d
--- /dev/null
+++ b/addons/mrp/wizard/mrp_workcenter_load_view.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+ Work Center Load
+ mrp.workcenter.load
+ form
+
+
+
+
+
+
+
+
diff --git a/addons/mrp/wizard/orderpoint_procurement.py b/addons/mrp/wizard/orderpoint_procurement.py
new file mode 100644
index 00000000000..731c3fca440
--- /dev/null
+++ b/addons/mrp/wizard/orderpoint_procurement.py
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+#
+# 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:
diff --git a/addons/mrp/wizard/orderpoint_procurement_view.xml b/addons/mrp/wizard/orderpoint_procurement_view.xml
new file mode 100644
index 00000000000..c17bedae84f
--- /dev/null
+++ b/addons/mrp/wizard/orderpoint_procurement_view.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+ Compute Stock Minimum Rules Only
+ mrp.procurement.orderpoint.compute
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/mrp/wizard/schedulers_all.py b/addons/mrp/wizard/schedulers_all.py
new file mode 100644
index 00000000000..62497564905
--- /dev/null
+++ b/addons/mrp/wizard/schedulers_all.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+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:
+
diff --git a/addons/mrp/wizard/schedulers_all_view.xml b/addons/mrp/wizard/schedulers_all_view.xml
new file mode 100644
index 00000000000..b8b465e03e9
--- /dev/null
+++ b/addons/mrp/wizard/schedulers_all_view.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+ Compute Schedulers
+ mrp.procurement.compute.all
+ form
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/mrp/wizard/wizard_change_production_qty.py b/addons/mrp/wizard/wizard_change_production_qty.py
deleted file mode 100644
index a9a8387acdf..00000000000
--- a/addons/mrp/wizard/wizard_change_production_qty.py
+++ /dev/null
@@ -1,117 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-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 = '''
-'''
-
-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:
diff --git a/addons/mrp/wizard/wizard_orderpoint_procurement.py b/addons/mrp/wizard/wizard_orderpoint_procurement.py
deleted file mode 100644
index a4fa57bb9a8..00000000000
--- a/addons/mrp/wizard/wizard_orderpoint_procurement.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-#
-# 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 = '''
-'''
-
-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:
-
diff --git a/addons/mrp/wizard/wizard_schedulers_all.py b/addons/mrp/wizard/wizard_schedulers_all.py
deleted file mode 100644
index e93e31c0599..00000000000
--- a/addons/mrp/wizard/wizard_schedulers_all.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import threading
-import pooler
-
-parameter_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:
-
diff --git a/addons/mrp_repair/__terp__.py b/addons/mrp_repair/__terp__.py
index 2f44e257a80..12a796b4f3b 100644
--- a/addons/mrp_repair/__terp__.py
+++ b/addons/mrp_repair/__terp__.py
@@ -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,
diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py
index fc91fe1f9e6..e456c3770d2 100644
--- a/addons/mrp_repair/mrp_repair.py
+++ b/addons/mrp_repair/mrp_repair.py
@@ -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',
diff --git a/addons/mrp_repair/mrp_repair_wizard.xml b/addons/mrp_repair/mrp_repair_wizard.xml
deleted file mode 100644
index 42383f517cc..00000000000
--- a/addons/mrp_repair/mrp_repair_wizard.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/addons/mrp_repair/report/order.rml b/addons/mrp_repair/report/order.rml
index 6c56c80978b..bb3e61ab4e7 100644
--- a/addons/mrp_repair/report/order.rml
+++ b/addons/mrp_repair/report/order.rml
@@ -397,7 +397,7 @@
- [[ format(o.quotation_notes) or '' ]]
+ [[ format(o.quotation_notes) or removeParentNode('blockTable') ]]
diff --git a/addons/mrp_repair/security/ir.model.access.csv b/addons/mrp_repair/security/ir.model.access.csv
index 0f12f66a815..c524afce69b 100644
--- a/addons/mrp_repair/security/ir.model.access.csv
+++ b/addons/mrp_repair/security/ir.model.access.csv
@@ -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
diff --git a/addons/mrp_repair/wizard/__init__.py b/addons/mrp_repair/wizard/__init__.py
index ec3063f01de..4f3075f055c 100644
--- a/addons/mrp_repair/wizard/__init__.py
+++ b/addons/mrp_repair/wizard/__init__.py
@@ -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:
diff --git a/addons/mrp_repair/wizard/cancel_repair.py b/addons/mrp_repair/wizard/cancel_repair.py
new file mode 100644
index 00000000000..91df6fb01ef
--- /dev/null
+++ b/addons/mrp_repair/wizard/cancel_repair.py
@@ -0,0 +1,87 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+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'] = """
+ """
+ return res
+
+repair_cancel()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/mrp_repair/wizard/make_invoice.py b/addons/mrp_repair/wizard/make_invoice.py
new file mode 100644
index 00000000000..063040590e6
--- /dev/null
+++ b/addons/mrp_repair/wizard/make_invoice.py
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+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:
+
diff --git a/addons/mrp_repair/wizard/mrp_repair_cancel_view.xml b/addons/mrp_repair/wizard/mrp_repair_cancel_view.xml
new file mode 100644
index 00000000000..4af2a3394b0
--- /dev/null
+++ b/addons/mrp_repair/wizard/mrp_repair_cancel_view.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+ Cancel Repair
+ mrp.repair.cancel
+ form
+
+
+
+
+
+
+ Cancel Repair Order
+ ir.actions.act_window
+ mrp.repair.cancel
+ form
+ form
+ new
+
+
+
+
+
diff --git a/addons/mrp_repair/wizard/mrp_repair_make_invoice_view.xml b/addons/mrp_repair/wizard/mrp_repair_make_invoice_view.xml
new file mode 100644
index 00000000000..f914d198d06
--- /dev/null
+++ b/addons/mrp_repair/wizard/mrp_repair_make_invoice_view.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+ Make Invoice
+ mrp.repair.make_invoice
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/mrp_repair/wizard/wizard_cancel_repair.py b/addons/mrp_repair/wizard/wizard_cancel_repair.py
deleted file mode 100644
index d895096ce6f..00000000000
--- a/addons/mrp_repair/wizard/wizard_cancel_repair.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import pooler
-
-cancel_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:
-
diff --git a/addons/mrp_repair/wizard/wizard_make_invoice.py b/addons/mrp_repair/wizard/wizard_make_invoice.py
deleted file mode 100644
index 71aefadfe4b..00000000000
--- a/addons/mrp_repair/wizard/wizard_make_invoice.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import pooler
-
-invoice_form = """
-
-"""
-invoice_fields = {
- 'group': {
- 'string': 'Group by partner invoice address',
- 'type':'boolean'
- },
-}
-
-ack_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:
-
diff --git a/addons/point_of_sale/__terp__.py b/addons/point_of_sale/__terp__.py
index e094d9dcb37..b1838a28fc1 100644
--- a/addons/point_of_sale/__terp__.py
+++ b/addons/point_of_sale/__terp__.py
@@ -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,
diff --git a/addons/point_of_sale/account_bank_statement.py b/addons/point_of_sale/account_bank_statement.py
index b599f0531f9..b71e78afcfd 100644
--- a/addons/point_of_sale/account_bank_statement.py
+++ b/addons/point_of_sale/account_bank_statement.py
@@ -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
diff --git a/addons/point_of_sale/pos_view.xml b/addons/point_of_sale/pos_view.xml
index baaac139ce4..f5ce8368bbe 100644
--- a/addons/point_of_sale/pos_view.xml
+++ b/addons/point_of_sale/pos_view.xml
@@ -43,7 +43,7 @@
-
+
@@ -68,8 +68,8 @@
-->
-
-
+
+
+
-
+
+
@@ -981,22 +981,29 @@ invoiced
-
+
-
+
+
+
+
-
+
-
-
-
+
+
+
+
+
diff --git a/addons/point_of_sale/pos_wizard.xml b/addons/point_of_sale/pos_wizard.xml
index 325350d031b..2e09b5cc9df 100644
--- a/addons/point_of_sale/pos_wizard.xml
+++ b/addons/point_of_sale/pos_wizard.xml
@@ -9,17 +9,13 @@
string="Return Goods"/>
-
+
-
+
@@ -30,64 +26,49 @@
-
-
+
-
+
+
+
-
+
-
-
+ string="Close Statements"/>-->
-
+ string="All Cashboxes Of the day"/-->
diff --git a/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py b/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py
index 854acfde3a9..f3c21da2dcb 100644
--- a/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py
+++ b/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py
@@ -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)
+
diff --git a/addons/point_of_sale/report/pos_payment_report_date.py b/addons/point_of_sale/report/pos_payment_report_date.py
index 1578f0e6958..82723a43125 100644
--- a/addons/point_of_sale/report/pos_payment_report_date.py
+++ b/addons/point_of_sale/report/pos_payment_report_date.py
@@ -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
diff --git a/addons/point_of_sale/report/pos_payment_report_user.py b/addons/point_of_sale/report/pos_payment_report_user.py
index cde5162425e..9af9377d64c 100644
--- a/addons/point_of_sale/report/pos_payment_report_user.py
+++ b/addons/point_of_sale/report/pos_payment_report_user.py
@@ -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 " \
diff --git a/addons/point_of_sale/report/pos_receipt.rml b/addons/point_of_sale/report/pos_receipt.rml
index ecf1aa8c52a..1d5e70241c7 100644
--- a/addons/point_of_sale/report/pos_receipt.rml
+++ b/addons/point_of_sale/report/pos_receipt.rml
@@ -104,7 +104,9 @@
E-mail : [[ address and address.email ]]Shop : [[ o.shop_id.name ]]Vendeur : [[ o.user_id1.name ]]
- Date : [[ o.date_order ]]
+
+ Date : [[ formatLang(o.date_order,date = True) ]]
+
diff --git a/addons/point_of_sale/report/pos_receipt_without_remboursment.rml b/addons/point_of_sale/report/pos_receipt_without_remboursment.rml
index d863efd40f3..0eb0dba773a 100644
--- a/addons/point_of_sale/report/pos_receipt_without_remboursment.rml
+++ b/addons/point_of_sale/report/pos_receipt_without_remboursment.rml
@@ -71,7 +71,7 @@
Tel : [[ address and address.phone ]]E-mail : [[ address and address.email ]]Salesman : [[ o.user_id.name ]]
- Sale Date : [[ o.date_order ]]
+ Sale Date : [[ str(o.date_order) ]]Purchase Voucher : [[o.name]]
diff --git a/addons/point_of_sale/report/pos_sales_user.py b/addons/point_of_sale/report/pos_sales_user.py
index 034587a8ae4..b1b7272a030 100644
--- a/addons/point_of_sale/report/pos_sales_user.py
+++ b/addons/point_of_sale/report/pos_sales_user.py
@@ -42,7 +42,7 @@ class pos_sales_user(report_sxw.rml_parse):
"from pos_order as po,res_users as ru,res_company as rc " \
"where po.date_order >= %s and po.date_order <= %s " \
"and po.company_id=rc.id and po.user_id=ru.id 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
diff --git a/addons/point_of_sale/report/pos_sales_user_today.py b/addons/point_of_sale/report/pos_sales_user_today.py
index 4e06a936116..a5caf899069 100644
--- a/addons/point_of_sale/report/pos_sales_user_today.py
+++ b/addons/point_of_sale/report/pos_sales_user_today.py
@@ -36,7 +36,7 @@ class pos_sales_user_today(report_sxw.rml_parse):
def _get_data(self,form):
data={}
- ids = form['user_id'][0][-1]
+ ids = form['user_id']
idss = map(str, ids)
self.cr.execute("select po.name as pos,po.date_order,ru.name as user,po.state,rc.name " \
diff --git a/addons/point_of_sale/security/ir.model.access.csv b/addons/point_of_sale/security/ir.model.access.csv
index efbe26893f1..a761e78c362 100644
--- a/addons/point_of_sale/security/ir.model.access.csv
+++ b/addons/point_of_sale/security/ir.model.access.csv
@@ -19,3 +19,12 @@
"access_report_sales_by_margin_pos","report.sales.by.margin.pos","model_report_sales_by_margin_pos","point_of_sale.group_pos_user",1,0,0,0
"access_report_sales_by_margin_pos_month","report.sales.by.margin.pos.month","model_report_sales_by_margin_pos_month","point_of_sale.group_pos_user",1,0,0,0
"access_singer_statement","singer.statement","model_singer_statement","point_of_sale.group_pos_user",1,0,0,0
+"access_add_product","pos.add.product ","model_pos_add_product","point_of_sale.group_pos_user",1,0,0,0
+"access_pos_confirm","pos.confirm","model_pos_confirm","point_of_sale.group_pos_user",1,0,0,0
+"access_pos_discount","pos.discount","model_pos_discount","point_of_sale.group_pos_user",1,0,0,0
+"access_pos_get_sale","pos.get.sale","model_pos_get_sale","point_of_sale.group_pos_user",1,0,0,0
+"access_pos_close_statement","pos.open.statement","model_pos_open_statement","point_of_sale.group_pos_user",1,0,0,0
+"access_pos_open_statement","pos.close.statement","model_pos_close_statement","point_of_sale.group_pos_user",1,0,0,0
+"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
+"acess_pos_details ","pos.details ","model_pos_details","point_of_sale.group_pos_user",1,0,0,0
diff --git a/addons/point_of_sale/statement_report.xml b/addons/point_of_sale/statement_report.xml
index 256d0644583..7bdece39a77 100644
--- a/addons/point_of_sale/statement_report.xml
+++ b/addons/point_of_sale/statement_report.xml
@@ -9,7 +9,7 @@
name="pos.user.product"
auto="False"
multi="True"
- rml="statement/report/pos_users_product.rml"
+ rml="point_of_sale/report/pos_users_product.rml"
/>
-
+=======
+ rml="point_of_sale/report/all_closed_cashbox_of_the_day.rml"
/>
+>>>>>>> MERGE-SOURCE
diff --git a/addons/point_of_sale/statement_view.xml b/addons/point_of_sale/statement_view.xml
index e7e7119583d..7f241e5bfa8 100644
--- a/addons/point_of_sale/statement_view.xml
+++ b/addons/point_of_sale/statement_view.xml
@@ -417,23 +417,27 @@
+
+ name="Open Registers" parent="point_of_sale.menu_point_config"
+ string="Open Register"
+ action="action_pos_open_statement"
+ id="menu_open_statement" sequence="1" />
+
+ />
+
+ name="Close Register" parent="point_of_sale.menu_point_config"
+ string="Close Register"
+ action="action_pos_close_statement"
+ id="menu_close_statement" sequence="2" />
+
+
diff --git a/addons/point_of_sale/statement_wizard.xml b/addons/point_of_sale/statement_wizard.xml
index f3bffb15ce1..c4f4ddf9072 100644
--- a/addons/point_of_sale/statement_wizard.xml
+++ b/addons/point_of_sale/statement_wizard.xml
@@ -1,9 +1,9 @@
-
-
-
+-->
-
+ string="All Cashboxes Of the day"/>-->
+
+ />
+
diff --git a/addons/point_of_sale/wizard/__init__.py b/addons/point_of_sale/wizard/__init__.py
index 1ff9c124861..1384fb8329a 100644
--- a/addons/point_of_sale/wizard/__init__.py
+++ b/addons/point_of_sale/wizard/__init__.py
@@ -20,24 +20,29 @@
#
##############################################################################
-import wizard_pos_payment
+#import wizard_pos_payment
import wizard_default_journal
-import wizard_refund_order
-import wizard_add_product
-import wizard_confirm
-import wizard_discount
-import wizard_get_sale
import wizard_scan_product
-import wizard_receipt
import wizard_return
-import wizard_pos_payment_report
-import wizard_pos_sales_user
-import wizard_pos_sales_user_today
-import wizard_pos_payment_report_date
-import wizard_pos_payment_report_user
-import wizard_pos_sales_user_current_user
-import wizard_pos_details
-import wizard_open_statement
-import wizard_all_closed_cashbox_of_the_day
+#import wizard_open_statement
+import pos_add_product
+import pos_confirm
+import pos_discount
+import pos_get_sale
+import pos_open_statement
+import pos_close_statement
+import pos_box_entries
+import pos_box_out
+import pos_details
+import pos_sales_user
+import pos_sales_user_today
+import pos_sales_user_current_user
+import all_closed_cashbox_of_the_day
+import pos_receipt
+import pos_payment_report_user
+import pos_payment_report_date
+import pos_payment_report
+import pos_payment
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.xml b/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.xml
new file mode 100644
index 00000000000..e78ef5c6d6a
--- /dev/null
+++ b/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+ all closed cashbox of the day
+ all.closed.cashbox.of.the.day
+ form
+
+
+
+
+
+
+
+
+ All Cashboxes Of the day
+ all.closed.cashbox.of.the.day
+ form
+ form
+ new
+
+
+
+
diff --git a/addons/point_of_sale/wizard/pos_add_product.py b/addons/point_of_sale/wizard/pos_add_product.py
new file mode 100644
index 00000000000..f02d8bd3b30
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_add_product.py
@@ -0,0 +1,67 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+
+class add_product(osv.osv_memory):
+ _name = 'pos.add.product'
+ _description = 'Add Product'
+
+ _columns = {
+ 'product_id': fields.many2one('product.product', 'Product',required=True),
+ 'quantity': fields.float('Quantity ', required=True),
+ }
+ _defaults = {
+ 'quantity': lambda *a: 1,
+ }
+
+ def select_product(self, cr, uid, ids, context):
+ """
+ To get the product and quantity and add in order .
+ @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 the add product form again for adding more product
+ """
+ this = self.browse(cr, uid, ids[0], context=context)
+ record_id = context and context.get('active_id',False)
+ assert record_id, _('Active ID is not found')
+ if record_id:
+ order_obj = self.pool.get('pos.order')
+ order_obj.add_product(cr, uid, record_id, this.product_id.id,this.quantity,context=context)
+
+ return {
+ 'name': _('Add Product'),
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'pos.add.product',
+ 'view_id': False,
+ 'target':'new',
+ 'views': False,
+ 'type': 'ir.actions.act_window',
+ }
+add_product()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/point_of_sale/wizard/pos_add_product.xml b/addons/point_of_sale/wizard/pos_add_product.xml
new file mode 100644
index 00000000000..5d380624f0d
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_add_product.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ Add Product
+ pos.add.product
+ form
+
+
+
+
+
+
+ Add Product
+ ir.actions.act_window
+ pos.add.product
+ form
+ form
+ new
+
+
+
+
diff --git a/addons/point_of_sale/wizard/pos_box_entries.py b/addons/point_of_sale/wizard/pos_box_entries.py
new file mode 100644
index 00000000000..83e3e576044
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_box_entries.py
@@ -0,0 +1,133 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+from tools.misc import UpdateableStr
+from mx import DateTime
+from tools.translate import _
+
+def get_journal(self,cr,uid,context):
+ """
+ Make the selection list of Cash Journal .
+ @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 :Return the list of journal
+ """
+
+ obj = self.pool.get('account.journal')
+ user = self.pool.get('res.users').browse(cr, uid, uid)
+ ids = obj.search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', user.company_id.id)])
+ res = obj.read(cr, uid, ids, ['id', 'name'], context)
+ res = [(r['id'], r['name']) for r in res]
+ res.insert(0, ('', ''))
+ return res
+
+class pos_box_entries(osv.osv_memory):
+ _name = 'pos.box.entries'
+ _description = 'Pos Box Entries'
+
+
+
+ def _get_income_product(self,cr,uid,context):
+
+ """
+ Make the selection list of purchasing products.
+ @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 :Return of operation of product
+ """
+ obj = self.pool.get('product.product')
+ ids = obj.search(cr, uid, [('income_pdt', '=', True)])
+ res = obj.read(cr, uid, ids, ['id', 'name'], context)
+ res = [(r['id'], r['name']) for r in res]
+ res.insert(0, ('', ''))
+
+ return res
+
+
+ _columns = {
+ 'name': fields.char('Name', size=32,required=True),
+ 'journal_id': fields.selection(get_journal, "Journal",required=True),
+ 'product_id': fields.selection(_get_income_product, "Operation",required=True),
+ 'amount' :fields.float('Amount', digits=(16,2)),
+ 'ref':fields.char('Ref', size=32),
+ }
+ _defaults = {
+ 'journal_id': lambda *a: 1,
+ 'product_id': lambda *a: 1,
+ }
+ def get_in(self, cr, uid, ids, context):
+
+
+ """
+ Create the entry of statement in journal .
+ @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 :Return of operation of product
+ """
+ statement_obj = self.pool.get('account.bank.statement')
+ product_obj = self.pool.get('product.template')
+ res_obj = self.pool.get('res.users')
+ product_obj=self.pool.get('product.product')
+ bank_statement=self.pool.get('account.bank.statement.line')
+ for data in self.read(cr, uid, ids):
+ args = {}
+ curr_company = res_obj.browse(cr,uid,uid).company_id.id
+ statement_id = statement_obj.search(cr,uid, [('journal_id','=',data['journal_id']),('company_id','=',curr_company),('user_id','=',uid),('state','=','open')])
+ if not statement_id:
+ raise osv.except_osv(_('Error !'), _('You have to open at least one cashbox'))
+
+ product = product_obj.browse(cr, uid, data['product_id'])
+ acc_id = product_obj.browse(cr,uid,data['product_id']).property_account_income
+ if not acc_id:
+ raise osv.except_osv(_('Error !'), _('please check that account is set to %s')%(product_obj.browse(cr,uid,data['product_id']).name))
+ if statement_id:
+ statement_id = statement_id[0]
+ if not statement_id:
+ statement_id = statement_obj.create(cr,uid,{'date':time.strftime('%Y-%m-%d 00:00:00'),
+ 'journal_id':data['journal_id'],
+ 'company_id':curr_company,
+ 'user_id':uid,
+ })
+
+ args['statement_id'] = statement_id
+ args['journal_id'] = data['journal_id']
+ if acc_id:
+ args['account_id'] = acc_id.id
+ args['amount'] = data['amount'] or 0.0
+ args['ref'] = "%s" %(data['ref'] or '')
+ args['name'] = "%s: %s "% (product_obj.browse(cr,uid,data['product_id']).name, data['name'].decode('utf8'))
+ address_u = res_obj.browse(cr,uid,uid).address_id
+ if address_u:
+ partner_id = address_u.partner_id and address_u.partner_id.id or None
+ args['partner_id'] = partner_id
+ statement_line_id =bank_statement.create(cr, uid, args)
+
+ return {}
+pos_box_entries()
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_box_entries.xml b/addons/point_of_sale/wizard/pos_box_entries.xml
new file mode 100644
index 00000000000..e0f0a21402f
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_box_entries.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+ Box Entries
+ pos.box.entries
+ form
+
+
+
+
+
+
+ Box Entries
+ ir.actions.act_window
+ pos.box.entries
+ form
+ form
+ new
+
+
+
+
diff --git a/addons/point_of_sale/wizard/pos_box_out.py b/addons/point_of_sale/wizard/pos_box_out.py
new file mode 100644
index 00000000000..52d2be0a3d0
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_box_out.py
@@ -0,0 +1,132 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+from tools.misc import UpdateableStr
+from mx import DateTime
+from tools.translate import _
+import pos_box_entries
+print dir(pos_box_entries)
+
+class pos_box_out(osv.osv_memory):
+ _name = 'pos.box.out'
+ _description = 'Pos Box Out'
+
+ def _get_expense_product(self,cr,uid,context):
+
+ """
+ Make the selection list of expense product.
+ @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 :Return of operation of product
+ """
+ obj = self.pool.get('product.product')
+ company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
+ ids = obj.search(cr, uid, ['&', ('expense_pdt', '=', True), '|', ('company_id', '=', company_id), ('company_id', '=', None)])
+ res = obj.read(cr, uid, ids, ['id', 'name'], context)
+ res = [(r['id'], r['name']) for r in res]
+ res.insert(0, ('', ''))
+ return res
+
+ _columns = {
+ 'name': fields.char('Name', size=32,required=True),
+ 'journal_id': fields.selection(pos_box_entries.get_journal, "Journal",required=True),
+ 'product_id': fields.selection(_get_expense_product, "Operation",required=True),
+ 'amount' :fields.float('Amount', digits=(16,2)),
+ 'ref':fields.char('Ref', size=32),
+ }
+ _defaults = {
+ 'journal_id': lambda *a: 1,
+ 'product_id': lambda *a: 1,
+ }
+ def get_out(self, cr, uid, ids, context):
+
+ """
+ Create the entries in the CashBox .
+ @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 :Return of operation of product
+ """
+ args = {}
+ statement_obj= self.pool.get('account.bank.statement')
+ statement_line_obj=self.pool.get('account.bank.statement.line')
+ product_obj= self.pool.get('product.template')
+ productp_obj= self.pool.get('product.product')
+ res_obj = self.pool.get('res.users')
+ for data in self.read(cr, uid, ids):
+
+ curr_company = res_obj.browse(cr,uid,uid).company_id.id
+ statement_id = statement_obj.search(cr,uid, [('journal_id','=',data['journal_id']),('company_id','=',curr_company),('user_id','=',uid),('state','=','open')])
+ monday = (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Monday,0))).strftime('%Y-%m-%d')
+ sunday = (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Sunday,0))).strftime('%Y-%m-%d')
+ done_statmt = statement_obj.search(cr,uid, [('date','>=',monday+' 00:00:00'),('date','<=',sunday+' 23:59:59'),('journal_id','=',data['journal_id']),('company_id','=',curr_company),('user_id','=',uid)])
+ stat_done = statement_obj.browse(cr,uid, done_statmt)
+ address_u = res_obj.browse(cr,uid,uid).address_id
+ am = 0.0
+
+ amount_check = productp_obj.browse(cr,uid,data['product_id']).am_out or False
+ for st in stat_done:
+ for s in st.line_ids:
+ if address_u and s.partner_id==address_u.partner_id and s.am_out:
+ am+=s.amount
+ if (-data['amount'] or 0.0)+ am <-(res_obj.browse(cr,uid,uid).company_id.max_diff or 0.0) and amount_check:
+ val = (res_obj.browse(cr,uid,uid).company_id.max_diff or 0.0)+ am
+ raise osv.except_osv(_('Error !'), _('The maximum value you can still withdraw is exceeded. \n Remaining value is equal to %d ')%(val))
+
+ acc_id = product_obj.browse(cr,uid,data['product_id']).property_account_income
+ if not acc_id:
+ raise osv.except_osv(_('Error !'), _('please check that account is set to %s')%(product_obj.browse(cr,uid,data['product_id']).name))
+ if not statement_id:
+ raise osv.except_osv(_('Error !'), _('You have to open at least one cashbox'))
+ if statement_id:
+ statement_id = statement_id[0]
+ if not statement_id:
+ statement_id = statement_obj.create(cr,uid,{'date':time.strftime('%Y-%m-%d 00:00:00'),
+ 'journal_id':data['journal_id'],
+ 'company_id':curr_company,
+ 'user_id':uid,
+ })
+ args['statement_id']= statement_id
+ args['journal_id']= data['journal_id']
+ if acc_id:
+ args['account_id']= acc_id.id
+ amount= data['amount'] or 0.0
+ if data['amount'] > 0:
+ amount= -data['amount']
+ args['amount'] = amount
+ if productp_obj.browse(cr,uid,data['product_id']).am_out:
+ args['am_out'] = True
+ args['ref'] = data['ref'] or ''
+ args['name'] = "%s: %s "%(product_obj.browse(cr,uid,data['product_id']).name, data['name'].decode('utf8'))
+ address_u = res_obj.browse(cr,uid,uid).address_id
+ if address_u:
+ partner_id = address_u.partner_id and address_u.partner_id.id or None
+ args['partner_id'] = partner_id
+ statement_line_id = statement_line_obj.create(cr, uid, args)
+ return {}
+
+pos_box_out()
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_box_out.xml b/addons/point_of_sale/wizard/pos_box_out.xml
new file mode 100644
index 00000000000..c634b4cf997
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_box_out.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+ Box Out
+ pos.box.out
+ form
+
+
+
+
+
+
+ Box Out
+ ir.actions.act_window
+ pos.box.out
+ form
+ form
+ new
+
+
+
+
diff --git a/addons/point_of_sale/wizard/pos_close_statement.py b/addons/point_of_sale/wizard/pos_close_statement.py
new file mode 100644
index 00000000000..4a1d305973d
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_close_statement.py
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+import time
+
+class pos_close_statement(osv.osv_memory):
+ _name = 'pos.close.statement'
+ _description = 'Close Statements'
+
+
+ def close_statement(self, cr, uid, ids, context):
+ """
+ Close the statements
+ @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 : Blank Dictionary
+ """
+ company_id=self.pool.get('res.users').browse(cr,uid,uid).company_id.id
+ statement_obj = self.pool.get('account.bank.statement')
+ singer_obj = self.pool.get('singer.statement')
+ journal_obj=self.pool.get('account.journal')
+ journal_lst=journal_obj.search(cr,uid,[('company_id','=',company_id),('auto_cash','=',True),('check_dtls','=',False)])
+ journal_ids=journal_obj.browse(cr,uid, journal_lst)
+ for journal in journal_ids:
+ ids = statement_obj.search(cr, uid, [('state','!=','confirm'),('user_id','=',uid),('journal_id','=',journal.id)])
+ statement_obj.button_confirm(cr,uid,ids)
+ return {}
+pos_close_statement()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_close_statement.xml b/addons/point_of_sale/wizard/pos_close_statement.xml
new file mode 100644
index 00000000000..fed3518b706
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_close_statement.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ Close Statements
+ pos.close.statement
+ form
+
+
+
+
+
+
+
+
+
+ Close Register
+ ir.actions.act_window
+ pos.close.statement
+ form
+ form
+ new
+
+
+
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_confirm.py b/addons/point_of_sale/wizard/pos_confirm.py
new file mode 100644
index 00000000000..f2765a5b74a
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_confirm.py
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+
+class pos_confirm(osv.osv_memory):
+ _name = 'pos.confirm'
+ _description = 'Point of Sale Confirm'
+ def action_confirm(self, cr, uid, ids, context):
+ """
+ Confirm the order and close the sales .
+ @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 :Blank dictionary
+ """
+
+ this = self.browse(cr, uid, ids[0], context=context)
+ record_id = context and context.get('active_id',False)
+ if record_id:
+ if isinstance(record_id, (int, long)):
+ record_id=[record_id]
+ if record_id:
+ company_id=self.pool.get('res.users').browse(cr,uid,uid).company_id
+ order_obj = self.pool.get('pos.order')
+
+ for order_id in order_obj.browse(cr, uid, record_id, context=context):
+ if order_id.state =='paid':
+ order_obj.write(cr,uid,[order_id.id],{'journal_entry':True})
+ order_obj.create_account_move(cr, uid, [order_id.id], context=context)
+
+ wf_service = netsvc.LocalService("workflow")
+ for i in record_id:
+ wf_service.trg_validate(uid, 'pos.order', i, 'done', cr)
+ return {}
+
+pos_confirm()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/point_of_sale/wizard/pos_confirm.xml b/addons/point_of_sale/wizard/pos_confirm.xml
new file mode 100644
index 00000000000..384d75f768f
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_confirm.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+ Sale Confirm
+ pos.confirm
+ form
+
+
+
+
+
+
+ Sale Confirm
+ ir.actions.act_window
+ pos.confirm
+ form
+ form
+ new
+
+
+
+
+ Sale Confirm
+ client_action_multi
+
+ action
+ pos.order
+
+
+
+
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_details.py b/addons/point_of_sale/wizard/pos_details.py
new file mode 100644
index 00000000000..d51b30bdca9
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_details.py
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+from mx import DateTime
+import time
+
+class pos_details(osv.osv_memory):
+ _name = 'pos.details'
+ _description = 'Sales Details'
+
+ _columns = {
+ 'date_start': fields.date('Date Start',required=True),
+ 'date_end': fields.date('Date End',required=True)
+ }
+ _defaults = {
+ 'date_start': lambda *a: time.strftime('%Y-%m-%d'),
+ 'date_end': lambda *a: time.strftime('%Y-%m-%d'),
+ }
+ def print_report(self, cr, uid, ids, context={}):
+ """
+ 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 = self.read(cr, uid, ids, ['date_start','date_end'], context)
+ res = res and res[0] or {}
+ datas['form'] = res
+
+ return {
+ 'type':'ir.actions.report.xml',
+ 'report_name':'pos.details',
+ 'datas':datas,
+ }
+pos_details()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/point_of_sale/wizard/pos_details.xml b/addons/point_of_sale/wizard/pos_details.xml
new file mode 100644
index 00000000000..7d6dd346c12
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_details.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+ POS Details
+ pos.details
+ form
+
+
+
+
+
+
+
+ Sale Details
+ ir.actions.act_window
+ pos.details
+ form
+ form
+ new
+ {'record_id' : active_id}
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_discount.py b/addons/point_of_sale/wizard/pos_discount.py
new file mode 100644
index 00000000000..8c9f9ac032d
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_discount.py
@@ -0,0 +1,111 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+
+class pos_discount(osv.osv_memory):
+ _name = 'pos.discount'
+ _description = 'Add Discount'
+
+ _columns = {
+ 'discount': fields.float('Discount ', required=True),
+ 'discount_notes': fields.char('Discount Notes',size= 128, required=True),
+ }
+ _defaults = {
+ 'discount': lambda *a: 5,
+ }
+
+ def apply_discount(self, cr, uid, ids, context):
+ """
+ To give the discount of product and check the.
+
+ @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 : nothing
+ """
+ this = self.browse(cr, uid, ids[0], context=context)
+ record_id = context and context.get('active_id', False)
+ if isinstance(record_id, (int, long)):
+ record_id=[record_id]
+
+ order_ref = self.pool.get('pos.order')
+ order_line_ref =self.pool.get('pos.order.line')
+
+ for order in order_ref.browse(cr, uid, record_id, context=context):
+
+ for line in order.lines :
+ company_discount = order.company_id.company_discount
+ applied_discount = this.discount
+
+ if applied_discount == 0.00:
+ notice = 'No Discount'
+ elif company_discount >= applied_discount:
+ notice = 'Minimum Discount'
+ else:
+ notice = this.discount_notes
+
+ res_new = {
+ }
+
+ if this.discount <= company_discount:
+ res_new = {
+ 'discount': this.discount,
+ 'notice': notice,
+ 'price_ded': line.price_unit * line.qty * (this.discount or 0) * 0.01 or 0.0
+ }
+ else:
+ res_new = {
+ 'discount': this.discount,
+ 'notice': notice,
+ 'price_ded': line.price_unit * line.qty * (this.discount or 0) * 0.01 or 0.0
+ }
+
+ order_line_ref.write(cr, uid, [line.id], res_new, context=context)
+ return {}
+
+# def check_discount(self, cr, uid, record_id, discount, context):
+# """
+# Check the discount of define by company .
+# @param self: The object pointer.
+# @param cr: A database cursor
+# @param uid: ID of the user currently logged in
+# @param record_id:Current Order id
+# @param discount:Select Discount
+# @param context: A standard dictionary
+# @return : retrun to apply and used the company discount base on condition
+# """
+
+# order_ref = self.pool.get('pos.order')
+#
+# for order in order_ref.browse(cr, uid, record_id, context=context):
+# company_disc = order.company_id.company_discount
+# for line in order.lines :
+# prod_disc = discount
+# if prod_disc <= company_disc :
+# return 'apply_discount'
+# else :
+# return 'disc_discount'
+pos_discount()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/point_of_sale/wizard/pos_discount.xml b/addons/point_of_sale/wizard/pos_discount.xml
new file mode 100644
index 00000000000..a0a7c534a95
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_discount.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ Apply Discount
+ pos.discount
+ form
+
+
+
+
+
+
+ Apply Discount
+ ir.actions.act_window
+ pos.discount
+ form
+ form
+ new
+
+
+
+
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_get_sale.py b/addons/point_of_sale/wizard/pos_get_sale.py
new file mode 100644
index 00000000000..901cc3a521f
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_get_sale.py
@@ -0,0 +1,79 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+
+class pos_get_sale(osv.osv_memory):
+ _name = 'pos.get.sale'
+ _description = 'Get From Sale'
+
+ _columns = {
+ 'picking_id': fields.many2one('stock.picking', 'Sale Order', domain=[('state','in',('assigned','confirmed')), ('type', '=', 'out')],context="{'contact_display':'partner'}",required=True),
+ }
+
+ def sale_complete(self, cr, uid, ids, context):
+ """
+ Select the picking order and add the in Point of sale order
+ @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 : nothing
+ """
+ this = self.browse(cr, uid, ids[0], context=context)
+ record_id = context and context.get('active_id',False)
+
+ proxy_pos = self.pool.get('pos.order')
+ proxy_pick = self.pool.get('stock.picking')
+ proxy_order_line=self.pool.get('pos.order.line')
+
+ if record_id:
+ order=proxy_pos.browse(cr, uid, record_id, context)
+
+ if order.state in ('paid', 'invoiced'):
+ raise osv.except_osv(_('UserError '), _("You can't modify this order. It has already been paid"))
+
+ for pick in proxy_pick.browse(cr, uid, [this.picking_id.id], context):
+ proxy_pos.write(cr, uid, record_id, {
+ 'last_out_picking':this.picking_id.id,
+ 'partner_id': pick.address_id and pick.address_id.partner_id.id
+ })
+
+ order = proxy_pick.write(cr, uid, [this.picking_id.id], {
+ 'invoice_state': 'none',
+ 'pos_order': record_id
+ })
+
+ for line in pick.move_lines:
+ proxy_order_line.create(cr, uid, {
+ 'name': line.sale_line_id.name,
+ 'order_id': record_id,
+ 'qty': line.product_qty,
+ 'product_id': line.product_id.id,
+ 'price_unit': line.sale_line_id.price_unit,
+ 'discount': line.sale_line_id.discount,
+ })
+
+ return {}
+pos_get_sale()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_get_sale.xml b/addons/point_of_sale/wizard/pos_get_sale.xml
new file mode 100644
index 00000000000..9a28da548d2
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_get_sale.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+ Open Sale Order
+ pos.get.sale
+ form
+
+
+
+
+
+ Select an Open Sale Order
+ ir.actions.act_window
+ pos.get.sale
+ form
+ form
+ new
+
+
+
+
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_open_statement.py b/addons/point_of_sale/wizard/pos_open_statement.py
new file mode 100644
index 00000000000..1c02221677c
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_open_statement.py
@@ -0,0 +1,90 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+import time
+class pos_open_statement(osv.osv_memory):
+ _name = 'pos.open.statement'
+ _description = 'Open Statements'
+
+
+ def open_statement(self, cr, uid, ids, context):
+ """
+ Open the statements
+ @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 : Blank Directory
+ """
+ company_id=self.pool.get('res.users').browse(cr,uid,uid).company_id.id
+ statement_obj =self.pool.get('account.bank.statement')
+ singer_obj = self.pool.get('singer.statement')
+ journal_obj=self.pool.get('account.journal')
+ journal_lst=journal_obj.search(cr,uid,[('company_id','=',company_id),('auto_cash','=',True)])
+ journal_ids=journal_obj.browse(cr,uid, journal_lst)
+ for journal in journal_ids:
+ ids = statement_obj.search(cr, uid, [('state','!=','confirm'),('user_id','=',uid),('journal_id','=',journal.id)])
+ if len(ids):
+ raise osv.except_osv(_('Message'),_('You can not open a Cashbox for "%s". \n Please close the cashbox related to. '%(journal.name) ))
+ sql = """ Select id from account_bank_statement
+ where journal_id=%d
+ and company_id =%d
+ order by id desc limit 1"""%(journal.id,company_id)
+ singer_ids=None
+ cr.execute(sql)
+ st_id = cr.fetchone()
+ number=''
+ sequence_obj=self.pool.get('ir.sequence')
+ if journal.statement_sequence_id:
+ number = sequence_obj.get_id(cr, uid, journal.id)
+ else:
+ number = sequence_obj.get(cr, uid,
+ 'account.bank.statement')
+
+ # statement_id=statement_obj.create(cr,uid,{'journal_id':journal.id,
+ # 'company_id':company_id,
+ # 'user_id':uid,
+ # 'state':'open',
+ # 'name':number
+ # })
+ period=statement_obj._get_period(cr,uid,context) or None
+ cr.execute("INSERT INTO account_bank_statement(journal_id,company_id,user_id,state,name, period_id,date) VALUES(%d,%d,%d,'open','%s',%d,'%s')"%(journal.id,company_id,uid,number, period, time.strftime('%Y-%m-%d %H:%M:%S')))
+ cr.commit()
+ cr.execute("select id from account_bank_statement where journal_id=%d and company_id=%d and user_id=%d and state='open' and name='%s'"%(journal.id,company_id,uid,number))
+ statement_id=cr.fetchone()[0]
+ if st_id:
+ statemt_id=statement_obj.browse(cr,uid,st_id[0])
+ if statemt_id and statemt_id.ending_details_ids:
+ statement_obj.write(cr, uid,[statement_id], {'balance_start':statemt_id.balance_end,
+ 'state':'open'})
+ if statemt_id.ending_details_ids:
+ for i in statemt_id.ending_details_ids:
+ c=singer_obj.create(cr,uid, { 'pieces':i.pieces,
+ 'number':i.number,
+ 'starting_id':statement_id,
+ })
+ cr.commit()
+ return {}
+pos_open_statement()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_open_statement.xml b/addons/point_of_sale/wizard/pos_open_statement.xml
new file mode 100644
index 00000000000..9b80a7ec60d
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_open_statement.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+ Open Statements
+ pos.open.statement
+ form
+
+
+
+
+
+
+
+ Open Register
+ ir.actions.act_window
+ pos.open.statement
+ form
+ form
+ new
+
+
+
+
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py
new file mode 100644
index 00000000000..b29a6a43b7f
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_payment.py
@@ -0,0 +1,204 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+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):
+ """
+ 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(pos_make_payment, self).default_get(cr, uid, fields, context=context)
+ 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
+ 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 = self.pool.get('pos.order').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})
+ self.pool.get('pos.order').action_paid(cr,uid,[record_id],context)
+ elif order.amount_paid > 0.0:
+ self.pool.get('pos.order').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})
+ if 'amount' in fields:
+ res.update({'amount':amount})
+ if 'invoice_wanted' in fields:
+ 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'})
+ 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
+ order = self.pool.get('pos.order').browse(cr, uid, record_id)
+ if not order.lines:
+ raise osv.except_osv('Error!','No Order Lines ')
+ True
+
+ def 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('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:
+ res['arch'] = """
+ """
+ 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)
+ order_obj = self.pool.get('pos.order')
+ 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]
+
+ # Todo need to check ...
+ 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)
+ 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)
+ else:
+ 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)
+ 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,
+ }
+
+ def print_report(self, cr, uid, ids, context=None):
+ 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',
+ 'datas' : datas,
+ }
+
+ def trigger_wkf(self, cr, uid, data, context):
+ record_id = context and context.get('active_id',False)
+ wf_service = netsvc.LocalService("workflow")
+ wf_service.trg_validate(uid, 'pos.order', record_id, 'payment', cr)
+ return {}
+
+ _columns = {
+ '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),
+ '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),
+ }
+
+pos_make_payment()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/point_of_sale/wizard/pos_payment.xml b/addons/point_of_sale/wizard/pos_payment.xml
new file mode 100644
index 00000000000..771ec3c72e3
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_payment.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+"""
+
+
+
+ Add payment :
+ pos.make.payment
+ form
+
+
+
+
+
+ Add payment
+ ir.actions.act_window
+ pos.make.payment
+ form
+ form
+ new
+
+
+
+
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_payment_report.py b/addons/point_of_sale/wizard/pos_payment_report.py
new file mode 100644
index 00000000000..12cc044e448
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_payment_report.py
@@ -0,0 +1,74 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
+#
+##############################################################################
+
+import pooler
+import netsvc
+import wizard
+import time# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+from mx import DateTime
+import time
+
+class pos_payment_report(osv.osv_memory):
+ _name = 'pos.payment.report'
+ _description = 'Payment Report'
+
+ def print_report(self, cr, uid, ids, context={}):
+ """
+ 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', [])}
+ return {
+ 'type':'ir.actions.report.xml',
+ 'report_name':'pos.payment.report',
+ 'datas':datas,
+ }
+pos_payment_report()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/point_of_sale/wizard/pos_payment_report.xml b/addons/point_of_sale/wizard/pos_payment_report.xml
new file mode 100644
index 00000000000..593068a9ebf
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_payment_report.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+ Payment Report
+ pos.payment.report
+ form
+
+
+
+
+
+
+ Payment Report
+ ir.actions.act_window
+ pos.details
+ form
+ form
+ new
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_payment_report_date.py b/addons/point_of_sale/wizard/pos_payment_report_date.py
new file mode 100644
index 00000000000..9e24fb76505
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_payment_report_date.py
@@ -0,0 +1,65 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
+#
+##############################################################################
+
+from osv import osv
+from osv import fields
+import time
+class pos_payment_report_date(osv.osv_memory):
+ '''
+ Open ERP Model
+ '''
+ _name = 'pos.payment.report.date'
+ _description = 'POS Payment Report according to date'
+ def print_report(self, cr, uid, ids, context=None):
+
+ """
+ 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 = self.read(cr, uid, ids, ['date_start','date_end','user_id'])
+ res = res and res[0] or {}
+ datas['form'] = res
+
+ return {
+ 'type' : 'ir.actions.report.xml',
+ 'report_name':'pos.payment.report.date',
+ 'datas' : datas,
+ }
+
+ _columns = {
+ 'date_start': fields.date('Start Date', required=True),
+ 'date_end': fields.date('End Date', required=True),
+ 'user_id':fields.many2many('res.users','res_user_sale','user_id','sale_id','Salesman')
+ }
+ _defaults = {
+ 'date_start': lambda *a: time.strftime('%Y-%m-%d'),
+ 'date_end': lambda *a: time.strftime('%Y-%m-%d'),
+ }
+pos_payment_report_date()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/point_of_sale/wizard/pos_payment_report_date_view.xml b/addons/point_of_sale/wizard/pos_payment_report_date_view.xml
new file mode 100644
index 00000000000..4c05c8ac514
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_payment_report_date_view.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ pos.payment.report.date.form
+ pos.payment.report.date
+ form
+
+
+
+
+
+
+ Sales lines Report
+ ir.actions.act_window
+ pos.payment.report.date
+ form
+ form
+ new
+
+
+
diff --git a/addons/point_of_sale/wizard/pos_payment_report_user.py b/addons/point_of_sale/wizard/pos_payment_report_user.py
new file mode 100644
index 00000000000..59df8d28881
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_payment_report_user.py
@@ -0,0 +1,56 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (). 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 .
+#
+##############################################################################
+
+from osv import osv
+from osv import fields
+
+class pos_payment_report_user(osv.osv_memory):
+ '''
+ Open ERP Model
+ '''
+ _name = 'pos.payment.report.user'
+ _description = 'Sales lines by Users'
+ def print_report(self, cr, uid, ids, context=None):
+
+ """
+ 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 = self.read(cr, uid, ids, ['user_id'])
+ res = res and res[0] or {}
+ datas['form'] = res
+
+ return {
+ 'type' : 'ir.actions.report.xml',
+ 'report_name':'pos.payment.report.user',
+ 'datas' : datas,
+ }
+
+ _columns = {
+ 'user_id':fields.many2many('res.users','res_user_sale','user_id','sale_id','Salesman')
+ }
+pos_payment_report_user()
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_payment_report_user.xml b/addons/point_of_sale/wizard/pos_payment_report_user.xml
new file mode 100644
index 00000000000..bccfe92a847
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_payment_report_user.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ Pyament Report
+ pos.payment.report
+ form
+
+
+
+
+
+
+
+ Pyament Report
+ ir.actions.act_window
+ pos.payment.report
+ form
+ form
+ new
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_payment_report_user_view.xml b/addons/point_of_sale/wizard/pos_payment_report_user_view.xml
new file mode 100644
index 00000000000..9d6e925ebd7
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_payment_report_user_view.xml
@@ -0,0 +1,27 @@
+
+
+
+
+ pos.payment.report.user.form
+ pos.payment.report.user
+ form
+
+
+
+
+
+ Sales lines by Users
+ ir.actions.act_window
+ pos.payment.report.user
+ form
+ form
+ new
+
+
+
diff --git a/addons/point_of_sale/wizard/pos_receipt.py b/addons/point_of_sale/wizard/pos_receipt.py
new file mode 100644
index 00000000000..a812ad342a4
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_receipt.py
@@ -0,0 +1,66 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
+#
+##############################################################################
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+
+from mx import DateTime
+import time
+
+class pos_receipt(osv.osv_memory):
+ _name = 'pos.receipt'
+ _description = 'Point of sale receipt'
+
+ _columns = {
+
+ }
+ def view_init(self, cr , uid , fields_list, context=None):
+ order_lst =self. pool.get('pos.order').browse(cr,uid,context['active_id'])
+ for order in order_lst:
+ if order.state_2 in ('to_verify'):
+ raise osv.except_osv(_('Error!', 'Can not print the receipt because of discount and/or payment '))
+ True
+ def print_report(self, cr, uid, ids, context=None):
+
+ """
+ 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',
+ 'datas' : datas,
+ }
+
+pos_receipt()
+
+
+
+
diff --git a/addons/point_of_sale/wizard/pos_receipt_view.xml b/addons/point_of_sale/wizard/pos_receipt_view.xml
new file mode 100644
index 00000000000..5839e4fcb3e
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_receipt_view.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+ Receipt
+ pos.receipt
+ form
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/point_of_sale/wizard/wizard_return.py b/addons/point_of_sale/wizard/pos_return.py
similarity index 93%
rename from addons/point_of_sale/wizard/wizard_return.py
rename to addons/point_of_sale/wizard/pos_return.py
index 591fd00b18a..1b5860cef1c 100644
--- a/addons/point_of_sale/wizard/wizard_return.py
+++ b/addons/point_of_sale/wizard/pos_return.py
@@ -20,19 +20,69 @@
#
##############################################################################
-import wizard
-import pooler
-from tools.misc import UpdateableStr
+#import wizard
+#import pooler
+#from tools.misc import UpdateableStr
+#
+#import netsvc
+#import time
+#
+#from tools.translate import _
+#from decimal import Decimal
+
+#arch=UpdateableStr()
+#fields={}
import netsvc
+from osv import osv,fields
+from tools.translate import _
+from mx import DateTime
import time
-from tools.translate import _
-from decimal import Decimal
+class pos_return(osv.osv_memory):
+ _name = 'pos.return'
+ _description = 'Point of sale return'
-arch=UpdateableStr()
-fields={}
+ _columns = {
+
+ }
+pos_return()
+
+class pos_add_payment(osv.osv_memory):
+ _name = 'pos.add.payment'
+ _description = 'Add Payment'
+
+ _columns = {
+ 'amount': fields.float('Amount', digits=(16,2),required=True),
+ 'journal': fields.function(_get_journal, 'Journal', method=True, required=True),
+ 'payment_date': fields.date('Payment date',required=True),
+ 'payment_name': fields.char('Payment name', size=32,required=True),
+ 'invoice_wanted': fields.boolean('Invoice'),
+ 'num_sale': fields.char('Num.Cof', size=32)
+ }
+ _defaults = {
+ 'payment_name': lambda *a: 'Payment'
+ }
+
+pos_add_payment()
+
+class pos_add_product(osv.osv_memory):
+ _name = 'pos.add.product'
+ _description = 'Add Product'
+
+ _columns = {
+ 'product': fields.many2one('product.product','Product', required=True),
+ 'quantity': fields.integer( 'Quantity',required=True),
+
+ }
+
+ _defaults = {
+ 'product': lambda *a: 'False',
+ 'quantity': lambda *a: 1
+ }
+
+pos_add_product()
def _get_journal(self, cr, uid, context):
diff --git a/addons/point_of_sale/wizard/pos_sale_user_today.xml b/addons/point_of_sale/wizard/pos_sale_user_today.xml
new file mode 100644
index 00000000000..78f01a4650f
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_sale_user_today.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+ Sales User Today
+ pos.sales.user.today
+ form
+
+
+
+
+
+ Sale by Users
+ ir.actions.act_window
+ pos.sales.user.today
+ form
+ form
+ new
+
+
+
+
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_sales_user.py b/addons/point_of_sale/wizard/pos_sales_user.py
new file mode 100644
index 00000000000..cbb2ddaead9
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_sales_user.py
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+from mx import DateTime
+import time
+
+class pos_sale_user(osv.osv_memory):
+ _name = 'pos.sale.user'
+ _description = 'Sale by User'
+
+ _columns = {
+ 'date_start': fields.date('Date Start',required=True),
+ 'date_end': fields.date('Date End',required=True),
+ 'user_id': fields.many2many('res.users', 'sale_user_rel', 'user_id', 'uid', 'Salesman'),
+ }
+
+ def print_report(self, cr, uid, ids, context={}):
+ """
+ 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 : return report
+ """
+
+ datas = {'ids' : context.get('active_ids', [])}
+ res = self.read(cr, uid, ids, ['date_start','date_end','user_id'], context)
+ res = res and res[0] or {}
+ datas['form'] = res
+ return {
+ 'type':'ir.actions.report.xml',
+ 'report_name':'pos.sales.user',
+ 'datas':datas,
+ }
+pos_sale_user()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/point_of_sale/wizard/pos_sales_user.xml b/addons/point_of_sale/wizard/pos_sales_user.xml
new file mode 100644
index 00000000000..0fc46f81aac
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_sales_user.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+ Sale By User
+ pos.sale.user
+ form
+
+
+
+
+
+
+
+ Sale by User
+ ir.actions.act_window
+ pos.sale.user
+ form
+ form
+ new
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/auction/wizard/auction_wizard_enable_taken.py b/addons/point_of_sale/wizard/pos_sales_user_current_user.py
similarity index 51%
rename from addons/auction/wizard/auction_wizard_enable_taken.py
rename to addons/point_of_sale/wizard/pos_sales_user_current_user.py
index 01f54ca28dc..22ac95a5451 100644
--- a/addons/auction/wizard/auction_wizard_enable_taken.py
+++ b/addons/point_of_sale/wizard/pos_sales_user_current_user.py
@@ -19,43 +19,39 @@
#
##############################################################################
-import wizard
import netsvc
-import pooler
-#field name="confirm_en"/>
+from osv import osv,fields
+from tools.translate import _
+from mx import DateTime
+import time
-take_form = """
-
-"""
-
-take_fields = {
- 'confirm_en': {'string':'Catalog Number', 'type':'integer'},
-}
-
-def _confirm_enable(self,cr,uid,data,context={}):
- pool = pooler.get_pool(cr.dbname)
- pool.get('auction.lots').write(cr,uid,data['ids'],{'ach_emp':False})
- return {}
-
-class enable_take_away(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {
- 'type' : 'form',
- 'arch' : take_form,
- 'fields' : take_fields,
- 'state' : [ ('end', 'Cancel'),('go', 'Enable Taken away')]}
- },
- 'go' : {
- 'actions' : [_confirm_enable],
- 'result' : {'type' : 'state', 'state' : 'end'}
- },
-}
-enable_take_away('auction.lots.enable')
+class pos_sales_user_today_current_user(osv.osv_memory):
+ _name = 'pos.sales.user.today.current_user'
+ _description = 'Sales Details'
+ _columns = {
+ }
+
+ def print_report(self, cr, uid, ids, context={}):
+ """
+ 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 = self.read(cr, uid, ids, [], context)
+ res = res and res[0] or {}
+ datas['form'] = res
+
+ return {
+ 'type':'ir.actions.report.xml',
+ 'report_name':'pos.sales.user.today.current.user',
+ 'datas':datas,
+ }
+pos_sales_user_today_current_user()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/point_of_sale/wizard/pos_sales_user_current_user.xml b/addons/point_of_sale/wizard/pos_sales_user_current_user.xml
new file mode 100644
index 00000000000..5625b70770f
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_sales_user_current_user.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ Sales for Current User
+ pos.sales.user.today.current_user
+ form
+
+
+
+
+
+
+
+ Sales for Current User
+ ir.actions.act_window
+ pos.sales.user.today.current_user
+ form
+ form
+ new
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/point_of_sale/wizard/pos_sales_user_today.py b/addons/point_of_sale/wizard/pos_sales_user_today.py
new file mode 100644
index 00000000000..50464b6936d
--- /dev/null
+++ b/addons/point_of_sale/wizard/pos_sales_user_today.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+from mx import DateTime
+import time
+
+class pos_sales_user_today(osv.osv_memory):
+ _name = 'pos.sales.user.today'
+ _description = 'Sales User Today'
+
+ _columns = {
+ 'user_id': fields.many2many('res.users', 'sale_user_rel_today', 'user_id', 'uid', 'Salesman'),
+ }
+
+ def print_report(self, cr, uid, ids, context={}):
+ """
+ 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 = self.read(cr, uid, ids, ['user_id'], context)
+ res = res and res[0] or {}
+ datas['form'] = res
+
+ return {
+ 'type':'ir.actions.report.xml',
+ 'report_name':'pos.sales.user.today',
+ 'datas':datas,
+ }
+pos_sales_user_today()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/point_of_sale/wizard/wizard_add_product.py b/addons/point_of_sale/wizard/wizard_add_product.py
deleted file mode 100644
index 0daa0bdf0db..00000000000
--- a/addons/point_of_sale/wizard/wizard_add_product.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-import pooler
-import wizard
-
-
-_form = """
-
-"""
-_fields = {
- 'product': {
- 'string': 'Product',
- 'type': 'many2one',
- 'relation': 'product.product',
- 'required': True,
- 'default': False
- },
-
- 'quantity': {
- 'string': 'Quantity',
- 'type': 'integer',
- 'required': True,
- 'default': 1},
- }
-
-
-def _add(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- order_obj = pool.get('pos.order')
- order_obj.add_product(cr, uid, data['id'], data['form']['product'],
- data['form']['quantity'], context=context)
-
- return {}
-
-
-def _pre_init(self, cr, uid, data, context):
- return {'product': False, 'quantity': 1}
-
-
-class add_product(wizard.interface):
-
- states = {
- 'init': {
- 'actions': [_pre_init],
- 'result': {
- 'type': 'form',
- 'arch': _form,
- 'fields': _fields,
- 'state': [('end', 'Cancel'), ('add', '_Add product', 'gtk-ok', True)
- ]
- }
- },
- 'add': {
- 'actions': [_add],
- 'result': {
- 'type': 'state',
- 'state': 'init',
- }
- },
- }
-
-add_product('pos.add_product')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/point_of_sale/wizard/wizard_all_closed_cashbox_of_the_day.py b/addons/point_of_sale/wizard/wizard_all_closed_cashbox_of_the_day.py
deleted file mode 100644
index bdb7f72cb93..00000000000
--- a/addons/point_of_sale/wizard/wizard_all_closed_cashbox_of_the_day.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-import pooler
-import netsvc
-import wizard
-import time
-
-
-class wizard_all_closed_cashbox_of_the_day(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type':'print', 'report':'all.closed.cashbox.of.the.day', 'state':'end'}
- },
- }
-
-wizard_all_closed_cashbox_of_the_day('all.closed.cashbox.of.the.day')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/point_of_sale/wizard/wizard_confirm.py b/addons/point_of_sale/wizard/wizard_confirm.py
deleted file mode 100644
index b819c840ae5..00000000000
--- a/addons/point_of_sale/wizard/wizard_confirm.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-
-import wizard
-import netsvc
-import pooler
-import time
-
-_form = """
-
-"""
-_fields = {}
-
-def _confirm(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- company_id=pool.get('res.users').browse(cr,uid,uid).company_id
- order_obj = pool.get('pos.order')
- for order_id in order_obj.browse(cr, uid, data['ids'], context=context):
- if order_id.state =='paid':
- order_obj.write(cr,uid,[order_id.id],{'journal_entry':True})
- order_obj.create_account_move(cr, uid, [order_id.id], context=context)
-
- wf_service = netsvc.LocalService("workflow")
- for i in data['ids']:
- wf_service.trg_validate(uid, 'pos.order', i, 'done', cr)
- return {}
-
-def _get_state(self, cr, uid, data, context):
- action = 'invoice'
- return action
-class pos_confirm(wizard.interface):
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {
- 'type': 'form',
- 'arch': _form,
- 'fields': _fields,
- 'state': (('end', 'No','gtk-cancel'),
- ('open', 'Yes', 'gtk-ok', True)
- )
- }
- },
- 'open': {
- 'actions': [_confirm],
- 'result': {
- 'type': 'state',
- 'state':'end'}
- },
- }
-
-pos_confirm('pos.confirm')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/point_of_sale/wizard/wizard_discount.py b/addons/point_of_sale/wizard/wizard_discount.py
deleted file mode 100644
index 035c387793c..00000000000
--- a/addons/point_of_sale/wizard/wizard_discount.py
+++ /dev/null
@@ -1,145 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-import pooler
-import wizard
-
-_form = """
-
-"""
-disc_form = """
-
-
-"""
-
-
-_fields = {
- 'discount': {
- 'string': 'Discount percentage',
- 'type': 'float',
- 'required': True,
- 'default': lambda *args: 5
- },
-}
-
-disc_fields = {
- 'note': {
- 'string': 'Discount Notes',
- 'type': 'char',
- 'size': 128,
- 'required': True
- },
-}
-
-class discount_wizard(wizard.interface):
-
- def apply_discount(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- order_ref = pool.get('pos.order')
- order_line_ref = pool.get('pos.order.line')
- for order in order_ref.browse(cr, uid, data['ids'], context=context):
- for line in order.lines :
- company_discount = order.company_id.company_discount
- applied_discount =data['form']['discount']
- if applied_discount == 0.00:
- notice = 'No Discount'
- elif company_discount >= applied_discount:
- notice = 'Minimum Discount'
- else:
- notice = data['form']['note']
- if self.check_discount(cr, uid, data, context) == 'apply_discount':
- order_line_ref.write(cr, uid, [line.id],
- {'discount': data['form']['discount'],
- 'price_ded':line.price_unit*line.qty*(data['form']['discount'] or 0)*0.01 or 0.0,
- 'notice':notice
- },
- context=context,)
- else :
- order_line_ref.write(cr, uid, [line.id],
- {'discount': data['form']['discount'],
- 'notice': notice,
- 'price_ded':line.price_unit*line.qty*(data['form']['discount'] or 0)*0.01 or 0.0
- },
- context=context,)
- return {}
-
- def check_discount(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- order_ref = pool.get('pos.order')
- for order in order_ref.browse(cr, uid, data['ids'], context=context):
- company_disc = order.company_id.company_discount
- for line in order.lines :
- prod_disc = data['form']['discount']
- if prod_disc <= company_disc :
- return 'apply_discount'
- else :
- return 'disc_discount'
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {
- 'type': 'form',
- 'arch': _form,
- 'fields': _fields,
- 'state': (('end', 'Cancel'),
- ('check_disc', 'Apply Discount', 'gtk-ok', True)
- )
- }
- },
-
- 'check_disc': {
- 'actions': [],
- 'result': {'type':'choice','next_state':check_discount}
- },
-
- 'disc_discount': {
- 'actions': [],
- 'result': {
- 'type': 'form',
- 'arch': disc_form,
- 'fields':disc_fields,
- 'state': (('end', 'Cancel'),
- ('apply_discount', 'Apply Discount', 'gtk-ok', True)
- )
- }
- },
- 'apply_discount': {
- 'actions': [],
- 'result': {
- 'type': 'action',
- 'action': apply_discount,
- 'state': "end",
- }
- },
- }
-
-discount_wizard('pos.discount')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/point_of_sale/wizard/wizard_get_sale.py b/addons/point_of_sale/wizard/wizard_get_sale.py
deleted file mode 100644
index de686c11d49..00000000000
--- a/addons/point_of_sale/wizard/wizard_get_sale.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-import pooler
-import wizard
-from tools.translate import _
-
-picking_form = """
-
-"""
-
-picking_fields = {
- 'picking_id': {'string': 'Sale Order', 'type': 'many2one', 'relation': 'stock.picking', 'required': True}
-}
-
-
-def _sale_complete(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- order = pool.get('pos.order').browse(cr, uid, data['id'], context)
-
- if order.state in ('paid', 'invoiced'):
- raise wizard.except_wizard(_('UserError'), _("You can't modify this order. It has already been paid"))
-
- pick = pool.get('stock.picking').browse(cr, uid, data['form']['picking_id'], context)
-
- pool.get('pos.order').write(cr, uid, data['id'], {
- 'last_out_picking': data['form']['picking_id'],
- 'partner_id': pick.address_id and pick.address_id.partner_id.id
- })
-
- order = pool.get('stock.picking').write(cr, uid, [data['form']['picking_id']], {
- 'invoice_state': 'none',
- 'pos_order': data['id']
- })
-
- for line in pick.move_lines:
- pool.get('pos.order.line').create(cr, uid, {
- 'name': line.sale_line_id.name,
- 'order_id': data['id'],
- 'qty': line.product_qty,
- 'product_id': line.product_id.id,
- 'price_unit': line.sale_line_id.price_unit,
- 'discount': line.sale_line_id.discount,
- })
-
- return {}
-
-
-class pos_sale_get(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {
- 'type': 'form',
- 'arch': picking_form,
- 'fields': picking_fields,
- 'state': (('end', 'Cancel'),
- ('set', 'Confirm', 'gtk-ok', True)
- )
- }
- },
- 'set': {
- 'actions': [_sale_complete],
- 'result': {
- 'type': 'state',
- 'state': "end",
- }
- },
- }
-
-pos_sale_get('pos.sale.get')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/point_of_sale/wizard/wizard_open_statement.py b/addons/point_of_sale/wizard/wizard_open_statement.py
deleted file mode 100644
index 09205a97b08..00000000000
--- a/addons/point_of_sale/wizard/wizard_open_statement.py
+++ /dev/null
@@ -1,147 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-import pooler
-import wizard
-from tools.translate import _
-import time
-
-statement_form = """
-
-"""
-statement_form_close = """
-
-"""
-
-statement_fields = {}
-
-def _close_statement(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- company_id=pool.get('res.users').browse(cr,uid,uid).company_id.id
- statement_obj = pool.get('account.bank.statement')
- singer_obj = pool.get('singer.statement')
- journal_obj=pool.get('account.journal')
- journal_lst=journal_obj.search(cr,uid,[('company_id','=',company_id),('auto_cash','=',True),('check_dtls','=',False)])
- journal_ids=journal_obj.browse(cr,uid, journal_lst)
- for journal in journal_ids:
- ids = statement_obj.search(cr, uid, [('state','!=','confirm'),('user_id','=',uid),('journal_id','=',journal.id)])
- statement_obj.button_confirm(cr,uid,ids)
- return {}
-def _open_statement(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- company_id=pool.get('res.users').browse(cr,uid,uid).company_id.id
- statement_obj = pool.get('account.bank.statement')
- singer_obj = pool.get('singer.statement')
- journal_obj=pool.get('account.journal')
- journal_lst=journal_obj.search(cr,uid,[('company_id','=',company_id),('auto_cash','=',True)])
- journal_ids=journal_obj.browse(cr,uid, journal_lst)
- for journal in journal_ids:
- ids = statement_obj.search(cr, uid, [('state','!=','confirm'),('user_id','=',uid),('journal_id','=',journal.id)])
- if len(ids):
- raise wizard.except_wizard(_('Message'),_('You can not open a Cashbox for "%s". \n Please close the cashbox related to. '%(journal.name) ))
- sql = """ Select id from account_bank_statement
- where journal_id=%d
- and company_id =%d
- order by id desc limit 1"""%(journal.id,company_id)
- singer_ids=None
- cr.execute(sql)
- st_id = cr.fetchone()
- number=''
- if journal.statement_sequence_id:
- number = pool.get('ir.sequence').get_id(cr, uid, journal.id)
- else:
- number = pool.get('ir.sequence').get(cr, uid,
- 'account.bank.statement')
-
-# statement_id=statement_obj.create(cr,uid,{'journal_id':journal.id,
-# 'company_id':company_id,
-# 'user_id':uid,
-# 'state':'open',
-# 'name':number
-# })
- period=statement_obj._get_period(cr,uid,context) or None
- cr.execute("INSERT INTO account_bank_statement(journal_id,company_id,user_id,state,name, period_id,date) VALUES(%d,%d,%d,'open','%s',%d,'%s')"%(journal.id,company_id,uid,number, period, time.strftime('%Y-%m-%d %H:%M:%S')))
- cr.commit()
- cr.execute("select id from account_bank_statement where journal_id=%d and company_id=%d and user_id=%d and state='open' and name='%s'"%(journal.id,company_id,uid,number))
- statement_id=cr.fetchone()[0]
- if st_id:
- statemt_id=statement_obj.browse(cr,uid,st_id[0])
- if statemt_id and statemt_id.ending_details_ids:
- statement_obj.write(cr, uid,[statement_id], {'balance_start':statemt_id.balance_end,
- 'state':'open'})
- if statemt_id.ending_details_ids:
- for i in statemt_id.ending_details_ids:
- c=singer_obj.create(cr,uid, { 'pieces':i.pieces,
- 'number':i.number,
- 'starting_id':statement_id,
- })
- cr.commit()
- return {}
-
-class statement_open(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {
- 'type': 'form',
- 'arch': statement_form,
- 'fields': statement_fields,
- 'state': (('end', 'No','gtk-cancel'),
- ('open', 'Yes', 'gtk-ok', True)
- )
- }
- },
- 'open': {
- 'actions': [_open_statement],
- 'result': {
- 'type': 'state',
-# 'action' :_open_statement,
- 'state':'end'}
- },
- }
-statement_open('statement.open')
-class statement_close(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {
- 'type': 'form',
- 'arch': statement_form_close,
- 'fields': statement_fields,
- 'state': (('end', 'No','gtk-cancel'),
- ('open', 'Yes', 'gtk-ok', True)
- )
- }
- },
- 'open': {
- 'actions': [_close_statement],
- 'result': {
- 'type': 'state',
- 'state':'end'}
- },
- }
-statement_close('statement.close')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/point_of_sale/wizard/wizard_pos_details.py b/addons/point_of_sale/wizard/wizard_pos_details.py
deleted file mode 100644
index 80a0593c08e..00000000000
--- a/addons/point_of_sale/wizard/wizard_pos_details.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2008 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-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
-
-
-pos_details_res_form= """
-
-"""
-
-pos_details_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')},
-
-
-}
-
-
-class wizard_pos_details(wizard.interface):
-
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : pos_details_res_form,
- 'fields' : pos_details_res_field,
- 'state' : [('end', 'Cancel','gtk-cancel'),('print_report', 'Print Report','gtk-print') ]}
- },
- 'print_report' : {
- 'actions' : [],
- 'result' : {'type' : 'print',
- 'report':'pos.details',
- 'state' : 'end'}
- },
- }
-wizard_pos_details('pos.details')
diff --git a/addons/point_of_sale/wizard/wizard_pos_payment.py b/addons/point_of_sale/wizard/wizard_pos_payment.py
deleted file mode 100644
index 580b0b308dd..00000000000
--- a/addons/point_of_sale/wizard/wizard_pos_payment.py
+++ /dev/null
@@ -1,233 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-import pooler
-import netsvc
-import wizard
-import time
-from decimal import Decimal
-from tools.translate import _
-
-
-def _get_journal(self, cr, uid, context):
- pool = pooler.get_pool(cr.dbname)
- obj = pool.get('account.journal')
- c=pool.get('res.users').browse(cr,uid,uid).company_id.id
- ids = obj.search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', c)])
- res = obj.read(cr, uid, ids, ['id', 'name'], context)
- res = [(r['id'], r['name']) for r in res]
- return res
-
-
-payment_form = """
-
-"""
-
-payment_fields = {
- 'amount': {'string': 'Amount', 'type': 'float', 'required': True},
- 'is_acc': {'string': 'Accompte', 'type': 'boolean'},
- 'invoice_wanted': {'string': 'Invoice', 'type': 'boolean'},
- 'journal': {'string': 'Journal',
- 'type': 'selection',
- 'selection': _get_journal,
- 'required': True,
- },
- 'payment_date': {'string': 'Payment date', 'type': 'date', 'required': True},
- 'payment_name': {'string': 'Payment name', 'type': 'char', 'size': '32', 'required':True, 'default':'Payment'},
- 'num_sale': {'string': 'Num.File', 'type': 'char', 'size': '32'},
- 'product_id': {'string':'Acompte','type': 'many2one', 'relation': 'product.product'},
- }
-
-
-def _pre_init(self, cr, uid, data, context):
- def _get_journal(pool, order):
- j_obj = pool.get('account.journal')
- c = pool.get('res.users').browse(cr,uid,uid).company_id.id
- journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', c)])
- if journal:
- journal = journal[0]
- else:
- journal = None
- return journal
-
- wf_service = netsvc.LocalService("workflow")
- # wf_service.trg_validate(uid, 'pos.order', data['id'], 'start_payment', cr)
-
- pool = pooler.get_pool(cr.dbname)
- order = pool.get('pos.order').browse(cr, uid, data['id'], context)
- #get amount to pay
- #amount = Decimal(str(order.amount_total)) - Decimal(str(order.amount_paid))
- amount = order.amount_total - order.amount_paid
-
- if amount<=0:
- context.update({'flag':True})
- pool.get('pos.order').action_paid(cr,uid,data['ids'],context)
- elif order.amount_paid > 0:
- pool.get('pos.order').write(cr, uid, data['id'],{'state':'advance'})
-
-
- # get journal:
- journal = _get_journal(pool, order)
-
- # check if an invoice is wanted:
- #invoice_wanted_checked = not not order.partner_id # not not -> boolean
- invoice_wanted_checked = False
-
- # select the current date
- current_date = time.strftime('%Y-%m-%d')
-
- return {'journal': journal, 'amount': amount, 'invoice_wanted': invoice_wanted_checked, 'payment_date': current_date}
-
-
-def _add_pay(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- order_obj = pool.get('pos.order')
- jrnl_obj = pool.get('account.journal')
- result = data['form']
- invoice_wanted = data['form']['invoice_wanted']
- jrnl_used=False
- if data['form'] and data['form'].get('journal',False):
- jrnl_used=jrnl_obj.browse(cr,uid,data['form']['journal'])
-
- # add 'invoice_wanted' in 'pos.order'
- order_obj.write(cr, uid, [data['id']], {'invoice_wanted': invoice_wanted})
-
- order_obj.add_payment(cr, uid, data['id'], result, context=context)
- return {}
-
-
-def _check(self, cr, uid, data, context):
- """Check the order:
- if the order is not paid: continue payment,
- if the order is paid print invoice (if wanted) or ticket.
- """
- pool = pooler.get_pool(cr.dbname)
- order_obj = pool.get('pos.order')
- order = order_obj.browse(cr, uid, data['id'], context)
- amount = order.amount_total - order.amount_paid
- if amount<=0:
- context.update({'flag':True})
- pool.get('pos.order').action_paid(cr,uid,data['ids'],context)
-
- action = 'ask_pay'
- if order_obj.test_paid(cr, uid, [data['id']]):
- if order.partner_id:
- if order.invoice_wanted:
- action = 'invoice'
- else:
- action = 'paid'
- elif order.date_payment:
- action = 'receipt'
- else:
- action = 'paid'
- return action
-
-
-def create_invoice(self, cr, uid, data, context):
- wf_service = netsvc.LocalService("workflow")
- for i in data['ids']:
- wf_service.trg_validate(uid, 'pos.order', i, 'invoice', cr)
- return {}
-
-def _trigger_wkf(self, cr, uid, data, context):
- wf_service = netsvc.LocalService("workflow")
- wf_service.trg_validate(uid, 'pos.order', data['id'], 'payment', cr)
- return {}
-
-
-
-class pos_payment(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {
- 'type': 'choice',
- 'next_state': _check,
- }
- },
- 'ask_pay': {
- 'actions': [_pre_init],
- 'result': {
- 'type': 'form',
- 'arch': payment_form,
- 'fields': payment_fields,
- 'state': (('end', 'Cancel'), ('finish', 'Finish'), ('add_pay', 'Ma_ke payment', 'gtk-ok', True))
- }
- },
- 'add_pay': {
- 'actions': [_add_pay],
- 'result': {
- 'type': 'state',
- 'state': "init",
- }
- },
- 'invoice': {
- 'actions': [create_invoice],
- 'result': {
- 'type': 'print',
- 'report': 'pos.invoice',
- 'state': 'finish'
- }
- },
- 'receipt': {
- 'actions': [],
- 'result': {
- 'type': 'print',
- 'report': 'pos.receipt',
- 'state': 'finish'
- }
- },
- 'paid': {
- 'actions': [],
- 'result': {
- 'type': 'print',
- 'report': 'pos.receipt',
- 'state': 'finish'
- }
- },
- 'finish': {
- 'actions': [_trigger_wkf],
- 'result': {
- 'type': 'state',
- 'state': 'end'
- }
- },
-
- }
-
-pos_payment('pos.payment')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/point_of_sale/wizard/wizard_pos_payment_report.py b/addons/point_of_sale/wizard/wizard_pos_payment_report.py
deleted file mode 100644
index 1f6ed1afda5..00000000000
--- a/addons/point_of_sale/wizard/wizard_pos_payment_report.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-import pooler
-import netsvc
-import wizard
-import time
-
-
-class wizard_pos_payment_report(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type':'print', 'report':'pos.payment.report', 'state':'end'}
- },
- }
-
-wizard_pos_payment_report('pos.payment.report')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/point_of_sale/wizard/wizard_pos_payment_report_date.py b/addons/point_of_sale/wizard/wizard_pos_payment_report_date.py
deleted file mode 100644
index 570b6de9ad7..00000000000
--- a/addons/point_of_sale/wizard/wizard_pos_payment_report_date.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-import pooler
-import netsvc
-import wizard
-import time
-
-pos_payment_report_date_form= """
-
-"""
-
-pos_payment_report_date_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_payment_report_date(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : pos_payment_report_date_form,
- 'fields' : pos_payment_report_date_field,
- 'state' : [('end', 'Cancel','gtk-cancel'),('print_report', 'Print Report','gtk-print') ]}
- },
- 'print_report' : {
- 'actions' : [],
- 'result' : {'type' : 'print',
- 'report':'pos.payment.report.date',
- 'state' : 'end'}
- },
- }
-
-wizard_pos_payment_report_date('pos.payment.report.date')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/point_of_sale/wizard/wizard_pos_payment_report_user.py b/addons/point_of_sale/wizard/wizard_pos_payment_report_user.py
deleted file mode 100644
index aaad1d328c5..00000000000
--- a/addons/point_of_sale/wizard/wizard_pos_payment_report_user.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2008 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-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
-
-
-pos_payment_report_user_form= """
-
-"""
-
-pos_payment_report_user_field= {
-
- 'user_id': {'string': 'Salesman', 'type': 'many2many', 'relation': 'res.users', 'required': True},
-
-}
-
-
-class wizard_pos_payment_report_user(wizard.interface):
-
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : pos_payment_report_user_form,
- 'fields' : pos_payment_report_user_field,
- 'state' : [('end', 'Cancel','gtk-cancel'),('print_report', 'Print Report','gtk-print') ]}
- },
- 'print_report' : {
- 'actions' : [],
- 'result' : {'type' : 'print',
- 'report':'pos.payment.report.user',
- 'state' : 'end'}
- },
- }
-wizard_pos_payment_report_user('pos.payment.report.user')
diff --git a/addons/point_of_sale/wizard/wizard_pos_sales_user_current_user.py b/addons/point_of_sale/wizard/wizard_pos_sales_user_current_user.py
deleted file mode 100644
index a76c0c97b59..00000000000
--- a/addons/point_of_sale/wizard/wizard_pos_sales_user_current_user.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-import pooler
-import netsvc
-import wizard
-import time
-
-
-class wizard_pos_sales_user_today_current_user(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type':'print', 'report':'pos.sales.user.today.current.user', 'state':'end'}
- },
- }
-
-wizard_pos_sales_user_today_current_user('pos.sales.user.today.current.user')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/point_of_sale/wizard/wizard_pos_sales_user_today.py b/addons/point_of_sale/wizard/wizard_pos_sales_user_today.py
deleted file mode 100644
index 58d990ef4bc..00000000000
--- a/addons/point_of_sale/wizard/wizard_pos_sales_user_today.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2008 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-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_pos_res_form= """
-
-"""
-
-sale_pos_res_field= {
-
- 'user_id': {'string': 'Salesman', 'type': 'many2many', 'relation': 'res.users', 'required': True},
-
-}
-
-
-class wizard_pos_sales_user_today(wizard.interface):
-
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : sale_pos_res_form,
- 'fields' : sale_pos_res_field,
- 'state' : [('end', 'Cancel','gtk-cancel'),('print_report', 'Print Report','gtk-print') ]}
- },
- 'print_report' : {
- 'actions' : [],
- 'result' : {'type' : 'print',
- 'report':'pos.sales.user.today',
- 'state' : 'end'}
- },
- }
-wizard_pos_sales_user_today('pos.sales.user.today')
diff --git a/addons/point_of_sale/wizard/wizard_receipt.py b/addons/point_of_sale/wizard/wizard_receipt.py
deleted file mode 100644
index 64e8a2e5685..00000000000
--- a/addons/point_of_sale/wizard/wizard_receipt.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-
-#import time
-#import netsvc
-#from tools.misc import UpdateableStr
-#import pooler
-import wizard
-import pooler
-from tools.translate import _
-
-def _check(self,cr,uid,data,*a):
- pool = pooler.get_pool(cr.dbname)
- order_lst = pool.get('pos.order').browse(cr,uid,data['ids'])
- for order in order_lst:
- if order.state_2 in ('to_verify'):
- raise wizard.except_wizard('Error!', 'Can not print the receipt because of discount and/or payment ')
- return data
-
-class print_order_receipt(wizard.interface):
- states = {
- 'init': {
- 'actions': [_check],
- 'result': {'type':'print', 'report':'pos.receipt', 'state':'end'}
- }
- }
-
-print_order_receipt('ord.receipt')
-
diff --git a/addons/point_of_sale/wizard/wizard_refund_order.py b/addons/point_of_sale/wizard/wizard_refund_order.py
deleted file mode 100644
index 188e7b47690..00000000000
--- a/addons/point_of_sale/wizard/wizard_refund_order.py
+++ /dev/null
@@ -1,232 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (). 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 .
-#
-##############################################################################
-
-
-import time
-import netsvc
-from tools.misc import UpdateableStr
-import wizard
-import pooler
-from mx import DateTime
-from tools.translate import _
-
-
-entry_form = '''
-
-'''
-
-def _get_journal(self,cr,uid,context):
- pool = pooler.get_pool(cr.dbname)
- obj = pool.get('account.journal')
- user = pool.get('res.users').browse(cr, uid, uid)
- ids = obj.search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', user.company_id.id)])
- res = obj.read(cr, uid, ids, ['id', 'name'], context)
- res = [(r['id'], r['name']) for r in res]
- res.insert(0, ('', ''))
- return res
-
-def _get_pdt(self,cr,uid,context):
- pool = pooler.get_pool(cr.dbname)
- obj = pool.get('product.product')
- ids = obj.search(cr, uid, [('income_pdt', '=', True)])
- res = obj.read(cr, uid, ids, ['id', 'name'], context)
- res = [(r['id'], r['name']) for r in res]
- res.insert(0, ('', ''))
- return res
-
-def _get_pdt_exp(self,cr,uid,context):
- pool = pooler.get_pool(cr.dbname)
- obj = pool.get('product.product')
- company_id = pool.get('res.users').browse(cr, uid, uid).company_id.id
- ids = obj.search(cr, uid, ['&', ('expense_pdt', '=', True), '|', ('company_id', '=', company_id), ('company_id', '=', None)])
- res = obj.read(cr, uid, ids, ['id', 'name'], context)
- res = [(r['id'], r['name']) for r in res]
- res.insert(0, ('', ''))
- return res
-
-entry_fields = {
- 'journal_id': {'string': 'Journal', 'type': 'selection', 'selection': _get_journal, 'required':True},
- 'product_id': {'string': 'Operation', 'type': 'selection', 'selection':_get_pdt , 'required':True},
- 'amount': {'string': 'Amount', 'type': 'float'},
- 'name': {'string': 'Name', 'type': 'char', 'size': '32', 'required':True},
- 'ref': {'string': 'Ref.', 'type': 'char', 'size': '32'},
-
-}
-
-out_fields = {
- 'journal_id': {'string': 'Journal', 'type': 'selection', 'selection': _get_journal, 'required':True},
- 'product_id': {'string': 'Operation', 'type': 'selection', 'selection':_get_pdt_exp , 'required':True},
- 'amount': {'string': 'Amount', 'type': 'float'},
- 'name': {'string': 'Name', 'type': 'char', 'size': '32', 'required':True},
- 'ref': {'string': 'Ref.', 'type': 'char', 'size': '32'},
-}
-
-def _get_out(self, cr, uid, data, context):
- args = {}
- pool = pooler.get_pool(cr.dbname)
- statement_obj= pool.get('account.bank.statement')
- product_obj= pool.get('product.template')
- productp_obj= pool.get('product.product')
- res_obj = pool.get('res.users')
- curr_company = res_obj.browse(cr,uid,uid).company_id.id
- statement_id = statement_obj.search(cr,uid, [('journal_id','=',data['form']['journal_id']),('company_id','=',curr_company),('user_id','=',uid),('state','=','open')])
- monday = (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Monday,0))).strftime('%Y-%m-%d')
- sunday = (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Sunday,0))).strftime('%Y-%m-%d')
- done_statmt = statement_obj.search(cr,uid, [('date','>=',monday+' 00:00:00'),('date','<=',sunday+' 23:59:59'),('journal_id','=',data['form']['journal_id']),('company_id','=',curr_company),('user_id','=',uid)])
- stat_done = statement_obj.browse(cr,uid, done_statmt)
- address_u = pool.get('res.users').browse(cr,uid,uid).address_id
- am = 0.0
- amount_check = productp_obj.browse(cr,uid,data['form']['product_id']).am_out or False
- for st in stat_done:
- for s in st.line_ids:
- if address_u and s.partner_id==address_u.partner_id and s.am_out:
- am+=s.amount
- if (-data['form']['amount'] or 0.0)+ am <-(res_obj.browse(cr,uid,uid).company_id.max_diff or 0.0) and amount_check:
- val = (res_obj.browse(cr,uid,uid).company_id.max_diff or 0.0)+ am
- raise wizard.except_wizard(_('Error !'), _('The maximum value you can still withdraw is exceeded. \n Remaining value is equal to %d ')%(val))
-
- acc_id = product_obj.browse(cr,uid,data['form']['product_id']).property_account_income
- if not acc_id:
- raise wizard.except_wizard(_('Error !'), _('please check that account is set to %s')%(product_obj.browse(cr,uid,data['form']['product_id']).name))
- if not statement_id:
- raise wizard.except_wizard(_('Error !'), _('You have to open at least one cashbox'))
- if statement_id:
- statement_id = statement_id[0]
- if not statement_id:
- statement_id = statement_obj.create(cr,uid,{'date':time.strftime('%Y-%m-%d 00:00:00'),
- 'journal_id':data['form']['journal_id'],
- 'company_id':curr_company,
- 'user_id':uid,
- })
- args['statement_id']= statement_id
- args['journal_id']= data['form']['journal_id']
- if acc_id:
- args['account_id']= acc_id.id
- amount= data['form']['amount'] or 0.0
- if data['form']['amount'] > 0:
- amount= -data['form']['amount']
- args['amount'] = amount
- if productp_obj.browse(cr,uid,data['form']['product_id']).am_out:
- args['am_out'] = True
- args['ref'] = data['form']['ref'] or ''
- args['name'] = "%s: %s "%(product_obj.browse(cr,uid,data['form']['product_id']).name, data['form']['name'].decode('utf8'))
- address_u = pool.get('res.users').browse(cr,uid,uid).address_id
- if address_u:
- partner_id = address_u.partner_id and address_u.partner_id.id or None
- args['partner_id'] = partner_id
- statement_line_id = pool.get('account.bank.statement.line').create(cr, uid, args)
- return {}
-
-def _get_in(self, cr, uid, data, context):
- args = {}
- pool = pooler.get_pool(cr.dbname)
- statement_obj = pool.get('account.bank.statement')
- product_obj = pool.get('product.template')
- res_obj = pool.get('res.users')
- curr_company = res_obj.browse(cr,uid,uid).company_id.id
- statement_id = statement_obj.search(cr,uid, [('journal_id','=',data['form']['journal_id']),('company_id','=',curr_company),('user_id','=',uid),('state','=','open')])
- if not statement_id:
- raise wizard.except_wizard(_('Error !'), _('You have to open at least one cashbox'))
-
- product = pool.get('product.product').browse(cr, uid, data['form']['product_id'])
- acc_id = product_obj.browse(cr,uid,data['form']['product_id']).property_account_income
- if not acc_id:
- raise wizard.except_wizard(_('Error !'), _('please check that account is set to %s')%(product_obj.browse(cr,uid,data['form']['product_id']).name))
- if statement_id:
- statement_id = statement_id[0]
- if not statement_id:
- statement_id = statement_obj.create(cr,uid,{'date':time.strftime('%Y-%m-%d 00:00:00'),
- 'journal_id':data['form']['journal_id'],
- 'company_id':curr_company,
- 'user_id':uid,
- })
-
- args['statement_id'] = statement_id
- args['journal_id'] = data['form']['journal_id']
- if acc_id:
- args['account_id'] = acc_id.id
- args['amount'] = data['form']['amount'] or 0.0
- args['ref'] = "%s" %(data['form']['ref'] or '')
- args['name'] = "%s: %s "% (product_obj.browse(cr,uid,data['form']['product_id']).name, data['form']['name'].decode('utf8'))
- address_u = pool.get('res.users').browse(cr,uid,uid).address_id
- if address_u:
- partner_id = address_u.partner_id and address_u.partner_id.id or None
- args['partner_id'] = partner_id
- statement_line_id = pool.get('account.bank.statement.line').create(cr, uid, args)
-
- return {}
-
-class box_entries(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {
- 'type': 'form',
- 'arch': entry_form % u'Entrée de caisse',
- 'fields': entry_fields,
- 'state': [('end', 'Cancel', 'gtk-cancel'), ('next', 'Make entries in the Cashbox', 'gtk-ok')]
- }
- },
- 'next': {
- 'actions': [],
- 'result': {
- 'type': 'action',
- 'action': _get_in,
- 'state': 'end'
- }
- },
- }
-
-box_entries('pos.entry')
-
-class box_out(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {
- 'type': 'form',
- 'arch': entry_form % u'Sortie de caisse',
- 'fields': out_fields,
- 'state': [('end', 'Cancel', 'gtk-cancel'), ('next', 'Make Entries in the CashBox', 'gtk-ok')]
- }
- },
- 'next': {
- 'actions': [],
- 'result': {
- 'type': 'action',
- 'action': _get_out,
- 'state': 'end'
- }
- },
- }
-
-box_out('pos.out')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/point_of_sale/wizard/wizard_pos_sales_user.py b/addons/pos_sales_user.py
similarity index 100%
rename from addons/point_of_sale/wizard/wizard_pos_sales_user.py
rename to addons/pos_sales_user.py
diff --git a/addons/product/product.py b/addons/product/product.py
index fdc8bcbf68e..d51d0733e81 100644
--- a/addons/product/product.py
+++ b/addons/product/product.py
@@ -82,9 +82,9 @@ class product_uom(osv.osv):
'name': fields.char('Name', size=64, required=True, translate=True),
'category_id': fields.many2one('product.uom.categ', 'UoM Category', required=True, ondelete='cascade',
help="Unit of Measure of a category can be converted between each others in the same category."),
- 'factor': fields.float('Rate', digits=(12, 6), required=True,
+ 'factor': fields.float('Ratio', digits=(12, 6), required=True,
help='The coefficient for the formula:\n' \
- '1 (base unit) = coeff (this unit). Rate = 1 / Factor.'),
+ '1 (base unit) = coeff (this unit). Ratio = 1 / Factor.'),
'factor_inv': fields.function(_factor, digits=(12, 6),
method=True, string='Factor',
help='The coefficient for the formula:\n' \
@@ -93,6 +93,9 @@ class product_uom(osv.osv):
'rounding': fields.float('Rounding Precision', digits=(16, 3), required=True,
help="The computed quantity will be a multiple of this value. Use 1.0 for products that can not be split."),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the unit of measure without removing it."),
+ 'uom_factor': fields.selection([('bigger','Bigger than the Default'),
+ ('smaller','Smaller than the Default'),
+ ('','')],'UoM Factor'),
}
_defaults = {
@@ -100,6 +103,7 @@ class product_uom(osv.osv):
'factor_inv': lambda *a: 1.0,
'active': lambda *a: 1,
'rounding': lambda *a: 0.01,
+ 'uom_factor': lambda *a: 'smaller',
}
_sql_constraints = [
@@ -204,7 +208,13 @@ class product_category(osv.osv):
'parent_id': fields.many2one('product.category','Parent Category', select=True),
'child_id': fields.one2many('product.category', 'parent_id', string='Child Categories'),
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of product categories."),
+ 'type': fields.selection([('view','View'), ('normal','Normal')], 'Category Type'),
}
+
+ _defaults = {
+ 'type' : lambda *a : 'normal',
+ }
+
_order = "sequence"
def _check_recursion(self, cr, uid, ids):
level = 100
@@ -252,7 +262,7 @@ class product_template(osv.osv):
'produce_delay': fields.float('Manufacturing Lead Time', help="Average time to produce this product. This is only for the production order and, if it is a multi-level bill of material, it's only for the level of this product. Different lead times will be summed for all levels and purchase orders."),
'procure_method': fields.selection([('make_to_stock','Make to Stock'),('make_to_order','Make to Order')], 'Requisition Method', required=True, help="'Make to Stock': When needed, take from the stock or wait until re-supplying. 'Make to Order': When needed, purchase or produce for the requisition request."),
'rental': fields.boolean('Can be Rent'),
- 'categ_id': fields.many2one('product.category','Category', required=True, change_default=True),
+ 'categ_id': fields.many2one('product.category','Category', required=True, change_default=True, domain="[('type','=','normal')]"),
'list_price': fields.float('Sale Price', digits_compute=dp.get_precision('Sale Price'), help="Base price for computing the customer price. Sometimes called the catalog price."),
'standard_price': fields.float('Cost Price', required=True, digits_compute=dp.get_precision('Account'), help="Product's cost for accounting stock valuation. It is the base price for the supplier price."),
'volume': fields.float('Volume', help="The volume in m3."),
@@ -441,7 +451,7 @@ class product_product(osv.osv):
'default_code' : fields.char('Code', size=64),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the product without removing it."),
'variants': fields.char('Variants', size=64),
- 'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=True),
+ 'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=False),
'ean13': fields.char('EAN13', size=13),
'packaging' : fields.one2many('product.packaging', 'product_id', 'Logistical Units', help="Gives the different ways to package the same product. This has no impact on the picking order and is mainly used if you use the EDI module."),
'price_extra': fields.float('Variant Price Extra', digits_compute=dp.get_precision('Sale Price')),
@@ -537,7 +547,7 @@ class product_product(osv.osv):
pricetype_obj = self.pool.get('product.price.type')
# Take the price_type currency from the product field
# This is right cause a field cannot be in more than one currency
- price_type_id = pricetype_obj.search(cr,ui,['field','=',ptype])[0]
+ price_type_id = pricetype_obj.search(cr, uid, [('field','=',ptype)])[0]
price_type_currency_id = pricetype_obj.browse(cr,uid,price_type_id).currency_id.id
res[product.id] = self.pool.get('res.currency').compute(cr, uid, price_type_currency_id,
context['currency_id'], res[product.id],context=context)
diff --git a/addons/product/product_data.xml b/addons/product/product_data.xml
index 4ed27c81d1d..300a2b0f546 100644
--- a/addons/product/product_data.xml
+++ b/addons/product/product_data.xml
@@ -21,25 +21,31 @@
PCE1.0
- 1.0
+ 1.0KGM1.0
- 1.0
+ 1.0Hour8.0
- 1.0
+ 1.0Day1.0
- 1.0
+ 1.0
+
+
+
+ TON
+ 1.0
+ 1.0
-
-
-
-
-
+
product.margin.graphproduct.product
diff --git a/addons/product_margin/wizard/__init__.py b/addons/product_margin/wizard/__init__.py
index 4e2ecc2e39a..e1f1680bccb 100644
--- a/addons/product_margin/wizard/__init__.py
+++ b/addons/product_margin/wizard/__init__.py
@@ -19,7 +19,7 @@
#
##############################################################################
-import wizard_product_margin
+import product_margin
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/product_margin/wizard/product_margin.py b/addons/product_margin/wizard/product_margin.py
new file mode 100644
index 00000000000..1907c6695c2
--- /dev/null
+++ b/addons/product_margin/wizard/product_margin.py
@@ -0,0 +1,96 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+import time
+from osv import osv
+from osv import fields
+
+import netsvc
+import time
+from tools.translate import _
+class product_margin(osv.osv_memory):
+ '''
+ Product Margin
+ '''
+ _name = 'product.margin'
+ _description = 'Product Margin'
+
+ def action_open_window(self, cr, uid, ids, context):
+ """
+ @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 if we want more than one
+
+ @return:
+ """
+ mod_obj = self.pool.get('ir.model.data')
+ result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view')
+ id = mod_obj.read(cr, uid, result, ['res_id'])
+ cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.graph', 'graph'))
+ view_res3 = cr.fetchone()[0]
+ cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.form.inherit', 'form'))
+ view_res2 = cr.fetchone()[0]
+ cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.tree', 'tree'))
+ view_res = cr.fetchone()[0]
+
+ #get the current product.margin object to obtain the values from it
+ product_margin_obj = self.browse(cr,uid,ids)[0]
+
+ return {
+ 'name': _('Product Margins'),
+ 'context':{'date_from':product_margin_obj.from_date,'date_to':product_margin_obj.to_date,'invoice_state' : product_margin_obj.invoice_state},
+ 'view_type': 'form',
+ "view_mode": 'tree,form,graph',
+ 'res_model':'product.product',
+ 'type': 'ir.actions.act_window',
+ 'views': [(view_res,'tree'), (view_res2,'form'), (view_res3,'graph')],
+ 'view_id': False,
+ 'search_view_id': id['res_id']
+ }
+
+ def action_cancel(self, cr, uid, ids, context=None):
+ """
+
+
+ @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 if we want more than one
+
+ @return:
+ """
+ return {'type':'ir.actions.act_window_close'}
+
+ _columns = {
+ #TODO : import time required to get currect date
+ 'from_date': fields.date('From'),
+ #TODO : import time required to get currect date
+ 'to_date': fields.date('To'),
+ 'invoice_state':fields.selection([
+ ('paid','Paid'),
+ ('open_paid','Open and Paid'),
+ ('draft_open_paid','Draft, Open and Paid'),
+ ],'Invoice State', select=True, required=True),
+ }
+ _defaults = {
+ 'from_date': lambda *a:time.strftime('%Y-01-01'),
+ 'to_date': lambda *a:time.strftime('%Y-01-01'),
+ 'invoice_state': lambda *a:"open_paid",
+ }
+product_margin()
diff --git a/addons/product_margin/wizard/product_margin_view.xml b/addons/product_margin/wizard/product_margin_view.xml
new file mode 100644
index 00000000000..66869e120a5
--- /dev/null
+++ b/addons/product_margin/wizard/product_margin_view.xml
@@ -0,0 +1,33 @@
+
+
+
+
+ product.margin.form
+ product.margin
+ form
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/product_margin/wizard/wizard_product_margin.py b/addons/product_margin/wizard/wizard_product_margin.py
deleted file mode 100644
index 625cfd4c1df..00000000000
--- a/addons/product_margin/wizard/wizard_product_margin.py
+++ /dev/null
@@ -1,93 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import pooler
-import time
-
-from tools.translate import _
-
-def _action_open_window(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- mod_obj = pool.get('ir.model.data')
- result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view')
- id = mod_obj.read(cr, uid, result, ['res_id'])
- cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.graph', 'graph'))
- view_res3 = cr.fetchone()[0]
- cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.form.inherit', 'form'))
- view_res2 = cr.fetchone()[0]
- cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.tree', 'tree'))
- view_res = cr.fetchone()[0]
- return {
- 'name': _('Product Margins'),
- 'context':{'date_from':data['form']['from_date'],'date_to':data['form']['to_date'],'invoice_state' : data['form']['invoice_state']},
- 'view_type': 'form',
- "view_mode": 'tree,form,graph',
- 'res_model':'product.product',
- 'type': 'ir.actions.act_window',
- 'views': [(view_res,'tree'), (view_res2,'form'), (view_res3,'graph')],
- 'view_id': False,
- 'search_view_id': id['res_id']
- }
-
-
-class product_margins(wizard.interface):
- form1 = '''
- '''
- form1_fields = {
- 'from_date': {
- 'string': 'From',
- 'type': 'date',
- 'default': lambda *a:time.strftime('%Y-01-01'),
-
- },
- 'to_date': {
- 'string': 'To',
- 'type': 'date',
- 'default': lambda *a:time.strftime('%Y-12-31'),
-
- },
- 'invoice_state': {
- 'string': 'Invoice State',
- 'type': 'selection',
- 'selection': [('paid','Paid'),('open_paid','Open and Paid'),('draft_open_paid','Draft, Open and Paid'),],
- 'required': True,
- 'default': lambda *a:"open_paid",
- },
- }
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel','gtk-cancel'),('open', 'Open Margins','gtk-ok')]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
- }
- }
-product_margins('product.margins')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project/security/project_security.xml b/addons/project/security/project_security.xml
index 7c34807517a..7fcb2e6fedb 100644
--- a/addons/project/security/project_security.xml
+++ b/addons/project/security/project_security.xml
@@ -23,7 +23,7 @@
- ['|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]
+ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
@@ -32,7 +32,7 @@
- ['|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]
+ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
diff --git a/addons/project_issue/report/project_issue_report.py b/addons/project_issue/report/project_issue_report.py
index 74444780b57..3ea0b196705 100644
--- a/addons/project_issue/report/project_issue_report.py
+++ b/addons/project_issue/report/project_issue_report.py
@@ -36,6 +36,10 @@ class project_issue_report(osv.osv):
c.project_id as project_id,
c.type_id as type_id,
count(*) as nbr,
+ sum(planned_revenue) as amount_revenue,
+ sum(planned_cost) as amount_costs,
+ sum(planned_revenue*probability/100)::decimal(16,2) as amount_revenue_prob,
+ avg(probability)::decimal(16,2) as probability,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
project_issue c
diff --git a/addons/purchase/__terp__.py b/addons/purchase/__terp__.py
index 11f3ae2d809..dfa362a97c6 100644
--- a/addons/purchase/__terp__.py
+++ b/addons/purchase/__terp__.py
@@ -39,9 +39,9 @@
'purchase_workflow.xml',
'purchase_sequence.xml',
'purchase_data.xml',
+ 'wizard/purchase_order_group_view.xml',
'purchase_view.xml',
'purchase_report.xml',
- 'purchase_wizard.xml',
'stock_view.xml',
'partner_view.xml',
'process/purchase_process.xml',
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index 887950bc746..0dc7926f428 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -32,7 +32,7 @@ from tools import config
from tools.translate import _
import decimal_precision as dp
-
+from osv.orm import browse_record, browse_null
#
# Model definition
@@ -394,7 +394,9 @@ class purchase_order(osv.osv):
istate = 'none'
if order.invoice_method=='picking':
istate = '2binvoiced'
+ pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.in')
picking_id = self.pool.get('stock.picking').create(cr, uid, {
+ 'name': pick_name,
'origin': order.name+((order.origin and (':'+order.origin)) or ''),
'type': 'in',
'address_id': order.dest_address_id.id or order.partner_address_id.id,
@@ -444,6 +446,114 @@ class purchase_order(osv.osv):
})
return super(purchase_order, self).copy(cr, uid, id, default, context)
+
+ def do_merge(self, cr, uid, ids, context):
+ """
+ To merge similar type of purchase orders.
+ Orders will only be merged if:
+ * Purchase Orders are in draft
+ * Purchase Orders belong to the same partner
+ * Purchase Orders are have same stock location, same pricelist
+ Lines will only be merged if:
+ * Order lines are exactly the same except for the quantity and unit
+
+ @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
+ @param context: A standard dictionary
+
+ @return: new purchase order id
+
+ """
+ wf_service = netsvc.LocalService("workflow")
+ def make_key(br, fields):
+ list_key = []
+ for field in fields:
+ field_val = getattr(br, field)
+ if field in ('product_id', 'move_dest_id', 'account_analytic_id'):
+ if not field_val:
+ field_val = False
+ if isinstance(field_val, browse_record):
+ field_val = field_val.id
+ elif isinstance(field_val, browse_null):
+ field_val = False
+ elif isinstance(field_val, list):
+ field_val = ((6, 0, tuple([v.id for v in field_val])),)
+ list_key.append((field, field_val))
+ list_key.sort()
+ return tuple(list_key)
+
+ # compute what the new orders should contain
+
+ new_orders = {}
+
+ for porder in [order for order in self.browse(cr, uid, ids) if order.state == 'draft']:
+ order_key = make_key(porder, ('partner_id', 'location_id', 'pricelist_id'))
+ new_order = new_orders.setdefault(order_key, ({}, []))
+ new_order[1].append(porder.id)
+ order_infos = new_order[0]
+ if not order_infos:
+ order_infos.update({
+ 'origin': porder.origin,
+ 'date_order': time.strftime('%Y-%m-%d'),
+ 'partner_id': porder.partner_id.id,
+ 'partner_address_id': porder.partner_address_id.id,
+ 'dest_address_id': porder.dest_address_id.id,
+ 'warehouse_id': porder.warehouse_id.id,
+ 'location_id': porder.location_id.id,
+ 'pricelist_id': porder.pricelist_id.id,
+ 'state': 'draft',
+ 'order_line': {},
+ 'notes': '%s' % (porder.notes or '',),
+ })
+ else:
+ #order_infos['name'] += ', %s' % porder.name
+ if porder.notes:
+ order_infos['notes'] = (order_infos['notes'] or '') + ('\n%s' % (porder.notes,))
+ if porder.origin:
+ order_infos['origin'] = (order_infos['origin'] or '') + ' ' + porder.origin
+
+ for order_line in porder.order_line:
+ line_key = make_key(order_line, ('name', 'date_planned', 'taxes_id', 'price_unit', 'notes', 'product_id', 'move_dest_id', 'account_analytic_id'))
+ o_line = order_infos['order_line'].setdefault(line_key, {})
+ if o_line:
+ # merge the line with an existing line
+ o_line['product_qty'] += order_line.product_qty * order_line.product_uom.factor / o_line['uom_factor']
+ else:
+ # append a new "standalone" line
+ for field in ('product_qty', 'product_uom'):
+ field_val = getattr(order_line, field)
+ if isinstance(field_val, browse_record):
+ field_val = field_val.id
+ o_line[field] = field_val
+ o_line['uom_factor'] = order_line.product_uom and order_line.product_uom.factor or 1.0
+
+
+
+ allorders = []
+ for order_key, (order_data, old_ids) in new_orders.iteritems():
+ # skip merges with only one order
+ if len(old_ids) < 2:
+ allorders += (old_ids or [])
+ continue
+
+ # cleanup order line data
+ for key, value in order_data['order_line'].iteritems():
+ del value['uom_factor']
+ value.update(dict(key))
+ order_data['order_line'] = [(0, 0, value) for value in order_data['order_line'].itervalues()]
+
+ # create the new order
+ neworder_id = self.create(cr, uid, order_data)
+ allorders.append(neworder_id)
+
+ # make triggers pointing to the old orders point to the new order
+ for old_id in old_ids:
+ wf_service.trg_redirect(uid, 'purchase.order', old_id, neworder_id, cr)
+ wf_service.trg_validate(uid, 'purchase.order', old_id, 'purchase_cancel', cr)
+ return allorders
+
purchase_order()
class purchase_order_line(osv.osv):
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index b8be61e1665..653238748b9 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -160,6 +160,7 @@
+
@@ -288,6 +289,15 @@
name="Product purchases"
res_model="purchase.order.line"
src_model="product.product"/>
-
+
diff --git a/addons/purchase/purchase_wizard.xml b/addons/purchase/purchase_wizard.xml
index e7fd3ce6efc..d76ce1e3819 100644
--- a/addons/purchase/purchase_wizard.xml
+++ b/addons/purchase/purchase_wizard.xml
@@ -1,11 +1,13 @@
+
diff --git a/addons/purchase/security/purchase_security.xml b/addons/purchase/security/purchase_security.xml
index 84b9a87ff05..2685e52d909 100644
--- a/addons/purchase/security/purchase_security.xml
+++ b/addons/purchase/security/purchase_security.xml
@@ -18,7 +18,7 @@
- ['|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]
+ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
@@ -29,7 +29,7 @@
- ['|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]
+ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
diff --git a/addons/purchase/wizard/__init__.py b/addons/purchase/wizard/__init__.py
index e79d70fbaeb..73bb88500a8 100644
--- a/addons/purchase/wizard/__init__.py
+++ b/addons/purchase/wizard/__init__.py
@@ -19,7 +19,7 @@
#
##############################################################################
-import wizard_group
+import purchase_order_group
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/purchase/wizard/purchase_order_group.py b/addons/purchase/wizard/purchase_order_group.py
new file mode 100644
index 00000000000..8c4e0784a7b
--- /dev/null
+++ b/addons/purchase/wizard/purchase_order_group.py
@@ -0,0 +1,70 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+import netsvc
+import pooler
+import time
+import wizard
+from osv.orm import browse_record, browse_null
+
+class purchase_order_group(osv.osv_memory):
+ _name = "purchase.order.group"
+ _description = "Purchase Wizard"
+ _columns = {
+
+ }
+
+ def merge_orders(self, cr, uid, ids, context):
+ """
+ To merge similar type of purchase orders.
+
+ @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
+ @param context: A standard dictionary
+
+ @return: purchase order view
+
+ """
+ order_obj = self.pool.get('purchase.order')
+ mod_obj =self.pool.get('ir.model.data')
+ result = mod_obj._get_id(cr, uid, 'purchase', 'view_purchase_order_filter')
+ id = mod_obj.read(cr, uid, result, ['res_id'])
+
+
+ allorders = order_obj.do_merge(cr, uid, context.get('active_ids',[]), context)
+
+
+ return {
+ 'domain': "[('id','in', [" + ','.join(map(str, allorders)) + "])]",
+ 'name': 'Purchase Orders',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'purchase.order',
+ 'view_id': False,
+ 'type': 'ir.actions.act_window',
+ 'search_view_id': id['res_id']
+ }
+purchase_order_group()
+
diff --git a/addons/purchase/wizard/purchase_order_group_view.xml b/addons/purchase/wizard/purchase_order_group_view.xml
new file mode 100644
index 00000000000..aa835b36f0b
--- /dev/null
+++ b/addons/purchase/wizard/purchase_order_group_view.xml
@@ -0,0 +1,39 @@
+
+
+
+
+ Merger Purchase Orders
+ purchase.order.group
+ form
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/purchase/wizard/wizard_group.py b/addons/purchase/wizard/wizard_group.py
deleted file mode 100644
index 050be8c88d6..00000000000
--- a/addons/purchase/wizard/wizard_group.py
+++ /dev/null
@@ -1,173 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import time
-
-import wizard
-import netsvc
-import pooler
-from osv.orm import browse_record, browse_null
-
-
-merge_form = """
-
-"""
-
-merge_fields = {
-}
-
-ack_form = """
-"""
-
-ack_fields = {}
-
-
-def _merge_orders(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- order_obj = pool.get('purchase.order')
- mod_obj = pool.get('ir.model.data')
- result = mod_obj._get_id(cr, uid, 'purchase', 'view_purchase_order_filter')
- id = mod_obj.read(cr, uid, result, ['res_id'])
-
- def make_key(br, fields):
- list_key = []
- for field in fields:
- field_val = getattr(br, field)
- if field in ('product_id', 'move_dest_id', 'account_analytic_id'):
- if not field_val:
- field_val = False
- if isinstance(field_val, browse_record):
- field_val = field_val.id
- elif isinstance(field_val, browse_null):
- field_val = False
- elif isinstance(field_val, list):
- field_val = ((6, 0, tuple([v.id for v in field_val])),)
- list_key.append((field, field_val))
- list_key.sort()
- return tuple(list_key)
-
- # compute what the new orders should contain
- new_orders = {}
- for porder in [order for order in order_obj.browse(cr, uid, data['ids']) if order.state == 'draft']:
- order_key = make_key(porder, ('partner_id', 'location_id', 'pricelist_id'))
-
- new_order = new_orders.setdefault(order_key, ({}, []))
- new_order[1].append(porder.id)
- order_infos = new_order[0]
- if not order_infos:
- order_infos.update({
- 'origin': porder.origin,
- 'date_order': time.strftime('%Y-%m-%d'),
- 'partner_id': porder.partner_id.id,
- 'partner_address_id': porder.partner_address_id.id,
- 'dest_address_id': porder.dest_address_id.id,
- 'warehouse_id': porder.warehouse_id.id,
- 'location_id': porder.location_id.id,
- 'pricelist_id': porder.pricelist_id.id,
- 'state': 'draft',
- 'order_line': {},
- 'notes': '%s' % (porder.notes or '',),
- })
- else:
- #order_infos['name'] += ', %s' % porder.name
- if porder.notes:
- order_infos['notes'] = (order_infos['notes'] or '') + ('\n%s' % (porder.notes,))
- if porder.origin:
- order_infos['origin'] = (order_infos['origin'] or '') + ' ' + porder.origin
-
- for order_line in porder.order_line:
- line_key = make_key(order_line, ('name', 'date_planned', 'taxes_id', 'price_unit', 'notes', 'product_id', 'move_dest_id', 'account_analytic_id'))
- o_line = order_infos['order_line'].setdefault(line_key, {})
- if o_line:
- # merge the line with an existing line
- o_line['product_qty'] += order_line.product_qty * order_line.product_uom.factor / o_line['uom_factor']
- else:
- # append a new "standalone" line
- for field in ('product_qty', 'product_uom'):
- field_val = getattr(order_line, field)
- if isinstance(field_val, browse_record):
- field_val = field_val.id
- o_line[field] = field_val
- o_line['uom_factor'] = order_line.product_uom and order_line.product_uom.factor or 1.0
-
- wf_service = netsvc.LocalService("workflow")
-
- allorders = []
- for order_key, (order_data, old_ids) in new_orders.iteritems():
- # skip merges with only one order
- if len(old_ids) < 2:
- allorders += (old_ids or [])
- continue
-
- # cleanup order line data
- for key, value in order_data['order_line'].iteritems():
- del value['uom_factor']
- value.update(dict(key))
- order_data['order_line'] = [(0, 0, value) for value in order_data['order_line'].itervalues()]
-
- # create the new order
- neworder_id = order_obj.create(cr, uid, order_data)
- allorders.append(neworder_id)
-
- # make triggers pointing to the old orders point to the new order
- for old_id in old_ids:
- wf_service.trg_redirect(uid, 'purchase.order', old_id, neworder_id, cr)
- wf_service.trg_validate(uid, 'purchase.order', old_id, 'purchase_cancel', cr)
-
- return {
- 'domain': "[('id','in', [" + ','.join(map(str, allorders)) + "])]",
- 'name': 'Purchase Orders',
- 'view_type': 'form',
- 'view_mode': 'tree,form',
- 'res_model': 'purchase.order',
- 'view_id': False,
- 'type': 'ir.actions.act_window',
- 'search_view_id': id['res_id']
- }
-
-
-class merge_orders(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch': merge_form, 'fields' : merge_fields, 'state' : [('end', 'Cancel'), ('merge', 'Merge orders') ]}
- },
- 'merge': {
- 'actions': [],
- 'result': {'type': 'action', 'action': _merge_orders, 'state': 'end'}
- },
- }
-
-merge_orders("purchase.order.merge")
-
diff --git a/addons/sale/__terp__.py b/addons/sale/__terp__.py
index 51ddf03fe55..a6ff79b38cd 100644
--- a/addons/sale/__terp__.py
+++ b/addons/sale/__terp__.py
@@ -45,16 +45,16 @@
'depends': ['product', 'stock', 'mrp', 'process'],
'init_xml': [],
'update_xml': [
+ 'wizard/sale_make_invoice_advance.xml',
+ 'wizard/sale_line_invoice.xml',
'security/sale_security.xml',
'security/ir.model.access.csv',
'sale_workflow.xml',
'sale_sequence.xml',
'sale_data.xml',
- 'sale_wizard.xml',
'sale_view.xml',
'report/sale_report_view.xml',
'sale_report.xml',
- 'sale_wizard.xml',
'stock_view.xml',
'process/sale_process.xml',
],
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index 501d9ac1ea7..8b77719171a 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -593,7 +593,9 @@ class sale_order(osv.osv):
location_id = order.shop_id.warehouse_id.lot_stock_id.id
if not picking_id:
loc_dest_id = order.partner_id.property_stock_customer.id
+ pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out')
picking_id = self.pool.get('stock.picking').create(cr, uid, {
+ 'name': pick_name,
'origin': order.name,
'type': 'out',
'state': 'auto',
diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml
index 7fa61108e4f..c62487cfe1e 100644
--- a/addons/sale/sale_view.xml
+++ b/addons/sale/sale_view.xml
@@ -85,6 +85,7 @@
+
@@ -150,7 +151,12 @@
-
+
@@ -262,6 +268,7 @@
+
@@ -380,8 +387,14 @@
-
-
+
+
diff --git a/addons/sale/sale_wizard.xml b/addons/sale/sale_wizard.xml
deleted file mode 100644
index 9df05e8e5dd..00000000000
--- a/addons/sale/sale_wizard.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/sale/security/ir.model.access.csv b/addons/sale/security/ir.model.access.csv
index 937322578cd..44ce9f7d1fa 100644
--- a/addons/sale/security/ir.model.access.csv
+++ b/addons/sale/security/ir.model.access.csv
@@ -21,3 +21,10 @@
"access_sale_order_line_manager","sale.order.line.manager","model_sale_order_line","group_sale_manager",1,1,1,1
"access_sale_report","sale.report","model_sale_report","group_sale_user",1,1,1,0
"access_sale_report_manager","sale.report","model_sale_report","group_sale_manager",1,1,1,1
+"access_sale_order_line_make_invoice","sale.order.line.make.invoice","model_sale_order_line_make_invoice","group_sale_user",1,1,1,0
+"access_sale_order_line_make_invoice_manager","sale.order.line.make.invoice","model_sale_order_line_make_invoice","group_sale_manager",1,1,1,1
+"access_sale_advance_payment_inv","sale.advance.payment.inv","model_sale_advance_payment_inv","group_sale_user",1,1,1,0
+"access_sale_advance_payment_inv_manager","sale.advance.payment.inv","model_sale_advance_payment_inv","group_sale_manager",1,1,1,1
+"access_sale_open_invoice","sale.open.invoice","model_sale_open_invoice","group_sale_user",1,1,1,0
+"access_sale_open_invoice_manager","sale.open.invoice","model_sale_open_invoice","group_sale_manager",1,1,1,1
+
diff --git a/addons/sale/security/sale_security.xml b/addons/sale/security/sale_security.xml
index 6f9bcc52bb1..590a849ab9a 100644
--- a/addons/sale/security/sale_security.xml
+++ b/addons/sale/security/sale_security.xml
@@ -9,7 +9,6 @@
Sale / Salesman
-
@@ -22,7 +21,7 @@
- ['|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]
+ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
@@ -33,7 +32,7 @@
- ['|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]
+ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
diff --git a/addons/sale/wizard/__init__.py b/addons/sale/wizard/__init__.py
index 6141e90b83b..07c5ceea83d 100644
--- a/addons/sale/wizard/__init__.py
+++ b/addons/sale/wizard/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,13 +15,12 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+# along with this program. If not, see .
#
##############################################################################
-from make_invoice import make_invoice
+#remaining make_invoice
+import sale_line_invoice
+import sale_make_invoice_advance
-import wizard_sale_line_invoice
-import make_invoice_advance
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/sale/wizard/make_invoice_advance.py b/addons/sale/wizard/make_invoice_advance.py
deleted file mode 100644
index eaa1fc4a14b..00000000000
--- a/addons/sale/wizard/make_invoice_advance.py
+++ /dev/null
@@ -1,157 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import pooler
-from osv import fields, osv
-from tools.translate import _
-
-form = """
-
-"""
-fields = {
- 'product_id': {'string':'Product', 'type':'many2one','relation':'product.product','required':True},
- 'amount': {'string':'Unit Price', 'type':'float', 'size':(16,2),'required':True},
- 'qtty': {'string':'Quantity', 'type':'float', 'size':(16,2),'required':True, 'default': lambda *a: 1},
-}
-
-form_msg = """
-
-"""
-fields_msg = {}
-
-def _createInvoices(self, cr, uid, data, context={}):
- list_inv = []
- pool_obj = pooler.get_pool(cr.dbname)
- obj_sale = pool_obj.get('sale.order')
- data_sale = obj_sale.browse(cr,uid,data['ids'])
- obj_lines = pool_obj.get('account.invoice.line')
- for sale in data_sale:
- address_contact = False
- address_invoice = False
- create_ids = []
- ids_inv = []
- if sale.order_policy == 'postpaid':
- raise osv.except_osv(
- _('Error'),
- _("You cannot make an advance on a sale order that is defined as 'Automatic Invoice after delivery'."))
- val = obj_lines.product_id_change(cr, uid, [], data['form']['product_id'],uom = False, partner_id = sale.partner_id.id, fposition_id=sale.fiscal_position.id)
- line_id =obj_lines.create(cr, uid, {
- 'name': val['value']['name'],
- 'account_id':val['value']['account_id'],
- 'price_unit': data['form']['amount'],
- 'quantity': data['form']['qtty'],
- 'discount': False,
- 'uos_id': val['value']['uos_id'],
- 'product_id':data['form']['product_id'],
- 'invoice_line_tax_id': [(6,0,val['value']['invoice_line_tax_id'])],
- 'account_analytic_id': sale.project_id and sale.project_id.id or False,
- 'note':'',
- })
- create_ids.append(line_id)
- inv = {
- 'name': sale.name,
- 'origin': sale.name,
- 'type': 'out_invoice',
- 'reference': False,
- 'account_id': sale.partner_id.property_account_receivable.id,
- 'partner_id': sale.partner_id.id,
- 'address_invoice_id':sale.partner_invoice_id.id,
- 'address_contact_id':sale.partner_order_id.id,
- 'invoice_line': [(6,0,create_ids)],
- 'currency_id' :sale.pricelist_id.currency_id.id,
- 'comment': '',
- 'payment_term':sale.payment_term.id,
- 'fiscal_position': sale.partner_id.property_account_position.id
- }
- inv_obj = pool_obj.get('account.invoice')
- inv_id = inv_obj.create(cr, uid, inv)
-
- for inv in sale.invoice_ids:
- ids_inv.append(inv.id)
- ids_inv.append(inv_id)
- obj_sale.write(cr,uid,sale.id,{'invoice_ids':[(6,0,ids_inv)]})
- list_inv.append(inv_id)
-#
-# If invoice on picking: add the cost on the SO
-# If not, the advance will be deduced when generating the final invoice
-#
- if sale.order_policy=='picking':
- pool_obj.get('sale.order.line').create(cr, uid, {
- 'order_id': sale.id,
- 'name': val['value']['name'],
- 'price_unit': -data['form']['amount'],
- 'product_uom_qty': data['form']['qtty'],
- 'product_uos_qty': data['form']['qtty'],
- 'product_uos': val['value']['uos_id'],
- 'product_uom': val['value']['uos_id'],
- 'product_id':data['form']['product_id'],
- 'discount': False,
- 'tax_id': [(6,0,val['value']['invoice_line_tax_id'])],
- }, context)
- return {'invoice_ids':list_inv}
-
-class sale_advance_payment(wizard.interface):
- def _open_invoice(self, cr, uid, data, context):
- pool_obj = pooler.get_pool(cr.dbname)
- mod_obj = pool_obj.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'])
- model_data_ids = pool_obj.get('ir.model.data').search(cr,uid,[('model','=','ir.ui.view'),('name','=','invoice_form')])
- resource_id = pool_obj.get('ir.model.data').read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id']
- return {
- 'domain': "[('id','in', ["+','.join(map(str,data['form']['invoice_ids']))+"])]",
- 'name': 'Invoices',
- 'view_type': 'form',
- 'view_mode': 'tree,form',
- 'res_model': 'account.invoice',
- 'views': [(False,'tree'),(resource_id,'form')],
- 'context': "{'type':'out_invoice'}",
- 'type': 'ir.actions.act_window',
- 'search_view_id': id['res_id']
- }
-
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form' , 'arch' : form,'fields' : fields,'state' : [('end','Cancel','gtk-cancel'),('create','Create Advance Invoice','gtk-ok')]}
- },
- 'create': {
- 'actions': [_createInvoices],
- 'result': {'type' : 'form' ,'arch' : form_msg,'fields' : fields_msg, 'state':[('end','Close','gtk-close'),('open','Open Advance Invoice','gtk-open')]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type':'action', 'action':_open_invoice, 'state':'end'}
- }
- }
-
-sale_advance_payment("sale.advance_payment_inv")
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/sale/wizard/sale_line_invoice.py b/addons/sale/wizard/sale_line_invoice.py
new file mode 100644
index 00000000000..4bf3074db54
--- /dev/null
+++ b/addons/sale/wizard/sale_line_invoice.py
@@ -0,0 +1,124 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+import wizard
+import netsvc
+import ir
+import pooler
+
+class sale_order_line_make_invoice(osv.osv_memory):
+ _name = "sale.order.line.make.invoice"
+ _description = "Sale OrderLine Make_invoice"
+ _columns = {
+ 'grouped': fields.boolean('Group the invoices'),
+ }
+ _default = {
+ 'grouped' : lambda *a: False
+ }
+
+ def make_invoices(self, cr, uid, ids, context):
+ """
+ To make invoices.
+
+ @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
+ @param context: A standard dictionary
+
+ @return: A dictionary which of fields with values.
+
+ """
+
+ res = False
+ invoices = {}
+
+ #TODO: merge with sale.py/make_invoice
+ def make_invoice(order, lines):
+ """
+ To make invoices.
+
+ @param order:
+ @param lines:
+
+ @return:
+
+ """
+ a = order.partner_id.property_account_receivable.id
+ if order.partner_id and order.partner_id.property_payment_term.id:
+ pay_term = order.partner_id.property_payment_term.id
+ else:
+ pay_term = False
+ inv = {
+ 'name': order.name,
+ 'origin': order.name,
+ 'type': 'out_invoice',
+ 'reference': "P%dSO%d" % (order.partner_id.id, order.id),
+ 'account_id': a,
+ 'partner_id': order.partner_id.id,
+ 'address_invoice_id': order.partner_invoice_id.id,
+ 'address_contact_id': order.partner_invoice_id.id,
+ 'invoice_line': [(6,0,lines)],
+ 'currency_id' : order.pricelist_id.currency_id.id,
+ 'comment': order.note,
+ 'payment_term': pay_term,
+ 'fiscal_position': order.partner_id.property_account_position.id
+ }
+ inv_id = self.pool.get('account.invoice').create(cr, uid, inv)
+ return inv_id
+
+ sales_order_line_obj = self.pool.get('sale.order.line')
+ sales_order_obj = self.pool.get('sale.order')
+ wf_service = netsvc.LocalService('workflow')
+ for line in sales_order_line_obj.browse(cr,uid,context['active_ids']):
+ if (not line.invoiced) and (line.state not in ('draft','cancel')):
+ if not line.order_id.id in invoices:
+ invoices[line.order_id.id] = []
+ line_id = sales_order_line_obj.invoice_line_create(cr, uid,
+ [line.id])
+ for lid in line_id:
+ invoices[line.order_id.id].append((line, lid))
+ sales_order_line_obj.write(cr, uid, [line.id],
+ {'invoiced': True})
+ flag = True
+ data_sale = sales_order_obj.browse(cr,uid,line.order_id.id)
+ for line in data_sale.order_line:
+ if not line.invoiced:
+ flag = False
+ break
+ if flag:
+ wf_service.trg_validate(uid, 'sale.order', line.order_id.id, 'all_lines', cr)
+ sales_order_obj.write(cr,uid,[line.order_id.id],{'state' : 'progress'})
+
+ for result in invoices.values():
+ order = result[0][0].order_id
+ il = map(lambda x: x[1], result)
+ res = make_invoice(order, il)
+ cr.execute('INSERT INTO sale_order_invoice_rel \
+ (order_id,invoice_id) values (%s,%s)', (order.id, res))
+ return {}
+
+
+sale_order_line_make_invoice()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/sale/wizard/sale_line_invoice.xml b/addons/sale/wizard/sale_line_invoice.xml
new file mode 100644
index 00000000000..a9ea13ea900
--- /dev/null
+++ b/addons/sale/wizard/sale_line_invoice.xml
@@ -0,0 +1,28 @@
+
+
+
+
+ Sale OrderLine Make Invoice
+ sale.order.line.make.invoice
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py
new file mode 100644
index 00000000000..6c9ca17b836
--- /dev/null
+++ b/addons/sale/wizard/sale_make_invoice_advance.py
@@ -0,0 +1,180 @@
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+from tools.translate import _
+import ir
+import netsvc
+import pooler
+import wizard
+
+
+class sale_advance_payment_inv(osv.osv_memory):
+ _name = "sale.advance.payment.inv"
+ _description = "Sale Advance Payment Invoice"
+ _columns = {
+ 'product_id': fields.many2one('product.product', 'Product', required=True),
+ 'amount': fields.float('Unit Price', size=(16, 2), required=True),
+ 'qtty': fields.float('Quantity', size=(16, 2), required=True),
+ }
+ _default = {
+ 'qtty' : lambda *a: 1
+ }
+ def create_invoices(self, cr, uid, ids, context={}):
+ """
+ To create invoices.
+
+ @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:
+
+ """
+ list_inv = []
+ obj_sale = self.pool.get('sale.order')
+ obj_lines = self.pool.get('account.invoice.line')
+ inv_obj = self.pool.get('account.invoice')
+
+ for sale_adv_obj in self.browse(cr, uid, ids):
+ for sale in obj_sale.browse(cr, uid, context['active_ids']):
+ address_contact = False
+ address_invoice = False
+ create_ids = []
+ ids_inv = []
+ if sale.order_policy == 'postpaid':
+ raise osv.except_osv(
+ _('Error'),
+ _("You cannot make an advance on a sale order \
+ that is defined as 'Automatic Invoice after delivery'."))
+ val = obj_lines.product_id_change(cr, uid, [], sale_adv_obj.product_id.id,
+ uom = False, partner_id = sale.partner_id.id, fposition_id=sale.fiscal_position.id)
+ line_id =obj_lines.create(cr, uid, {
+ 'name': val['value']['name'],
+ 'account_id': val['value']['account_id'],
+ 'price_unit': sale_adv_obj.amount,
+ 'quantity': sale_adv_obj.qtty,
+ 'discount': False,
+ 'uos_id': val['value']['uos_id'],
+ 'product_id': sale_adv_obj.product_id.id,
+ 'invoice_line_tax_id': [(6, 0, val['value']['invoice_line_tax_id'])],
+ 'account_analytic_id': sale.project_id.id or False,
+ #'note':'',
+ })
+ create_ids.append(line_id)
+ inv = {
+ 'name': sale.name,
+ 'origin': sale.name,
+ 'type': 'out_invoice',
+ 'reference': False,
+ 'account_id': sale.partner_id.property_account_receivable.id,
+ 'partner_id': sale.partner_id.id,
+ 'address_invoice_id':sale.partner_invoice_id.id,
+ 'address_contact_id':sale.partner_order_id.id,
+ 'invoice_line': [(6, 0, create_ids)],
+ 'currency_id' :sale.pricelist_id.currency_id.id,
+ 'comment': '',
+ 'payment_term':sale.payment_term.id,
+ 'fiscal_position': sale.partner_id.property_account_position.id
+ }
+
+ inv_id = inv_obj.create(cr, uid, inv)
+
+ for inv in sale.invoice_ids:
+ ids_inv.append(inv.id)
+ ids_inv.append(inv_id)
+ obj_sale.write(cr, uid, sale.id, {'invoice_ids':[(6, 0, ids_inv)]})
+ list_inv.append(inv_id)
+ #
+ # If invoice on picking: add the cost on the SO
+ # If not, the advance will be deduced when generating the final invoice
+ #
+ if sale.order_policy=='picking':
+ self.pool.get('sale.order.line').create(cr, uid, {
+ 'order_id': sale.id,
+ 'name': val['value']['name'],
+ 'price_unit': -sale_adv_obj.amount,
+ 'product_uom_qty': sale_adv_obj.qtty,
+ 'product_uos_qty': sale_adv_obj.qtty,
+ 'product_uos': val['value']['uos_id'],
+ 'product_uom': val['value']['uos_id'],
+ 'product_id': sale_adv_obj.product_id.id,
+ 'discount': False,
+ 'tax_id': [(6, 0, val['value']['invoice_line_tax_id'])],
+ }, context)
+
+ return {#'invoice_ids':list_inv,
+ 'name': 'Open Invoice',
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'sale.open.invoice',
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ 'context': "{'invoice_ids'=%s}" % (list_inv)
+ }
+
+sale_advance_payment_inv()
+
+class sale_open_invoice(osv.osv_memory):
+ _name = "sale.open.invoice"
+ _description = "Sale Open Invoice"
+ _columns = {
+ }
+
+ def open_invoice(self, cr, uid, ids, context):
+ """
+ To open invoice.
+
+ @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:
+
+ """
+ mod_obj = self.pool.get('ir.model.data')
+ invoices = []
+ #TODO: Can not get invoice ids here
+ for advance_pay in self.browse(cr, uid, ids):
+ result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
+ id = mod_obj.read(cr, uid, result, ['res_id'])
+ model_data_ids = mod_obj.search(cr, uid,
+ [('model', '=', 'ir.ui.view'), ('name', '=', 'invoice_form')])
+ resource_id = mod_obj.read(cr, uid, model_data_ids,
+ fields=['res_id'])[0]['res_id']
+ return {
+# 'domain': "[('id','in', ["+','.join(map(str, invoices))+"])]", # TODO
+ 'name': 'Invoices',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.invoice',
+ 'views': [(False, 'tree'), (resource_id, 'form')],
+ 'context': "{'type':'out_invoice'}",
+ 'type': 'ir.actions.act_window',
+ 'search_view_id': id['res_id']
+ }
+sale_open_invoice()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/sale/wizard/sale_make_invoice_advance.xml b/addons/sale/wizard/sale_make_invoice_advance.xml
new file mode 100644
index 00000000000..5fc8b993921
--- /dev/null
+++ b/addons/sale/wizard/sale_make_invoice_advance.xml
@@ -0,0 +1,59 @@
+
+
+
+
+ Sale Advance Payment Invoive
+ sale.advance.payment.inv
+ form
+
+
+
+
+
+
+
+
+
+
+ Open Invoice
+ sale.open.invoice
+ form
+
+
+
+
+
+
+ Open Invoice
+ ir.actions.act_window
+ sale.open.invoice
+ form
+ form
+ new
+
+
+
diff --git a/addons/sale/wizard/wizard_sale_line_invoice.py b/addons/sale/wizard/wizard_sale_line_invoice.py
deleted file mode 100644
index 8e1e49ab22d..00000000000
--- a/addons/sale/wizard/wizard_sale_line_invoice.py
+++ /dev/null
@@ -1,121 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import ir
-import pooler
-
-invoice_form = """
-
-"""
-
-invoice_fields = {
- 'grouped' : {'string':'Group the invoices', 'type':'boolean', 'default': lambda *a: False}
-}
-
-def _makeInvoices(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- res = False
- invoices = {}
-
- #TODO: merge with sale.py/make_invoice
- def make_invoice(order, lines):
- a = order.partner_id.property_account_receivable.id
- if order.partner_id and order.partner_id.property_payment_term.id:
- pay_term = order.partner_id.property_payment_term.id
- else:
- pay_term = False
- inv = {
- 'name': order.name,
- 'origin': order.name,
- 'type': 'out_invoice',
- 'reference': "P%dSO%d" % (order.partner_id.id, order.id),
- 'account_id': a,
- 'partner_id': order.partner_id.id,
- 'address_invoice_id': order.partner_invoice_id.id,
- 'address_contact_id': order.partner_invoice_id.id,
- 'invoice_line': [(6,0,lines)],
- 'currency_id' : order.pricelist_id.currency_id.id,
- 'comment': order.note,
- 'payment_term': pay_term,
- 'fiscal_position': order.partner_id.property_account_position.id
- }
- inv_id = pool.get('account.invoice').create(cr, uid, inv)
- return inv_id
-
- for line in pool.get('sale.order.line').browse(cr,uid,data['ids']):
- if (not line.invoiced) and (line.state not in ('draft','cancel')):
- if not line.order_id.id in invoices:
- invoices[line.order_id.id] = []
- line_id = pool.get('sale.order.line').invoice_line_create(cr, uid,
- [line.id])
- for lid in line_id:
- invoices[line.order_id.id].append((line, lid))
- pool.get('sale.order.line').write(cr, uid, [line.id],
- {'invoiced': True})
- flag = True
- data_sale = pool.get('sale.order').browse(cr,uid,line.order_id.id)
- for line in data_sale.order_line:
- if not line.invoiced:
- flag = False
- break
- if flag:
- wf_service = netsvc.LocalService('workflow')
- wf_service.trg_validate(uid, 'sale.order', line.order_id.id, 'all_lines', cr)
- pool.get('sale.order').write(cr,uid,[line.order_id.id],{'state' : 'progress'})
-
- for result in invoices.values():
- order = result[0][0].order_id
- il = map(lambda x: x[1], result)
- res = make_invoice(order, il)
- cr.execute('INSERT INTO sale_order_invoice_rel \
- (order_id,invoice_id) values (%s,%s)', (order.id, res))
- return {}
-
-
-class line_make_invoice(wizard.interface):
- states = {
- 'init' : {
- 'actions': [],
- 'result': {
- 'type': 'form',
- 'arch': invoice_form,
- 'fields': invoice_fields,
- 'state': [
- ('end', 'Cancel'),
- ('invoice', 'Create invoices')
- ]
- }
- },
- 'invoice' : {
- 'actions' : [_makeInvoices],
- 'result' : {'type': 'state', 'state': 'end'}
- },
- }
-
-line_make_invoice("sale.order.line.make_invoice")
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/stock/__init__.py b/addons/stock/__init__.py
index a2df9bdd809..9cc33351689 100644
--- a/addons/stock/__init__.py
+++ b/addons/stock/__init__.py
@@ -24,8 +24,6 @@ import partner
import product
import report
import wizard
-import stock_wizard
-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/__terp__.py b/addons/stock/__terp__.py
index 7a03b225dc2..5fa272238d5 100644
--- a/addons/stock/__terp__.py
+++ b/addons/stock/__terp__.py
@@ -41,11 +41,21 @@ Thanks to the double entry management, the inventory controlling is powerful and
"init_xml" : [],
"demo_xml" : ["stock_demo.xml"],
"update_xml" : [
- "stock_workflow.xml",
"stock_data.xml",
+ "wizard/stock_move_view.xml",
+ "wizard/stock_partial_picking_view.xml",
+ "wizard/stock_partial_move_view.xml",
+ "wizard/stock_inventory_set_stock_zero_view.xml",
+ "wizard/stock_fill_inventory_view.xml",
+ "wizard/stock_invoice_onshipping_view.xml",
+ "wizard/stock_location_product_view.xml",
+ "wizard/stock_inventory_line_split_view.xml",
+ "wizard/stock_change_standard_price_view.xml",
+
+ "wizard/stock_traceability_view.xml",
+ "stock_workflow.xml",
"stock_incoterms.xml",
- "stock_wizard.xml",
- "stock_wizard_view.xml",
+ "stock_wizard.xml",
"stock_view.xml",
"stock_report.xml",
"stock_sequence.xml",
diff --git a/addons/stock/product.py b/addons/stock/product.py
index 3e789fa7ecd..d771815a4d4 100644
--- a/addons/stock/product.py
+++ b/addons/stock/product.py
@@ -24,7 +24,127 @@ from tools.translate import _
class product_product(osv.osv):
- _inherit = "product.product"
+ _inherit = "product.product"
+
+ def do_change_standard_price(self, cr, uid, ids, datas, context={}):
+ """
+ Changes the Standard Price of Product.
+ And creates an account move accordingly.
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal
+ @param context: A standard dictionary
+
+ @return:
+
+ """
+ location_obj = self.pool.get('stock.location')
+ move_obj = self.pool.get('account.move')
+ move_line_obj = self.pool.get('account.move.line')
+
+ new_price = datas.get('new_price', 0.0)
+ stock_output_acc = datas.get('stock_output_account', False)
+ stock_input_acc = datas.get('stock_input_account', False)
+ journal_id = datas.get('stock_journal', False)
+
+ move_ids = []
+ for rec_id in ids:
+ loc_ids = location_obj.search(cr, uid, [('account_id','<>',False),('usage','=','internal')])
+ for location in location_obj.browse(cr, uid, loc_ids):
+ c = context.copy()
+ c.update({
+ 'location': location.id,
+ 'compute_child': False
+ })
+
+ product = self.browse(cr, uid, rec_id, context=c)
+ qty = product.qty_available
+ diff = product.standard_price - new_price
+ assert diff, _("Could not find any difference between standard price and new price!")
+ if qty:
+ location_account = location.account_id and location.account_id.id or False
+ company_id = location.company_id and location.company_id.id or False
+ assert location_account, _('Inventory Account is not specified for Location: %s' % (location.name))
+ assert company_id, _('Company is not specified in Location')
+ #
+ # Accounting Entries
+ #
+ if not journal_id:
+ journal_id = product.categ_id.property_stock_journal and product.categ_id.property_stock_journal.id or False
+ if not journal_id:
+ raise osv.except_osv(_('Error!'),
+ _('There is no journal defined '\
+ 'on the product category: "%s" (id: %d)') % \
+ (product.categ_id.name,
+ product.categ_id.id,))
+ move_id = move_obj.create(cr, uid, {
+ 'journal_id': journal_id,
+ 'company_id': company_id
+ })
+
+ move_ids.append(move_id)
+
+
+ if diff > 0:
+ if not stock_input_acc:
+ stock_input_acc = product.product_tmpl_id.\
+ property_stock_account_input.id
+ if not stock_input_acc:
+ stock_input_acc = product.categ_id.\
+ property_stock_account_input_categ.id
+ if not stock_input_acc:
+ raise osv.except_osv(_('Error!'),
+ _('There is no stock input account defined ' \
+ 'for this product: "%s" (id: %d)') % \
+ (product.name,
+ product.id,))
+ amount_diff = qty * diff
+ move_line_obj.create(cr, uid, {
+ 'name': product.name,
+ 'account_id': stock_input_acc,
+ 'debit': amount_diff,
+ 'move_id': move_id,
+ })
+ move_line_obj.create(cr, uid, {
+ 'name': location.name,
+ 'account_id': location_account,
+ 'credit': amount_diff,
+ 'move_id': move_id
+ })
+ elif diff < 0:
+ if not stock_output_acc:
+ stock_output_acc = product.product_tmpl_id.\
+ property_stock_account_output.id
+ if not stock_output_acc:
+ stock_output_acc = product.categ_id.\
+ property_stock_account_output_categ.id
+ if not stock_output_acc:
+ raise osv.except_osv(_('Error!'),
+ _('There is no stock output account defined ' \
+ 'for this product: "%s" (id: %d)') % \
+ (product.name,
+ product.id,))
+ amount_diff = qty * -diff
+ move_line_obj.create(cr, uid, {
+ 'name': product.name,
+ 'account_id': stock_output_acc,
+ 'credit': amount_diff,
+ 'move_id': move_id
+ })
+ move_line_obj.create(cr, uid, {
+ 'name': location.name,
+ 'account_id': location_account,
+ 'debit': amount_diff,
+ 'move_id': move_id
+ })
+
+ self.write(cr, uid, rec_id, {'standard_price': new_price})
+
+ return move_ids
+
def view_header_get(self, cr, user, view_id, view_type, context):
res = super(product_product, self).view_header_get(cr, user, view_id, view_type, context)
if res: return res
diff --git a/addons/stock/product_view.xml b/addons/stock/product_view.xml
index 9f9dd4b6ec2..d027465c34d 100644
--- a/addons/stock/product_view.xml
+++ b/addons/stock/product_view.xml
@@ -54,6 +54,20 @@
+
+ product.product.standard.price.form.inherit
+ product.product
+ form
+
+
+
+
+
+
+
+
+
+ product.normal.stock.acc.property.form.inherit
diff --git a/addons/stock/report/report_stock_view.xml b/addons/stock/report/report_stock_view.xml
index 21f7d91a806..21b8a0a2f4e 100644
--- a/addons/stock/report/report_stock_view.xml
+++ b/addons/stock/report/report_stock_view.xml
@@ -12,10 +12,12 @@
+
+
@@ -152,7 +154,7 @@
- Latest Inventory Date by Product
+ Latest Inventories Dates by Productreport.stock.lines.dateformtree,form
diff --git a/addons/stock/security/ir.model.access.csv b/addons/stock/security/ir.model.access.csv
index d00a55b0b9f..8e7db1c068b 100644
--- a/addons/stock/security/ir.model.access.csv
+++ b/addons/stock/security/ir.model.access.csv
@@ -22,5 +22,16 @@
"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_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
+"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_stock_inventory_set_stock_zero","stock.inventory.set.stock.zero","model_stock_inventory_set_stock_zero","stock.group_stock_user",1,0,0,0
+"access_stock_fill_inventory","stock.fill.inventory","model_stock_fill_inventory","stock.group_stock_user",1,0,0,0
+"access_stock_inventory_line_split","stock.inventory.line.split","model_stock_inventory_line_split","stock.group_stock_user",1,0,0,0
+"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
diff --git a/addons/stock/security/stock_security.xml b/addons/stock/security/stock_security.xml
index 2d91d958957..e1e412690fc 100644
--- a/addons/stock/security/stock_security.xml
+++ b/addons/stock/security/stock_security.xml
@@ -25,14 +25,14 @@
-
- ['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)]
- child_of
- user.company_id.id
+
+ ['|',('company_id','=',False),,('company_id','=',False)]
+ child_of
+ user.company_id.id
-
+ Warehouse multi-company
@@ -41,7 +41,7 @@
- ['|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]
+ ['|',('company_id','=',False),,('company_id','child_of',[user.company_id.id])]
@@ -52,7 +52,7 @@
- ['|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]
+ ['|',('company_id','=',False),,('company_id','child_of',[user.company_id.id])]
@@ -61,10 +61,10 @@
-
- ['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)]
- child_of
- user.company_id.id
+
+ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
+ child_of
+ user.company_id.id
@@ -76,7 +76,7 @@
- ['|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]
+ ['|',('company_id','=',False),,('company_id','child_of',[user.company_id.id])]
@@ -87,7 +87,7 @@
- ['|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]
+ [('company_id','=',False),('company_id','child_of',[user.company_id.id])]
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index e5696dde1e7..68450edd6d0 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -492,6 +492,7 @@ class stock_picking(osv.osv):
'max_date': fields.function(get_min_max_date, fnct_inv=_set_maximum_date, multi="min_max_date",
method=True, store=True, type='datetime', string='Max. Expected Date', select=2),
'move_lines': fields.one2many('stock.move', 'picking_id', 'Entry lines', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}),
+ 'delivery_line':fields.one2many('stock.delivery', 'picking_id', 'Delivery lines', readonly=True),
'auto_picking': fields.boolean('Auto-Picking'),
'address_id': fields.many2one('res.partner.address', 'Partner', help="Address of partner"),
'invoice_state': fields.selection([
@@ -552,6 +553,8 @@ class stock_picking(osv.osv):
def action_assign(self, cr, uid, ids, *args):
for pick in self.browse(cr, uid, ids):
move_ids = [x.id for x in pick.move_lines if x.state == 'confirmed']
+ if not move_ids:
+ raise osv.except_osv(_('Warning !'),_('Not Available. Moves are not confirmed.'))
self.pool.get('stock.move').action_assign(cr, uid, move_ids)
return True
@@ -862,6 +865,150 @@ class stock_picking(osv.osv):
continue
return super(stock_picking, self).unlink(cr, uid, ids, context=context)
+ def do_partial(self, cr, uid, ids, partial_datas, context={}):
+ """
+ @ partial_datas : dict. contain details of partial picking
+ like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom
+ """
+ res = {}
+ move_obj = self.pool.get('stock.move')
+ delivery_obj = self.pool.get('stock.delivery')
+ product_obj = self.pool.get('product.product')
+ currency_obj = self.pool.get('res.currency')
+ users_obj = self.pool.get('res.users')
+ uom_obj = self.pool.get('product.uom')
+ price_type_obj = self.pool.get('product.price.type')
+ sequence_obj = self.pool.get('ir.sequence')
+ wf_service = netsvc.LocalService("workflow")
+ partner_id = partial_datas.get('partner_id', False)
+ address_id = partial_datas.get('address_id', False)
+ delivery_date = partial_datas.get('delivery_date', False)
+ for pick in self.browse(cr, uid, ids, context=context):
+ new_picking = None
+ new_moves = []
+
+ complete, too_many, too_few = [], [], []
+ move_product_qty = {}
+ for move in pick.move_lines:
+ if move.state in ('done', 'cancel'):
+ continue
+ partial_data = partial_datas.get('move%s'%(move.id), False)
+ assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id))
+ product_qty = partial_data.get('product_qty',0.0)
+ move_product_qty[move.id] = product_qty
+ product_uom = partial_data.get('product_uom',False)
+ product_price = partial_data.get('product_price',0.0)
+ product_currency = partial_data.get('product_currency',False)
+ if move.product_qty == product_qty:
+ complete.append(move)
+ elif move.product_qty > product_qty:
+ too_few.append(move)
+ else:
+ too_many.append(move)
+
+ # Average price computation
+ if (pick.type == 'in') and (move.product_id.cost_method == 'average'):
+ product = product_obj.browse(cr, uid, move.product_id.id)
+ user = users_obj.browse(cr, uid, uid)
+ context['currency_id'] = move.company_id.currency_id.id
+ qty = uom_obj._compute_qty(cr, uid, product_uom, product_qty, product.uom_id.id)
+ pricetype = False
+ if user.company_id.property_valuation_price_type:
+ pricetype = price_type_obj.browse(cr, uid, user.company_id.property_valuation_price_type.id)
+ if pricetype and qty > 0:
+ new_price = currency_obj.compute(cr, uid, product_currency,
+ user.company_id.currency_id.id, product_price)
+ new_price = uom_obj._compute_price(cr, uid, product_uom, new_price,
+ product.uom_id.id)
+ if product.qty_available <= 0:
+ new_std_price = new_price
+ else:
+ # Get the standard price
+ amount_unit = product.price_get(pricetype.field, context)[product.id]
+ new_std_price = ((amount_unit * product.qty_available)\
+ + (new_price * qty))/(product.qty_available + qty)
+
+ # Write the field according to price type field
+ product_obj.write(cr, uid, [product.id],
+ {pricetype.field: new_std_price})
+ move_obj.write(cr, uid, [move.id], {'price_unit': new_price})
+
+
+ for move in too_few:
+ product_qty = move_product_qty[move.id]
+ if not new_picking:
+
+ new_picking = self.copy(cr, uid, pick.id,
+ {
+ 'name': sequence_obj.get(cr, uid, 'stock.picking.%s'%(pick.type)),
+ 'move_lines' : [],
+ 'state':'draft',
+ })
+ if product_qty != 0:
+
+ new_obj = move_obj.copy(cr, uid, move.id,
+ {
+ 'product_qty' : product_qty,
+ 'product_uos_qty': product_qty, #TODO: put correct uos_qty
+ 'picking_id' : new_picking,
+ 'state': 'assigned',
+ 'move_dest_id': False,
+ 'price_unit': move.price_unit,
+ })
+
+ move_obj.write(cr, uid, [move.id],
+ {
+ 'product_qty' : move.product_qty - product_qty,
+ 'product_uos_qty':move.product_qty - product_qty, #TODO: put correct uos_qty
+
+ })
+
+ if new_picking:
+ move_obj.write(cr, uid, [c.id for c in complete], {'picking_id': new_picking})
+ for move in too_many:
+ product_qty = move_product_qty[move.id]
+ move_obj.write(cr, uid, [move.id],
+ {
+ 'product_qty' : product_qty,
+ 'product_uos_qty': product_qty, #TODO: put correct uos_qty
+ 'picking_id': new_picking,
+ })
+ else:
+ for move in too_many:
+ product_qty = move_product_qty[move.id]
+ move_obj.write(cr, uid, [move.id],
+ {
+ 'product_qty': product_qty,
+ 'product_uos_qty': product_qty #TODO: put correct uos_qty
+ })
+
+ # At first we confirm the new picking (if necessary)
+ if new_picking:
+ wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr)
+ # Then we finish the good picking
+ if new_picking:
+ self.write(cr, uid, [pick.id], {'backorder_id': new_picking})
+ self.action_move(cr, uid, [new_picking])
+ wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_done', cr)
+ wf_service.trg_write(uid, 'stock.picking', pick.id, cr)
+ delivered_pack_id = new_picking
+ else:
+ self.action_move(cr, uid, [pick.id])
+ wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_done', cr)
+ delivered_pack_id = pick.id
+
+ delivered_pack = self.browse(cr, uid, delivered_pack_id, context=context)
+ delivery_id = delivery_obj.create(cr, uid, {
+ 'name': delivered_pack.name,
+ 'partner_id': partner_id,
+ 'address_id': address_id,
+ 'date': delivery_date,
+ 'picking_id' : pick.id,
+ 'move_delivered' : [(6,0, map(lambda x:x.id, delivered_pack.move_lines))]
+ }, context=context)
+ res[pick.id] = {'delivered_picking': delivered_pack.id or False}
+ return res
+
stock_picking()
@@ -959,7 +1106,23 @@ class stock_production_lot_revision(osv.osv):
}
stock_production_lot_revision()
-
+
+class stock_delivery(osv.osv):
+
+ """ Tracability of partialdeliveries """
+
+ _name = "stock.delivery"
+ _description = "Delivery"
+ _columns = {
+ 'name': fields.char('Name', size=60, required=True),
+ 'date': fields.datetime('Date', required=True),
+ 'partner_id': fields.many2one('res.partner', 'Partner', required=True),
+ 'address_id': fields.many2one('res.partner.address', 'Address', required=True),
+ 'move_delivered':fields.one2many('stock.move', 'delivered_id', 'Move Delivered'),
+ 'picking_id': fields.many2one('stock.picking', 'Picking list'),
+
+ }
+stock_delivery()
# ----------------------------------------------------
# Move
# ----------------------------------------------------
@@ -1043,6 +1206,7 @@ class stock_move(osv.osv):
'backorder_id': fields.related('picking_id','backorder_id',type='many2one', relation="stock.picking", string="Back Orders"),
'origin': fields.related('picking_id','origin',type='char', size=64, relation="stock.picking", string="Origin"),
'move_stock_return_history': fields.many2many('stock.move', 'stock_move_return_history', 'move_id', 'return_move_id', 'Move Return History',readonly=True),
+ 'delivered_id': fields.many2one('stock.delivery', 'Product delivered'),
'scraped': fields.boolean('Scraped'),
}
_constraints = [
@@ -1156,13 +1320,13 @@ class stock_move(osv.osv):
product = self.pool.get('product.product').browse(cr, uid, [prod_id], context=ctx)[0]
uos_id = product.uos_id and product.uos_id.id or False
result = {
- 'name': product.partner_ref,
'product_uom': product.uom_id.id,
'product_uos': uos_id,
'product_qty': 1.00,
'product_uos_qty' : self.pool.get('stock.move').onchange_quantity(cr, uid, ids, prod_id, 1.00, product.uom_id.id, uos_id)['value']['product_uos_qty']
}
-
+ if not ids:
+ result['name'] = product.partner_ref
if loc_id:
result['location_id'] = loc_id
if loc_dest_id:
@@ -1285,7 +1449,7 @@ class stock_move(osv.osv):
if done:
count += len(done)
self.write(cr, uid, done, {'state': 'assigned'})
-
+
if count:
for pick_id in pickings:
wf_service = netsvc.LocalService("workflow")
@@ -1318,8 +1482,8 @@ class stock_move(osv.osv):
for id in ids:
wf_service.trg_trigger(uid, 'stock.move', id, cr)
#self.action_cancel(cr,uid, ids2, context)
- return True
-
+ return True
+
def action_done(self, cr, uid, ids, context=None):
track_flag = False
picking_ids = []
@@ -1451,7 +1615,7 @@ class stock_move(osv.osv):
ir_sequence_obj = self.pool.get('ir.sequence')
sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
if not sequence:
- raise wizard.except_wizard(_('Error!'), _('No production sequence defined'))
+ raise osv.except_osv(_('Error!'), _('No production sequence defined'))
prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix': prefix}, {'product_id': product_id})
prodlot = prodlot_obj.browse(cr, uid, prodlot_id)
ref = ','.join(map(lambda x:str(x),ids))
@@ -1460,6 +1624,7 @@ class stock_move(osv.osv):
prodlot_obj.write(cr, uid, [prodlot_id], {'ref': ref})
return prodlot_id
+
def action_scrap(self, cr, uid, ids, quantity, location_id, context=None):
'''
Move the scrap/damaged product into scrap location
@@ -1489,7 +1654,7 @@ class stock_move(osv.osv):
new_move = self.copy(cr, uid, move.id, default_val)
#self.write(cr, uid, [new_move], {'move_history_ids':[(4,move.id)]}) #TODO : to track scrap moves
res += [new_move]
- self.action_done(cr, uid, res)
+ self.action_done(cr, uid, res)
return res
def action_split(self, cr, uid, ids, quantity, split_by_qty=1, prefix=False, with_lot=True, context=None):
@@ -1624,7 +1789,134 @@ class stock_move(osv.osv):
self.write(cr, uid, [move.id], update_val)
self.action_done(cr, uid, res)
- return res
+ return res
+
+ def do_partial(self, cr, uid, ids, partial_datas, context={}):
+ """
+ @ partial_datas : dict. contain details of partial picking
+ like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom
+ """
+ res = {}
+ picking_obj = self.pool.get('stock.picking')
+ delivery_obj = self.pool.get('stock.delivery')
+ product_obj = self.pool.get('product.product')
+ currency_obj = self.pool.get('res.currency')
+ users_obj = self.pool.get('res.users')
+ uom_obj = self.pool.get('product.uom')
+ price_type_obj = self.pool.get('product.price.type')
+ sequence_obj = self.pool.get('ir.sequence')
+ wf_service = netsvc.LocalService("workflow")
+ partner_id = partial_datas.get('partner_id', False)
+ address_id = partial_datas.get('address_id', False)
+ delivery_date = partial_datas.get('delivery_date', False)
+
+ new_moves = []
+
+ complete, too_many, too_few = [], [], []
+ move_product_qty = {}
+ for move in self.browse(cr, uid, ids, context=context):
+ if move.state in ('done', 'cancel'):
+ continue
+ partial_data = partial_datas.get('move%s'%(move.id), False)
+ assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id))
+ product_qty = partial_data.get('product_qty',0.0)
+ move_product_qty[move.id] = product_qty
+ product_uom = partial_data.get('product_uom',False)
+ product_price = partial_data.get('product_price',0.0)
+ product_currency = partial_data.get('product_currency',False)
+ if move.product_qty == product_qty:
+ complete.append(move)
+ elif move.product_qty > product_qty:
+ too_few.append(move)
+ else:
+ too_many.append(move)
+
+ # Average price computation
+ if (move.picking_id.type == 'in') and (move.product_id.cost_method == 'average'):
+ product = product_obj.browse(cr, uid, move.product_id.id)
+ user = users_obj.browse(cr, uid, uid)
+ context['currency_id'] = move.company_id.currency_id.id
+ qty = uom_obj._compute_qty(cr, uid, product_uom, product_qty, product.uom_id.id)
+ pricetype = False
+ if user.company_id.property_valuation_price_type:
+ pricetype = price_type_obj.browse(cr, uid, user.company_id.property_valuation_price_type.id)
+ if pricetype and qty > 0:
+ new_price = currency_obj.compute(cr, uid, product_currency,
+ user.company_id.currency_id.id, product_price)
+ new_price = uom_obj._compute_price(cr, uid, product_uom, new_price,
+ product.uom_id.id)
+ if product.qty_available <= 0:
+ new_std_price = new_price
+ else:
+ # Get the standard price
+ amount_unit = product.price_get(pricetype.field, context)[product.id]
+ new_std_price = ((amount_unit * product.qty_available)\
+ + (new_price * qty))/(product.qty_available + qty)
+
+ # Write the field according to price type field
+ product_obj.write(cr, uid, [product.id],
+ {pricetype.field: new_std_price})
+ self.write(cr, uid, [move.id], {'price_unit': new_price})
+
+ for move in too_few:
+ product_qty = move_product_qty[move.id]
+ if product_qty != 0:
+ new_move = self.copy(cr, uid, move.id,
+ {
+ 'product_qty' : product_qty,
+ 'product_uos_qty': product_qty,
+ 'picking_id' : move.picking_id.id,
+ 'state': 'assigned',
+ 'move_dest_id': False,
+ 'price_unit': move.price_unit,
+ })
+ complete.append(self.browse(cr, uid, new_move))
+ self.write(cr, uid, move.id,
+ {
+ 'product_qty' : move.product_qty - product_qty,
+ 'product_uos_qty':move.product_qty - product_qty,
+ })
+
+
+ for move in too_many:
+ self.write(cr, uid, move.id,
+ {
+ 'product_qty': product_qty,
+ 'product_uos_qty': product_qty
+ })
+ complete.append(move)
+
+ for move in complete:
+ self.action_done(cr, uid, [move.id])
+
+ # TOCHECK : Done picking if all moves are done
+ cr.execute("""
+ SELECT move.id FROM stock_picking pick
+ RIGHT JOIN stock_move move ON move.picking_id = pick.id AND move.state = %s
+ WHERE pick.id = %s""",
+ ('done', move.picking_id.id))
+ res = cr.fetchall()
+ if len(res) == len(move.picking_id.move_lines):
+ picking_obj.action_move(cr, uid, [move.picking_id.id])
+ wf_service.trg_validate(uid, 'stock.picking', move.picking_id.id, 'button_done', cr)
+
+ ref = {}
+ done_move_ids = []
+ for move in complete:
+ done_move_ids.append(move.id)
+ if move.picking_id.id not in ref:
+ delivery_id = delivery_obj.create(cr, uid, {
+ 'partner_id': partner_id,
+ 'address_id': address_id,
+ 'date': delivery_date,
+ 'name' : move.picking_id.name,
+ 'picking_id': move.picking_id.id
+ }, context=context)
+ ref[move.picking_id.id] = delivery_id
+ delivery_obj.write(cr, uid, ref[move.picking_id.id], {
+ 'move_delivered' : [(4,move.id)]
+ })
+ return done_move_ids
stock_move()
@@ -1646,10 +1938,12 @@ class stock_inventory(osv.osv):
'state': lambda *a: 'draft',
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c)
}
+
+
+ def _inventory_line_hook(self, cr, uid, inventory_line, move_vals):
+ '''Creates a stock move from an inventory line'''
+ return self.pool.get('stock.move').create(cr, uid, move_vals)
- #
- # Update to support tracking
- #
def action_done(self, cr, uid, ids, context=None):
for inv in self.browse(cr, uid, ids):
move_ids = []
@@ -1689,7 +1983,7 @@ class stock_inventory(osv.osv):
'prodlot_id': lot_id,
'product_qty': line.product_qty
})
- move_ids.append(self.pool.get('stock.move').create(cr, uid, value))
+ move_ids.append(self._inventory_line_hook(cr, uid, line, value))
if len(move_ids):
self.pool.get('stock.move').action_done(cr, uid, move_ids,
context=context)
@@ -1721,8 +2015,10 @@ class stock_inventory_line(osv.osv):
'product_uom': fields.many2one('product.uom', 'Product UOM', required=True),
'product_qty': fields.float('Quantity'),
'company_id': fields.related('inventory_id','company_id',type='many2one',relation='res.company',string='Company',store=True),
- 'prod_lot_id': fields.many2one('stock.production.lot', 'Production Lot', domain="[('product_id','=',product_id)]")
+ 'prod_lot_id': fields.many2one('stock.production.lot', 'Production Lot', domain="[('product_id','=',product_id)]"),
+ 'state': fields.related('inventory_id','state',type='char',string='State',readonly=True),
}
+
def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False):
if not product:
return {}
@@ -1754,7 +2050,7 @@ class stock_warehouse(osv.osv):
_defaults = {
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c),
}
-stock_warehouse()
+stock_warehouse()
# Move wizard :
diff --git a/addons/stock/stock_report.xml b/addons/stock/stock_report.xml
index d72106eead6..7b8d9eb13b3 100644
--- a/addons/stock/stock_report.xml
+++ b/addons/stock/stock_report.xml
@@ -1,19 +1,11 @@
-
-
-
-
-
-
-
-
diff --git a/addons/stock/stock_sequence.xml b/addons/stock/stock_sequence.xml
index d002b62ae83..9c5083d13b4 100644
--- a/addons/stock/stock_sequence.xml
+++ b/addons/stock/stock_sequence.xml
@@ -2,18 +2,59 @@
-
- Picking
- stock.picking
+
+ Picking IN
+ stock.picking.in
+
+
+
+ Picking OUT
+ stock.picking.out
+
+
+
+ Picking INT
+ stock.picking.internal
-
- Picking
- stock.picking
- PACK
+
+ Picking Delivery
+ stock.picking.delivery
+
+
+
+
+
+ Picking IN
+ stock.picking.in
+ IN/
+ 5
+
+
+
+ Picking OUT
+ stock.picking.out
+ OUT/
+ 5
+
+
+
+ Picking INT
+ stock.picking.internal
+ INT/
+ 5
+
+
+
+ Picking DLV
+ stock.picking.delivery
+ DLV/
+ 5
-
+ string="Downstream traceability"/-->
-
+ string="Upstream traceability"/-->
-
+ string="Downstream traceability"/-->
-
+
stock.location.form
@@ -413,6 +426,7 @@
+
stock.location.treestock.location
@@ -524,7 +538,7 @@
new{'action_id': active_id}
-
+ stock.picking.calendar
@@ -551,7 +565,7 @@
-
+
@@ -571,6 +585,18 @@
+
+
@@ -585,55 +611,55 @@
-
+
-
+ name="%(stock.track_line)d"
+ string="Split in production lots"
+ type="action" icon="gtk-justify-fill"
+ states="draft,waiting,confirmed,assigned" />
+
+
@@ -646,7 +672,7 @@
-
+
@@ -661,12 +687,11 @@
-
+
-
stock.picking.list.selectstock.picking
@@ -683,7 +708,8 @@
-
+
+
@@ -706,7 +732,7 @@
-
+
@@ -726,6 +752,18 @@
+
+
@@ -740,50 +778,49 @@
-
+
-
+ name="%(stock.track_line)d"
+ string="Split in production lots"
+ type="action" icon="gtk-justify-fill"
+ states="draft,waiting,confirmed,assigned" />
+
@@ -796,7 +833,7 @@
-
+
@@ -811,7 +848,7 @@
-
+
@@ -831,7 +868,8 @@
-
+
+
@@ -888,11 +926,8 @@
-
+
-
@@ -911,6 +946,18 @@
+
+
@@ -925,53 +972,53 @@
-
+
-
+ name="%(stock.track_line)d"
+ string="Split in production lots"
+ type="action" icon="gtk-justify-fill"
+ states="draft,waiting,confirmed,assigned" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -983,10 +1030,13 @@
-
+
+
+
+
@@ -1003,25 +1053,26 @@
-
+ stock.picking.out.searchstock.pickingsearch
-
+
-
-
+
+
+
-
-
+
+
@@ -1053,7 +1104,7 @@
calendar
-
+
stock.picking.in.tree
@@ -1069,7 +1120,7 @@
-
+
@@ -1090,6 +1141,18 @@
+
+
@@ -1102,50 +1165,49 @@
-
-
+ name="%(stock.track_line)d"
+ string="Split in production lots"
+ type="action" icon="gtk-justify-fill"
+ states="draft,waiting,confirmed,assigned" />
+
+
@@ -1297,6 +1364,7 @@
+
@@ -1317,17 +1385,17 @@
-
+
-
+
-
+
@@ -1359,7 +1427,8 @@
-
+
+
@@ -1398,11 +1467,11 @@
- ====================================
+ ====================================
Reception Picking (By Stock Move)
====================================
-
+ stock.move.tree2stock.movetree
@@ -1410,7 +1479,7 @@
-
+
@@ -1419,89 +1488,91 @@
-
+
-
+ stock.move.form2stock.moveform
-
+ stock.move.search2stock.movesearch
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
-
+ Incoming Productsstock.moveir.actions.act_window
@@ -1513,17 +1584,17 @@
-
- tree
-
-
-
+
+ tree
+
+
+
-
- form
-
-
-
+
+ form
+
+
+
@@ -1606,82 +1677,132 @@
tree_but_openstock.locationOpen Products
-
+
-
-
-
- Products To Received
- report.products.to.received.planned
- tree
-
-
-
-
-
-
-
-
+
+
+
+ Products To Received
+ report.products.to.received.planned
+ tree
+
+
+
+
+
+
+
+
-
- Products To Received
- report.products.to.received.planned
- graph
-
-
-
-
-
-
-
-
+
+ Products To Received
+ report.products.to.received.planned
+ graph
+
+
+
+
+
+
+
+
-
- Number of Products to receive Vs planned
- report.products.to.received.planned
- ir.actions.act_window
- form
- graph,tree
-
-
+
+ Number of Products to receive Vs planned
+ report.products.to.received.planned
+ ir.actions.act_window
+ form
+ graph,tree
+
+
-
-
- Delivery Products
- report.delivery.products.planned
- tree
-
-
-
-
-
-
-
-
+
+
+ Delivery Products
+ report.delivery.products.planned
+ tree
+
+
+
+
+
+
+
+
-
- Delivery Products
- report.delivery.products.planned
- graph
-
-
-
-
-
-
-
-
-
-
- Delivery Products Vs Planned
- report.delivery.products.planned
- ir.actions.act_window
- form
- graph,tree
-
-
+
+ Delivery Products
+ report.delivery.products.planned
+ graph
+
+
+
+
+
+
+
+
+
+ Delivery Products Vs Planned
+ report.delivery.products.planned
+ ir.actions.act_window
+ form
+ graph,tree
+
+
+
+
+ stock.delivery.from
+ stock.delivery
+ form
+
+
+
+
+
+ stock.delivery.tree
+ stock.delivery
+ tree
+
+
+
+
+
+
+
+
+
+
+
+ Delivered Products
+ stock.delivery
+ ir.actions.act_window
+ form
+ form,tree
+
+
+
+
diff --git a/addons/stock/stock_wizard.xml b/addons/stock/stock_wizard.xml
index 5db1269d42c..f9a2dfc93b0 100644
--- a/addons/stock/stock_wizard.xml
+++ b/addons/stock/stock_wizard.xml
@@ -13,20 +13,23 @@
multi="True"
name="stock.move.split"
string="Split move line"/>
+
-
+
-
+
-
-
-
-
-
-
-
-
-
+ id="wizard_merge_inventory"/-->
-
-
-
-
-
+
diff --git a/addons/stock/wizard/__init__.py b/addons/stock/wizard/__init__.py
index 6a15449a151..6f5a83a07b3 100644
--- a/addons/stock/wizard/__init__.py
+++ b/addons/stock/wizard/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,24 +15,26 @@
# 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 .
+# along with this program. If not, see .
#
##############################################################################
import stock_traceability
-import wizard_partial_picking
-import wizard_partial_move
+import stock_move
+import stock_partial_picking
+import stock_partial_move
import wizard_picking_make
import wizard_replacement
import wizard_return
import wizard_split_lot_line
import wizard_ups
-import wizard_invoice_onshipping
-import wizard_location_product
-import wizard_inventory
-import wizard_split_inventory_lots
-import inventory_merge_zero
import inventory_merge
+import stock_inventory_set_stock_zero
+import stock_fill_inventory
+import stock_inventory_line_split
+import stock_invoice_onshipping
+import stock_location_product
+import stock_change_standard_price
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/inventory_merge.py b/addons/stock/wizard/inventory_merge.py
deleted file mode 100644
index 7be8eb2b3e3..00000000000
--- a/addons/stock/wizard/inventory_merge.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-
-import wizard
-import pooler
-from tools.translate import _
-
-
-_form = """
-
-"""
-
-
-def do_merge(self, cr, uid, data, context):
-
- invent_obj = pooler.get_pool(cr.dbname).get('stock.inventory')
- invent_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line')
-
- invent_lines = {}
-
- if len(data['ids']) < 2:
- raise wizard.except_wizard(_('Warning'),
- _('Please select at least two inventories.'))
-
-
-
- for inventory in invent_obj.browse(cr, uid, data['ids'], context=context):
- if inventory.state == "done":
- raise wizard.except_wizard(_('Warning'),
- _('Merging is only allowed on draft inventories.'))
-
- for line in inventory.inventory_line_id:
- key = (line.location_id.id, line.product_id.id, line.product_uom.id)
- if key in invent_lines:
- invent_lines[key] += line.product_qty
- else:
- invent_lines[key] = line.product_qty
-
-
- new_invent = invent_obj.create(cr, uid, {
- 'name': 'Merged inventory'
- }, context=context)
-
- for key, quantity in invent_lines.items():
- invent_line_obj.create(cr, uid, {
- 'inventory_id': new_invent,
- 'location_id': key[0],
- 'product_id': key[1],
- 'product_uom': key[2],
- 'product_qty': quantity,
- })
-
- return {}
-
-
-class merge_inventory(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : _form,
- 'fields' : {},
- 'state' : [('end', 'Cancel', 'gtk-cancel'),
- ('merge', 'Yes', 'gtk-apply', True) ]}
- },
- 'merge' : {
- 'actions' : [],
- 'result' : {'type' : 'action',
- 'action': do_merge,
- 'state' : 'end'}
- },
- }
-merge_inventory("inventory.merge")
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/stock/wizard/inventory_merge_zero.py b/addons/stock/wizard/inventory_merge_zero.py
deleted file mode 100644
index 3aa2b1e9fd9..00000000000
--- a/addons/stock/wizard/inventory_merge_zero.py
+++ /dev/null
@@ -1,94 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-
-import wizard
-import pooler
-from tools.translate import _
-
-
-_form = """
-
-"""
-_inventory_fields = {
- 'location_id' : {
- 'string':'Location',
- 'type':'many2one',
- 'relation':'stock.location',
- 'required':True
- }
-}
-
-
-def do_merge(self, cr, uid, data, context):
- invent_obj = pooler.get_pool(cr.dbname).get('stock.inventory')
- invent_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line')
- prod_obj = pooler.get_pool(cr.dbname).get('product.product')
-
- if len(data['ids']) <> 1:
- raise wizard.except_wizard(_('Warning'),
- _('Please select one and only one inventory !'))
-
- loc = str(data['form']['location_id'])
-
- cr.execute('select distinct location_id,product_id from stock_inventory_line where inventory_id=%s', (data['ids'][0],))
- inv = cr.fetchall()
- cr.execute('select distinct product_id from stock_move where location_dest_id=%s or location_id=%s',(loc,loc,))
- stock = cr.fetchall()
- for s in stock:
- if (loc,s[0]) not in inv:
- p = prod_obj.browse(cr, uid, s[0])
- invent_line_obj.create(cr, uid, {
- 'inventory_id': data['ids'][0],
- 'location_id': loc,
- 'product_id': s[0],
- 'product_uom': p.uom_id.id,
- 'product_qty': 0.0,
- })
- return {}
-
-
-class merge_inventory(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : _form,
- 'fields' : _inventory_fields,
- 'state' : [('end', 'Cancel', 'gtk-cancel'),
- ('merge', 'Set to Zero', 'gtk-apply', True) ]}
- },
- 'merge' : {
- 'actions' : [],
- 'result' : {'type' : 'action',
- 'action': do_merge,
- 'state' : 'end'}
- },
- }
-merge_inventory("inventory.merge.stock.zero")
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/stock/wizard/stock_change_standard_price.py b/addons/stock/wizard/stock_change_standard_price.py
new file mode 100644
index 00000000000..8e2ec5f555e
--- /dev/null
+++ b/addons/stock/wizard/stock_change_standard_price.py
@@ -0,0 +1,115 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from tools.translate import _
+
+class change_standard_price(osv.osv_memory):
+ _name = "stock.change.standard.price"
+ _description = "Change Standard Price"
+ _columns = {
+ 'new_price': fields.float('Price', required=True),
+ 'stock_account_input':fields.many2one('account.account', 'Stock Input Account'),
+ 'stock_account_output':fields.many2one('account.account', 'Stock Output Account'),
+ 'stock_journal':fields.many2one('account.journal', 'Stock journal', required=True),
+ 'enable_stock_in_out_acc':fields.boolean('Enable Related Account',),
+ }
+
+ def default_get(self, cr, uid, fields, context):
+ """
+ To get default values for the object.
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param fields: List of fields for which we want default values
+ @param context: A standard dictionary
+
+ @return: A dictionary which of fields with values.
+
+ """
+ product_obj = self.pool.get('product.product').browse(cr, uid, context.get('active_id', False))
+ res = super(change_standard_price, self).default_get(cr, uid, fields, context=context)
+
+ stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False
+ if not stock_input_acc:
+ stock_input_acc = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id or False
+
+ stock_output_acc = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id or False
+ if not stock_output_acc:
+ stock_output_acc = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id or False
+
+ price = product_obj.standard_price
+ journal_id = product_obj.categ_id.property_stock_journal and product_obj.categ_id.property_stock_journal.id or False
+
+ if 'new_price' in fields:
+ res.update({'new_price': price})
+ if 'stock_account_input' in fields:
+ res.update({'stock_account_input': stock_input_acc})
+ if 'stock_account_output' in fields:
+ res.update({'stock_account_output': stock_output_acc})
+ if 'stock_journal' in fields:
+ res.update({'stock_journal': journal_id})
+ if 'enable_stock_in_out_acc' in fields:
+ res.update({'enable_stock_in_out_acc': True})
+
+
+ return res
+
+ def onchange_price(self, cr, uid, ids, new_price, context = {}):
+ product_obj = self.pool.get('product.product').browse(cr, uid, context.get('active_id', False))
+ price = product_obj.standard_price
+ diff = price - new_price
+ if diff > 0 :
+ return {'value' : {'enable_stock_in_out_acc':True}}
+ else :
+ return {'value' : {'enable_stock_in_out_acc':False}}
+
+ def change_price(self, cr, uid, ids, context):
+ """
+ Changes the Standard Price of Product.
+ And creates an account move accordingly.
+
+ @param self: The object pointer.
+ @param cr: A database cursor
+ @param uid: ID of the user currently logged in
+ @param ids: List of IDs selected
+ @param context: A standard dictionary
+
+ @return:
+
+ """
+ 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.do_change_standard_price(cr, uid, [rec_id], datas, context)
+ return {}
+
+change_standard_price()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/stock_change_standard_price_view.xml b/addons/stock/wizard/stock_change_standard_price_view.xml
new file mode 100644
index 00000000000..ffca108390d
--- /dev/null
+++ b/addons/stock/wizard/stock_change_standard_price_view.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ Change Standard Price
+ stock.change.standard.price
+ form
+
+
+
+
+
+
+ Change Standard Price
+ ir.actions.act_window
+ stock.change.standard.price
+ form
+ form
+
+ new
+
+
+
+
diff --git a/addons/stock/wizard/stock_fill_inventory.py b/addons/stock/wizard/stock_fill_inventory.py
new file mode 100644
index 00000000000..c96638c8d52
--- /dev/null
+++ b/addons/stock/wizard/stock_fill_inventory.py
@@ -0,0 +1,104 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+from tools.misc import UpdateableStr, UpdateableDict
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import wizard
+
+
+class stock_fill_inventory(osv.osv_memory):
+ _name = "stock.fill.inventory"
+ _description = "Fill Inventory"
+ _columns = {
+ 'location_id': fields.many2one('stock.location', 'Location', required=True),
+ 'recursive': fields.boolean("Include all childs for the location"),
+ }
+
+ def fill_inventory(self, cr, uid, ids, context):
+ """
+ To fill stock inventory according to products available in the selected locations..
+
+ @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:
+
+ """
+ inventory_line_obj = self.pool.get('stock.inventory.line')
+ location_obj = self.pool.get('stock.location')
+ product_obj = self.pool.get('product.product')
+ stock_location_obj = self.pool.get('stock.location')
+ for fill_inventory in self.browse(cr, uid, ids):
+ res = {}
+ res_location = {}
+ if fill_inventory.recursive :
+ location_ids = location_obj.search(cr, uid, [('location_id',
+ 'child_of', fill_inventory.location_id.id)])
+ for location in location_ids :
+ res = location_obj._product_get(cr, uid, location)
+ res_location[location] = res
+ else:
+ context.update({'compute_child': False})
+ 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]
+
+ 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.'))
+ return {}
+
+stock_fill_inventory()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/stock_fill_inventory_view.xml b/addons/stock/wizard/stock_fill_inventory_view.xml
new file mode 100644
index 00000000000..ef95a3bf447
--- /dev/null
+++ b/addons/stock/wizard/stock_fill_inventory_view.xml
@@ -0,0 +1,31 @@
+
+
+
+
+ Fill Inventory
+ stock.fill.inventory
+ form
+
+
+
+
+
+
+
+
+
diff --git a/addons/stock/wizard/stock_inventory_line_split.py b/addons/stock/wizard/stock_inventory_line_split.py
new file mode 100644
index 00000000000..9fe71582c7f
--- /dev/null
+++ b/addons/stock/wizard/stock_inventory_line_split.py
@@ -0,0 +1,117 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+from tools.misc import UpdateableStr, UpdateableDict
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import wizard
+
+class stock_inventory_line_split(osv.osv_memory):
+ _inherit = "stock.move.split"
+ _name = "stock.inventory.line.split"
+ _description = "Split inventory lines"
+
+
+ def default_get(self, cr, uid, fields, context):
+ """
+ To check the availability of production lot.
+
+ @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)
+ res = super(stock_inventory_line_split, self).default_get(cr, uid, fields, context=context)
+ line= self.pool.get('stock.inventory.line').browse(cr, uid, record_id)
+ if 'product_id' in fields:
+ res.update({'product_id':line.product_id.id})
+ return res
+
+ def split(self, cr, uid, ids, line_ids, context=None):
+ """
+ To split stock inventory lines according to production lot
+
+ @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 line_ids: the ID or list of IDs of inventory lines we want to split
+ @param context: A standard dictionary
+
+ @return:
+
+ """
+ prodlot_obj = self.pool.get('stock.production.lot')
+ ir_sequence_obj = self.pool.get('ir.sequence')
+ line_obj = self.pool.get('stock.inventory.line')
+ new_line = []
+ for data in self.browse(cr, uid, ids):
+ for inv_line in line_obj.browse(cr, uid, line_ids):
+ line_qty = inv_line.product_qty
+ quantity_rest = inv_line.product_qty
+ new_line = []
+ for line in data.line_ids:
+ quantity = line.quantity
+
+
+ if quantity <= 0 or line_qty == 0:
+ continue
+ quantity_rest -= quantity
+ if quantity_rest <= 0:
+ quantity_rest = quantity
+ break
+ default_val = {
+ 'product_qty': quantity,
+ }
+ current_line = line_obj.copy(cr, uid, inv_line.id, default_val)
+ new_line.append(current_line)
+ prodlot_id = False
+ if line.use_exist and line.name:
+ prodlot_id = prodlot_obj.search(cr, uid, [('prefix','=',line.name),('product_id','=',data.product_id.id)])
+ if prodlot_id:
+ prodlot_id = prodlot_id[0]
+ if not prodlot_id:
+ sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
+ prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix' : line.name},
+ {'product_id': data.product_id.id})
+ line_obj.write(cr, uid, [current_line], {'prod_lot_id': prodlot_id})
+ prodlot = prodlot_obj.browse(cr, uid, prodlot_id)
+
+ update_val = {}
+ if quantity_rest > 0:
+ update_val['product_qty'] = quantity_rest
+ line_obj.write(cr, uid, [inv_line.id], update_val)
+
+
+ return new_line
+stock_inventory_line_split()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/stock/wizard/stock_inventory_line_split_view.xml b/addons/stock/wizard/stock_inventory_line_split_view.xml
new file mode 100644
index 00000000000..42b8a4648da
--- /dev/null
+++ b/addons/stock/wizard/stock_inventory_line_split_view.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+ Split inventory lines
+ stock.inventory.line.split
+ form
+
+
+
+
+
+
+
+ Split inventory lines
+ ir.actions.act_window
+ stock.inventory.line.split
+ form
+ form
+ new
+
+
+
+
diff --git a/addons/stock/wizard/stock_inventory_merge.py b/addons/stock/wizard/stock_inventory_merge.py
new file mode 100644
index 00000000000..64620054ff8
--- /dev/null
+++ b/addons/stock/wizard/stock_inventory_merge.py
@@ -0,0 +1,83 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+from tools.misc import UpdateableStr, UpdateableDict
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import wizard
+
+class stock_inventory_merge(osv.osv_memory):
+ _name = "stock.inventory.merge"
+ _description = "Merge Inventory"
+ _columns = {
+
+ }
+
+ def do_merge(self, cr, uid, ids, context):
+
+ invent_obj = self.pool.get('stock.inventory')
+ invent_line_obj = self.pool.get('stock.inventory.line')
+
+ invent_lines = {}
+
+ if len(context['active_ids']) < 2:
+ raise osv.except_osv(_('Warning'),
+ _('Please select at least two inventories.'))
+
+
+
+ for inventory in invent_obj.browse(cr, uid, context['active_ids'], context=context):
+ print"-------active-ids----",context['active_ids']
+ if inventory.state == "done":
+ raise osv.except_osv(_('Warning'),
+ _('Merging is only allowed on draft inventories.'))
+
+ for line in inventory.inventory_line_id:
+ key = (line.location_id.id, line.product_id.id, line.product_uom.id)
+ if key in invent_lines:
+ invent_lines[key] += line.product_qty
+ else:
+ invent_lines[key] = line.product_qty
+
+
+ new_invent = invent_obj.create(cr, uid, {
+ 'name': 'Merged inventory'
+ }, context=context)
+
+ for key, quantity in invent_lines.items():
+ invent_line_obj.create(cr, uid, {
+ 'inventory_id': new_invent,
+ 'location_id': key[0],
+ 'product_id': key[1],
+ 'product_uom': key[2],
+ 'product_qty': quantity,
+ })
+
+ return {}
+
+stock_inventory_merge()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/stock/wizard/stock_inventory_set_stock_zero.py b/addons/stock/wizard/stock_inventory_set_stock_zero.py
new file mode 100644
index 00000000000..63296b69875
--- /dev/null
+++ b/addons/stock/wizard/stock_inventory_set_stock_zero.py
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+from tools.misc import UpdateableStr, UpdateableDict
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import wizard
+
+
+class inventory_set_stock_zero(osv.osv_memory):
+ _name = "stock.inventory.set.stock.zero"
+ _description = "Set Stock to 0"
+ _columns = {
+ 'location_id': fields.many2one('stock.location', 'Location', required=True),
+ }
+
+ def do_merge(self, cr, uid, ids, context):
+ """
+ To set stock to Zero
+
+ @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:
+
+ """
+ invent_obj = pooler.get_pool(cr.dbname).get('stock.inventory')
+ invent_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line')
+ prod_obj = pooler.get_pool(cr.dbname).get('product.product')
+
+ if len(context['active_ids']) <> 1:
+ raise osv.except_osv(_('Warning'),
+ _('Please select one and only one inventory !'))
+ for id in ids:
+ datas = self.read(cr, uid, id)
+ loc = str(datas['location_id'])
+
+ cr.execute('select distinct location_id,product_id \
+ from stock_inventory_line \
+ where inventory_id=%s', (context['active_id'],))
+ inv = cr.fetchall()
+ cr.execute('select distinct product_id from stock_move where \
+ location_dest_id=%s or location_id=%s', (loc, loc,))
+ stock = cr.fetchall()
+ for s in stock:
+ if (loc, s[0]) not in inv:
+ p = prod_obj.browse(cr, uid, s[0])
+ invent_line_obj.create(cr, uid, {
+ 'inventory_id': context['active_id'],
+ 'location_id': loc,
+ 'product_id': s[0],
+ 'product_uom': p.uom_id.id,
+ 'product_qty': 0.0,
+ })
+ return {}
+
+inventory_set_stock_zero()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml b/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml
new file mode 100644
index 00000000000..0ee84d2045d
--- /dev/null
+++ b/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+ Set Stock to Zero
+ stock.inventory.set.stock.zero
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/stock/wizard/stock_invoice_onshipping.py b/addons/stock/wizard/stock_invoice_onshipping.py
new file mode 100644
index 00000000000..22e48631f8b
--- /dev/null
+++ b/addons/stock/wizard/stock_invoice_onshipping.py
@@ -0,0 +1,135 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+from tools.misc import UpdateableStr, UpdateableDict
+from tools.translate import _
+import netsvc
+import pooler
+import time
+import wizard
+
+class stock_invoice_onshipping(osv.osv_memory):
+ _name = "stock.invoice.onshipping"
+ _description = "Stock Invoice Onshipping"
+ _columns = {
+ 'journal_id': fields.many2one('account.journal', 'Destination Journal', required=True),
+ 'group': fields.boolean("Group by partner"),
+ 'type': fields.selection([('out_invoice', 'Customer Invoice'),
+ ('in_invoice', 'Supplier Invoice'),
+ ('out_refund', 'Customer Refund'),
+ ('in_refund', 'Supplier Refund')] , 'Type', required=True),
+ 'invoice_date': fields.date('Invoiced date'),
+ }
+
+ def _get_type(self, cr, uid, context):
+ """
+ To get invoice 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: invoice type
+
+ """
+ picking_obj = self.pool.get('stock.picking')
+ usage = 'customer'
+ pick = picking_obj.browse(cr, uid, context['active_id'])
+ if pick.invoice_state == 'invoiced':
+ raise osv.except_osv(_('UserError'), _('Invoice is already created.'))
+ if pick.invoice_state == 'none':
+ raise osv.except_osv(_('UserError'), _('Invoice cannot be created from Picking.'))
+ if pick.move_lines:
+ usage = pick.move_lines[0].location_id.usage
+
+ if pick.type == 'out' and usage == 'supplier':
+ type = 'in_refund'
+ elif pick.type == 'out' and usage == 'customer':
+ type = 'out_invoice'
+ elif pick.type == 'in' and usage == 'supplier':
+ type = 'in_invoice'
+ elif pick.type == 'in' and usage == 'customer':
+ type = 'out_refund'
+ else:
+ type = 'out_invoice'
+ return type
+
+ _defaults = {
+ 'type': _get_type,
+ }
+
+ def create_invoice(self, cr, uid, ids, context):
+ """
+ To create invoice
+
+ @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: invoice ids
+
+ """
+ result = []
+ picking_obj = self.pool.get('stock.picking')
+ mod_obj = self.pool.get('ir.model.data')
+ act_obj = self.pool.get('ir.actions.act_window')
+
+ for onshipdata_obj in self.read(cr, uid, ids, ['journal_id', 'group', 'type', 'invoice_date']):
+ if context.get('new_picking', False):
+ onshipdata_obj[id] = onshipdata_obj.new_picking
+ onshipdata_obj[ids] = onshipdata_obj.new_picking
+
+ type = onshipdata_obj['type']
+ context['date_inv'] = onshipdata_obj['invoice_date']
+ res = picking_obj.action_invoice_create(cr, uid,context['active_ids'],
+ journal_id = onshipdata_obj['journal_id'],
+ group=onshipdata_obj['group'],
+ type=type,
+ context=context)
+ invoice_ids = res.values()
+ if not invoice_ids:
+ raise osv.except_osv(_('Error'), _('Invoice is not created'))
+
+ if type == 'out_invoice':
+ xml_id = 'action_invoice_tree1'
+ elif type == 'in_invoice':
+ xml_id = 'action_invoice_tree2'
+ elif type == 'out_refund':
+ xml_id = 'action_invoice_tree3'
+ else:
+ xml_id = 'action_invoice_tree4'
+
+ result = mod_obj._get_id(cr, uid, 'account', xml_id)
+ id = mod_obj.read(cr, uid, result, ['res_id'])
+ result = act_obj.read(cr, uid, id['res_id'])
+ result['res_id'] = invoice_ids
+ return result
+
+stock_invoice_onshipping()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/stock/wizard/stock_invoice_onshipping_view.xml b/addons/stock/wizard/stock_invoice_onshipping_view.xml
new file mode 100644
index 00000000000..62689019af0
--- /dev/null
+++ b/addons/stock/wizard/stock_invoice_onshipping_view.xml
@@ -0,0 +1,33 @@
+
+
+
+
+ Stock Invoice Onshipping
+ stock.invoice.onshipping
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/stock/wizard/stock_location_product.py b/addons/stock/wizard/stock_location_product.py
new file mode 100755
index 00000000000..d3ee334bac0
--- /dev/null
+++ b/addons/stock/wizard/stock_location_product.py
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+
+class stock_location_product(osv.osv_memory):
+ _name = "stock.location.product"
+ _description = "Products by Location"
+ _columns = {
+ 'from_date': fields.datetime('From'),
+ 'to_date': fields.datetime('To'),
+ }
+
+ def action_open_window(self, cr, uid, ids, context):
+ """
+ To open location wise product information specific to given duration
+
+ @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: invoice type
+
+ """
+ mod_obj = self.pool.get('ir.model.data')
+ for location_obj in self.read(cr, uid, ids, ['from_date', 'to_date']):
+ return {
+ 'name': False,
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'product.product',
+ 'type': 'ir.actions.act_window',
+ 'context': {'location': context['active_id'],
+ 'from_date': location_obj['from_date'],
+ 'to_date': location_obj['to_date']},
+ 'domain': [('type', '<>', 'service')],
+ }
+
+stock_location_product()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/stock_location_product_view.xml b/addons/stock/wizard/stock_location_product_view.xml
new file mode 100644
index 00000000000..518bc6eab35
--- /dev/null
+++ b/addons/stock/wizard/stock_location_product_view.xml
@@ -0,0 +1,34 @@
+
+
+
+
+ Products by Location
+ stock.location.product
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/stock/stock_wizard.py b/addons/stock/wizard/stock_move.py
similarity index 65%
rename from addons/stock/stock_wizard.py
rename to addons/stock/wizard/stock_move.py
index eb522c2e2fe..500b0bdc372 100644
--- a/addons/stock/stock_wizard.py
+++ b/addons/stock/wizard/stock_move.py
@@ -36,6 +36,18 @@ class stock_move_track(osv.osv_memory):
}
def track_lines(self, cr, uid, ids, context={}):
+ """
+ To track stock moves lines
+
+ @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:
+
+ """
datas = self.read(cr, uid, ids)[0]
move_obj = self.pool.get('stock.move')
move_obj._track_lines(cr, uid, context['active_id'], datas, context=context)
@@ -52,32 +64,46 @@ class stock_move_consume(osv.osv_memory):
'product_qty': fields.float('Quantity', required=True),
'product_uom': fields.many2one('product.uom', 'Product UOM', required=True),
'location_id': fields.many2one('stock.location', 'Location', required=True)
- }
+ }
- def _get_product_id(self, cr, uid, context):
+ def default_get(self, cr, uid, fields, context=None):
+ """
+ Get default values
+
+ @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 default value
+ @param context: A standard dictionary
+
+ @return: default values of fields
+
+ """
+ res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context)
move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
- return move.product_id.id
-
- def _get_product_qty(self, cr, uid, context):
- move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
- return move.product_qty
-
- def _get_product_uom(self, cr, uid, context):
- move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
- return move.product_uom.id
-
- def _get_location_id(self, cr, uid, context):
- move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
- return move.location_id.id
-
- _defaults = {
- 'product_id': _get_product_id,
- 'product_qty': _get_product_qty,
- 'product_uom': _get_product_uom,
- 'location_id': _get_location_id
- }
-
+ if 'product_id' in fields:
+ res.update({'product_id': move.product_id.id})
+ if 'product_uom' in fields:
+ res.update({'product_uom': move.product_uom.id})
+ if 'product_qty' in fields:
+ res.update({'product_qty': move.product_qty})
+ if 'location_id' in fields:
+ res.update({'location_id': move.location_id.id})
+ return res
+
def do_move_consume(self, cr, uid, ids, context={}):
+ """
+ To move consumed products
+
+ @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:
+
+ """
move_obj = self.pool.get('stock.move')
move_ids = context['active_ids']
for data in self.read(cr, uid, ids):
@@ -99,6 +125,18 @@ class stock_move_scrap(osv.osv_memory):
}
def move_scrap(self, cr, uid, ids, context={}):
+ """
+ To move scraped products
+
+ @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:
+
+ """
move_obj = self.pool.get('stock.move')
move_ids = context['active_ids']
for data in self.read(cr, uid, ids):
@@ -114,24 +152,60 @@ class split_in_production_lot(osv.osv_memory):
_name = "stock.move.split"
_description = "Split in Production lots"
+ def default_get(self, cr, uid, fields, context=None):
+ """
+ Get default values
+
+ @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 default value
+ @param context: A standard dictionary
+
+ @return: default values of fields
+
+ """
+
+ res = super(split_in_production_lot, self).default_get(cr, uid, fields, context=context)
+ move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
+ if 'product_id' in fields:
+ res.update({'product_id': move.product_id.id})
+ return res
+
_columns = {
'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
'line_ids': fields.one2many('stock.move.split.lines', 'lot_id', 'Lots Number')
}
-
- def _get_product_id(self, cr, uid, context):
- move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
- return move.product_id.id
-
- _defaults = {
- 'product_id': _get_product_id,
- }
-
def split_lot(self, cr, uid, ids, context=None):
+ """
+ To split a lot
+
+ @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:
+
+ """
self.split(cr, uid, ids, context.get('active_ids'), context=context)
return {}
def split(self, cr, uid, ids, move_ids, context=None):
+ """
+ To split stock moves into production lot
+
+ @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 move_ids: the ID or list of IDs of stock move we want to split
+ @param context: A standard dictionary
+
+ @return:
+
+ """
prodlot_obj = self.pool.get('stock.production.lot')
ir_sequence_obj = self.pool.get('ir.sequence')
move_obj = self.pool.get('stock.move')
@@ -182,8 +256,6 @@ class split_in_production_lot(osv.osv_memory):
update_val['product_qty'] = quantity_rest
update_val['product_uos_qty'] = uos_qty_rest
move_obj.write(cr, uid, [move.id], update_val)
-
-
return new_move
split_in_production_lot()
diff --git a/addons/stock/stock_wizard_view.xml b/addons/stock/wizard/stock_move_view.xml
similarity index 100%
rename from addons/stock/stock_wizard_view.xml
rename to addons/stock/wizard/stock_move_view.xml
diff --git a/addons/stock/wizard/stock_partial_move.py b/addons/stock/wizard/stock_partial_move.py
new file mode 100644
index 00000000000..bf8d1058aa2
--- /dev/null
+++ b/addons/stock/wizard/stock_partial_move.py
@@ -0,0 +1,217 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+from service import web_services
+from tools.translate import _
+import netsvc
+import pooler
+import time
+
+class stock_partial_move(osv.osv_memory):
+ _name = "stock.partial.move"
+ _description = "Partial Move"
+ _columns = {
+ 'date': fields.datetime('Date', required=True),
+ 'partner_id': fields.many2one('res.partner',string="Partner", required=True),
+ 'address_id': fields.many2one('res.partner.address', 'Delivery Address', help="Address where goods are to be delivered", required=True),
+
+ }
+
+ def view_init(self, cr, uid, fields_list, context=None):
+ res = super(stock_partial_move, self).view_init(cr, uid, fields_list, context=context)
+ move_obj = self.pool.get('stock.move')
+ if not context:
+ context={}
+ moveids = []
+ for m in move_obj.browse(cr, uid, context.get('active_ids', [])):
+ if m.state in ('done', 'cancel'):
+ continue
+ if 'move%s_product_id'%(m.id) not in self._columns:
+ self._columns['move%s_product_id'%(m.id)] = fields.many2one('product.product',string="Product")
+ if 'move%s_product_qty'%(m.id) not in self._columns:
+ self._columns['move%s_product_qty'%(m.id)] = fields.float("Quantity")
+ if 'move%s_product_uom'%(m.id) not in self._columns:
+ self._columns['move%s_product_uom'%(m.id)] = fields.many2one('product.uom',string="Product UOM")
+
+ if (m.picking_id.type == 'in') and (m.product_id.cost_method == 'average'):
+ if 'move%s_product_price'%(m.id) not in self._columns:
+ self._columns['move%s_product_price'%(m.id)] = fields.float("Price")
+ if 'move%s_product_currency'%(m.id) not in self._columns:
+ self._columns['move%s_product_currency'%(m.id)] = fields.many2one('res.currency',string="Currency")
+ return res
+
+ def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False):
+ result = super(stock_partial_move, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)
+ move_obj = self.pool.get('stock.move')
+ move_ids = context.get('active_ids', False)
+ move_ids = move_obj.search(cr, uid, [('id','in',move_ids)])
+ _moves_arch_lst = """
"""
+ result['arch'] = _moves_arch_lst
+ result['fields'] = _moves_fields
+ return result
+
+ 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.
+
+ """
+
+ res = super(stock_partial_move, self).default_get(cr, uid, fields, context=context)
+ move_obj = self.pool.get('stock.move')
+ if not context:
+ context={}
+ moveids = []
+ if 'date' in fields:
+ res.update({'date': time.strftime('%Y-%m-%d %H:%M:%S')})
+ for m in move_obj.browse(cr, uid, context.get('active_ids', [])):
+ if m.state in ('done', 'cancel'):
+ continue
+ if 'move%s_product_id'%(m.id) in fields:
+ res['move%s_product_id'%(m.id)] = m.product_id.id
+ if 'move%s_product_qty'%(m.id) in fields:
+ res['move%s_product_qty'%(m.id)] = m.product_qty
+ if 'move%s_product_uom'%(m.id) in fields:
+ res['move%s_product_uom'%(m.id)] = m.product_uom.id
+
+ if (m.picking_id.type == 'in') and (m.product_id.cost_method == 'average'):
+ price = 0
+ if hasattr(m, 'purchase_line_id') and m.purchase_line_id:
+ price = m.purchase_line_id.price_unit
+
+ currency = False
+ if hasattr(m.picking_id, 'purchase_id') and m.picking_id.purchase_id:
+ currency = m.picking_id.purchase_id.pricelist_id.currency_id.id
+
+ if 'move%s_product_price'%(m.id) in fields:
+ res['move%s_product_price'%(m.id)] = price
+ if 'move%s_product_currency'%(m.id) in fields:
+ res['move%s_product_currency'%(m.id)] = currency
+ return res
+
+ def do_partial(self, cr, uid, ids, context):
+ move_obj = self.pool.get('stock.move')
+ move_ids = context.get('active_ids', False)
+ partial = self.browse(cr, uid, ids[0], context)
+ partial_datas = {
+ 'partner_id' : partial.partner_id and partial.partner_id.id or False,
+ 'address_id' : partial.address_id and partial.address_id.id or False,
+ 'delivery_date' : partial.date
+ }
+ for m in move_obj.browse(cr, uid, move_ids):
+ if m.state in ('done', 'cancel'):
+ continue
+ partial_datas['move%s'%(m.id)] = {
+ 'product_id' : getattr(partial, 'move%s_product_id'%(m.id)).id,
+ 'product_qty' : getattr(partial, 'move%s_product_qty'%(m.id)),
+ 'product_uom' : getattr(partial, 'move%s_product_uom'%(m.id)).id
+ }
+
+ if (m.picking_id.type == 'in') and (m.product_id.cost_method == 'average'):
+ partial_datas['move%s'%(m.id)].update({
+ 'product_price' : getattr(partial, 'move%s_product_price'%(m.id)),
+ 'product_currency': getattr(partial, 'move%s_product_currency'%(m.id)).id
+ })
+
+ res = move_obj.do_partial(cr, uid, move_ids, partial_datas, context=context)
+ return {}
+
+stock_partial_move()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/stock/wizard/stock_partial_move_view.xml b/addons/stock/wizard/stock_partial_move_view.xml
new file mode 100644
index 00000000000..30b7f3fca0e
--- /dev/null
+++ b/addons/stock/wizard/stock_partial_move_view.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ Delivery Product
+ stock.partial.move
+ form
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
new file mode 100644
index 00000000000..eba095718cd
--- /dev/null
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -0,0 +1,235 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+from osv import fields, osv
+from service import web_services
+from tools.translate import _
+import netsvc
+import pooler
+import time
+
+class stock_partial_picking(osv.osv_memory):
+ _name = "stock.partial.picking"
+ _description = "Partial Picking"
+ _columns = {
+ 'date': fields.datetime('Date', required=True),
+ 'partner_id': fields.many2one('res.partner',string="Partner", required=True),
+ 'address_id': fields.many2one('res.partner.address', 'Delivery Address', help="Address where goods are to be delivered", required=True),
+
+ }
+
+ def view_init(self, cr, uid, fields_list, context=None):
+ res = super(stock_partial_picking, self).view_init(cr, uid, fields_list, context=context)
+ pick_obj = self.pool.get('stock.picking')
+ if not context:
+ context={}
+ moveids = []
+ for pick in pick_obj.browse(cr, uid, context.get('active_ids', [])):
+ for m in pick.move_lines:
+ if m.state in ('done', 'cancel'):
+ continue
+ if 'move%s_product_id'%(m.id) not in self._columns:
+ self._columns['move%s_product_id'%(m.id)] = fields.many2one('product.product',string="Product")
+ if 'move%s_product_qty'%(m.id) not in self._columns:
+ self._columns['move%s_product_qty'%(m.id)] = fields.float("Quantity")
+ if 'move%s_product_uom'%(m.id) not in self._columns:
+ self._columns['move%s_product_uom'%(m.id)] = fields.many2one('product.uom',string="Product UOM")
+
+ if (pick.type == 'in') and (m.product_id.cost_method == 'average'):
+ if 'move%s_product_price'%(m.id) not in self._columns:
+ self._columns['move%s_product_price'%(m.id)] = fields.float("Price")
+ if 'move%s_product_currency'%(m.id) not in self._columns:
+ self._columns['move%s_product_currency'%(m.id)] = fields.many2one('res.currency',string="Currency")
+ return res
+
+ def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False):
+ result = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)
+ pick_obj = self.pool.get('stock.picking')
+ picking_ids = context.get('active_ids', False)
+ picking_ids = pick_obj.search(cr, uid, [('id', 'in', picking_ids)])
+ _moves_arch_lst = """
+
+
+
+
+
+
+
+
+ Stock traceability lot upstream
+ stock.traceability.lot.upstream
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Stock traceability lot downstream
+ stock.traceability.lot.downstream
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/stock/wizard/wizard_inventory.py b/addons/stock/wizard/wizard_inventory.py
deleted file mode 100644
index 42345353866..00000000000
--- a/addons/stock/wizard/wizard_inventory.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-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 _
-
-inventory_form = """
-
-
-
-
-
-
-
-
-"""
-
-inventory_fields = {
- 'location_id' : {
- 'string':'Location',
- 'type':'many2one',
- 'relation':'stock.location',
- 'required':True
- },
- 'recursive' : {'string':'Include all childs for the location', 'type':'boolean'}
-}
-
-
-
-def _fill_inventory(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- inventory_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line')
- location_obj = pooler.get_pool(cr.dbname).get('stock.location')
- res={}
- res_location={}
- if data['form']['recursive'] :
- location_ids = location_obj.search(cr, uid, [('location_id', 'child_of', [data['form']['location_id']])])
- for location in location_ids :
- res=location_obj._product_get(cr, uid, location)
- res_location[location]=res
- else:
- context.update({'compute_child':False})
- res=location_obj._product_get(cr, uid, data['form']['location_id'],context=context)
- res_location[data['form']['location_id']]=res
-
- product_ids=[]
- for location in res_location.keys():
- res=res_location[location]
- for product_id in res.keys():
- #product_ids.append(product_id)
- prod = pool.get('product.product').browse(cr, uid, [product_id])[0]
- uom = prod.uom_id.id
- context.update({'uom': uom})
- amount=pool.get('stock.location')._product_get(cr, uid, location, [product_id], context=context)[product_id]
-
- if(amount):
- line_ids=inventory_line_obj.search(cr,uid,[('inventory_id','=',data['id']),('location_id','=',location),('product_id','=',product_id),('product_uom','=',uom),('product_qty','=',amount)])
- if not len(line_ids):
- inventory_line={'inventory_id':data['id'],'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 wizard.except_wizard(_('Message !'), _('No product in this location.'))
- return {}
-
-
-
-class fill_inventory(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : inventory_form,
- 'fields' : inventory_fields,
- 'state' : [('end', 'Cancel', 'gtk-cancel'),('fill_inventory', 'Fill Inventory', 'gtk-apply', True) ]}
- },
- 'fill_inventory' : {
- 'actions' : [],
- 'result' : {'type' : 'action', 'action': _fill_inventory, 'state' : 'end'}
- },
- }
-fill_inventory("stock.fill_inventory")
-
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/wizard_invoice_onshipping.py b/addons/stock/wizard/wizard_invoice_onshipping.py
deleted file mode 100644
index 22cdbc97e70..00000000000
--- a/addons/stock/wizard/wizard_invoice_onshipping.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import pooler
-from tools.translate import _
-
-invoice_form = """
-
-
-
-
-
-
-
-
-
-
-"""
-
-invoice_fields = {
- 'journal_id': {
- 'string': 'Destination Journal',
- 'type': 'many2one',
- 'relation': 'account.journal',
- 'required': True
- },
- 'group': {
- 'string': 'Group by partner',
- 'type': 'boolean'
- },
- 'type': {
- 'string': 'Type',
- 'type': 'selection',
- 'selection': [],
- 'required': True
- },
- 'invoice_date': {'string': 'Invoiced date', 'type':'date' }
-}
-
-
-def _get_type(obj, cr, uid, data, context):
- picking_obj = pooler.get_pool(cr.dbname).get('stock.picking')
- usage = 'customer'
- pick = picking_obj.browse(cr, uid, data['id'], context)
- if pick.invoice_state == 'invoiced':
- raise wizard.except_wizard(_('UserError'), _('Invoice is already created.'))
- if pick.invoice_state == 'none':
- raise wizard.except_wizard(_('UserError'), _('Invoice cannot be created from Picking.'))
-
- if pick.move_lines:
- usage = pick.move_lines[0].location_id.usage
-
- if pick.type =='out':
- invoice_fields['type']['selection'] = [
- ('out_invoice', 'Customer Invoice'),
- ('in_refund', 'Supplier Refund'),
- ]
- elif pick.type =='in':
- invoice_fields['type']['selection'] = [
- ('in_invoice', 'Supplier Invoice'),
- ('out_refund', 'Customer Refund'),
- ]
- else:
- invoice_fields['type']['selection']=[
- ('out_invoice', 'Customer Invoice'),
- ('in_invoice', 'Supplier Invoice'),
- ('out_refund', 'Customer Refund'),
- ('in_refund', 'Supplier Refund'),
- ]
-
- if pick.type == 'out' and usage == 'supplier':
- type = 'in_refund'
- elif pick.type == 'out' and usage == 'customer':
- type = 'out_invoice'
- elif pick.type == 'in' and usage == 'supplier':
- type = 'in_invoice'
- elif pick.type == 'in' and usage == 'customer':
- type = 'out_refund'
- else:
- type = 'out_invoice'
- return {'type': type}
-
-
-def _create_invoice(obj, cr, uid, data, context):
- if data['form'].get('new_picking', False):
- data['id'] = data['form']['new_picking']
- data['ids'] = [data['form']['new_picking']]
- pool = pooler.get_pool(cr.dbname)
- picking_obj = pooler.get_pool(cr.dbname).get('stock.picking')
- mod_obj = pool.get('ir.model.data')
- act_obj = pool.get('ir.actions.act_window')
-
- type = data['form']['type']
-
- context['date_inv'] = data['form']['invoice_date']
- res = picking_obj.action_invoice_create(cr, uid, data['ids'],
- journal_id = data['form']['journal_id'], group=data['form']['group'],
- type=type, context= context)
-
- invoice_ids = res.values()
- if not invoice_ids:
- raise wizard.except_wizard(_('Error'), _('Invoice is not created'))
-
- if type == 'out_invoice':
- xml_id = 'action_invoice_tree1'
- elif type == 'in_invoice':
- xml_id = 'action_invoice_tree2'
- elif type == 'out_refund':
- xml_id = 'action_invoice_tree3'
- else:
- xml_id = 'action_invoice_tree4'
-
- result = mod_obj._get_id(cr, uid, 'account', xml_id)
- id = mod_obj.read(cr, uid, result, ['res_id'])
- result = act_obj.read(cr, uid, id['res_id'])
- result['res_id'] = invoice_ids
- return result
-
-
-class make_invoice_onshipping(wizard.interface):
- states = {
- 'init': {
- 'actions': [_get_type],
- 'result': {
- 'type': 'form',
- 'arch': invoice_form,
- 'fields': invoice_fields,
- 'state': [
- ('end', 'Cancel', 'gtk-cancel'),
- ('create_invoice', 'Create invoice', 'gtk-apply', True)
- ]
- }
- },
- 'create_invoice': {
- 'actions': [],
- 'result': {
- 'type': 'action',
- 'action': _create_invoice,
- 'state': 'end'
- }
- },
- }
-
-make_invoice_onshipping("stock.invoice_onshipping")
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/stock/wizard/wizard_location_product.py b/addons/stock/wizard/wizard_location_product.py
deleted file mode 100755
index c423c426832..00000000000
--- a/addons/stock/wizard/wizard_location_product.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import wizard
-import pooler
-import time
-
-def _action_open_window(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- mod_obj = pool.get('ir.model.data')
- result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view')
- id = mod_obj.read(cr, uid, result, ['res_id'])
- return {
- 'name': False,
- 'view_type': 'form',
- "view_mode": 'tree,form',
- 'res_model': 'product.product',
- 'type': 'ir.actions.act_window',
- 'context':{'location': data['ids'][0],'from_date':data['form']['from_date'],'to_date':data['form']['to_date']},
- 'domain':[('type','<>','service')],
- 'search_view_id': id['res_id']
- }
-
-
-class product_by_location(wizard.interface):
- form1 = '''
-
-
-
-
-
-
-
-
-
'''
- form1_fields = {
- 'from_date': {
- 'string': 'From',
- 'type': 'datetime',
- },
- 'to_date': {
- 'string': 'To',
- 'type': 'datetime',
- },
- }
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel', 'gtk-cancel'),('open', 'Open Products', 'gtk-apply', True)]}
- },
- 'open': {
- 'actions': [],
- 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
- }
- }
-product_by_location('stock.location.products')
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock/wizard/wizard_partial_move.py b/addons/stock/wizard/wizard_partial_move.py
deleted file mode 100644
index 928d96461c8..00000000000
--- a/addons/stock/wizard/wizard_partial_move.py
+++ /dev/null
@@ -1,220 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import time
-import netsvc
-from tools.misc import UpdateableStr, UpdateableDict
-import pooler
-
-import wizard
-from osv import osv
-import tools
-from tools.translate import _
-
-_moves_arch = UpdateableStr()
-_moves_fields = UpdateableDict()
-
-_moves_arch_end = '''
-
-'''
-inv_fields = {
- 'prefix': {
- 'string': 'Prefix',
- 'type': 'char',
- 'size': 64,
- },
- 'quantity': {
- 'string': 'Quantity per lot',
- 'type': 'float',
- 'default': 1,
- }
-}
-
-def _check_production_lot(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- inv_obj = pool.get('stock.inventory.line').browse(cr, uid, data['id'])
- if not inv_obj.prod_lot_id:
- raise wizard.except_wizard(_('Caution!'), _('Before splitting the inventory lines, make sure the production lot is assigned to this product.'))
- return data['form']
-
-def _split_lines(self, cr, uid, data, context):
- inv_id = data['id']
-
- pool = pooler.get_pool(cr.dbname)
- inv_line_obj = pool.get('stock.inventory.line')
- prodlot_obj = pool.get('stock.production.lot')
-
- ir_sequence_obj = pool.get('ir.sequence')
-
- sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
- if not sequence:
- raise wizard.except_wizard(_('Error!'), _('No production sequence defined'))
- if data['form']['prefix']:
- sequence=data['form']['prefix']+'/'+(sequence or '')
-
- inv = inv_line_obj.browse(cr, uid, [inv_id])[0]
- quantity=data['form']['quantity']
- prodlot_obj.write(cr, uid, inv.prod_lot_id.id, {'name':sequence})
-
- if quantity <= 0 or inv.product_qty == 0:
- return {}
-
- quantity_rest = inv.product_qty%quantity
-
- update_val = {
- 'product_qty': quantity,
- }
-
- new_line = []
- for idx in range(int(inv.product_qty//quantity)):
- if idx:
- current_line = inv_line_obj.copy(cr, uid, inv.id, {'prod_lot_id': inv.prod_lot_id.id})
- new_line.append(current_line)
- else:
- current_line = inv.id
- inv_line_obj.write(cr, uid, [current_line], update_val)
-
- if quantity_rest > 0:
- idx = int(inv.product_qty//quantity)
- update_val['product_qty']=quantity_rest
-
- if idx:
- current_line = inv_line_obj.copy(cr, uid, inv.id, {'prod_lot_id': inv.prod_lot_id.id})
- new_line.append(current_line)
- else:
- current_line = inv.id
- inv_line_obj.write(cr, uid, [current_line], update_val)
-
- return {}
-
-class wizard_split_inventory_lots(wizard.interface):
- states = {
- 'init': {
- 'actions': [_check_production_lot],
- 'result': {'type': 'form', 'arch': inv_form, 'fields': inv_fields, 'state': [('end', 'Cancel', 'gtk-cancel'), ('split', 'Ok', 'gtk-apply', True)]},
- },
- 'split': {
- 'actions': [_split_lines],
- 'result': {'type':'state', 'state':'end'}
- }
- }
-
-wizard_split_inventory_lots('stock.inventory.line.split')
\ No newline at end of file
diff --git a/addons/stock_planning/__init__.py b/addons/stock_planning/__init__.py
new file mode 100644
index 00000000000..f0fea471a21
--- /dev/null
+++ b/addons/stock_planning/__init__.py
@@ -0,0 +1,24 @@
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import stock_planning
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/stock_planning/__terp__.py b/addons/stock_planning/__terp__.py
new file mode 100644
index 00000000000..1ff4e8d0b10
--- /dev/null
+++ b/addons/stock_planning/__terp__.py
@@ -0,0 +1,146 @@
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+{
+ "name":"Master Procurement Schedule",
+ "version":"1.1",
+ "author":"Tiny and Grzegorz Grzelak (Cirrus)",
+ "category":"Custom",
+ "depends":["hr","stock","sale"],
+ "description": """
+This module is based on original Tiny module stock_planning version 1.0 of the same name Master Procurement Schedule.
+
+Purpose of MPS is to allow create a manual procurement (requisition) apart of MRP scheduler (which works automatically on minimum stock rules).
+
+Terms used in the module:
+- Stock and Sales Period - is the time (between Start Date and End Date) for which you plan Stock and Sales Forecast and make Procurement Planning.
+- Stock and Sales Forecast - is the quantity of products you plan to sell in the Period.
+- Stock Planning - is the quantity of products you plan to purchase or produce for the Period.
+
+Because we have another module sale_forecast which uses terms "Sales Forecast" and "Planning" as amount values we will use terms "Stock and Sales Forecast" and "Stock Planning" to emphasize that we use quantity values.
+
+Activity with this module is divided to three steps:
+- Creating Periods. Mandatory step.
+- Creating Sale Forecasts and entering quantities to them. Optional step but useful for farther planning.
+- Creating Planning lines, entering quantities to them and making Procurement. Making procurement is the final step for the Period.
+
+Periods
+=======
+You have two menu items for Periods in "Sales Management - Configuration". There are:
+- "Create Sales Periods" - Which automates creating daily, weekly or monthly periods.
+- "Stock and sales Periods" - Which allows to create any type of periods, change the dates and change the State of period.
+
+Creating periods is the first step you have to do to use modules features. You can create custom periods using "New" button in "Stock and Sales Periods" form or view but it is recommended to use automating tool.
+
+Remarks:
+- These periods (officially Stock and Sales Periods) are separated of Financial or other periods in the system.
+- Periods are not assigned to companies (when you use multicompany feature at all). Module suppose that you use the same periods across companies. If you wish to use different periods for different companies define them as you wish (they can overlap). Later on in this text will be indications how to use such periods.
+- When periods are created automatically their start and finish dates are with with start hour 00:00:00 and end hour 23:59:00. Fe. when you create daily periods they will have start date 31.01.2010 00:00:00 and end date 31.01.2010 23:59:00. It works only in automatic creation of periods. When you create periods manually you have to take care about hours because you can have incorrect values form sales or stock.
+- If you use overlapping periods for the same product, warehouse and company results can be unpredictable.
+- If current date doesn't belong to any period or you have holes between periods results can be unpredictable.
+
+Sales Forecasts
+===============
+You have few menus for Sales forecast in "Sales Management - Sales Forecasts".
+- "Create Sales Forecasts for Sales Periods" - which automates creating forecasts lines according to some parameters.
+- "Sales Forecasts" - few menus for working with forecasts lists and forms.
+
+Menu "Create Sales Forecasts for Sales Periods" creates Forecasts for products from selected Category, for selected Period and for selected Warehouse. It is an option "Copy Last Forecast" to copy forecast and other settings of period before this one to created one.
+
+Remarks:
+- This tool doesn't create lines if relevant lines (for the same Product, Period, Warehouse and validated or created by you) already exists. If you wish to create another forecast if relevant lines exists you have to do it manually using menus described bellow.
+- When created lines are validated by someone else you can use this tool to create another lines for the same Period, Product and Warehouse.
+- When you choose "Copy Last Forecast" created line takes quantity and some settings from your (validated by you or created by you if not validated yet) forecast which is for last period before period of created forecast. If there are few your forecasts for period before this one (it is possible) system takes one of them (no rule which of them).
+
+
+Menus "Sales Forecasts"
+On "Sales Forecast" form mainly you have to enter a forecast quantity in "Product Quantity". Farther calculation can work for draft forecasts. But validation can save your data against any accidental changes. You can click "Validate" button but it is not mandatory.
+
+Instead of forecast quantity you can enter amount of forecast sales in field "Product Amount". System will count quantity from amount according to Sale price of the Product.
+
+All values on the form are expressed in unit of measure selected on form. You can select one of unit of measure from default category or from second category. When you change unit of measure the quanities will be recalculated according to new UoM: editable values (blue fields) immediately, non edited fields after clicking of "Calculate Planning" button.
+
+To find proper value for Sale Forecast you can use "Sales History" table for this product. You have to enter parameters to the top and left of this table and system will count sale quantities according to these parameters. So you can select fe. your department (at the top) then (to the left): last period, period before last and period year ago.
+
+Remarks:
+
+
+Procurement Planning
+====================
+Menu for Planning you can find in "Warehouse - Stock Planning".
+- "Create Stock Planning Lines" - allows you to automate creating planning lines according to some parameters.
+- "Master Procurement Scheduler" - is the most important menu of the module which allows to create procurement.
+
+As Sales forecast is phase of planning sales. The Procurement Planning (Planning) is the phase of scheduling Purchasing or Producing. You can create Procurement Planning quickly using tool from menu "Create Stock Planning Lines", then you can review created planning and make procurement using menu "Master Procurement Schedule".
+
+Menu "Create Stock Planning Lines" allows you to create quickly Planning lines for products from selected Category, for selected Period, and for selected Warehouse. When you check option "All Products with Forecast" system creates lines for all products having forecast for selected Period and Warehouse. Selected Category will be ignored in this case.
+
+Under menu "Master Procurement Scheduler" you can generally change the values "Planned Out" and "Planned In" to observe the field "Stock Simulation" and decide if this value would be accurate for end of the Period.
+"Planned Out" can be based on "Warehouse Forecast" which is the sum of all forecasts for Period and Warehouse. But your planning can be based on any other information you have. It is not necessary to have any forecast.
+"Planned In" quantity is used to calculate field "Incoming Left" which is the quantity to be procured to make stock as indicated in "Stock Simulation" at the and of Period. You can compare "Stock Simulation" quantity to minimum stock rules visible on the form. But you can plan different quantity than in Minimum Stock Rules. Calculation is made for whole Warehouse by default. But if you want to see values for Stock location of calculated warehouse you can use check box "Stock Location Only".
+
+If after few tries you decide that you found correct quantities for "Planned Out" and "Planned In" and you are satisfied with end of period stock calculated in "Stock Simulation" you can click "Procure Incoming Left" button to procure quantity of field "Incoming Left" into the Warehouse. System creates appropriate Procurement Order. You can decide if procurement will be made to Stock or Input location of calculated Warehouse.
+
+If you don't want to Produce or Buy the product but just pick calculated quantity from another warehouse you can click "Supply from Another Warehouse" (instead of "Procure Incoming Left"). System creates pick list with move from selected source Warehouse to calculated Warehouse (as destination). You can also decide if this pick should be done from Stock or Output location of source warehouse. Destination location (Stock or Input) of destination warehouse will be used as set for "Procure Incoming Left".
+
+To see proper quantities in fields "Confirmed In", "Confirmed Out", "Confirmed In Before", "Planned Out Before" and "Stock Simulation" you have to click button "Calculate Planning".
+
+All values on the form are expressed in unit of measure selected on form. You can select one of unit of measure from default category or from second category. When you change unit of measure the quanities will be recalculated according to new UoM: editable values (blue fields) immediately, non edited fields after clicking of "Calculate Planning" button.
+
+How Stock Simulation field is calculated:
+Generally Stock Simulation shows the stock for end of the calculated period according to some planned or confirmed stock moves. Calculation always starts with quantity of real stock of beginning of current period. Then calculation adds or subtracts quantities of calculated period or periods before calculated.
+When you are in the same period (current period is the same as calculated) Stock Simulation is calculated as follows:
+Stock Simulation =
+ Stock of beginning of current Period
+ - Planned Out
+ + Planned In
+
+When you calculate period next to current:
+Stock Simulation =
+ Stock of beginning of current Period
+ - Planned Out of current Period
+ + Confirmed In of current Period (incl. Already In)
+ - Planned Out of calculated Period
+ + Planned In of calculated Period .
+
+As you see calculated Period is taken the same way like in case above. But calculation of current Period are made a little bit different. First you should note that system takes for current Period only Confirmed In moves. It means that you have to make planning and procurement for current Period before this calculation (for Period next to current).
+
+When you calculate Period ahead:
+Stock Simulation =
+ Stock of beginning of current Period
+ - Sum of Planned Out of Periods before calculated
+ + Sum of Confirmed In of Periods before calculated (incl. Already In)
+ - Planned Out of calculated Period
+ + Planned In of calculated Period.
+
+Periods before calculated means periods starting from current till period before calculated.
+
+Remarks:
+- Remember to make planning for all periods before calculated because omitting these quantities and procurements can cause wrong suggestions for procurements few periods ahead.
+- If you made planning few periods ahead and you find that real Confirmed Out is bigger than Planned Out in some periods before you can repeat Planning and make another procurement. You should do it in the same planning line. If you create another planning line the suggestions can be wrong.
+- When you wish to work with different periods for some part of products define two kinds of periods (fe. Weekly and Monthly) and use them for different products. Example: If you use always Weekly periods for Products A, and Monthly periods for Products B your all calculations will work correctly. You can also use different kind of periods for the same products from different warehouse or companies. But you cannot use overlapping periods for the same product, warehouse and company because results can be unpredictable. The same apply to Forecasts lines.
+""",
+ "demo_xml":[],
+ "update_xml":["security/ir.model.access.csv","stock_planning_view.xml"],
+ "active": False,
+ "installable": True,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/stock_planning/security/ir.model.access.csv b/addons/stock_planning/security/ir.model.access.csv
new file mode 100644
index 00000000000..b0ee2853b87
--- /dev/null
+++ b/addons/stock_planning/security/ir.model.access.csv
@@ -0,0 +1,7 @@
+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
+"access_stock_planning","stock.planning","model_stock_planning","stock.group_stock_user",1,1,1,1
+"access_stock_period_create_lines","stock.period.createlines","model_stock_period_createlines","stock.group_stock_user",1,1,1,1
+"access_stock_period","stock.period","model_stock_period","stock.group_stock_user",1,1,1,1
+"access_stock_sale_forecast_createlines","stock.sale.forecast.createlines","model_stock_sale_forecast_createlines","stock.group_stock_user",1,1,1,1
+"access_stock_sale_forecast","stock.sale.forecast","model_stock_sale_forecast","stock.group_stock_user",1,1,1,1
+"access_stock_planning_createlines","stock.planning.createlines","model_stock_planning_createlines","stock.group_stock_user",1,1,1,1
diff --git a/addons/stock_planning/stock_planning.py b/addons/stock_planning/stock_planning.py
new file mode 100644
index 00000000000..fa0bec2f5b1
--- /dev/null
+++ b/addons/stock_planning/stock_planning.py
@@ -0,0 +1,1009 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (). 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 .
+#
+##############################################################################
+
+from osv import fields,osv
+import pooler
+from tools import config
+import time
+import netsvc
+import math
+import mx.DateTime
+from mx.DateTime import RelativeDateTime, now, DateTime, localtime
+from tools.translate import _
+
+def rounding(fl, round_value):
+ if not round_value:
+ return fl
+ return round(fl / round_value) * round_value
+
+
+# Object creating periods quickly
+# changed that stop_date is created with hour 23:59:00 when it was 00:00:00 stop date was excluded from period
+class stock_period_createlines(osv.osv_memory):
+ _name = "stock.period.createlines"
+
+ def _get_new_period_start(self,cr,uid,context={}):
+ cr.execute("select max(date_stop) from stock_period")
+ result=cr.fetchone()
+ last_date = result and result[0] or False
+ if last_date:
+ period_start = mx.DateTime.strptime(last_date,"%Y-%m-%d %H:%M:%S")+ RelativeDateTime(days=1)
+ period_start = period_start - RelativeDateTime(hours=period_start.hour, minutes=period_start.minute, seconds=period_start.second)
+ else:
+ period_start = mx.DateTime.today()
+ return period_start.strftime('%Y-%m-%d')
+
+
+ _columns = {
+ 'name': fields.char('Period Name', size=64),
+ 'date_start': fields.date('Start Date', required=True),
+ 'date_stop': fields.date('End Date', required=True),
+ 'period_ids': fields.one2many('stock.period', 'planning_id', 'Periods'),
+ }
+ _defaults={
+ 'date_start':_get_new_period_start,
+ }
+
+ def create_period_weekly(self,cr, uid, ids, context={}):
+ res=self.create_period(cr, uid, ids, context, 6, 'Weekly')
+ return {
+ 'view_type': 'form',
+ "view_mode": 'tree',
+ 'res_model': 'stock.period',
+ 'type': 'ir.actions.act_window',
+ }
+
+ def create_period_monthly(self,cr, uid, ids, context={},interval=1):
+ for p in self.browse(cr, uid, ids, context):
+ dt = p.date_start
+ ds = mx.DateTime.strptime(p.date_start, '%Y-%m-%d')
+ while ds.strftime('%Y-%m-%d') val.product_id.uom_id.category_id.id:
+ coef = coef / val.product_id.uos_coeff
+ return val.product_id.uom_id.factor / coef
+
+ def _from_default_uom_factor(self, cr, uid, val, uom_id, context):
+ uom_obj = self.pool.get('product.uom')
+ uom = uom_obj.browse(cr, uid, uom_id, context=context)
+ res = uom.factor
+ if uom.category_id.id <> val.product_id.uom_id.category_id.id:
+ res = res / val.product_id.uos_coeff
+ return res / val.product_id.uom_id.factor, uom.rounding
+
+ def _sales_per_users(self, cr, uid, so, so_line, company, users):
+ cr.execute("SELECT sum(sol.product_uom_qty) FROM sale_order_line AS sol LEFT JOIN sale_order AS s ON (s.id = sol.order_id) " \
+ "WHERE (sol.id IN (%s)) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN (%s)) AND (s.company_id=%s) " \
+ "AND (s.user_id IN (%s)) " %(so_line, so, company, users))
+ ret = cr.fetchone()[0] or 0.0
+ return ret
+
+ def _sales_per_warehouse(self, cr, uid, so, so_line, company, shops):
+ cr.execute("SELECT sum(sol.product_uom_qty) FROM sale_order_line AS sol LEFT JOIN sale_order AS s ON (s.id = sol.order_id) " \
+ "WHERE (sol.id IN (%s)) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN (%s))AND (s.company_id=%s) " \
+ "AND (s.shop_id IN (%s))" %(so_line, so, company, shops))
+ ret = cr.fetchone()[0] or 0.0
+ return ret
+
+ def _sales_per_company(self, cr, uid, so, so_line, company, ):
+ cr.execute("SELECT sum(sol.product_uom_qty) FROM sale_order_line AS sol LEFT JOIN sale_order AS s ON (s.id = sol.order_id) " \
+ "WHERE (sol.id IN (%s)) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN (%s)) AND (s.company_id=%s)"%(so_line, so, company))
+ ret = cr.fetchone()[0] or 0.0
+ return ret
+
+ def calculate_sales_history(self, cr, uid, ids, context, *args):
+ sales=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],]
+ for obj in self.browse(cr, uid, ids):
+ periods =obj.analyzed_period1_id, obj.analyzed_period2_id, obj.analyzed_period3_id, obj.analyzed_period4_id, obj.analyzed_period5_id
+ so_obj = self.pool.get('sale.order')
+ so_line_obj= self.pool.get('sale.order.line')
+ so_line_product_ids = so_line_obj.search(cr, uid, [('product_id','=', obj.product_id.id)], context = context)
+ if so_line_product_ids:
+ so_line_product_set = ','.join(map(str,so_line_product_ids))
+ if obj.analyzed_warehouse_id:
+ shops = self.pool.get('sale.shop').search(cr, uid,[('warehouse_id','=', obj.analyzed_warehouse_id.id)], context = context)
+ shops_set = ','.join(map(str,shops))
+ else:
+ shops = False
+ if obj.analyzed_dept_id:
+ dept_obj = self.pool.get('hr.department')
+ dept_id = obj.analyzed_dept_id.id and [obj.analyzed_dept_id.id] or []
+ dept_ids = dept_obj.search(cr,uid,[('parent_id','child_of',dept_id)])
+ dept_ids_set = ','.join(map(str,dept_ids))
+ cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN (%s))" %(dept_ids_set))
+ dept_users = [x for x, in cr.fetchall()]
+ dept_users_set = ','.join(map(str,dept_users))
+ else:
+ dept_users = False
+ factor, round_value = self._from_default_uom_factor(cr, uid, obj, obj.product_uom.id, context=context)
+ for i, period in enumerate(periods):
+ if period:
+ so_period_ids = so_obj.search(cr, uid, [('date_order','>=',period.date_start), ('date_order','<=',period.date_stop)], context = context)
+ if so_period_ids:
+ so_period_set = ','.join(map(str,so_period_ids))
+ if obj.analyzed_user_id:
+ user_set = str(obj.analyzed_user_id.id)
+ sales[i][0] =self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, user_set)
+ sales[i][0] *=factor
+ if dept_users:
+ sales[i][1]= self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, dept_users_set)
+ sales[i][1]*=factor
+ if shops:
+ sales[i][2]= self._sales_per_warehouse(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, shops_set)
+ sales[i][2]*=factor
+ if obj.analyze_company:
+ sales[i][3]= self._sales_per_company(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, )
+ sales[i][3]*=factor
+ self.write(cr, uid, ids, {
+ 'analyzed_period1_per_user':sales[0][0],
+ 'analyzed_period2_per_user':sales[1][0],
+ 'analyzed_period3_per_user':sales[2][0],
+ 'analyzed_period4_per_user':sales[3][0],
+ 'analyzed_period5_per_user':sales[4][0],
+ 'analyzed_period1_per_dept':sales[0][1],
+ 'analyzed_period2_per_dept':sales[1][1],
+ 'analyzed_period3_per_dept':sales[2][1],
+ 'analyzed_period4_per_dept':sales[3][1],
+ 'analyzed_period5_per_dept':sales[4][1],
+ 'analyzed_period1_per_warehouse':sales[0][2],
+ 'analyzed_period2_per_warehouse':sales[1][2],
+ 'analyzed_period3_per_warehouse':sales[2][2],
+ 'analyzed_period4_per_warehouse':sales[3][2],
+ 'analyzed_period5_per_warehouse':sales[4][2],
+ 'analyzed_period1_per_company':sales[0][3],
+ 'analyzed_period2_per_company':sales[1][3],
+ 'analyzed_period3_per_company':sales[2][3],
+ 'analyzed_period4_per_company':sales[3][3],
+ 'analyzed_period5_per_company':sales[4][3],
+ })
+ return True
+
+
+stock_sale_forecast()
+
+# Creates stock planning records for products from selected Product Category for selected 'Warehouse - Period'
+# Object added by contributor in ver 1.1
+class stock_planning_createlines(osv.osv_memory):
+ _name = "stock.planning.createlines"
+
+ def onchange_company(self, cr, uid, ids, company_id):
+ result = {}
+ if company_id:
+ result['warehouse_id2'] = False
+ return {'value': result}
+
+ _columns = {
+ 'company_id': fields.many2one('res.company', 'Company', required = True),
+ 'period_id2': fields.many2one('stock.period' , 'Period', required=True, help = 'Period which planning will concern.'),
+ 'warehouse_id2': fields.many2one('stock.warehouse' , 'Warehouse', required=True, help = 'Warehouse which planning will concern.'),
+ 'product_categ_id2': fields.many2one('product.category' , 'Product Category', \
+ help = 'Planning will be created for products from Product Category selected by this field. '\
+ 'This field is ignored when you check \"All Forecasted Product\" box.' ),
+ 'forecasted_products': fields.boolean('All Products with Forecast', \
+ help = "Check this box to create planning for all products having any forecast for selected Warehouse and Period. "\
+ "Product Category field will be ignored."),
+ }
+
+ _defaults = {
+ 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.planning', context=c),
+ }
+
+ def create_planning(self,cr, uid, ids, context={}):
+ product_obj = self.pool.get('product.product')
+ planning_obj=self.pool.get('stock.planning')
+
+ for f in self.browse(cr, uid, ids, context=context):
+ if f.forecasted_products:
+ cr.execute("SELECT product_id \
+ FROM stock_sale_forecast \
+ WHERE (period_id = %s) AND (warehouse_id = %s)", (f.period_id2.id, f.warehouse_id2.id))
+ products_id1 = [x for x, in cr.fetchall()]
+ else:
+ prod_categ_obj=self.pool.get('product.category')
+ template_obj=self.pool.get('product.template')
+ categ_ids = f.product_categ_id2.id and [f.product_categ_id2.id] or []
+ prod_categ_ids=prod_categ_obj.search(cr,uid,[('parent_id','child_of',categ_ids)])
+ templates_ids = template_obj.search(cr,uid,[('categ_id','in',prod_categ_ids)])
+ products_id1 = product_obj.search(cr,uid,[('product_tmpl_id','in',templates_ids)])
+ if len(products_id1)==0:
+ raise osv.except_osv(_('Error !'), _('No forecasts for selected period or no products in selected category !'))
+
+ for p in product_obj.browse(cr, uid, products_id1,context=context):
+ if len(planning_obj.search(cr, uid, [('product_id','=',p.id),
+ ('period_id','=',f.period_id2.id),
+ ('warehouse_id','=',f.warehouse_id2.id)]))== 0:
+ cr.execute("SELECT period.date_stop, planning.product_uom, planning.planned_outgoing, planning.to_procure, \
+ planning.stock_only, planning.procure_to_stock, planning.confirmed_forecasts_only, \
+ planning.supply_warehouse_id, planning.stock_supply_location \
+ FROM stock_planning AS planning \
+ LEFT JOIN stock_period AS period \
+ ON planning.period_id = period.id \
+ WHERE (planning.create_uid = %s OR planning.write_uid = %s) \
+ AND planning.warehouse_id = %s AND planning.product_id = %s \
+ AND period.date_stop < %s \
+ ORDER BY period.date_stop DESC",
+ (uid, uid, f.warehouse_id2.id, p.id, f.period_id2.date_stop) )
+ ret=cr.fetchone()
+# forecast_qty = ret and ret[0] or 0.0
+ if ret:
+# raise osv.except_osv(_('Error !'), _('ret is %s %s %s %s %s %s')%(ret[0],ret[2],ret[3],ret[4],ret[5],ret[6],))
+ prod_uom = ret[1]
+ planned_out = ret[2]
+ to_procure = ret[3]
+ stock_only = ret[4]
+ procure_to_stock = ret[5]
+ confirmed_forecasts_only = ret[6]
+ supply_warehouse_id = ret[7]
+ stock_supply_location = ret[8]
+ else:
+ prod_uom = p.uom_id.id
+ planned_out = False
+ to_procure = False
+ stock_only = False
+ procure_to_stock = False
+ confirmed_forecasts_only = False
+ supply_warehouse_id = False
+ stock_supply_location = False
+ prod_uos_categ = False
+ if p.uos_id:
+ prod_uos_categ = p.uos_id.category_id.id
+ planning_obj.create(cr, uid, {
+ 'company_id' : f.warehouse_id2.company_id.id,
+ 'period_id': f.period_id2.id,
+ 'warehouse_id' : f.warehouse_id2.id,
+ 'product_id': p.id,
+ 'product_uom' : prod_uom,
+ 'product_uom_categ' : p.uom_id.category_id.id,
+ 'product_uos_categ' : prod_uos_categ,
+ 'active_uom' : prod_uom,
+ 'planned_outgoing': planned_out,
+ 'to_procure': to_procure,
+ 'stock_only': stock_only,
+ 'procure_to_stock': procure_to_stock,
+ 'confirmed_forecasts_only': confirmed_forecasts_only,
+ 'supply_warehouse_id': supply_warehouse_id,
+ 'stock_supply_location': stock_supply_location,
+
+ })
+ return {
+ 'view_type': 'form',
+ "view_mode": 'tree',
+ 'res_model': 'stock.planning',
+ 'type': 'ir.actions.act_window',
+ }
+stock_planning_createlines()
+
+
+# The main Stock Planning object
+# A lot of changes by contributor in ver 1.1
+class stock_planning(osv.osv):
+ _name = "stock.planning"
+
+ def _get_in_out(self, cr, uid, val, date_start, date_stop, direction, done, context):
+# res = {}
+# if not context:
+# context = {}
+ mapping = {'in': {
+ 'field': "incoming_qty",
+ 'adapter': lambda x: x,
+ },
+ 'out': {
+ 'field': "outgoing_qty",
+ 'adapter': lambda x: -x,
+ },
+ }
+ context['from_date'] = date_start
+ context['to_date'] = date_stop
+ locations = [val.warehouse_id.lot_stock_id.id,]
+ if not val.stock_only:
+ locations.extend([val.warehouse_id.lot_input_id.id, val.warehouse_id.lot_output_id.id])
+ context['location'] = locations
+ context['compute_child'] = True
+ product_obj = self.pool.get('product.product')
+ prod_id = val.product_id.id
+ if done:
+ c1=context.copy()
+ c1.update({ 'states':('done',), 'what':(direction,) })
+ prod_ids = [prod_id]
+ st = product_obj.get_product_available(cr,uid, prod_ids, context=c1)
+ res = mapping[direction]['adapter'](st.get(prod_id,0.0))
+ else:
+ product=product_obj.read(cr, uid, prod_id,[], context)
+ product_qty = product[mapping[direction]['field']]
+ res = mapping[direction]['adapter'](product_qty)
+# res[val.id] = product_obj['incoming_qty']
+ return res
+
+ def _get_outgoing_before(self, cr, uid, val, date_start, date_stop, context):
+ cr.execute("SELECT sum(planning.planned_outgoing), planning.product_uom \
+ FROM stock_planning AS planning \
+ LEFT JOIN stock_period AS period \
+ ON (planning.period_id = period.id) \
+ WHERE (period.date_stop >= %s) AND (period.date_stop <= %s) \
+ AND (planning.product_id = %s) AND (planning.company_id = %s) \
+ GROUP BY planning.product_uom", \
+ (date_start, date_stop, val.product_id.id, val.company_id.id,))
+ planning_qtys = cr.fetchall()
+ res = self._to_planning_uom(cr, uid, val, planning_qtys, context)
+ return res
+
+ def _to_planning_uom(self, cr, uid, val, qtys, context):
+ res_qty = 0
+ if qtys:
+ uom_obj = self.pool.get('product.uom')
+ for qty, prod_uom in qtys:
+ coef = self._to_default_uom_factor(cr, uid, val, prod_uom, context=context)
+ res_coef, round_value = self._from_default_uom_factor(cr, uid, val, val.product_uom.id, context=context)
+ coef = coef * res_coef
+ res_qty += rounding(qty * coef, round_value)
+ return res_qty
+
+
+ def _get_forecast(self, cr, uid, ids, field_names, arg, context):
+ res = {}
+ for val in self.browse(cr, uid, ids):
+ res[val.id]={}
+ valid_part = val.confirmed_forecasts_only and " AND state = 'validated'" or ""
+ cr.execute('SELECT sum(product_qty), product_uom \
+ FROM stock_sale_forecast \
+ WHERE product_id = %s AND period_id = %s AND company_id = %s '+valid_part+ \
+ 'GROUP BY product_uom', \
+ (val.product_id.id,val.period_id.id, val.company_id.id))
+ company_qtys = cr.fetchall()
+ res[val.id]['company_forecast'] = self._to_planning_uom(cr, uid, val, company_qtys, context)
+
+ cr.execute('SELECT sum(product_qty), product_uom \
+ FROM stock_sale_forecast \
+ WHERE product_id = %s and period_id = %s AND warehouse_id = %s ' + valid_part + \
+ 'GROUP BY product_uom', \
+ (val.product_id.id,val.period_id.id, val.warehouse_id.id))
+ warehouse_qtys = cr.fetchall()
+ res[val.id]['warehouse_forecast'] = self._to_planning_uom(cr, uid, val, warehouse_qtys, context)
+ res[val.id]['warehouse_forecast'] = rounding(res[val.id]['warehouse_forecast'], val.product_id.uom_id.rounding)
+ return res
+
+ def _get_stock_start(self, cr, uid, val, date, context):
+ context['from_date'] = None
+ context['to_date'] = date
+ locations = [val.warehouse_id.lot_stock_id.id,]
+ if not val.stock_only:
+ locations.extend([val.warehouse_id.lot_input_id.id, val.warehouse_id.lot_output_id.id])
+ context['location'] = locations
+ context['compute_child'] = True
+ product_obj = self.pool.get('product.product').read(cr, uid,val.product_id.id,[], context)
+ res = product_obj['qty_available'] # value for stock_start
+ return res
+
+ def _get_past_future(self, cr, uid, ids, field_names, arg, context):
+ res = {}
+ for val in self.browse(cr, uid, ids, context=context):
+ if val.period_id.date_stop < time.strftime('%Y-%m-%d'):
+ res[val.id] = 'Past'
+ else:
+ res[val.id] = 'Future'
+ return res
+
+ def _get_op(self, cr, uid, ids, field_names, arg, context): # op = OrderPoint
+ res = {}
+ for val in self.browse(cr, uid, ids, context=context):
+ res[val.id]={}
+ cr.execute("SELECT product_min_qty, product_max_qty, product_uom \
+ FROM stock_warehouse_orderpoint \
+ WHERE warehouse_id = %s AND product_id = %s AND active = 'TRUE'", (val.warehouse_id.id, val.product_id.id))
+ ret = cr.fetchone() or [0.0,0.0,False]
+ coef = 1
+ round_value = 1
+ if ret[2]:
+ coef = self._to_default_uom_factor(cr, uid, val, ret[2], context)
+ res_coef, round_value = self._from_default_uom_factor(cr, uid, val, val.product_uom.id, context=context)
+ coef = coef * res_coef
+ res[val.id]['minimum_op'] = rounding(ret[0]*coef, round_value)
+ res[val.id]['maximum_op'] = ret[1]*coef
+ return res
+
+ def onchange_company(self, cr, uid, ids, company_id):
+ result = {}
+ if company_id:
+ result['warehouse_id'] = False
+ return {'value': result}
+
+ def onchange_uom(self, cr, uid, ids, product_uom, ):
+ if not product_uom:
+ return {}
+ ret={}
+ val1 = self.browse(cr, uid, ids)
+ val = val1[0]
+ coeff_uom2def = self._to_default_uom_factor(cr, uid, val, val.active_uom.id, {})
+ coeff_def2uom, round_value = self._from_default_uom_factor( cr, uid, val, product_uom, {})
+ coeff = coeff_uom2def * coeff_def2uom
+ ret['planned_outgoing'] = rounding(coeff * val.planned_outgoing, round_value)
+ ret['to_procure'] = rounding(coeff * val.to_procure, round_value)
+ ret['active_uom'] = product_uom
+ return {'value': ret}
+
+ _columns = {
+ 'company_id': fields.many2one('res.company', 'Company', required = True),
+ 'history' : fields.text('Procurement History', readonly=True, help = "History of procurement or internal supply of this planning line."),
+ 'state' : fields.selection([('draft','Draft'),('done','Done')],'State',readonly=True),
+ 'period_id': fields.many2one('stock.period' , 'Period', required=True, \
+ help = 'Period for this planning. Requisition will be created for beginning of the period.'),
+ 'warehouse_id' : fields.many2one('stock.warehouse','Warehouse', required=True),
+ 'product_id': fields.many2one('product.product' , 'Product', required=True, help = 'Product which this planning is created for.'),
+ 'product_uom_categ' : fields.many2one('product.uom.categ', 'Product UoM Category'), # Invisible field for product_uom domain
+ 'product_uom' : fields.many2one('product.uom', 'UoM', required=True, help = "Unit of Measure used to show the quanities of stock calculation." \
+ "You can use units form default category or from second category (UoS category)."),
+ 'product_uos_categ' : fields.many2one('product.uom.categ', 'Product UoM Category'), # Invisible field for product_uos domain
+# Field used in onchange_uom to check what uom was before change to recalculate quantities acording to old uom (active_uom) and new uom.
+ 'active_uom' :fields.many2one('product.uom', string = "Active UoM"),
+ 'planned_outgoing' : fields.float('Planned Out', required=True, \
+ help = 'Enter planned outgoing quantity from selected Warehouse during the selected Period of selected Product. '\
+ 'To plan this value look at Confirmed Out or Sales Forecasts. This value should be equal or greater than Confirmed Out.'),
+ 'company_forecast': fields.function(_get_forecast, method=True, string ='Company Forecast', multi = 'company', \
+ help = 'All sales forecasts for whole company (for all Warehouses) of selected Product during selected Period.'),
+ 'warehouse_forecast': fields.function(_get_forecast, method=True, string ='Warehouse Forecast', multi = 'warehouse',\
+ help = 'All sales forecasts for selected Warehouse of selected Product during selected Period.'),
+ 'stock_simulation': fields.float('Stock Simulation', readonly =True, \
+ help = 'Stock simulation at the end of selected Period.\n For current period it is: \n' \
+ 'Initial Stock - Already Out + Already In - Expected Out + Incoming Left.\n' \
+ 'For periods ahead it is: \nInitial Stock - Planned Out Before + Incoming Before - Planned Out + Planned In.'),
+ 'incoming': fields.float('Confirmed In', readonly=True, \
+ help = 'Quantity of all confirmed incoming moves in calculated Period.'),
+ 'outgoing': fields.float('Confirmed Out', readonly=True, \
+ help = 'Quantity of all confirmed outgoing moves in calculated Period.'),
+ 'incoming_left': fields.float('Incoming Left', readonly=True, \
+ help = 'Quantity left to Planned incoming quantity. This is calculated difference between Planned In and Confirmed In. ' \
+ 'For current period Already In is also calculated. This value is used to create procurement for lacking quantity.'),
+ 'outgoing_left': fields.float('Expected Out', readonly=True, \
+ help = 'Quantity expected to go out in selected period. As a difference between Planned Out and Confirmed Out. ' \
+ 'For current period Already Out is also calculated'),
+ 'to_procure': fields.float(string='Planned In', required=True, \
+ help = 'Enter quantity which (by your plan) should come in. Change this value and observe Stock simulation. ' \
+ 'This value should be equal or greater than Confirmed In.'),
+ 'line_time' : fields.function(_get_past_future, method=True,type='char', string='Past/Future'),
+ 'minimum_op' : fields.function(_get_op, method=True, type='float', string = 'Minimum Rule', multi= 'minimum', \
+ help = 'Minimum quantity set in Minimum Stock Rules for this Warhouse'),
+ 'maximum_op' : fields.function(_get_op, method=True, type='float', string = 'Maximum Rule', multi= 'maximum', \
+ help = 'Maximum quantity set in Minimum Stock Rules for this Warhouse'),
+ 'outgoing_before' : fields.float('Planned Out Before', readonly=True, \
+ help= 'Planned Out in periods before calculated. '\
+ 'Between start date of current period and one day before start of calculated period.'),
+ 'incoming_before': fields.float('Incoming Before', readonly = True, \
+ help= 'Confirmed incoming in periods before calculated (Including Already In). '\
+ 'Between start date of current period and one day before start of calculated period.'),
+ 'stock_start' : fields.float('Initial Stock', readonly=True, \
+ help= 'Stock quantity one day before current period.'),
+ 'already_out' : fields.float('Already Out', readonly=True, \
+ help= 'Quantity which is already dispatched out of this warehouse in current period.'),
+ 'already_in' : fields.float('Already In', readonly=True, \
+ help= 'Quantity which is already picked up to this warehouse in current period.'),
+ 'stock_only' : fields.boolean("Stock Location Only", help = "Check to calculate stock location of selected warehouse only. " \
+ "If not selected calculation is made for input, stock and output location of warehouse."),
+ "procure_to_stock" : fields.boolean("Procure To Stock Location", help = "Chect to make procurement to stock location of selected warehouse. " \
+ "If not selected procurement will be made into input location of warehouse."),
+ "confirmed_forecasts_only" : fields.boolean("Validated Forecasts", help = "Check to take validated forecasts only. " \
+ "If not checked system takes validated and draft forecasts."),
+ 'supply_warehouse_id' : fields.many2one('stock.warehouse','Source Warehouse', help = "Warehouse used as source in supply pick move created by 'Supply from Another Warhouse'."),
+ "stock_supply_location" : fields.boolean("Stock Supply Location", help = "Check to supply from Stock location of Supply Warehouse. " \
+ "If not checked supply will be made from Output location of Supply Warehouse. Used in 'Supply from Another Warhouse' with Supply Warehouse."),
+
+ }
+
+ _defaults = {
+ 'state': lambda *args: 'draft' ,
+ 'to_procure' : 0.0,
+ 'planned_outgoing' : 0.0,
+ 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.planning', context=c),
+ }
+
+ _order = 'period_id'
+
+ def _to_default_uom_factor(self, cr, uid, val, uom_id, context):
+ uom_obj = self.pool.get('product.uom')
+ uom = uom_obj.browse(cr, uid, uom_id, context=context)
+ coef = uom.factor
+ if uom.category_id.id != val.product_id.uom_id.category_id.id:
+ coef = coef / val.product_id.uos_coeff
+ return val.product_id.uom_id.factor / coef
+
+
+ def _from_default_uom_factor(self, cr, uid, val, uom_id, context):
+ uom_obj = self.pool.get('product.uom')
+ uom = uom_obj.browse(cr, uid, uom_id, context=context)
+ res = uom.factor
+ if uom.category_id.id != val.product_id.uom_id.category_id.id:
+ res = res / val.product_id.uos_coeff
+ return res / val.product_id.uom_id.factor, uom.rounding
+
+ def calculate_planning(self, cr, uid, ids, context, *args):
+ one_minute = RelativeDateTime(minutes=1)
+ current_date_beginning_c = mx.DateTime.today()
+ current_date_end_c = current_date_beginning_c + RelativeDateTime(days=1, minutes=-1) # to get hour 23:59:00
+ current_date_beginning = current_date_beginning_c.strftime('%Y-%m-%d %H:%M:%S')
+ current_date_end = current_date_end_c.strftime('%Y-%m-%d %H:%M:%S')
+ for val in self.browse(cr, uid, ids, context=context):
+ day = mx.DateTime.strptime(val.period_id.date_start, '%Y-%m-%d %H:%M:%S')
+ dbefore = mx.DateTime.DateTime(day.year, day.month, day.day) - one_minute
+ day_before_calculated_period = dbefore.strftime('%Y-%m-%d %H:%M:%S') # one day before start of calculated period
+ cr.execute("SELECT date_start \
+ FROM stock_period AS period \
+ LEFT JOIN stock_planning AS planning \
+ ON (planning.period_id = period.id) \
+ WHERE (period.date_stop >= %s) AND (period.date_start <= %s) AND \
+ planning.product_id = %s", (current_date_end, current_date_end, val.product_id.id,)) #
+ date = cr.fetchone()
+ start_date_current_period = date and date[0] or False
+ start_date_current_period = start_date_current_period or current_date_beginning
+ day = mx.DateTime.strptime(start_date_current_period, '%Y-%m-%d %H:%M:%S')
+ dbefore = mx.DateTime.DateTime(day.year, day.month, day.day) - one_minute
+ date_for_start = dbefore.strftime('%Y-%m-%d %H:%M:%S') # one day before current period
+ already_out = self._get_in_out(cr, uid, val, start_date_current_period, current_date_end, direction='out', done = True, context=context),
+ already_in = self._get_in_out(cr, uid, val, start_date_current_period, current_date_end, direction='in', done = True, context=context),
+ outgoing = self._get_in_out(cr, uid, val, val.period_id.date_start, val.period_id.date_stop, direction='out', done = False, context=context),
+ incoming = self._get_in_out(cr, uid, val, val.period_id.date_start, val.period_id.date_stop, direction='in', done = False, context=context),
+ outgoing_before = self._get_outgoing_before(cr, uid, val, start_date_current_period, day_before_calculated_period, context=context),
+ incoming_before = self._get_in_out(cr, uid, val, start_date_current_period, day_before_calculated_period, direction='in', done = False, context=context),
+ stock_start = self._get_stock_start(cr, uid, val, date_for_start, context=context),
+ if start_date_current_period == val.period_id.date_start: # current period is calculated
+ current=True
+ else:
+ current=False
+ factor, round_value = self._from_default_uom_factor(cr, uid, val, val.product_uom.id, context=context)
+ self.write(cr, uid, ids, {
+ 'already_out': rounding(already_out[0]*factor,round_value),
+ 'already_in': rounding(already_in[0]*factor,round_value),
+ 'outgoing': rounding(outgoing[0]*factor,round_value),
+ 'incoming': rounding(incoming[0]*factor,round_value),
+ 'outgoing_before' : rounding(outgoing_before[0]*factor,round_value),
+ 'incoming_before': rounding((incoming_before[0]+ (not current and already_in[0]))*factor,round_value),
+ 'outgoing_left': rounding(val.planned_outgoing - (outgoing[0] + (current and already_out[0]))*factor,round_value),
+ 'incoming_left': rounding(val.to_procure - (incoming[0] + (current and already_in[0]))*factor,round_value),
+ 'stock_start' : rounding(stock_start[0]*factor,round_value),
+ 'stock_simulation': rounding(val.to_procure - val.planned_outgoing + (stock_start[0]+ incoming_before[0] - outgoing_before[0] \
+ + (not current and already_in[0]))*factor,round_value),
+ })
+ return True
+
+# method below converts quantities and uoms to general OpenERP standard with UoM Qty, UoM, UoS Qty, UoS.
+# from stock_planning standard where you have one Qty and one UoM (any from UoM or UoS category)
+# so if UoM is from UoM category it is used as UoM in standard and if product has UoS the UoS will be calcualated.
+# If UoM is from UoS category it is recalculated to basic UoS from product (in planning you can use any UoS from UoS category)
+# and basic UoM is calculated.
+ def _qty_to_standard(self, cr, uid, val, context):
+ uos = False
+ uos_qty = 0.0
+ if val.product_uom.category_id.id == val.product_id.uom_id.category_id.id:
+ uom_qty = val.incoming_left
+ uom = val.product_uom.id
+ if val.product_id.uos_id:
+ uos = val.product_id.uos_id.id
+ coeff_uom2def = self._to_default_uom_factor(cr, uid, val, val.product_uom.id, {})
+ coeff_def2uom, round_value = self._from_default_uom_factor(cr, uid, val, uos, {})
+ uos_qty = rounding(val.incoming_left * coeff_uom2def * coeff_def2uom, round_value)
+ elif val.product_uom.category_id.id == val.product_id.uos_id.category_id.id:
+ coeff_uom2def = self._to_default_uom_factor(cr, uid, val, val.product_uom.id, {})
+ uos = val.product_id.uos_id.id
+ coeff_def2uom, round_value = self._from_default_uom_factor(cr, uid, val, uos, {})
+ uos_qty = rounding(val.incoming_left * coeff_uom2def * coeff_def2uom, round_value)
+ uom = val.product_id.uom_id.id
+ coeff_def2uom, round_value = self._from_default_uom_factor(cr, uid, val, uom, {})
+ uom_qty = rounding(val.incoming_left * coeff_uom2def * coeff_def2uom, round_value)
+ return uom_qty, uom, uos_qty, uos
+
+ def procure_incomming_left(self, cr, uid, ids, context, *args):
+ for obj in self.browse(cr, uid, ids):
+ if obj.incoming_left <= 0:
+ raise osv.except_osv(_('Error !'), _('Incoming Left must be greater than 0 !'))
+ uom_qty, uom, uos_qty, uos = self._qty_to_standard(cr, uid, obj, context)
+ user = self.pool.get('res.users').browse(cr, uid, uid, context)
+ proc_id = self.pool.get('mrp.procurement').create(cr, uid, {
+ 'company_id' : obj.company_id.id,
+ 'name': _('Manual planning for ') + obj.period_id.name,
+ 'origin': _('MPS(') + str(user.login) +') '+ obj.period_id.name,
+ 'date_planned': obj.period_id.date_start,
+ 'product_id': obj.product_id.id,
+ 'product_qty': uom_qty,
+ 'product_uom': uom,
+ 'product_uos_qty': uos_qty,
+ 'product_uos': uos,
+ 'location_id': obj.procure_to_stock and obj.warehouse_id.lot_stock_id.id or obj.warehouse_id.lot_input_id.id,
+ 'procure_method': 'make_to_order',
+ 'note' : _("Procurement created in MPS by user: ") + str(user.login) + _(" Creation Date: ") + \
+ time.strftime('%Y-%m-%d %H:%M:%S') + \
+ _("\nFor period: ") + obj.period_id.name + _(" according to state:") + \
+ _("\n Warehouse Forecast: ") + str(obj.warehouse_forecast) + \
+ _("\n Initial Stock: ") + str(obj.stock_start) + \
+ _("\n Planned Out: ") + str(obj.planned_outgoing) + _(" Planned In: ") + str(obj.to_procure) + \
+ _("\n Already Out: ") + str(obj.already_out) + _(" Already In: ") + str(obj.already_in) + \
+ _("\n Confirmed Out: ") + str(obj.outgoing) + _(" Confirmed In: ") + str(obj.incoming) + \
+ _("\n Planned Out Before: ") + str(obj.outgoing_before) + _(" Confirmed In Before: ") + \
+ str(obj.incoming_before) + \
+ _("\n Expected Out: ") + str(obj.outgoing_left) + _(" Incoming Left: ") + str(obj.incoming_left) + \
+ _("\n Stock Simulation: ") + str(obj.stock_simulation) + _(" Minimum stock: ") + str(obj.minimum_op),
+
+ }, context=context)
+ wf_service = netsvc.LocalService("workflow")
+ wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
+ self.calculate_planning(cr, uid, ids, context)
+ prev_text = obj.history or ""
+ self.write(cr, uid, ids, {
+ 'history' : prev_text + _('Requisition (') + str(user.login) + ", " + time.strftime('%Y.%m.%d %H:%M) ') + str(obj.incoming_left) + \
+ " " + obj.product_uom.name + "\n",
+ })
+ return True
+
+ def internal_supply(self, cr, uid, ids, context, *args):
+ for obj in self.browse(cr, uid, ids):
+ if obj.incoming_left <= 0:
+ raise osv.except_osv(_('Error !'), _('Incoming Left must be greater than 0 !'))
+ if not obj.supply_warehouse_id:
+ raise osv.except_osv(_('Error !'), _('You must specify a Source Warehouse !'))
+ if obj.supply_warehouse_id.id == obj.warehouse_id.id:
+ raise osv.except_osv(_('Error !'), _('You must specify a Source Warehouse different than calculated (destination) Warehouse !'))
+ uom_qty, uom, uos_qty, uos = self._qty_to_standard(cr, uid, obj, context)
+ user = self.pool.get('res.users').browse(cr, uid, uid, context)
+ picking_id = self.pool.get('stock.picking').create(cr, uid, {
+ 'origin': _('MPS(') + str(user.login) +') '+ obj.period_id.name,
+ 'type': 'internal',
+ 'state': 'auto',
+ 'date' : obj.period_id.date_start,
+ 'move_type': 'direct',
+ 'invoice_state': 'none',
+ 'company_id': obj.company_id.id,
+ 'note': _("Pick created from MPS by user: ") + str(user.login) + _(" Creation Date: ") + \
+ time.strftime('%Y-%m-%d %H:%M:%S') + \
+ _("\nFor period: ") + obj.period_id.name + _(" according to state:") + \
+ _("\n Warehouse Forecast: ") + str(obj.warehouse_forecast) + \
+ _("\n Initial Stock: ") + str(obj.stock_start) + \
+ _("\n Planned Out: ") + str(obj.planned_outgoing) + _(" Planned In: ") + str(obj.to_procure) + \
+ _("\n Already Out: ") + str(obj.already_out) + _(" Already In: ") + str(obj.already_in) + \
+ _("\n Confirmed Out: ") + str(obj.outgoing) + _(" Confirmed In: ") + str(obj.incoming) + \
+ _("\n Planned Out Before: ") + str(obj.outgoing_before) + _(" Confirmed In Before: ") + \
+ str(obj.incoming_before) + \
+ _("\n Expected Out: ") + str(obj.outgoing_left) + _(" Incoming Left: ") + str(obj.incoming_left) + \
+ _("\n Stock Simulation: ") + str(obj.stock_simulation) + _(" Minimum stock: ") + str(obj.minimum_op),
+ })
+
+ move_id = self.pool.get('stock.move').create(cr, uid, {
+ 'name': _('MPS(') + str(user.login) +') '+ obj.period_id.name,
+ 'picking_id': picking_id,
+ 'product_id': obj.product_id.id,
+ 'date_planned': obj.period_id.date_start,
+ 'product_qty': uom_qty,
+ 'product_uom': uom,
+ 'product_uos_qty': uos_qty,
+ 'product_uos': uos,
+ 'location_id': obj.stock_supply_location and obj.supply_warehouse_id.lot_stock_id.id or \
+ obj.supply_warehouse_id.lot_output_id.id,
+ 'location_dest_id': obj.procure_to_stock and obj.warehouse_id.lot_stock_id.id or \
+ obj.warehouse_id.lot_input_id.id,
+ 'tracking_id': False,
+ 'company_id': obj.company_id.id,
+ })
+ wf_service = netsvc.LocalService("workflow")
+ wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
+
+ self.calculate_planning(cr, uid, ids, context)
+ prev_text = obj.history or ""
+ pick_name = self.pool.get('stock.picking').browse(cr, uid, picking_id).name
+ self.write(cr, uid, ids, {
+ 'history' : prev_text + _('Pick List ')+ pick_name + " (" + str(user.login) + ", " + time.strftime('%Y.%m.%d %H:%M) ') \
+ + str(obj.incoming_left) +" " + obj.product_uom.name + "\n",
+ })
+
+ return True
+
+ def product_id_change(self, cr, uid, ids, product_id):
+ ret={}
+ if product_id:
+ product_rec = self.pool.get('product.product').browse(cr, uid, product_id)
+ ret['product_uom'] = product_rec.uom_id.id
+ ret['active_uom'] = product_rec.uom_id.id
+ ret['product_uom_categ'] = product_rec.uom_id.category_id.id
+ ret['product_uos_categ'] = product_rec.uos_id and product_rec.uos_id.category_id.id or False
+ else:
+ ret['product_uom'] = False
+ ret['product_uom_categ'] = False
+ ret['product_uos_categ'] = False
+ res = {'value': ret}
+ return res
+
+stock_planning()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/stock_planning/stock_planning_view.xml b/addons/stock_planning/stock_planning_view.xml
new file mode 100644
index 00000000000..e90d68cf855
--- /dev/null
+++ b/addons/stock_planning/stock_planning_view.xml
@@ -0,0 +1,432 @@
+
+
+
+
+
+
+
+
+ stock.period.createlines.form
+ stock.period.createlines
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Stock and Sales Planning Periods
+ stock.period.createlines
+ form
+ form
+
+ new
+
+
+
+
+
+
+
+ stock.period.form
+ stock.period
+ form
+
+
+
+
+
+
+
+
+
+
+
+ stock.period.tree
+ stock.period
+ tree
+
+
+
+
+
+
+
+
+
+
+
+ Stock and Sales Periods
+ stock.period
+ form
+ tree,form
+
+
+
+
+
+
+
+
+ stock.sale.forecast.createlines
+ stock.sale.forecast.createlines
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create Stock and Sales Forecasts
+ stock.sale.forecast.createlines
+ form
+ form
+
+ new
+
+
+
+
+
+
+
+ stock.sale.forecast.form
+ stock.sale.forecast
+ form
+
+