diff --git a/addons/l10n_ch/__init__.py b/addons/l10n_ch/__init__.py index f30b73e7ed8..177c5068d65 100755 --- a/addons/l10n_ch/__init__.py +++ b/addons/l10n_ch/__init__.py @@ -25,3 +25,6 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## + +import bvr +import dta diff --git a/addons/l10n_ch/bvr/__init__.py b/addons/l10n_ch/bvr/__init__.py new file mode 100644 index 00000000000..450bd78cdfc --- /dev/null +++ b/addons/l10n_ch/bvr/__init__.py @@ -0,0 +1,29 @@ +############################################################################## +# +# Copyright (c) 2004 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 bvr diff --git a/addons/l10n_ch/bvr/bvr.py b/addons/l10n_ch/bvr/bvr.py new file mode 100644 index 00000000000..c375605fb2f --- /dev/null +++ b/addons/l10n_ch/bvr/bvr.py @@ -0,0 +1,58 @@ +############################################################################## +# +# 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 + +class account_invoice_bvr(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(account_invoice_bvr, self).__init__(cr, uid, name, context) + self.localcontext.update({ + 'time': time, + 'user':self.pool.get("res.users").browse(cr,uid,uid), + 'mod10r': self._mod10r, + }) + + def _mod10r(self,nbr): + """ + Input arg : account or invoice number + Output return: the same number completed with the recursive mod10 + key + """ + + codec=[0,9,4,6,8,2,7,1,3,5] + report = 0 + result="" + for chiffre in nbr: + + if not chiffre.isdigit(): + continue + + report = codec[ (int(chiffre) +report) % 10 ] + result += chiffre + return result + str((10-report) % 10) +report_sxw.report_sxw('report.l10n_ch.bvr', 'account.invoice', 'addons/l10n_ch_bvr/bvr/bvr.rml', parser=account_invoice_bvr) diff --git a/addons/l10n_ch/bvr/bvr.rml b/addons/l10n_ch/bvr/bvr.rml new file mode 100644 index 00000000000..82bdc98eecb --- /dev/null +++ b/addons/l10n_ch/bvr/bvr.rml @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[ repeatIn(objects,'o') ]][[ setLang(o.partner_id.lang) ]] + Header of Document + + + + + + + + + + + + + + + + + + + + Versement pour : + Banque Cantonale Vaudoise + 1001 Lausanne + + + Versement pour : + Banque Cantonale Vaudoise + 1001 Lausanne + + + Motif : + + + + + + + + + + En faveur de : + ALCO SA + 1022 Chavanne-Lausanne + + + En faveur de : + ALCO SA + 1022 Chavanne-Lausanne + + + + + + + + + + + + + + + compte : [[mod10r(user.company_id.partner_id.bank_ids[0].iban) or '']] + + + compte : [[mod10r(user.company_id.partner_id.bank_ids[0].iban) or '']] + + + + + + + + + + + + + + + CHF [[ '%.2f' % o.amount_total ]] + + + CHF [[ '%.2f' % o.amount_total ]] + + + [[ mod10r(o.number).rjust(27,'0')]] + + + + + + + + + + Versé par + [[ o.partner_id.title or '' ]] [[ o.partner_id.name ]] + [[ o.address_invoice_id.zip or '' ]] [[ o.address_invoice_id.city or '' ]] + + + + + + + + Versé par + [[ o.partner_id.title or '' ]] [[ o.partner_id.name ]] + [[ o.address_invoice_id.zip or '' ]] [[ o.address_invoice_id.city or '' ]] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 01[[mod10r('%.2f' % o.amount_total).rjust(11,'0')]]> + + + [[ mod10r(o.number).rjust(27,'0')]]+ + + + [[mod10r(user.company_id.partner_id.bank_ids[0].iban)]]> + + + + + + + + + + + diff --git a/addons/l10n_ch/bvr/bvr_report.xml b/addons/l10n_ch/bvr/bvr_report.xml new file mode 100644 index 00000000000..82027a50dfd --- /dev/null +++ b/addons/l10n_ch/bvr/bvr_report.xml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/addons/l10n_ch/dta/__init__.py b/addons/l10n_ch/dta/__init__.py new file mode 100755 index 00000000000..bfa4e78022e --- /dev/null +++ b/addons/l10n_ch/dta/__init__.py @@ -0,0 +1,28 @@ +############################################################################## +# +# Copyright (c) 2004 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. +# +############################################################################## + diff --git a/addons/purchase_journal/__init__.py b/addons/purchase_journal/__init__.py new file mode 100644 index 00000000000..8886aa9e20e --- /dev/null +++ b/addons/purchase_journal/__init__.py @@ -0,0 +1,31 @@ +############################################################################## +# +# Copyright (c) 2004 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 purchase_journal +import purchase_journal_inherit +import purchase_journal_report diff --git a/addons/purchase_journal/__terp__.py b/addons/purchase_journal/__terp__.py new file mode 100644 index 00000000000..c09dbdad30d --- /dev/null +++ b/addons/purchase_journal/__terp__.py @@ -0,0 +1,16 @@ +# +# Use the custom module to put your specific code in a separate module. +# +{ + "name" : "Managing sales and deliveries by journal", + "version" : "1.0", + "author" : "Tiny", + "category" : "Generic Modules/Sales & Purchases", + "website": "http://www.tinyerp.com", + "depends" : ["stock","purchase"], + "demo_xml" : ['purchase_journal_demo.xml'], + "init_xml" : ['purchase_journal_data.xml'], + "update_xml" : ["purchase_journal_view.xml"], + "active": False, + "installable": True +} diff --git a/addons/purchase_journal/purchase_journal.py b/addons/purchase_journal/purchase_journal.py new file mode 100644 index 00000000000..c5feed4f2f1 --- /dev/null +++ b/addons/purchase_journal/purchase_journal.py @@ -0,0 +1,82 @@ +############################################################################## +# +# Copyright (c) 2004 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. +# +############################################################################## + +from osv import osv, fields +import netsvc +import time + +class purchase_journal(osv.osv): + _name = 'purchase_journal.purchase.journal' + _description = 'purchase Journal' + _columns = { + 'name': fields.char('Journal', size=64, required=True), + 'code': fields.char('Code', size=16, required=True), + 'user_id': fields.many2one('res.users', 'Responsible', required=True), + 'date': fields.date('Journal date', required=True), + 'date_created': fields.date('Creation date', readonly=True, required=True), + 'date_validation': fields.date('Validation date', readonly=True), + 'purchase_stats_ids': fields.one2many("purchase_journal.purchase.stats", "journal_id", 'purchase Stats', readonly=True), + 'state': fields.selection([ + ('draft','Draft'), + ('open','Open'), + ('done','Done'), + ], 'Creation date', required=True), + 'note': fields.text('Note'), + } + _defaults = { + 'date': lambda *a: time.strftime('%Y-%m-%d'), + 'date_created': lambda *a: time.strftime('%Y-%m-%d'), + 'user_id': lambda self,cr,uid,context: uid, + 'state': lambda self,cr,uid,context: 'draft', + } + def button_purchase_cancel(self, cr, uid, ids, context={}): + for id in ids: + purchase_ids = self.pool.get('purchase.order').search(cr, uid, [('journal_id','=',id),('state','=','draft')]) + for purchaseid in purchase_ids: + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'purchase.order', purchaseid, 'cancel', cr) + return True + def button_purchase_confirm(self, cr, uid, ids, context={}): + for id in ids: + purchase_ids = self.pool.get('purchase.order').search(cr, uid, [('journal_id','=',id),('state','=','draft')]) + for purchaseid in purchase_ids: + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'purchase.order', purchaseid, 'order_confirm', cr) + return True + + def button_open(self, cr, uid, ids, context={}): + self.write(cr, uid, ids, {'state':'open'}) + return True + def button_draft(self, cr, uid, ids, context={}): + self.write(cr, uid, ids, {'state':'draft'}) + return True + def button_close(self, cr, uid, ids, context={}): + self.write(cr, uid, ids, {'state':'done', 'date_validation':time.strftime('%Y-%m-%d')}) + return True +purchase_journal() + diff --git a/addons/purchase_journal/purchase_journal_data.xml b/addons/purchase_journal/purchase_journal_data.xml new file mode 100644 index 00000000000..f60494d5328 --- /dev/null +++ b/addons/purchase_journal/purchase_journal_data.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/addons/purchase_journal/purchase_journal_demo.xml b/addons/purchase_journal/purchase_journal_demo.xml new file mode 100644 index 00000000000..98793851804 --- /dev/null +++ b/addons/purchase_journal/purchase_journal_demo.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/addons/purchase_journal/purchase_journal_inherit.py b/addons/purchase_journal/purchase_journal_inherit.py new file mode 100644 index 00000000000..49a6161ba85 --- /dev/null +++ b/addons/purchase_journal/purchase_journal_inherit.py @@ -0,0 +1,37 @@ +############################################################################## +# +# Copyright (c) 2004 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. +# +############################################################################## + +from osv import osv, fields + + +class purchase(osv.osv): + _inherit="purchase.order" + _columns = { + 'journal_id': fields.many2one('purchase_journal.purchase.journal', 'Journal', relate=True), + } +purchase() diff --git a/addons/purchase_journal/purchase_journal_report.py b/addons/purchase_journal/purchase_journal_report.py new file mode 100644 index 00000000000..358a7e5c0bd --- /dev/null +++ b/addons/purchase_journal/purchase_journal_report.py @@ -0,0 +1,74 @@ +############################################################################## +# +# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# $Id: purchase.py 1005 2005-07-25 08:41:42Z nicoe $ +# +# 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. +# +############################################################################## + +from osv import fields,osv + +class report_purchase_journal_purchase(osv.osv): + _name = "purchase_journal.purchase.stats" + _description = "purchases Orders by Journal" + _auto = False + _columns = { + 'name': fields.date('Month', readonly=True), + 'state': fields.selection([ + ('draft','Quotation'), + ('waiting_date','Waiting Schedule'), + ('manual','Manual in progress'), + ('progress','In progress'), + ('shipping_except','Shipping Exception'), + ('invoice_except','Invoice Exception'), + ('done','Done'), + ('cancel','Cancel') + ], 'Order State', readonly=True), + 'journal_id':fields.many2one('purchase_journal.purchase.journal', 'Journal', readonly=True, relate=True), + 'quantity': fields.float('Quantities', readonly=True), + 'price_total': fields.float('Total Price', readonly=True), + 'price_average': fields.float('Average Price', readonly=True), + 'count': fields.integer('# of Lines', readonly=True), + } + _order = 'journal_id,name desc,price_total desc' + def init(self, cr): + cr.execute(""" + create or replace view purchase_journal_purchase_stats as ( + select + min(l.id) as id, + substring(s.date_order for 7)||'-'||'01' as name, + s.state, + s.journal_id, + sum(l.product_qty) as quantity, + count(*), + sum(l.product_qty*l.price_unit) as price_total, + (sum(l.product_qty*l.price_unit)/sum(l.product_qty))::decimal(16,2) as price_average + from purchase_order s + right join purchase_order_line l on (s.id=l.order_id) + group by s.journal_id, substring(s.date_order for 7),s.state + ) + """) +report_purchase_journal_purchase() + + diff --git a/addons/purchase_journal/purchase_journal_view.xml b/addons/purchase_journal/purchase_journal_view.xml new file mode 100644 index 00000000000..94df7223766 --- /dev/null +++ b/addons/purchase_journal/purchase_journal_view.xml @@ -0,0 +1,196 @@ + + + + purchase_journal.purchase.journal.form + purchase_journal.purchase.journal + form + +
+ + + + + + + + + + + + +