savoirfairelinux-openerp team mailing list archive
-
savoirfairelinux-openerp team
-
Mailing list archive
-
Message #01249
[Merge] lp:~savoirfairelinux-openerp/purchase-wkfl/purchase_profit_forecast into lp:purchase-wkfl
Maxime Chambreuil (http://www.savoirfairelinux.com) has proposed merging lp:~savoirfairelinux-openerp/purchase-wkfl/purchase_profit_forecast into lp:purchase-wkfl.
Commit message:
[ADD] Add purchase profit forecast
Requested reviews:
Purchase Core Editors (purchase-core-editors)
For more details, see:
https://code.launchpad.net/~savoirfairelinux-openerp/purchase-wkfl/purchase_profit_forecast/+merge/216326
[ADD] Add purchase profit forecast
--
https://code.launchpad.net/~savoirfairelinux-openerp/purchase-wkfl/purchase_profit_forecast/+merge/216326
Your team Savoir-faire Linux' OpenERP is subscribed to branch lp:~savoirfairelinux-openerp/purchase-wkfl/purchase_profit_forecast.
=== added directory 'purchase_profit_forecast'
=== added file 'purchase_profit_forecast/__init__.py'
--- purchase_profit_forecast/__init__.py 1970-01-01 00:00:00 +0000
+++ purchase_profit_forecast/__init__.py 2014-04-17 13:53:57 +0000
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2010-2013 Savoir-faire Linux. All Rights Reserved.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import report
=== added file 'purchase_profit_forecast/__openerp__.py'
--- purchase_profit_forecast/__openerp__.py 1970-01-01 00:00:00 +0000
+++ purchase_profit_forecast/__openerp__.py 2014-04-17 13:53:57 +0000
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2010-2013 Savoir-faire Linux. All Rights Reserved.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+ 'name': 'Purchase profit forecast',
+ 'version': '1.1',
+ 'category': 'Finance',
+ 'description': """
+ """,
+ 'author': 'Savoir-faire Linux',
+ 'website': 'http://www.savoirfairelinux.com/',
+ 'depends': ['account', 'purchase'],
+ 'data': [
+ 'report/purchase_profit_view.xml',
+ ],
+ 'test': [
+ ],
+ 'demo': [],
+ 'installable': True,
+ 'active': False,
+ 'certificate': False,
+}
=== added directory 'purchase_profit_forecast/report'
=== added file 'purchase_profit_forecast/report/__init__.py'
--- purchase_profit_forecast/report/__init__.py 1970-01-01 00:00:00 +0000
+++ purchase_profit_forecast/report/__init__.py 2014-04-17 13:53:57 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2010-2013 Savoir-faire Linux. All Rights Reserved.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+from . import purchase
+from . import analytic
=== added file 'purchase_profit_forecast/report/analytic.py'
--- purchase_profit_forecast/report/analytic.py 1970-01-01 00:00:00 +0000
+++ purchase_profit_forecast/report/analytic.py 2014-04-17 13:53:57 +0000
@@ -0,0 +1,22 @@
+from openerp.osv import orm, fields
+
+class account_analytic_line(orm.Model):
+
+ _inherit = 'account.analytic.line'
+
+ def reference_po(self, cr, uid, ids, name, arg, context=None):
+
+ res = {}
+ for line in self.pool.get('account.analytic.line').browse(cr, uid, ids):
+
+ res[line.id] = line.account_id.purchase_order.name
+
+ return res
+
+ _columns = {
+ 'reference_po': fields.function(reference_po,
+ string='Reference PO',
+ type='char',
+ size=64,
+ store=True),
+ }
=== added file 'purchase_profit_forecast/report/purchase.py'
--- purchase_profit_forecast/report/purchase.py 1970-01-01 00:00:00 +0000
+++ purchase_profit_forecast/report/purchase.py 2014-04-17 13:53:57 +0000
@@ -0,0 +1,54 @@
+from openerp.osv import orm, fields
+from datetime import datetime, timedelta
+
+class purchase_profit(orm.Model):
+ _name = "purchase.profit"
+ _description = "Purchase Profit"
+ _auto = False
+ _log_access = True
+
+ _columns = {
+ 'lot': fields.char('Lot', size=10),
+ 'purchase': fields.char('Purchase', size=10),
+ 'purchase landed costs': fields.char('Purchase Landed cost', size=10),
+ 'sales landed costs': fields.char('Sales Landed Costs', size=10),
+ 'refund': fields.char('Refund', size=10),
+ 'sale': fields.char('Sale', size=10),
+ 'balance': fields.char('Balance', size=10),
+ }
+
+
+class purchase_profit_config(orm.TransientModel):
+
+ _name = "purchase.profit.config"
+ _description = "Purchase Profit"
+
+ _columns = {
+ 'start_date': fields.datetime('Start date'),
+ 'end_date': fields.datetime('End date')
+ }
+
+ _defaults = {
+ 'start_date': lambda *a: datetime.now().strftime('%Y-%m-%d'),
+ 'end_date': lambda *a: (
+ datetime.now() + timedelta(days=14)).strftime("%Y-%m-%d")
+ }
+
+
+ def purchase_profit_open_window(self, cr, uid, ids, context=None):
+ mod_obj = self.pool.get('ir.model.data')
+ act_obj = self.pool.get('ir.actions.act_window')
+ result_context = {}
+
+ if context is None:
+ context = {}
+
+ result = mod_obj.get_object_reference(
+ cr, uid, 'purchase_profit_forecast', 'action_purchase_profit')
+
+ id = result and result[1] or False
+
+ result = act_obj.read(cr, uid, [id], context=context)[0]
+ result['context'] = context
+ return result
+
=== added file 'purchase_profit_forecast/report/purchase_profit_view.xml'
--- purchase_profit_forecast/report/purchase_profit_view.xml 1970-01-01 00:00:00 +0000
+++ purchase_profit_forecast/report/purchase_profit_view.xml 2014-04-17 13:53:57 +0000
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record id="purchase_profit_analytic" model="ir.ui.view">
+ <field name="name">Purchase profit</field>
+ <field name="model">account.analytic.line</field>
+ <field name="inherit_id" ref="account.view_account_analytic_line_tree" />
+ <field name="arch" type="xml">
+ <field name="account_id" position="before">
+ <field name="reference_po" />
+ </field>
+ </field>
+ </record>
+
+ <record id="purchase_profit_analytic_filter" model="ir.ui.view">
+ <field name="inherit_id" ref="account.view_account_analytic_line_filter" />
+ <field name="model">account.analytic.line</field>
+ <field name="arch" type="xml">
+
+ <xpath expr="//filter[@string='Analytic Account']"
+ position="after">
+ <filter string="Reference PO" domain="[]" context="{'group_by':'reference_po'}"/>
+
+ </xpath>
+ </field>
+ </record>
+
+
+
+ <!-- Report view -->
+ <record id="purchase_profit_form" model="ir.ui.view">
+ <field eval="1" name="priority"/>
+ <field name="name">purchase.profit.form</field>
+ <field name="model">purchase.profit</field>
+ <field name="arch" type="xml">
+ <tree string="Stock Forecast" create="false">
+ <field name="lot" />
+ </tree>
+ </field>
+ </record>
+
+ <!-- Wizard view -->
+ <record id="purchase_profit_config_form" model="ir.ui.view">
+ <field eval="1" name="priority" />
+ <field name="name">purchase.profit.config.form</field>
+ <field name="model">purchase.profit.config</field>
+ <field name="arch" type="xml">
+ <form string="Model" version="7.0">
+ <group string="Purchase Profit">
+ <field name="start_date" />
+ <field name="end_date" />
+ </group>
+ <footer>
+ <button name="purchase_profit_open_window" string="Open" type="object" class="oe_highlight"/>
+ or
+ <button string="Cancel" class="oe_link" special="cancel"/>
+ </footer>
+ </form>
+ </field>
+ </record>
+
+ <!-- Wizard action -->
+ <record id="action_purchase_profit_config" model="ir.actions.act_window">
+ <field name="name">Purchase Profit</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">purchase.profit.config</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">tree,form</field>
+ <field name="view_id" ref="purchase_profit_config_form"/>
+ <field name="target">new</field>
+ </record>
+
+ <!-- Action to open the report -->
+ <record id="action_purchase_profit" model="ir.actions.act_window">
+ <field name="name">Purchase Profit</field>
+ <field name="res_model">purchase.profit</field>
+ <field name="view_type">tree</field>
+ <field name="view_mode">tree</field>
+ <field name="view_id" ref="purchase_profit_form" />
+ </record>
+
+ <!-- Action placement -->
+ <menuitem action="action_purchase_profit_config"
+ id="menu_action_purchase_profit_config"
+ parent="stock.next_id_61" />
+
+ </data>
+</openerp>
Follow ups