REPORT_INTRASTAT: new module

bzr revid: ced-f1486bd96027b4314ee821f415892f81299e9290
This commit is contained in:
ced 2007-01-18 15:11:04 +00:00
parent da259d631c
commit b50b4f02a6
5 changed files with 302 additions and 0 deletions

View File

@ -0,0 +1,30 @@
##############################################################################
#
# Copyright (c) 2004-2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id: __init__.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.
#
##############################################################################
import report_intrastat

View File

@ -0,0 +1,14 @@
{
"name" : "Intrastat Reporting - Reporting",
"version" : "1.0",
"author" : "Tiny",
"website" : "http://tinyerp.com",
"depends" : ["base", "product", "stock", "sale", "purchase"],
"category" : "Generic Modules/Inventory Control",
"description": "A module that adds intrastat reports.",
"init_xml" : ["report_intrastat_data.xml",],
"demo_xml" : [],
"update_xml" : ["report_intrastat_view.xml",],
"active": False,
"installable": True
}

View File

@ -0,0 +1,106 @@
##############################################################################
#
# Copyright (c) 2004-2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id: __init__.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 osv, fields
class res_country(osv.osv):
_name = 'res.country'
_inherit = 'res.country'
_columns = {
'intrastat': fields.boolean('Intrastat member'),
}
_defaults = {
'intrastat': lambda *a: False,
}
res_country()
class product_template(osv.osv):
_name = "product.template"
_inherit = "product.template"
_columns = {
'intrastat': fields.char('Intrastat code', size=16),
}
product_template()
class report_intrastat(osv.osv):
_name = "report.intrastat"
_description = "Intrastat report"
_auto = False
_columns = {
'name': fields.date('Month', readonly=True),
'code': fields.char('Country code', size="2", readonly=True),
'intrastat': fields.char('Intratstat number', size=16, readonly=True),
'weight': fields.float('Weight', readonly=True),
'value': fields.float('Value', readonly=True),
'type': fields.selection([('import', 'Import'), ('export', 'Export')], 'Type')
}
def init(self, cr):
cr.execute("""
create or replace view report_intrastat as (
select
substring(m.create_date for 7)||'-01' as name,
min(m.id) as id,
pt.intrastat as intrastat,
case when l.usage in ('supplier', 'customer') then pc.code else c.code end as code,
sum(case when pol.price_unit is not null
then pol.price_unit * m.product_qty
else
case when sol.price_unit is not null
then sol.price_unit * m.product_qty
else pt.standard_price * m.product_qty
end
end) as value,
sum(pt.weight_net * m.product_qty) as weight,
case when l.usage in ('supplier', 'customer') then 'import' else 'export' end as type
from
stock_move m
left join (product_template pt
left join product_product pp on (pp.product_tmpl_id = pt.id))
on (m.product_id = pt.id)
left join (res_partner_address a
left join res_country c on (c.id = a.country_id))
on (a.id = m.address_id)
left join (stock_picking sp
left join (res_partner_address pa
left join res_country pc on (pc.id = pa.country_id))
on (pa.id = sp.address_id))
on (sp.id = m.picking_id)
left join stock_location l on (l.id = m.location_id)
left join stock_location dl on (dl.id = m.location_dest_id)
left join purchase_order_line pol on (pol.id = m.purchase_line_id)
left join sale_order_line sol on (sol.id = m.sale_line_id)
where
m.state != 'draft'
and ((l.usage in ('supplier', 'customer') and dl.usage not in ('supplier', 'customer'))
or (dl.usage in ('supplier', 'customer') and l.usage not in ('supplier', 'customer')))
and (c.intrastat is not null or pc.intrastat is not null)
group by substring(m.create_date for 7), pt.intrastat, c.code, pc.code, l.usage, dl.usage
)""")
report_intrastat()

View File

@ -0,0 +1,77 @@
<?xml version="1.0"?>
<terp>
<data noupdate="1">
<record model="res.country" id="base.de">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.at">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.cy">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.dk">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.es">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.ee">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.fi">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.fr">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.gr">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.hu">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.ie">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.it">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.lv">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.lt">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.lu">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.mt">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.nl">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.pl">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.pt">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.sk">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.cz">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.gb">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.si">
<field name="intrastat" eval="True"/>
</record>
<record model="res.country" id="base.se">
<field name="intrastat" eval="True"/>
</record>
</data>
</terp>

View File

@ -0,0 +1,75 @@
<?xml version="1.0"?>
<terp>
<data>
<!-- Country -->
<record model="ir.ui.view" id="view_country_tree">
<field name="name">res.country.tree</field>
<field name="model">res.country</field>
<field name="inherit_id" ref="base.view_country_tree"/>
<field name="arch" type="xml">
<field name="code" position="after">
<field name="intrastat"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_country_form">
<field name="name">res.country.form</field>
<field name="model">res.country</field>
<field name="inherit_id" ref="base.view_country_form"/>
<field name="arch" type="xml">
<field name="code" position="after">
<field name="intrastat" select="1"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="product_normal_form_view">
<field name="name">product.normal.form</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<field name="product_manager" position="after">
<field name="intrastat"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_report_intrastat_tree">
<field name="name">report.intrastat.view</field>
<field name="model">report.intrastat</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Intrastat Data">
<field name="name"/>
<field name="code"/>
<field name="intrastat"/>
<field name="weight"/>
<field name="value"/>
<field name="type"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_intrastat_tree">
<field name="name">report.intrastat</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">report.intrastat</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="domain">[('name','=',time.strftime('%Y-%m-01'))]</field>
</record>
<menuitem name="Inventory Control/Reporting/This Month/Intrastat" action="action_report_intrastat_tree" id="menu_report_intrastat"/>
<record model="ir.actions.act_window" id="action_report_intrastat_tree_all">
<field name="name">report.intrastat</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">report.intrastat</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
</record>
<menuitem name="Inventory Control/Reporting/All Months/Intrastat" action="action_report_intrastat_tree_all" id="menu_report_intrastat_all"/>
</data>
</terp>