purchase_journal: Add journals to purchases Add statistics on purchases of a journal New reporting menu for purchases Improvement in module l10n_ch: BVR print (still buggy) DTA generation (draft) bzr revid: pinky-b2c5bf783db58b9b6d12cc7f2a4b9decb1bdd6f3master
parent
24175f7863
commit
2f9a0fcc2b
@ -0,0 +1,29 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import bvr
|
@ -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)
|
@ -0,0 +1,205 @@
|
||||
<?xml version="1.0"?>
|
||||
<document filename="test.pdf">
|
||||
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
|
||||
<pageTemplate id="first">
|
||||
<frame id="Frame1" x1="33.0" y1="7" width="527.0" height="68.0"/>
|
||||
<frame id="first" x1="34.0" y1="28.0" width="527" height="786"/>
|
||||
</pageTemplate>
|
||||
</template>
|
||||
<stylesheet>
|
||||
<blockTableStyle id="Standard_Outline">
|
||||
<blockAlignment value="LEFT"/>
|
||||
<blockValign value="TOP"/>
|
||||
</blockTableStyle>
|
||||
<blockTableStyle id="Table1">
|
||||
<blockAlignment value="LEFT"/>
|
||||
<blockValign value="TOP"/>
|
||||
<lineStyle kind="GRID" colorName="black"/>
|
||||
</blockTableStyle>
|
||||
<initialize>
|
||||
<paraStyle name="all" alignment="justify"/>
|
||||
</initialize>
|
||||
<paraStyle name="P1" fontName="Courier-Bold" fontSize="12.0" leading="15" alignment="LEFT"/>
|
||||
<paraStyle name="P2" fontName="Courier" fontSize="9.0" leading="11" alignment="LEFT"/>
|
||||
<paraStyle name="P3" fontName="Courier" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="P4" fontName="Courier" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="P5" fontName="Courier" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="P6" fontName="Courier" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="P7" fontName="Courier-Bold" fontSize="12.0" leading="15" alignment="LEFT"/>
|
||||
<paraStyle name="P8" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="P9" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="P10" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Standard" fontName="Times-Roman"/>
|
||||
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Frame contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Index" fontName="Times-Roman"/>
|
||||
</stylesheet>
|
||||
<story>
|
||||
<para style="P8">[[ repeatIn(objects,'o') ]]<font face="Times-Roman">[[ setLang(o.partner_id.lang) ]]</font></para>
|
||||
<para style="P9">Header of Document</para>
|
||||
<para style="P9">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<para style="P9">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<para style="P9">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<para style="P10">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<currentFrame name="Frame1"/>
|
||||
<para style="P1">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<blockTable colWidths="126.0,135.0,167.0,90.0" style="Table1">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P2">Versement pour :</para>
|
||||
<para style="P2">Banque Cantonale Vaudoise</para>
|
||||
<para style="P2">1001 Lausanne</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P2">Versement pour :</para>
|
||||
<para style="P2">Banque Cantonale Vaudoise</para>
|
||||
<para style="P2">1001 Lausanne</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">Motif :</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P3">En faveur de :</para>
|
||||
<para style="P3">ALCO SA</para>
|
||||
<para style="P4">1022 Chavanne-Lausanne</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">En faveur de :</para>
|
||||
<para style="P3">ALCO SA</para>
|
||||
<para style="P3">1022 Chavanne-Lausanne</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P3">compte : <font face="Times-Roman">[[mod10r(user.company_id.partner_id.bank_ids[0].iban) or '']]</font></para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">compte : <font face="Times-Roman">[[mod10r(user.company_id.partner_id.bank_ids[0].iban) or '']]</font></para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P5">CHF [[ '%.2f' % o.amount_total ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P5">CHF [[ '%.2f' % o.amount_total ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P4">[[ mod10r(o.number).rjust(27,'0')]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P2">Versé par</para>
|
||||
<para style="P2">[[ o.partner_id.title or '' ]] [[ o.partner_id.name ]]</para>
|
||||
<para style="P2">[[ o.address_invoice_id.zip or '' ]] [[ o.address_invoice_id.city or '' ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P2">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">Versé par</para>
|
||||
<para style="P2">[[ o.partner_id.title or '' ]] [[ o.partner_id.name ]]</para>
|
||||
<para style="P3">[[ o.address_invoice_id.zip or '' ]] [[ o.address_invoice_id.city or '' ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P3">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P3">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P6">01<font face="Times-Roman">[[mod10r('%.2f' % o.amount_total).rjust(11,'0')]]></font></para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P4">[[ mod10r(o.number).rjust(27,'0')]]+</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P4">[[mod10r(user.company_id.partner_id.bank_ids[0].iban)]]></para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<para style="P7">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<frameEnd/>
|
||||
<pageBreak/>
|
||||
</story>
|
||||
</document>
|
||||
|
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<terp>
|
||||
<data>
|
||||
<report
|
||||
id="account_invoice_bvr"
|
||||
string="BVR report"
|
||||
model="account.invoice"
|
||||
name="l10n_ch.bvr"
|
||||
rml="l10n_ch_bvr/bvr/bvr.rml"
|
||||
auto="False"
|
||||
/>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
@ -0,0 +1,31 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import purchase_journal
|
||||
import purchase_journal_inherit
|
||||
import purchase_journal_report
|
@ -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
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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()
|
||||
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data noupdate="1">
|
||||
|
||||
|
||||
</data>
|
||||
</terp>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data noupdate="1">
|
||||
|
||||
</data>
|
||||
</terp>
|
@ -0,0 +1,37 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
# Fabien Pinckaers <fp@tiny.Be>
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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()
|
@ -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()
|
||||
|
||||
|
@ -0,0 +1,196 @@
|
||||
<terp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="view_purchase_journal_form">
|
||||
<field name="name">purchase_journal.purchase.journal.form</field>
|
||||
<field name="model">purchase_journal.purchase.journal</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="purchase Journal">
|
||||
<notebook>
|
||||
<page string="Journal">
|
||||
<separator string="Journal Information" colspan="4"/>
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="date" select="1"/>
|
||||
<field name="date_created" select="1"/>
|
||||
<field name="date_validation" select="1"/>
|
||||
<separator string="States" colspan="4"/>
|
||||
<field name="state"/>
|
||||
<group col="3" colspan="2">
|
||||
<button name="button_open" string="Open Journal" states="draft" type="object"/>
|
||||
<button name="button_close" string="Close Journal" states="open" type="object"/>
|
||||
<button name="button_draft" string="Set to Draft" states="close,open" type="object"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="purchases">
|
||||
<button string="Confirm purchases" name="button_purchase_confirm" states="draft,open" type="object"/>
|
||||
<button string="Cancel purchases" name="button_purchase_cancel" states="draft,open" type="object"/>
|
||||
<newline/>
|
||||
<field name="purchase_stats_ids" colspan="4" nolabel="1">
|
||||
<tree string="purchases">
|
||||
<field name="name"/>
|
||||
<field name="quantity"/>
|
||||
<field name="price_total"/>
|
||||
<field name="price_average"/>
|
||||
<field name="count"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page><page string="Notes">
|
||||
<field name="note" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_purchase_journal_tree">
|
||||
<field name="name">purchase_journal.purchase.journal.tree</field>
|
||||
<field name="model">purchase_journal.purchase.journal</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="purchase Journal">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="date" select="1"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_definition_journal">
|
||||
<field name="name">purchase_journal.purchase.journal.tree</field>
|
||||
<field name="res_model">purchase_journal.purchase.journal</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Purchase Management/Configuration/purchases Journals"
|
||||
id="menu_definition_journal"
|
||||
action="action_definition_journal"/>
|
||||
|
||||
|
||||
<record model="ir.actions.act_window" id="action_definition_journal_tree">
|
||||
<field name="name">purchase_journal.purchase.journal.tree</field>
|
||||
<field name="res_model">purchase_journal.purchase.journal</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[]</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Purchase Management/purchases by Journal"
|
||||
id="menu_definition_journal_purchases"
|
||||
action="action_definition_journal_tree"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_definition_journal_tree_my">
|
||||
<field name="name">purchase_journal.purchase.journal.tree.my</field>
|
||||
<field name="res_model">purchase_journal.purchase.journal</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('user_id','=',uid),('state','=','open')]</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Purchase Management/purchases by Journal/My open Journals"
|
||||
id="menu_definition_journal_purchases_my_open"
|
||||
action="action_definition_journal_tree_my"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_definition_journal_tree_all">
|
||||
<field name="name">purchase_journal.purchase.journal.tree.all</field>
|
||||
<field name="res_model">purchase_journal.purchase.journal</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('state','=','open')]</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Purchase Management/purchases by Journal/All open Journals"
|
||||
id="menu_definition_journal_purchases_all_open"
|
||||
action="action_definition_journal_tree_all"/>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="purchase_journal_purchase_order">
|
||||
<field name="name">purchase.order.journal.view.form</field>
|
||||
<field name="type">form</field>
|
||||
<field name="model">purchase.order</field>
|
||||
<field name="inherit_id" ref="purchase.purchase_order_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="client_order_ref" position="after">
|
||||
<field name="journal_id" select="1"/>
|
||||
<field name="invoice_type_id" select="1"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="purchase_journal_purchase_order_tree">
|
||||
<field name="name">purchase.order.journal.view.tree</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="model">purchase.order</field>
|
||||
<field name="inherit_id" ref="purchase.purchase_order_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="state" position="after">
|
||||
<field name="journal_id"/>
|
||||
<field name="invoice_type_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_purchase_journal_purchase_stats_tree">
|
||||
<field name="name">purchase_journal.purchase.stats.tree</field>
|
||||
<field name="model">purchase_journal.purchase.stats</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="purchases by Journal">
|
||||
<field name="name"/>
|
||||
<field name="state"/>
|
||||
<field name="journal_id"/>
|
||||
<field name="quantity"/>
|
||||
<field name="count"/>
|
||||
<field name="price_total"/>
|
||||
<field name="price_average"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_purchase_journal_purchase_stats_form">
|
||||
<field name="name">purchase_journal.purchase.stats.form</field>
|
||||
<field name="model">purchase_journal.purchase.stats</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="purchases by Journal">
|
||||
<field name="name" select="1"/>
|
||||
<field name="state" select="1"/>
|
||||
<field name="journal_id" select="1"/>
|
||||
<field name="quantity"/>
|
||||
<field name="count"/>
|
||||
<field name="price_total"/>
|
||||
<field name="price_average"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_purchase_purchase_stats_open_menu_month">
|
||||
<field name="name">purchase_journal.purchase.stats.open</field>
|
||||
<field name="res_model">purchase_journal.purchase.stats</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('name','=',time.strftime('%Y-%m-01'))]</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Purchase Management/Reporting/This Month/purchases by journal"
|
||||
action="action_purchase_purchase_stats_open_menu_month"
|
||||
id="menu_purchase_purchase_stats_open_menu"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_purchase_purchase_stats_open_menu_all">
|
||||
<field name="name">purchase_journal.purchase.stats.open</field>
|
||||
<field name="res_model">purchase_journal.purchase.stats</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Purchase Management/Reporting/All Months/purchases by journal"
|
||||
action="action_purchase_purchase_stats_open_menu_all"
|
||||
id="menu_purchase_purchase_stats_open_all"/>
|
||||
|
||||
|
||||
|
||||
</data>
|
||||
</terp>
|
Loading…
Reference in new issue