diff --git a/addons/account/wizard/wizard_account_balance_report.py b/addons/account/wizard/wizard_account_balance_report.py
index 7ae386a10f5..d02907f72cc 100644
--- a/addons/account/wizard/wizard_account_balance_report.py
+++ b/addons/account/wizard/wizard_account_balance_report.py
@@ -70,7 +70,7 @@ period_fields = {
},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With Movements'),('bal_solde','With Balance != 0'),('bal_all','All')]},
- 'date_from': {'string':"Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
+ 'date_from': {'string':" Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
'date_to': {'string':"End date",'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
diff --git a/addons/account_voucher/__init__.py b/addons/account_voucher/__init__.py
new file mode 100755
index 00000000000..71118c9f783
--- /dev/null
+++ b/addons/account_voucher/__init__.py
@@ -0,0 +1,3 @@
+import voucher
+import voucher_account
+import report
\ No newline at end of file
diff --git a/addons/account_voucher/__terp__.py b/addons/account_voucher/__terp__.py
new file mode 100755
index 00000000000..97105b77379
--- /dev/null
+++ b/addons/account_voucher/__terp__.py
@@ -0,0 +1,33 @@
+{
+ "name" : "India Accounting",
+ "version" : "1.0",
+ "author" : "Tiny",
+ "description": """
+ India Accounting module includes all the basic requirenment of
+ Basic Accounting, plus new things which available are
+ * Indian Account Chart
+ * New Invoice - (Local, Retail)
+ * Invoice Report
+ * Tax structure
+ * Journals
+ * VAT Declaration report
+ * Accounting Periods
+ """,
+ "category" : "Generic Modules/Accounting",
+ "website" : "http://tinyerp.com",
+ "depends" : ["base", "account"],
+ "init_xml" : [
+ ],
+
+ "demo_xml" : [
+ ],
+
+ "update_xml" : [
+ "account_voucher_sequence.xml",
+ "account_view.xml",
+ "account_report.xml",
+ "voucher_view.xml",
+ ],
+ "active": False,
+ "installable": True
+}
\ No newline at end of file
diff --git a/addons/account_voucher/account_report.xml b/addons/account_voucher/account_report.xml
new file mode 100755
index 00000000000..134581c8816
--- /dev/null
+++ b/addons/account_voucher/account_report.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account_voucher/account_view.xml b/addons/account_voucher/account_view.xml
new file mode 100755
index 00000000000..572a0d34095
--- /dev/null
+++ b/addons/account_voucher/account_view.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+ account.form
+
+ account.account
+ form
+
+
+
+
+
+
+
+
+
+
+
+ account.form
+
+ account.account
+ form
+
+
+
+
+
+
+
+ account.form
+
+ account.account
+ form
+
+
+
+
+
+
+
+
+ account.form
+
+ account.account
+ form
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account_voucher/account_voucher_sequence.xml b/addons/account_voucher/account_voucher_sequence.xml
new file mode 100644
index 00000000000..70e804de8c6
--- /dev/null
+++ b/addons/account_voucher/account_voucher_sequence.xml
@@ -0,0 +1,110 @@
+
+
+
+
+
+ Voucher
+ account.voucher
+
+
+
+
+ Account Cash Received Voucher
+ account.voucher.rec_voucher
+
+
+
+ Account Cash Payble Voucher
+ account.voucher.pay_voucher
+
+
+ Account Bank Received Voucher
+ account.voucher.bank_rec_voucher
+
+
+ Account Bank Payble Voucher
+ account.voucher.bank_pay_voucher
+
+
+ Account Contra Voucher
+ account.voucher.cont_voucher
+
+
+ Account Journal Voucher
+ account.voucher.journal_sale_vou
+
+
+ Account Journal Voucher
+ account.voucher.journal_pur_vou
+
+
+
+
+ Account Cash Received Voucher
+ account.voucher.rec_voucher
+
+ %(year)s/
+
+
+
+ Account Cash Payble Voucher
+ account.voucher.pay_voucher
+
+ %(year)s/
+
+
+ Account Bank Received Voucher
+ account.voucher.bank_rec_voucher
+
+ %(year)s/
+
+
+ Account Bank Payble Voucher
+ account.voucher.bank_pay_voucher
+
+ %(year)s/
+
+
+ Account Contra Voucher
+ account.voucher.cont_voucher
+
+ %(year)s/
+
+
+ Account Journal Voucher
+ account.voucher.journal_sale_vou
+
+ %(year)s/
+
+
+ Account Journal Voucher
+ account.voucher.journal_pur_vou
+
+ %(year)s/
+
+
+
+
+
+
diff --git a/addons/account_voucher/account_voucher_wizard.xml b/addons/account_voucher/account_voucher_wizard.xml
new file mode 100644
index 00000000000..ffe7b25c87c
--- /dev/null
+++ b/addons/account_voucher/account_voucher_wizard.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account_voucher/account_voucher_workflow.xml b/addons/account_voucher/account_voucher_workflow.xml
new file mode 100644
index 00000000000..0299c79997d
--- /dev/null
+++ b/addons/account_voucher/account_voucher_workflow.xml
@@ -0,0 +1,75 @@
+
+
+
+
+
+ account.voucher.basic
+ account.voucher
+ True
+
+
+
+
+ True
+ draft
+
+
+
+
+ performa
+ open_voucher()
+ function
+
+
+
+
+ posted
+ proforma_voucher()
+ True
+ function
+
+
+
+
+ cancel
+ cancel_voucher()
+ function
+
+
+
+
+
+ open_voucher
+
+
+
+
+
+ proforma_voucher
+
+
+
+
+
+ cancel_voucher
+
+
+
+
+
+ cancel_voucher
+
+
+
+
+
+ cancel_voucher
+
+
+
+
+
+ open_voucher
+
+
+
\ No newline at end of file
diff --git a/addons/account_voucher/report/__init__.py b/addons/account_voucher/report/__init__.py
new file mode 100755
index 00000000000..c55dad59fef
--- /dev/null
+++ b/addons/account_voucher/report/__init__.py
@@ -0,0 +1,2 @@
+import report_voucher
+import report_voucher_amount
\ No newline at end of file
diff --git a/addons/account_voucher/report/report_voucher.py b/addons/account_voucher/report/report_voucher.py
new file mode 100755
index 00000000000..b3e3c686f58
--- /dev/null
+++ b/addons/account_voucher/report/report_voucher.py
@@ -0,0 +1,72 @@
+##############################################################################
+#
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+# 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 time
+from report import report_sxw
+from tools import amount_to_text_en
+
+
+class report_voucher(report_sxw.rml_parse):
+ def __init__(self, cr, uid, name, context):
+ super(report_voucher, self).__init__(cr, uid, name, context)
+ self.localcontext.update({
+ 'time': time,
+ 'convert':self.convert,
+ 'debit':self.debit,
+ 'credit':self.credit,
+ 'get_ref' : self._get_ref
+ })
+
+ def convert(self,amount, cur):
+ amt_en = amount_to_text_en.amount_to_text(amount,'en',cur);
+ return amt_en
+
+ def debit(self, move_ids):
+ debit = 0.0
+ for move in move_ids:#self.pool.get('account.move.line').browse(self.cr, self.uid, move_ids):
+ debit +=move.debit
+ return debit
+
+ def credit(self, move_ids):
+ credit = 0.0
+ for move in move_ids:#self.pool.get('account.move.line').browse(self.cr, self.uid, move_ids):
+ credit +=move.credit
+ return credit
+
+ def _get_ref(self, voucher_id, move_ids):
+ voucher_line = self.pool.get('account.voucher.line').search(self.cr, self.uid, [('partner_id','=',move_ids.partner_id.id), ('voucher_id','=',voucher_id)])
+ if voucher_line:
+ voucher = self.pool.get('account.voucher.line').browse(self.cr, self.uid, voucher_line)[0]
+ return voucher.ref
+ else:
+ return
+report_sxw.report_sxw(
+ 'report.voucher.cash_receipt',
+ 'account.voucher',
+ 'addons/account_voucher/report/report_voucher.rml',
+ parser=report_voucher,header=False
+)
\ No newline at end of file
diff --git a/addons/account_voucher/report/report_voucher.rml b/addons/account_voucher/report/report_voucher.rml
new file mode 100755
index 00000000000..685983045ae
--- /dev/null
+++ b/addons/account_voucher/report/report_voucher.rml
@@ -0,0 +1,381 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [[ repeatIn(objects,'voucher') ]]
+ [[ company.name ]]
+ [[ company.partner_id.address and company.partner_id.address[0].street ]]
+ [[ company.partner_id.address and company.partner_id.address[0].zip ]] [[ company.partner_id.address and company.partner_id.address[0].city ]] - [[ company.partner_id.address and company.partner_id.address[0].country_id and company.partner_id.address[0].country_id.name ]]
+ [[ company.partner_id.address and company.partner_id.address[0].phone ]]
+ [[ company.partner_id.address and company.partner_id.address[0].email ]]
+
+
+
+ Cash Receipt Voucher [[ (voucher.type == 'rec_voucher' or removeParentNode('para')) and '' ]]
+ Cash Payment Voucher [[ (voucher.type == 'pay_voucher' or removeParentNode('para')) and '' ]]
+ Bank Receipt Voucher [[ (voucher.type == 'bank_rec_voucher' or removeParentNode('para')) and '' ]]
+ Bank Payment Voucher [[ (voucher.type == 'bank_pay_voucher' or removeParentNode('para')) and '' ]]
+
+
+
+
+
+
+ No.
+
+
+ [[ voucher.number ]]
+
+
+
+
+
+
+
+ Dated :
+
+
+ [[ time.strftime('%d %B,%Y', time.strptime(voucher.date , '%Y-%m-%d')) or '' ]]
+
+
+
+
+ State :
+
+
+ PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]]
+ Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]]
+ Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]]
+ Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]]
+
+
+
+
+
+
+
+ Ref. :
+
+
+ [[ voucher.reference ]]
+
+
+
+
+
+
+
+
+
+
+
+
+ Particulars
+
+
+ Debit
+
+
+ Credit
+
+
+
+
+
+
+
+ [[ repeatIn(voucher.move_ids,'move_ids') ]]
+
+
+
+ [[ (move_ids.partner_id and move_ids.partner_id.name) or '']] :
+ [[ move_ids.account_id.name ]]
+ [[ get_ref(voucher.id,move_ids) ]]
+
+
+ [[ move_ids.debit ]]
+
+
+ [[ move_ids.credit ]]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Through :
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [[ voucher.narration or '']]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ On Account of :
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [[ voucher.name ]]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Amount (in words) :
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [[ convert(voucher.amount,voucher.currency_id.name) ]]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [[ debit(voucher.move_ids)]]
+
+
+ [[ credit(voucher.move_ids) ]]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Receiver's Signature
+
+
+
+
+
+
+
+
+
+
+
+
+ Authorised Signatory
+
+
+
+
+
+
+
+
diff --git a/addons/mrp_repair/report/order.py b/addons/account_voucher/report/report_voucher_amount.py
old mode 100644
new mode 100755
similarity index 70%
rename from addons/mrp_repair/report/order.py
rename to addons/account_voucher/report/report_voucher_amount.py
index 664b86c3825..3b67ff7a9ac
--- a/addons/mrp_repair/report/order.py
+++ b/addons/account_voucher/report/report_voucher_amount.py
@@ -1,9 +1,6 @@
-# -*- encoding: utf-8 -*-
##############################################################################
#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id$
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@@ -30,15 +27,25 @@
import time
from report import report_sxw
-from osv import osv
+from tools import amount_to_text_en
-class order(report_sxw.rml_parse):
+
+class report_voucher_amount(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
- super(order, self).__init__(cr, uid, name, context)
+ super(report_voucher_amount, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
+ 'convert':self.convert
})
-report_sxw.report_sxw('report.repair.order','mrp.repair','addons/mrp_repair/report/order.rml',parser=order)
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+ def convert(self,amount, cur):
+ amt_en = amount_to_text_en.amount_to_text(amount,'en',cur);
+ return amt_en
+
+
+report_sxw.report_sxw(
+ 'report.voucher.cash_amount',
+ 'account.voucher',
+ 'addons/account_voucher/report/report_voucher_amount.rml',
+ parser=report_voucher_amount,header=False
+)
\ No newline at end of file
diff --git a/addons/account_voucher/report/report_voucher_amount.rml b/addons/account_voucher/report/report_voucher_amount.rml
new file mode 100755
index 00000000000..8adec4c6712
--- /dev/null
+++ b/addons/account_voucher/report/report_voucher_amount.rml
@@ -0,0 +1,353 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [[ repeatIn(objects,'voucher') ]]
+ [[ company.name ]]
+ [[ company.partner_id.address and company.partner_id.address[0].street ]]
+ [[ company.partner_id.address and company.partner_id.address[0].zip ]] [[ company.partner_id.address and company.partner_id.address[0].city ]] - [[ company.partner_id.address and company.partner_id.address[0].country_id and company.partner_id.address[0].country_id.name ]]
+ [[ company.partner_id.address and company.partner_id.address[0].phone ]]
+ [[ company.partner_id.address and company.partner_id.address[0].email ]]
+
+
+
+ Cash Receipt Voucher [[ (voucher.type == 'rec_voucher' or removeParentNode('para')) and '' ]]
+ Cash Payment Voucher [[ (voucher.type == 'pay_voucher' or removeParentNode('para')) and '' ]]
+ Bank Receipt Voucher [[ (voucher.type == 'bank_rec_voucher' or removeParentNode('para')) and '' ]]
+ Bank Payment Voucher [[ (voucher.type == 'bank_pay_voucher' or removeParentNode('para')) and '' ]]
+
+
+
+
+
+
+ No.
+
+
+ [[ voucher.number ]]
+
+
+
+
+
+
+
+ Dated :
+
+
+ [[ time.strftime('%d %B,%Y', time.strptime(voucher.date , '%Y-%m-%d')) or '' ]]
+
+
+
+
+ State :
+
+
+ PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]]
+ Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]]
+ Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]]
+ Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]]
+
+
+
+
+
+
+
+ Ref. :
+
+
+ [[ voucher.reference ]]
+
+
+
+
+ Account :
+
+
+ [[ voucher.account_id.name ]]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Particulars
+
+
+ Amount
+
+
+
+
+
+
+
+
+
+ [[ repeatIn(voucher.payment_ids,'payment_ids') ]]
+
+
+
+ [[ payment_ids.partner_id.name ]] :
+ [[ payment_ids.account_id.name ]]
+ [[ payment_ids.ref ]] [[ payment_ids.amount ]] [[ payment_ids.type ]]
+
+
+ [[ payment_ids.amount ]]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Through :
+
+
+
+
+
+
+
+
+
+ [[ voucher.narration or '' ]]
+
+
+
+
+
+
+
+
+
+ On Account of :
+
+
+
+
+
+
+
+
+
+ [[ voucher.name ]]
+
+
+
+
+
+
+
+
+
+ Amount (in words) :
+
+
+
+
+
+
+
+
+
+ [[ convert(voucher.amount,voucher.currency_id.name) ]]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [[ voucher.amount ]]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Receiver's Signature
+
+
+
+
+
+
+
+
+
+
+
+
+ Authorised Signatory
+
+
+
+
+
+
+
+
diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py
new file mode 100755
index 00000000000..d3b3343395c
--- /dev/null
+++ b/addons/account_voucher/voucher.py
@@ -0,0 +1,537 @@
+import time
+import netsvc
+from osv import fields, osv
+import ir
+import pooler
+import mx.DateTime
+from mx.DateTime import RelativeDateTime
+
+from tools import config
+
+
+class account_voucher(osv.osv):
+ def _get_period(self, cr, uid, context):
+ periods = self.pool.get('account.period').find(cr, uid)
+ if periods:
+ return periods[0]
+ else:
+ return False
+
+ def _get_type(self, cr, uid, context={}):
+ type = context.get('type', 'rec_voucher')
+ return type
+
+ def _get_reference_type(self, cursor, user, context=None):
+ return [('none', 'Free Reference')]
+
+
+
+ def _get_journal(self, cr, uid, context):
+ type_inv = context.get('type', 'rec_voucher')
+ type2journal = {'rec_voucher': 'cash', 'bank_rec_voucher': 'cash','pay_voucher': 'cash','bank_pay_voucher': 'cash', 'cont_voucher': 'cash','journal_sale_voucher': 'sale','journal_pur_voucher': 'purchase' }
+ journal_obj = self.pool.get('account.journal')
+ res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'cash'))], limit=1)
+ if res:
+ return res[0]
+ else:
+ return False
+
+ def _get_currency(self, cr, uid, context):
+ user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, [uid])[0]
+ if user.company_id:
+ return user.company_id.currency_id.id
+ else:
+ return pooler.get_pool(cr.dbname).get('res.currency').search(cr, uid, [('rate','=',1.0)])[0]
+
+ _name = 'account.voucher'
+ _description = 'Accounting Voucher'
+ _order = "number"
+ _columns = {
+ 'name':fields.char('Name', size=256, required=True, readonly=True, states={'draft':[('readonly',False)]}),
+ 'type': fields.selection([
+ ('pay_voucher','Cash Payment Voucher'),
+ ('bank_pay_voucher','Bank Payment Voucher'),
+ ('rec_voucher','Cash Receipt Voucher'),
+ ('bank_rec_voucher','Bank Receipt Voucher'),
+ ('cont_voucher','Contra Voucher'),
+ ('journal_sale_vou','Journal Sale Voucher'),
+ ('journal_pur_voucher','Journal Purchase Voucher'),
+ ],'Type', readonly=True, select=True),
+ 'date':fields.date('Date', readonly=True, states={'draft':[('readonly',False)]}),
+ 'journal_id':fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}),
+ 'account_id':fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly',False)]}),
+ 'payment_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=False, states={'proforma':[('readonly',True)]}),
+ 'period_id': fields.many2one('account.period', 'Period', required=True, states={'posted':[('readonly',True)]}),
+ 'narration':fields.text('Narration', readonly=True, states={'draft':[('readonly',False)]}),
+ 'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}),
+ 'company_id': fields.many2one('res.company', 'Company', required=True),
+ 'state':fields.selection(
+ [('draft','Draft'),
+ ('proforma','Pro-forma'),
+ ('posted','Posted'),
+ ('cancel','Cancel')
+ ], 'State',
+ readonly=True),
+ 'amount':fields.float('Amount', readonly=True),
+# , states={'draft':[('readonly',False)]}
+ 'number':fields.char('Number', size=32, readonly=True),
+ 'reference': fields.char('Voucher Reference', size=64),
+ 'reference_type': fields.selection(_get_reference_type, 'Reference Type',
+ required=True),
+ 'move_id':fields.many2one('account.move', 'Account Entry'),
+ 'move_ids':fields.many2many('account.move.line', 'voucher_id', 'account_id', 'rel_account_move', 'Real Entry'),
+ }
+
+# def get_bank(self, cr, uid, context={}):
+# type = context.get('type', 'bank_payment')
+# journal = self.pool.get('account.journal')
+# if type == 'bank_payment':
+# id = journal.search(cr, uid, [('name','ilike','Bank')])
+# return id
+# elif type == 'cash_payment':
+# id = journal.search(cr, uid, [('name','ilike','Cash')])
+# return id
+#
+# return 3
+
+ _defaults = {
+ #'journal_id':get_bank,
+ 'state': lambda *a: 'draft',
+ 'date' : lambda *a: time.strftime('%Y-%m-%d'),
+ 'period_id': _get_period,
+ 'type': _get_type,
+ 'reference_type': lambda *a: 'none',
+ 'journal_id':_get_journal,
+ 'company_id': lambda self, cr, uid, context: \
+ self.pool.get('res.users').browse(cr, uid, uid,
+ context=context).company_id.id,
+ 'currency_id': _get_currency,
+
+
+ }
+
+ def _get_analityc_lines(self, cr, uid, id):
+ inv = self.browse(cr, uid, [id])[0]
+ cur_obj = self.pool.get('res.currency')
+
+ def onchange_account(self, cr, uid, ids, account_id):
+ if not account_id:
+ return {'value':{'amount':False}}
+ account = self.pool.get('account.account').browse(cr,uid,account_id)
+ balance=account.balance
+ return {'value':{'amount':balance}}
+
+
+ def onchange_journal(self, cr, uid, ids, journal_id,type):
+ if not journal_id:
+ return {'value':{'account_id':False}}
+ journal = self.pool.get('account.journal')
+ if journal_id and (type in ('rec_voucher','bank_rec_voucher','journal_pur_voucher')):
+ account_id = journal.browse(cr, uid, journal_id).default_debit_account_id
+ return {'value':{'account_id':account_id.id}}
+ elif journal_id and (type in ('pay_voucher','bank_pay_voucher','journal_sale_vou')) :
+ account_id = journal.browse(cr, uid, journal_id).default_credit_account_id
+ return {'value':{'account_id':account_id.id}}
+ else:
+ account_id = journal.browse(cr, uid, journal_id).default_credit_account_id
+ return {'value':{'account_id':account_id.id}}
+
+
+
+
+ def open_voucher(self, cr, uid, ids, context={}):
+ obj=self.pool.get('account.voucher').browse(cr,uid,ids)
+ total=0
+ for i in obj[0].payment_ids:
+ total+=i.amount
+ self.write(cr,uid,ids,{'amount':total})
+ self.write(cr, uid, ids, {'state':'proforma'})
+ return True
+ def proforma_voucher(self, cr, uid, ids, context={}):
+ self.action_move_line_create(cr, uid, ids)
+ self.action_number(cr, uid, ids)
+ self.write(cr, uid, ids, {'state':'posted'})
+ return True
+ def cancel_voucher(self,cr,uid,ids,context={}):
+ self.action_cancel(cr, uid, ids)
+ self.write(cr, uid, ids, {'state':'cancel'})
+ return True
+
+ def action_cancel_draft(self, cr, uid, ids, *args):
+ self.write(cr, uid, ids, {'state':'draft'})
+ return True
+
+
+ def unlink(self, cr, uid, ids):
+ vouchers = self.read(cr, uid, ids, ['state'])
+ unlink_ids = []
+ for t in vouchers:
+ if t['state'] in ('draft', 'cancel'):
+ unlink_ids.append(t['id'])
+ else:
+ raise osv.except_osv('Invalid action !', 'Cannot delete invoice(s) which are already opened or paid !')
+ osv.osv.unlink(self, cr, uid, unlink_ids)
+ return True
+
+
+ def _get_analityc_lines(self, cr, uid, id):
+ inv = self.browse(cr, uid, [id])[0]
+ cur_obj = self.pool.get('res.currency')
+
+ company_currency = inv.company_id.currency_id.id
+ if inv.type in ('rec_voucher'):
+ sign = 1
+ else:
+ sign = -1
+
+ iml = self.pool.get('account.voucher.line').move_line_get(cr, uid, inv.id)
+
+ for il in iml:
+ if il['account_analytic_id']:
+ if inv.type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_vou','journal_pur_voucher'):
+ ref = inv.reference
+ else:
+ ref = self._convert_ref(cr, uid, inv.number)
+ il['analytic_lines'] = [(0,0, {
+ 'name': il['name'],
+ 'date': inv['date'],
+ 'account_id': il['account_analytic_id'],
+ 'amount': inv['amount'] * sign,
+ 'partner_id': il['partner_id'] or False,
+ 'general_account_id': il['account_id'] or False,
+ 'journal_id': self._get_journal(cr, uid, inv.type),
+ 'ref': ref,
+ })]
+
+ return iml
+
+ def action_move_line_create(self, cr, uid, ids, *args):
+ for inv in self.browse(cr, uid, ids):
+ if inv.move_id:
+ continue
+ company_currency = inv.company_id.currency_id.id
+ # create the analytical lines
+ line_ids = self.read(cr, uid, [inv.id], ['payment_ids'])[0]['payment_ids']
+ ils = self.pool.get('account.voucher.line').read(cr, uid, line_ids)
+ # one move line per invoice line
+ iml = self._get_analityc_lines(cr, uid, inv.id)
+ # check if taxes are all computed
+ diff_currency_p = inv.currency_id.id <> company_currency
+ # create one move line for the total and possibly adjust the other lines amount
+ total = 0
+ if inv.type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_vou','journal_pur_voucher'):
+ ref = inv.reference
+ else:
+ ref = self._convert_ref(cr, uid, inv.number)
+ date = inv.date
+ total_currency = 0
+ for i in iml:
+ if inv.currency_id.id != company_currency:
+ i['currency_id'] = inv.currency_id.id
+ i['amount_currency'] = i['amount']
+
+ else:
+ i['amount_currency'] = False
+ i['currency_id'] = False
+ i['ref'] = ref
+ if inv.type in ('rec_voucher','bank_rec_voucher','journal_pur_voucher'):
+ total += i['amount']
+ total_currency += i['amount_currency'] or i['amount']
+ i['amount'] = - i['amount']
+ else:
+ total -= i['amount']
+ total_currency -= i['amount_currency'] or i['amount']
+ acc_id = inv.account_id.id
+
+ name = inv['name'] or '/'
+ totlines = False
+
+ iml.append({
+ 'type': 'dest',
+ 'name': name,
+ 'amount': total,
+ 'account_id': acc_id,
+ 'amount_currency': diff_currency_p \
+ and total_currency or False,
+ 'currency_id': diff_currency_p \
+ and inv.currency_id.id or False,
+ 'ref': ref
+ })
+
+ date = inv.date
+ inv.amount=total
+
+
+ line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x,date, context={})) ,iml)
+
+ journal_id = inv.journal_id.id #self._get_journal(cr, uid, {'type': inv['type']})
+ journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
+ if journal.sequence_id:
+ name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
+
+ move = {'name': name, 'line_id': line, 'journal_id': journal_id}
+ if inv.period_id:
+ move['period_id'] = inv.period_id.id
+ for i in line:
+ i[2]['period_id'] = inv.period_id.id
+ move_id = self.pool.get('account.move').create(cr, uid, move)
+ # make the invoice point to that move
+ self.write(cr, uid, [inv.id], {'move_id': move_id})
+ obj=self.pool.get('account.move').browse(cr,uid,move_id)
+ for line in obj.line_id :
+ cr.execute('insert into voucher_id (account_id,rel_account_move) values (%d, %d)',(int(ids[0]),int(line.id)))
+# self.pool.get('account.move').post(cr, uid, [move_id])
+# self._log_event(cr, uid, ids)
+ return True
+
+
+
+ def line_get_convert(self, cr, uid, x, date, context={}):
+ return {
+ 'date':date,
+ 'date_maturity': x.get('date_maturity', False),
+ 'partner_id':x.get('partner_id',False),
+ 'name':x['name'][:64],
+ 'debit':x['amount']>0 and x['amount'],
+ 'credit':x['amount']<0 and -x['amount'],
+ 'account_id':x['account_id'],
+ 'analytic_lines':x.get('analytic_lines', []),
+ 'amount_currency':x.get('amount_currency', False),
+ 'currency_id':x.get('currency_id', False),
+ 'tax_code_id': x.get('tax_code_id', False),
+ 'tax_amount': x.get('tax_amount', False),
+ 'ref':x.get('ref',False)
+ }
+ def _convert_ref(self, cr, uid, ref):
+ return (ref or '').replace('/','')
+
+
+ def action_number(self, cr, uid, ids, *args):
+ cr.execute('SELECT id, type, number, move_id, reference ' \
+ 'FROM account_voucher ' \
+ 'WHERE id IN ('+','.join(map(str,ids))+')')
+ for (id, invtype, number, move_id, reference) in cr.fetchall():
+ if not number:
+ number = self.pool.get('ir.sequence').get(cr, uid,
+ 'account.voucher.' + invtype)
+
+ if type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_vou','journal_pur_voucher'):
+ ref = reference
+ else:
+ ref = self._convert_ref(cr, uid, number)
+ cr.execute('UPDATE account_voucher SET number=%s ' \
+ 'WHERE id=%d', (number, id))
+ cr.execute('UPDATE account_move_line SET ref=%s ' \
+ 'WHERE move_id=%d AND (ref is null OR ref = \'\')',
+ (ref, move_id))
+ cr.execute('UPDATE account_analytic_line SET ref=%s ' \
+ 'FROM account_move_line ' \
+ 'WHERE account_move_line.move_id = %d ' \
+ 'AND account_analytic_line.move_id = account_move_line.id',
+ (ref, move_id))
+ return True
+
+
+
+ def name_get(self, cr, uid, ids, context={}):
+ if not len(ids):
+ return []
+ types = {
+ 'pay_voucher': 'CPV: ',
+ 'rec_voucher': 'CRV: ',
+ 'cont_voucher': 'CV: ',
+ 'bank_pay_voucher': 'BPV: ',
+ 'bank_rec_voucher': 'BRV: ',
+ 'journal_sale_vou': 'JSV: ',
+ 'journal_pur_voucher': 'JPV: ',
+
+ }
+ return [(r['id'], types[r['type']]+(r['number'] or '')+' '+(r['name'] or '')) for r in self.read(cr, uid, ids, ['type', 'number', 'name'], context, load='_classic_write')]
+
+ def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
+ if not args:
+ args=[]
+ if not context:
+ context={}
+ ids = []
+ if name:
+ ids = self.search(cr, user, [('number','=',name)]+ args, limit=limit, context=context)
+ if not ids:
+ ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
+ return self.name_get(cr, user, ids, context)
+
+ def copy(self, cr, uid, id, default=None, context=None):
+ if default is None:
+ default = {}
+ default = default.copy()
+ default.update({'state':'draft', 'number':False, 'move_id':False, 'move_ids':False})
+ if 'date' not in default:
+ default['date'] = time.strftime('%Y-%m-%d')
+ return super(account_voucher, self).copy(cr, uid, id, default, context)
+
+ def action_cancel(self, cr, uid, ids, *args):
+ account_move_obj = self.pool.get('account.move')
+ voucher = self.read(cr, uid, ids, ['move_id'])
+ for i in voucher:
+ if i['move_id']:
+ account_move_obj.button_cancel(cr, uid, [i['move_id'][0]])
+ # delete the move this invoice was pointing to
+ # Note that the corresponding move_lines and move_reconciles
+ # will be automatically deleted too
+ account_move_obj.unlink(cr, uid, [i['move_id'][0]])
+ self.write(cr, uid, ids, {'state':'cancel', 'move_id':False})
+# self._log_event(cr, uid, ids,-1.0, 'Cancel Invoice')
+ return True
+
+account_voucher()
+
+class VoucherLine(osv.osv):
+ _name = 'account.voucher.line'
+ _description = 'Voucher Line'
+ _columns = {
+ 'voucher_id':fields.many2one('account.voucher', 'Voucher'),
+ 'name':fields.char('Description', size=256, required=True),
+ 'account_id':fields.many2one('account.account','Account', required=True),
+ 'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, required=True, ),
+ 'amount':fields.float('Amount'),
+ 'type':fields.selection([('dr','Debit'),('cr','Credit')], 'Type'),
+ 'ref':fields.char('Ref.', size=32),
+ 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account')
+ }
+ _defaults = {
+ 'type': lambda *a: 'cr'
+ }
+ def move_line_get(self, cr, uid, voucher_id, context={}):
+ res = []
+
+ cur_obj = self.pool.get('res.currency')
+ inv = self.pool.get('account.voucher').browse(cr, uid, voucher_id)
+ company_currency = inv.company_id.currency_id.id
+ cur = inv.currency_id
+
+ for line in inv.payment_ids:
+ res.append(self.move_line_get_item(cr, uid, line, context))
+ return res
+
+ def onchange_partner(self, cr, uid, ids, partner_id, type,type1):
+ if not partner_id:
+ return {'value' : {'account_id' : False, 'type' : False ,'amount':False}}
+ obj = self.pool.get('res.partner')
+ account_id = False
+
+ if type1 in ('rec_voucher','bank_rec_voucher'):
+ account_id = obj.browse(cr, uid, partner_id).property_account_receivable
+ balance=obj.browse(cr,uid,partner_id).credit
+ type = 'cr'
+ elif type1 in ('pay_voucher','bank_pay_voucher','cont_voucher') :
+ account_id = obj.browse(cr, uid, partner_id).property_account_payable
+ balance=obj.browse(cr,uid,partner_id).debit
+ type = 'dr'
+ elif type1 in ('journal_sale_vou') :
+ account_id = obj.browse(cr, uid, partner_id).property_account_receivable
+ balance=obj.browse(cr,uid,partner_id).credit
+ type = 'dr'
+
+ elif type1 in ('journal_pur_vou') :
+ account_id = obj.browse(cr, uid, partner_id).property_account_payable
+ balance=obj.browse(cr,uid,partner_id).debit
+ type = 'cr'
+
+ return {
+ 'value' : {'account_id' : account_id.id, 'type' : type, 'amount':balance}
+ }
+
+ def onchange_amount(self, cr, uid, ids,partner_id,amount, type,type1):
+ if not amount:
+ return {'value' : {'type' : False}}
+ obj = self.pool.get('res.partner')
+ if type1 in ('rec_voucher','bank_rec_voucher'):
+ if amount < 0 :
+ account_id = obj.browse(cr, uid, partner_id).property_account_payable
+ type = 'dr'
+ else:
+ account_id = obj.browse(cr, uid, partner_id).property_account_receivable
+ type = 'cr'
+
+ elif type1 in ('pay_voucher','bank_pay_voucher','cont_voucher') :
+ if amount < 0 :
+ account_id = obj.browse(cr, uid, partner_id).property_account_receivable
+ type = 'cr'
+ else:
+ account_id = obj.browse(cr, uid, partner_id).property_account_payable
+ type = 'dr'
+
+ elif type1 in ('journal_sale_vou') :
+ if amount < 0 :
+ account_id = obj.browse(cr, uid, partner_id).property_account_payable
+ type = 'cr'
+ else:
+ account_id = obj.browse(cr, uid, partner_id).property_account_receivable
+ type = 'dr'
+
+ elif type1 in ('journal_pur_vou') :
+ if amount< 0 :
+ account_id = obj.browse(cr, uid, partner_id).property_account_receivable
+ type = 'dr'
+ else:
+ account_id = obj.browse(cr, uid, partner_id).property_account_payable
+ type = 'cr'
+
+ return {
+ 'value' : { 'type' : type , 'amount':amount}
+ }
+
+
+ def onchange_type(self, cr, uid, ids,partner_id,amount,type,type1):
+ if not partner_id:
+ return {'value' : {'type' : False}}
+ obj = self.pool.get('res.partner')
+
+ if type1 in ('rec_voucher','bank_rec_voucher'):
+ if type == 'dr' :
+ account_id = obj.browse(cr, uid, partner_id).property_account_payable
+ total=amount*(-1)
+ else:
+ account_id = obj.browse(cr, uid, partner_id).property_account_receivable
+ total=amount*1
+
+ elif type1 in ('pay_voucher','bank_pay_voucher','cont_voucher') :
+ if type == 'cr' :
+ account_id = obj.browse(cr, uid, partner_id).property_account_receivable
+ amount*=-1
+ else:
+ account_id = obj.browse(cr, uid, partner_id).property_account_payable
+ amount*=1
+
+ elif type1 in ('journal_sale_vou') :
+ if type == 'cr' :
+ account_id = obj.browse(cr, uid, partner_id).property_account_payable
+ amount*=-1
+ else:
+ account_id = obj.browse(cr, uid, partner_id).property_account_receivable
+ amount*=1
+
+ elif type1 in ('journal_pur_vou') :
+ if type == 'dr' :
+ account_id = obj.browse(cr, uid, partner_id).property_account_receivable
+ amount*=-1
+ else:
+ account_id = obj.browse(cr, uid, partner_id).property_account_payable
+ amount*=1
+
+ return {
+ 'value' : {'type' : type , 'amount':total}
+ }
+
+
+ def move_line_get_item(self, cr, uid, line, context={}):
+ return {
+ 'type':'src',
+ 'name': line.name[:64],
+ 'amount':line.amount,
+ 'account_id':line.account_id.id,
+ 'partner_id':line.partner_id.id or False ,
+ 'account_analytic_id':line.account_analytic_id.id or False,
+ }
+VoucherLine()
+
diff --git a/addons/account_voucher/voucher_account.py b/addons/account_voucher/voucher_account.py
new file mode 100644
index 00000000000..928a546145d
--- /dev/null
+++ b/addons/account_voucher/voucher_account.py
@@ -0,0 +1,125 @@
+import time
+import netsvc
+from osv import fields, osv
+import ir
+import pooler
+import mx.DateTime
+from mx.DateTime import RelativeDateTime
+
+from tools import config
+
+class Account(osv.osv):
+ _inherit = "account.account"
+
+ def __compute(self, cr, uid, ids, field_names, arg, context={}, query=''):
+ #compute the balance/debit/credit accordingly to the value of field_name for the given account ids
+ mapping = {
+ 'balance': "COALESCE(SUM(l.debit) - SUM(l.credit) , 0) as balance ",
+ 'debit': "COALESCE(SUM(l.debit), 0) as debit ",
+ 'credit': "COALESCE(SUM(l.credit), 0) as credit "
+ }
+ #get all the necessary accounts
+ ids2 = self._get_children_and_consol(cr, uid, ids, context)
+ acc_set = ",".join(map(str, ids2))
+ #compute for each account the balance/debit/credit from the move lines
+ accounts = {}
+ if ids2:
+ query = self.pool.get('account.move.line')._query_get(cr, uid,
+ context=context)
+ cr.execute(("SELECT l.account_id as id, " +\
+ ' , '.join(map(lambda x: mapping[x], field_names)) +
+ "FROM " \
+ "account_move_line l " \
+ "WHERE " \
+ "l.account_id IN (%s) " \
+ "AND " + query + " " \
+ "GROUP BY l.account_id") % (acc_set, ))
+
+ for res in cr.dictfetchall():
+ accounts[res['id']] = res
+
+ #for the asked accounts, get from the dictionnary 'accounts' the value of it
+ res = {}
+ for id in ids:
+ res[id] = self._get_account_values(cr, uid, id, accounts, field_names, context)
+ for id in ids:
+ open=self.browse(cr, uid, id, context)
+ type_id=open.user_type
+ obj=self.pool.get('account.account.type').browse(cr,uid,type_id.id)
+ open_balance=open.open_bal
+ if obj.code in ('cash','asset','expense'):
+ res[id]['balance']+=open_balance
+ elif obj.code in ('equity','income','liability'):
+ total=open_balance*(-1)
+ res[id]['balance']+=total
+ else:
+ res[id]=res[id]
+ return res
+
+ def _get_account_values(self, cr, uid, id, accounts, field_names, context={}):
+ res = {}.fromkeys(field_names, 0.0)
+ browse_rec = self.browse(cr, uid, id)
+ if browse_rec.type == 'consolidation':
+ ids2 = self.read(cr, uid, [browse_rec.id], ['child_consol_ids'], context)[0]['child_consol_ids']
+ for t in self.search(cr, uid, [('parent_id', 'child_of', [browse_rec.id])]):
+ if t not in ids2 and t != browse_rec.id:
+ ids2.append(t)
+ for i in ids2:
+ tmp = self._get_account_values(cr, uid, i, accounts, field_names, context)
+ for a in field_names:
+ res[a] += tmp[a]
+ else:
+ ids2 = self.search(cr, uid, [('parent_id', 'child_of', [browse_rec.id])])
+ for i in ids2:
+ for a in field_names:
+ res[a] += accounts.get(i, {}).get(a, 0.0)
+ return res
+
+ def _diff(self, cr, uid, ids, field_name, arg, context={}):
+
+ res={}
+ dr_total=0.0
+ cr_total=0.0
+ difference=0.0
+ for id in ids:
+ open=self.browse(cr, uid, id, context)
+ if open.type1 == 'dr':
+ dr_total+=open.open_bal
+ elif open.type1 == 'cr':
+ cr_total+=open.open_bal
+ else:
+ difference=0.0
+ difference=dr_total-cr_total
+ for id in ids:
+ res[id]=difference
+ return res
+
+ _columns = {
+ 'open_bal' : fields.float('Opening Balance',digits=(16,2)),
+ 'diff' : fields.function(_diff, digits=(16,2),method=True,string='Difference of Opening Bal.'),
+ 'type1':fields.selection([('dr','Debit'),('cr','Credit'),('none','None')], 'Dr/Cr',store=True),
+ 'balance': fields.function(__compute, digits=(16,2), method=True, string='Closing Balance', multi='balance'),
+ 'credit': fields.function(__compute, digits=(16,2), method=True, string='Credit', multi='balance'),
+ 'debit': fields.function(__compute, digits=(16,2), method=True, string='Debit', multi='balance'),
+
+
+ }
+
+
+ def onchange_type(self, cr, uid, ids,user_type,type1):
+ obj=self.pool.get('account.account.type').browse(cr,uid,user_type)
+ account_type=obj.code
+ if not account_type:
+ return {'value' : {}}
+ if account_type in ('cash','asset','expense'):
+ type1 = 'dr'
+ elif account_type in ('equity','income','liability') :
+ type1 = 'cr'
+ else:
+ type1 = 'none'
+
+ return {
+ 'value' : {'type1' : type1}
+ }
+
+Account()
diff --git a/addons/account_voucher/voucher_view.xml b/addons/account_voucher/voucher_view.xml
new file mode 100755
index 00000000000..5b625f1c267
--- /dev/null
+++ b/addons/account_voucher/voucher_view.xml
@@ -0,0 +1,295 @@
+
+
+
+
+ account.voucher.tree
+ account.voucher
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+ account.voucher.form
+ account.voucher
+ form
+
+
+
+
+
+
+ Vouchers
+ account.voucher
+ form
+ tree,form
+
+
+
+
+
+
+ Receipt Vouchers
+ account.voucher
+ form
+ tree,form
+
+ [('type','like','rec_voucher')]
+ {'type':'rec_voucher'}
+
+
+
+
+ Cash Receipt
+ account.voucher
+ form
+ tree,form
+
+ [('type','=','rec_voucher')]
+ {'type':'rec_voucher'}
+
+
+
+
+ Cash Receipt Voucher
+ account.voucher
+ form
+ tree,form
+
+ [('type','=','rec_voucher'),('state','=','draft')]
+ {'type':'rec_voucher'}
+
+
+
+
+ Cash Receipt Voucher
+ account.voucher
+ form
+ tree,form
+
+ [('type','=','rec_voucher'),('state','=','proforma')]
+ {'type':'rec_voucher'}
+
+
+
+
+ Cash Receipt Voucher
+ account.voucher
+ form
+ tree,form
+
+ [('type','=','rec_voucher'),('state','=','posted')]
+ {'type':'rec_voucher'}
+
+
+
+
+ Cash Receipt Voucher
+ account.voucher
+ form
+ tree,form
+
+ [('type','=','rec_voucher'),('state','=','cancel')]
+ {'type':'rec_voucher'}
+
+
+
+
+
+ Cash Receipt Voucher
+ account.voucher
+ form
+ form,tree
+
+ [('type','=','rec_voucher')]
+ {'type':'rec_voucher'}
+
+
+
+
+ Bank Receipt
+ account.voucher
+ form
+ tree,form
+
+ [('type','=','bank_rec_voucher')]
+ {'type':'rec_voucher'}
+
+
+
+
+ Bank Receipt Voucher
+ account.voucher
+ form
+ form,tree
+
+ [('type','=','bank_rec_voucher')]
+ {'type':'bank_rec_voucher'}
+
+
+
+
+
+
+
+
+
+ Payment Vouchers
+ account.voucher
+ form
+ tree,form
+
+ [('type','like','pay_voucher')]
+ {'type':'rec_voucher'}
+
+
+
+
+ Payment Vouchers
+ account.voucher
+ form
+ tree,form
+
+ [('type','=','pay_voucher')]
+ {'type':'rec_voucher'}
+
+
+
+
+ Cash Payment Voucher
+ account.voucher
+ form
+ form,tree
+
+ [('type','=','pay_voucher')]
+ {'type':'pay_voucher'}
+
+
+
+
+ Payment Vouchers
+ account.voucher
+ form
+ tree,form
+
+ [('type','=','bank_pay_voucher')]
+ {'type':'rec_voucher'}
+
+
+
+
+ Bank Payment Voucher
+ account.voucher
+ form
+ form,tree
+
+ [('type','=','bank_pay_voucher')]
+ {'type':'bank_pay_voucher'}
+
+
+
+
+
+
+
+ Other Vouchers
+ account.voucher
+ form
+ tree,form
+
+
+
+
+
+ Contra Voucher
+ account.voucher
+ form
+ form,tree
+
+ [('type','=','cont_voucher')]
+ {'type':'cont_voucher'}
+
+
+
+ Journal Sale Voucher
+ account.voucher
+ form
+ form,tree
+
+ [('type','=','journal_sale_voucher')]
+ {'type':'journal_sale_voucher'}
+
+
+
+ Journal Purchase Voucher
+ account.voucher
+ form
+ form,tree
+
+ [('type','=','journal_pur_voucher')]
+ {'type':'journal_pur_voucher'}
+
+
+
+
+
\ No newline at end of file
diff --git a/addons/account_voucher/wizard/__init__.py b/addons/account_voucher/wizard/__init__.py
new file mode 100644
index 00000000000..e347d6dc636
--- /dev/null
+++ b/addons/account_voucher/wizard/__init__.py
@@ -0,0 +1 @@
+import open_voucher
\ No newline at end of file
diff --git a/addons/account_voucher/wizard/open_voucher.py b/addons/account_voucher/wizard/open_voucher.py
new file mode 100644
index 00000000000..e0c592fe2e7
--- /dev/null
+++ b/addons/account_voucher/wizard/open_voucher.py
@@ -0,0 +1,113 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
+#
+# $Id$
+#
+# 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
+from tools.translate import _
+import pooler
+
+_voucher_form = '''
+
'''
+
+_types = {
+ 'pay_voucher':'Cash Payment Voucher',
+ 'bank_pay_voucher':'Bank Payment Voucher',
+ 'rec_voucher':'Cash Receipt Voucher',
+ 'bank_rec_voucher':'Bank Receipt Voucher',
+ 'cont_voucher':'Contra Voucher',
+ 'journal_sale_voucher':'Journal Sale Voucher',
+ 'journal_pur_voucher':'Journal Purchase Voucher'
+}
+_states = {
+ 'draft':'Draft',
+ 'proforma':'Pro-forma',
+ 'posted':'Posted',
+ 'cancel':'Cancel'
+}
+
+_voucher_fields = {
+ 'type': {'string':'Voucher Type', 'type':'selection', 'selection':[
+ ('pay_voucher','Cash Payment Voucher'),
+ ('bank_pay_voucher','Bank Payment Voucher'),
+ ('rec_voucher','Cash Receipt Voucher'),
+ ('bank_rec_voucher','Bank Receipt Voucher'),
+ ('cont_voucher','Contra Voucher'),
+ ('journal_sale_voucher','Journal Sale Voucher'),
+ ('journal_pur_voucher','Journal Purchase Voucher')], 'required':True},
+ 'state': {'string':'State', 'type':'selection', 'selection':[
+ ('draft','Draft'),
+ ('proforma','Pro-forma'),
+ ('posted','Posted'),
+ ('cancel','Cancel')], 'required':True},
+ 'period_ids': {'string':'Periods', 'type':'many2many', 'relation':'account.period'},
+}
+
+def _action_open_window(self, cr, uid, data, context):
+ form = data['form']
+ periods = []
+
+ if not form['period_ids'][0][2]:
+ pool = pooler.get_pool(cr.dbname)
+ period = pool.get('account.period')
+ year = pool.get('account.fiscalyear')
+
+ year = year.find(cr, uid)
+ periods = period.search(cr, uid, [('fiscalyear_id','=',year)])
+ else:
+ periods = form['period_ids'][0][2]
+
+ return {
+ 'domain': "[('type','=','%s'), ('state','=','%s'), ('period_id','in',%s)]" % (form['type'], form['state'], periods),
+ 'name': "%s - %s" % (_types[form['type']], _states[form['state']]),
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.voucher',
+ 'view_id': False,
+ 'context': "{'type':'%s', 'state':'%s', 'period_id':%s}" % (form['type'], form['state'], periods),
+ 'type': 'ir.actions.act_window'
+ }
+
+class OpenVoucherEntries(wizard.interface):
+ states = {
+ 'init': {
+ 'actions': [],
+ 'result': {'type': 'form', 'arch':_voucher_form, 'fields':_voucher_fields, 'state':[('end','Cancel'),('open','Open Voucher Entries')]}
+ },
+ 'open': {
+ 'actions': [],
+ 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
+ }
+ }
+OpenVoucherEntries('account.voucher.open')
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/l10n_fr/plan-99-03_societe.xml b/addons/l10n_fr/plan-99-03_societe.xml
index 61dceacecdb..5f8f9a38e0e 100644
--- a/addons/l10n_fr/plan-99-03_societe.xml
+++ b/addons/l10n_fr/plan-99-03_societe.xml
@@ -7015,6 +7015,7 @@
receivable
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- mrp.repair.tree
- mrp.repair
- tree
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- New Repair
- ir.actions.act_window
- mrp.repair
- form
- form,tree
-
-
-
- Repair Orders
- ir.actions.act_window
- mrp.repair
- form
- tree,form
-
-
-
- Repairs in quotation
- ir.actions.act_window
- mrp.repair
- form
- tree,form
- [('state','=','draft')]
-
-
-
- Repairs in progress
- ir.actions.act_window
- mrp.repair
- form
- tree,form
- [('state','=','confirmed')]
-
-
-
- Repairs to be invoiced
- ir.actions.act_window
- mrp.repair
- form
- tree,form
- [('state','=','2binvoiced')]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/mrp_repair/mrp_repair_wizard.xml b/addons/mrp_repair/mrp_repair_wizard.xml
deleted file mode 100644
index 1847740da08..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/mrp_repair_workflow.xml b/addons/mrp_repair/mrp_repair_workflow.xml
deleted file mode 100644
index 08e8ef6be36..00000000000
--- a/addons/mrp_repair/mrp_repair_workflow.xml
+++ /dev/null
@@ -1,249 +0,0 @@
-
-
-
-
- mrp.repair.basic
- mrp.repair
- True
-
-
-
-
-
- True
- draft
-
-
-
- router
- function
- action_wait()
- OR
-
-
-
- wait_invoice
-
-
-
- wait_ship
-
-
-
-
- done
- True
- function
- write({'state':'done'})
- AND
-
-
-
- cancel
- True
- stopall
- action_cancel()
-
-
-
- cancel2
- True
- stopall
- action_cancel()
-
-
-
- cancel3
- True
- stopall
- action_cancel()
-
-
-
-
- invoice
- subflow
-
- action_invoice_create()
-
-
-
- invoice_except
- function
- action_invoice_cancel()
-
-
-
- invoice_end
- dummy
-
-
-
- invoice_cancel
- True
- stopall
- action_cancel()
-
-
-
-
- ship
- function
- action_ship_create()
-
-
-
-
- ship_except
- function
- write({'state':'shipping_except'})
-
-
-
- ship_end
- function
- action_ship_end()
-
-
-
- ship_cancel
- True
- stopall
- action_cancel()
-
-
-
-
-
-
-
-
-
-
-
-
- repair_confirm
-
-
-
-
-
- cancel
-
-
-
-
-
- all_lines
-
-
-
-
-
- True
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- cancel
-
-
-
-
-
- cancel
-
-
-
-
-
- (invoice_method=='after_repair' or invoice_method=='none')
-
-
-
-
-
- (invoice_method=='b4repair')
-
-
-
-
-
- make_invoice
-
-
-
-
-
- subflow.paid
-
-
-
-
- subflow.cancel
-
-
-
-
- invoice_recreate
-
-
-
-
- invoice_corrected
-
-
-
-
- invoice_cancel
-
-
-
-
-
-
-
-
-
- mrp.procurement
- procurement_lines_get()
- test_state('finished')
-
-
-
-
-
- test_state('canceled')
-
-
-
-
- ship_recreate
-
-
-
-
- ship_corrected
-
-
-
-
- ship_cancel
-
-
-
-
diff --git a/addons/mrp_repair/report/__init__.py b/addons/mrp_repair/report/__init__.py
deleted file mode 100644
index b78b753a323..00000000000
--- a/addons/mrp_repair/report/__init__.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id$
-#
-# 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 order
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/mrp_repair/report/order.rml b/addons/mrp_repair/report/order.rml
deleted file mode 100644
index bf833e99c43..00000000000
--- a/addons/mrp_repair/report/order.rml
+++ /dev/null
@@ -1,236 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [[ repeatIn(objects,'o') ]] [[ setLang(o.partner_id.lang) ]]
-
-
-
- Shipping address :
- [[ o.partner_id.title or '' ]] [[ o.partner_id.name ]]
- [[ o.address_id.title or '' ]] [[ o.address_id.name ]]
- [[ o.address_id.street ]]
- [[ o.address_id.street2 or '' ]]
- [[ o.address_id.zip or '' ]] [[ o.address_id.city or '' ]]
- [[ o.address_id.state_id and o.address_id.state_id.name or '' ]]
- [[ o.address_id.country_id and o.address_id.country_id.name or '' ]]
-
-
-
- Invoice address :
- [[ o.address_id.street ]][[ o.address_id.street2 and (', %s' % o.address_id.street2 or '') ]]
- [[ o.address_id.zip or '' ]] [[ o.address_id.city or '' ]] [[ o.address_id.country_id and (', %s' % (o.address_id.country_id and o.address_id.country_id.name or '')) ]]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [[ o.state<>'draft' and removeParentNode('para') ]] Quotation N° : [[ o.name ]]
- [[ o.state=='draft' and removeParentNode('para') ]] Order N° : [[ o.name ]]
-
-
-
- Your order reference : [[ o.client_order_ref or '' ]]
- Date ordered : [[ time.strftime('%d/%m/%Y', time.strptime(o.date_order, '%Y-%m-%d')) ]]
- Our salesman : [[ o.user_id.name ]]
-
-
-
-
-
-
- Product
-
-
- Quantity
-
-
- Unit Price
-
-
- Price
-
-
-
-
- [[ repeatIn(o.operations,'line') ]]
-
-
-
- [[ line.product_id.name ]]
-
-
- [[ line.product_qty ]] [[ line.product_uom.name ]]
-
-
- [[ line.price_unit ]]
-
-
- [[ line.price_unit ]]
-
-
-
-
-
-
-
-
-
-
-
-
- Net Total :
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Taxes :
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- TOTAL :
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [[ format((o.partner_id.property_payment_term and o.partner_id.property_payment_term[1]) or '') ]]
-
-
-
-
-
-
-
-
diff --git a/addons/mrp_repair/wizard/__init__.py b/addons/mrp_repair/wizard/__init__.py
deleted file mode 100644
index 4f4d4d74876..00000000000
--- a/addons/mrp_repair/wizard/__init__.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id$
-#
-# 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_cancel_repair
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
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 0790baa0f8c..00000000000
--- a/addons/mrp_repair/wizard/wizard_cancel_repair.py
+++ /dev/null
@@ -1,86 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id$
-#
-# 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
-
-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.state == 'draft':
- pool.get('mrp.repair').write(cr,uid,data['ids'],{'state':'cancel'})
- return 'end'
- else:
- return 'display'
-
-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'])[0]
- pool.get('mrp.repair').write(cr,uid,data['ids'],{'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/sale_delivery/__init__.py b/addons/sale_delivery/__init__.py
deleted file mode 100644
index 1d6e7cb3107..00000000000
--- a/addons/sale_delivery/__init__.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id$
-#
-# 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 sale_delivery
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/sale_delivery/__terp__.py b/addons/sale_delivery/__terp__.py
deleted file mode 100644
index 2ec84f19c7a..00000000000
--- a/addons/sale_delivery/__terp__.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved.
-#
-# $Id$
-#
-# 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.
-###############################################################################
-# -*- encoding: utf-8 -*-
-{
- "name":"Sale Delivery Planning",
- "version":"1.0",
- "author":"Tiny",
- "category":"Custom",
- "depends":["sale"],
- "demo_xml":[],
- "update_xml":["sale_delivery_view.xml"],
- "active": False,
- "installable": True,
-}
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/sale_delivery/sale_delivery.py b/addons/sale_delivery/sale_delivery.py
deleted file mode 100644
index 3f3a7ea6ecf..00000000000
--- a/addons/sale_delivery/sale_delivery.py
+++ /dev/null
@@ -1,206 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id$
-#
-# 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 time
-from osv import fields,osv
-import netsvc
-
-class sale_delivery_line(osv.osv):
- _name = 'sale.delivery.line'
- def _check_product_qty(self, cr, uid, ids):
- for delivery in self.browse(cr, uid, ids):
- cr.execute('select sum(product_uom_qty) from sale_order_line where order_id = %d and product_id = %d',(delivery.order_id,delivery.product_id))
- sale_product_qty = cr.fetchall()[0][0]
- cr.execute('select sum(product_qty) from sale_delivery_line where order_id = %d and product_id = %d',(delivery.order_id,delivery.product_id))
- product_qty = cr.fetchall()[0][0]
- if sale_product_qty < product_qty:
- return False
- return True
-
- def _check_products(self, cr, uid, ids):
- for delivery in self.browse(cr, uid, ids):
- cr.execute('select id from sale_order_line where order_id = %d and product_id = %d',(delivery.order_id,delivery.product_id))
- if not len(cr.fetchall()):
- return False
- return True
-
- _columns = {
- 'product_id': fields.many2one('product.product', string='Product', required=True ),
- 'product_qty': fields.float('Product Quantity', digits=(16,2), required=True),
- 'product_uom' : fields.many2one('product.uom', 'Product UoM', required=True),
- 'packaging_id' : fields.many2one('product.packaging', 'Packaging'),
- 'date_planned': fields.datetime('Date Planned', select=True, required=True),
- 'priority': fields.integer('Priority'),
- 'note' : fields.text('Note'),
- 'order_id': fields.many2one('sale.order', 'Order Ref', required=True, ondelete='cascade', select=True),
- }
- _constraints = [
- (_check_products,
- 'You have selected a product which is not in related Sale Order',
- ['product_id']),
- (_check_product_qty,
- 'The quanitties plannified in Deliveries must be equals to or less then the quantities in the Sale Order lines',
- ['product_qty'])]
-
-sale_delivery_line()
-
-
-class sale_order(osv.osv):
- _inherit = 'sale.order'
- _columns = {
- 'delivery_line': fields.one2many('sale.delivery.line', 'order_id', 'Delivery Lines', readonly=True, states={'draft':[('readonly',False)]}),
- }
-
- def action_ship_create(self, cr, uid, ids, *args):
-# picking_id=False
- picking = {}
- company = self.pool.get('res.users').browse(cr, uid, uid).company_id
- for order in self.browse(cr, uid, ids, context={}):
- output_id = order.shop_id.warehouse_id.lot_output_id.id
-# picking_id = False
-# if not order.delivery_line:
-# return super(sale_order, self).action_ship_create(cr, uid, ids)
- for line in order.delivery_line:
- cr.execute('select id from sale_order_line where order_id = %d and product_id = %d',(ids[0],line.product_id.id))
- sale_line_id = cr.fetchall()[0][0]
- sale_line = self.pool.get('sale.order.line').browse(cr, uid, sale_line_id)
- proc_id=False
- date_planned = line.date_planned
-# date_planned = (date_planned - DateTime.RelativeDateTime(days=company.security_lead)).strftime('%Y-%m-%d %H:%M:%S')
-# if line.state == 'done':
-# continue
- if line.product_id and line.product_id.product_tmpl_id.type in ('product', 'consu'):
- location_id = order.shop_id.warehouse_id.lot_stock_id.id
-# if not picking_id:
- if not date_planned in picking:
- loc_dest_id = order.partner_id.property_stock_customer.id
- picking_id = self.pool.get('stock.picking').create(cr, uid, {
- 'origin': order.name,
- 'type': 'out',
- 'state': 'confirmed',
- 'move_type': order.picking_policy,
- 'sale_id': order.id,
- 'address_id': order.partner_shipping_id.id,
- 'note': order.note,
- 'invoice_state': (order.order_policy=='picking' and '2binvoiced') or 'none',
- })
- picking[date_planned] = picking_id
-
- else:
- picking_id = picking[date_planned]
-
- move_id = self.pool.get('stock.move').create(cr, uid, {
- 'name': line.product_id.name[:64],
- 'picking_id': picking_id,
- 'product_id': line.product_id.id,
- 'date_planned': date_planned,
- 'product_qty': line.product_qty,
- 'product_uom': line.product_uom.id,
- 'product_uos_qty': line.product_qty,
- 'product_uos': line.product_uom.id,
- 'product_packaging' : line.packaging_id.id,
- 'address_id' : order.partner_shipping_id.id,
- 'location_id': location_id,
- 'location_dest_id': output_id,
- 'tracking_id': False,
- 'state': 'waiting',
- 'note': line.note,
- })
- proc_id = self.pool.get('mrp.procurement').create(cr, uid, {
- 'name': order.name,
- 'origin': order.name,
- 'date_planned': date_planned,
- 'product_id': line.product_id.id,
- 'product_qty': line.product_qty,
- 'product_uom': line.product_uom.id,
- 'product_uos_qty': line.product_qty,
- 'product_uos': line.product_uom.id,
- 'location_id': order.shop_id.warehouse_id.lot_stock_id.id,
- 'procure_method': sale_line.type,
- 'move_id': move_id,
- 'property_ids': [(6, 0, [x.id for x in sale_line.property_ids])],
- })
- wf_service = netsvc.LocalService("workflow")
- wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
-# self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id})
- elif line.product_id and line.product_id.product_tmpl_id.type=='service':
- proc_id = self.pool.get('mrp.procurement').create(cr, uid, {
- 'name': line.name,
- 'origin': order.name,
- 'date_planned': date_planned,
- 'product_id': line.product_id.id,
- 'product_qty': line.product_uom_qty,
- 'product_uom': line.product_uom.id,
- 'location_id': order.shop_id.warehouse_id.lot_stock_id.id,
- 'procure_method': line.type,
- 'property_ids': [(6, 0, [x.id for x in line.property_ids])],
- })
- wf_service = netsvc.LocalService("workflow")
- wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
-# self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id})
- else:
- #
- # No procurement because no product in the sale.order.line.
- #
- pass
- wf_service = netsvc.LocalService("workflow")
- wf_service.trg_validate(uid, 'stock.picking', picking['date_planned'], 'button_confirm', cr)
-
- val = {}
-# if 'date_planned' in picking and picking['date_planned']:
-# print
-
- if order.state=='shipping_except':
- val['state'] = 'progress'
- if (order.order_policy == 'manual') and order.invoice_ids:
- val['state'] = 'manual'
- self.write(cr, uid, [order.id], val)
-
- return True
-sale_order()
-
-class sale_order_line(osv.osv):
- _inherit = 'sale.order.line'
-
- def _get_planned_deliveries(self, cr, uid, ids, field_name, arg, context):
- res = {}
- for val in self.browse(cr, uid, ids):
- cr.execute('select sum(product_qty) from sale_delivery_line where order_id = %d and product_id = %d',(val.order_id,val.product_id))
- product_qty = cr.fetchall()[0][0]
- res[val.id] = product_qty
- return res
-
- _columns = {
- 'deliveries': fields.function(_get_planned_deliveries, method=True, string='Planned Deliveries'),
- }
-
-sale_order_line()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/sale_delivery/sale_delivery_view.xml b/addons/sale_delivery/sale_delivery_view.xml
deleted file mode 100644
index f5372876dff..00000000000
--- a/addons/sale_delivery/sale_delivery_view.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-
-
- sale.delivery.form.inherit
- sale.order
- form
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- sale.order.line.form1
- sale.order.line
- tree
-
-
-
-
-
-
-
-
-
-
- sale.delivery.form.inherit1
- sale.order
- form
-
-
-
-
-
-
-
-
-
-