Merge lp:~ajite/purchase-wkfl/7.0-add-purchase_landed_costs_extended into lp:~purchase-core-editors/purchase-wkfl/7.0

Status: Work in progress
Proposed branch: lp:~ajite/purchase-wkfl/7.0-add-purchase_landed_costs_extended
Merge into: lp:~purchase-core-editors/purchase-wkfl/7.0
Diff against target: 1143 lines (+1082/-0)
11 files modified
purchase_landed_costs_extended/__init__.py (+24/-0)
purchase_landed_costs_extended/__openerp__.py (+39/-0)
purchase_landed_costs_extended/purchase.py (+167/-0)
purchase_landed_costs_extended/purchase_view.xml (+173/-0)
purchase_landed_costs_extended/report/__init__.py (+22/-0)
purchase_landed_costs_extended/report/purchase_report.py (+399/-0)
purchase_landed_costs_extended/report/purchase_report_view.xml (+144/-0)
purchase_landed_costs_extended/security/ir.model.access.csv (+3/-0)
purchase_landed_costs_extended/wizard/__init__.py (+22/-0)
purchase_landed_costs_extended/wizard/landed_cost_position_invoice.py (+57/-0)
purchase_landed_costs_extended/wizard/landed_cost_position_invoice_view.xml (+32/-0)
To merge this branch: bzr merge lp:~ajite/purchase-wkfl/7.0-add-purchase_landed_costs_extended
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Needs Resubmitting
Review via email: mp+223669@code.launchpad.net

Description of the change

Added a new module for landed costs to handle different currencies.
(SQL report is still in progress since it does not handle the multi currency)

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

This project is now hosted on https://github.com/OCA/purchase-workflow. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

review: Needs Resubmitting
Revision history for this message
Augustin Cisterne-Kaas - www.elico-corp.com (ajite) wrote :

> This project is now hosted on https://github.com/OCA/purchase-workflow. Please
> move your proposal there. This guide may help you https://github.com/OCA
> /maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

Thanks. It has been done :)!

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Please put here for reference the link to the PR.

Regards.

Revision history for this message
Augustin Cisterne-Kaas - www.elico-corp.com (ajite) wrote :

Unmerged revisions

38. By Augustin Cisterne-Kaas - www.elico-corp.com

[ADD] Purchase landed costs extended

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'purchase_landed_costs_extended'
2=== added file 'purchase_landed_costs_extended/__init__.py'
3--- purchase_landed_costs_extended/__init__.py 1970-01-01 00:00:00 +0000
4+++ purchase_landed_costs_extended/__init__.py 2014-06-19 02:41:00 +0000
5@@ -0,0 +1,24 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
11+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@elico-corp.com>
12+#
13+# This program is free software: you can redistribute it and/or modify
14+# it under the terms of the GNU Affero General Public License as
15+# published by the Free Software Foundation, either version 3 of the
16+# License, or (at your option) any later version.
17+#
18+# This program is distributed in the hope that it will be useful,
19+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+# GNU Affero General Public License for more details.
22+#
23+# You should have received a copy of the GNU Affero General Public License
24+# along with this program. If not, see <http://www.gnu.org/licenses/>.
25+#
26+##############################################################################
27+import purchase
28+import report
29+import wizard
30
31=== added file 'purchase_landed_costs_extended/__openerp__.py'
32--- purchase_landed_costs_extended/__openerp__.py 1970-01-01 00:00:00 +0000
33+++ purchase_landed_costs_extended/__openerp__.py 2014-06-19 02:41:00 +0000
34@@ -0,0 +1,39 @@
35+# -*- coding: utf-8 -*-
36+##############################################################################
37+#
38+# OpenERP, Open Source Management Solution
39+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
40+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@elico-corp.com>
41+#
42+# This program is free software: you can redistribute it and/or modify
43+# it under the terms of the GNU Affero General Public License as
44+# published by the Free Software Foundation, either version 3 of the
45+# License, or (at your option) any later version.
46+#
47+# This program is distributed in the hope that it will be useful,
48+# but WITHOUT ANY WARRANTY; without even the implied warranty of
49+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50+# GNU Affero General Public License for more details.
51+#
52+# You should have received a copy of the GNU Affero General Public License
53+# along with this program. If not, see <http://www.gnu.org/licenses/>.
54+#
55+##############################################################################
56+{'name': 'Purchase Landed Costs Extended',
57+ 'version': '0.1',
58+ 'category': 'Warehouse Management',
59+ 'depends': ['purchase_landed_costs'],
60+ 'author': 'Elico Corp',
61+ 'license': 'AGPL-3',
62+ 'website': 'https://www.elico-corp.com',
63+ 'description': """
64+
65+""",
66+ 'images': [],
67+ 'demo': [],
68+ 'data': ['purchase_view.xml',
69+ 'report/purchase_report_view.xml',
70+ 'wizard/landed_cost_position_invoice_view.xml',
71+ 'security/ir.model.access.csv'],
72+ 'installable': True,
73+ 'application': False}
74
75=== added file 'purchase_landed_costs_extended/purchase.py'
76--- purchase_landed_costs_extended/purchase.py 1970-01-01 00:00:00 +0000
77+++ purchase_landed_costs_extended/purchase.py 2014-06-19 02:41:00 +0000
78@@ -0,0 +1,167 @@
79+# -*- coding: utf-8 -*-
80+##############################################################################
81+#
82+# OpenERP, Open Source Management Solution
83+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
84+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@elico-corp.com>
85+#
86+# This program is free software: you can redistribute it and/or modify
87+# it under the terms of the GNU Affero General Public License as
88+# published by the Free Software Foundation, either version 3 of the
89+# License, or (at your option) any later version.
90+#
91+# This program is distributed in the hope that it will be useful,
92+# but WITHOUT ANY WARRANTY; without even the implied warranty of
93+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
94+# GNU Affero General Public License for more details.
95+#
96+# You should have received a copy of the GNU Affero General Public License
97+# along with this program. If not, see <http://www.gnu.org/licenses/>.
98+#
99+##############################################################################
100+from openerp.osv import orm, fields
101+import openerp.addons.decimal_precision as dp
102+
103+
104+class landed_cost_position(orm.Model):
105+ _inherit = 'landed.cost.position'
106+
107+ def onchange_partner_id(self, cr, uid, ids, partner_id, context=None):
108+ if not partner_id:
109+ return {}
110+ partner = self.pool.get('res.partner').browse(
111+ cr, uid, partner_id, context=context)
112+ pricelist = partner.property_product_pricelist_purchase
113+ return {'value': {'currency_id': pricelist.currency_id.id}}
114+
115+ def onchange_amount_currency(self, cr, uid, ids,
116+ amount_currency, currency_id,
117+ date_po, context=None):
118+ assert len(ids) < 2
119+ parent_currency_id = None
120+ if ids:
121+ landed_cost = self.browse(cr, uid, ids[0], context=context)
122+ parent_currency_id = landed_cost.po_currency_id.id
123+ else:
124+ parent_currency_id = self._default_currency(
125+ cr, uid, context=context)
126+ if not parent_currency_id or not amount_currency or not currency_id:
127+ return {}
128+ cur_obj = self.pool.get('res.currency')
129+ amount = amount_currency
130+ if currency_id != parent_currency_id:
131+ ctx = context.copy()
132+ ctx['date'] = date_po or False
133+ amount = cur_obj.compute(cr, uid,
134+ currency_id,
135+ parent_currency_id,
136+ amount,
137+ context=ctx)
138+ return {'value': {'amount': amount}}
139+
140+ def _default_currency(self, cr, uid, context=None):
141+ context = context or {}
142+ pricelist_id = context.get('pricelist_id', [])
143+ pricelist = self.pool.get('product.pricelist').read(
144+ cr, uid, pricelist_id, ['currency_id'])
145+ parent_currency_id = None
146+ if pricelist:
147+ parent_currency_id = pricelist['currency_id'][0]
148+ return parent_currency_id
149+
150+ _columns = {
151+ 'amount_currency': fields.float(
152+ 'Currency Amount',
153+ digits_compute=dp.get_precision('Purchase Price'),
154+ help="Landed cost expressed in Landed Cost line currency"),
155+ 'currency_id': fields.many2one(
156+ 'res.currency', 'Currency'),
157+ 'po_pricelist_id': fields.related(
158+ 'purchase_order_id', 'pricelist_id',
159+ type='many2one',
160+ relation='product.pricelist',
161+ string='PO Pricelist',
162+ store=True,
163+ readonly=True,
164+ help="PO pricelist"),
165+ 'po_currency_id': fields.related(
166+ 'po_pricelist_id', 'currency_id',
167+ type='many2one',
168+ relation='res.currency',
169+ string='PO Currency',
170+ store=True,
171+ readonly=True,
172+ help="PO Currency"),
173+ 'invoice_id': fields.many2one('account.invoice', 'Invoice'),
174+ 'active': fields.boolean('Active')
175+ }
176+
177+ _defaults = {
178+ 'currency_id': _default_currency,
179+ 'active': True
180+ }
181+
182+ def open_invoice(self, cr, uid, ids, context=None):
183+ assert len(ids) == 1
184+ lcp = self.browse(cr, uid, ids[0], context=context)
185+ if not lcp.invoice_id:
186+ return {}
187+ return {
188+ 'type': 'ir.actions.act_window',
189+ 'name': 'Form heading',
190+ 'view_mode': 'form',
191+ 'view_type': 'form',
192+ 'res_model': 'account.invoice',
193+ 'nodestroy': True,
194+ 'res_id': lcp.invoice_id.id,
195+ 'context': context
196+ }
197+
198+
199+class purchase_order(orm.Model):
200+ _inherit = 'purchase.order'
201+
202+ def _generate_invoice_from_landed_cost(self, cr, uid, landed_cost,
203+ context=None):
204+ if landed_cost.invoice_id:
205+ return landed_cost.invoice_id.id
206+ inv_id = super(
207+ purchase_order, self
208+ )._generate_invoice_from_landed_cost(
209+ cr, uid, landed_cost, context=context)
210+ landed_cost.write({'invoice_id': inv_id}, context=context)
211+ return inv_id
212+
213+ def _prepare_landed_cost_inv_line(self, cr, uid, account_id, inv_id,
214+ landed_cost, context=None):
215+ res = super(purchase_order, self)._prepare_landed_cost_inv_line(
216+ cr, uid, account_id, inv_id, landed_cost, context=context)
217+ res['price_unit'] = landed_cost.amount_currency
218+ return res
219+
220+ def _prepare_landed_cost_inv(self, cr, uid, landed_cost, context=None):
221+ res = super(purchase_order, self)._prepare_landed_cost_inv(
222+ cr, uid, landed_cost, context=context)
223+ res['currency_id'] = landed_cost.currency_id.id
224+ return res
225+
226+ def wkf_approve_order(self, cr, uid, ids, context=None):
227+ """ On PO approval, generate all invoices for all landed cost position.
228+
229+ Remember that only landed cost position with the checkbox
230+ generate_invoice ticked are generated.
231+
232+ """
233+ lcp_pool = self.pool.get('landed.cost.position')
234+ line_ids = []
235+ for order in self.browse(cr, uid, ids, context=context):
236+ for po_line in order.order_line:
237+ for line_cost in po_line.landed_cost_line_ids:
238+ if not line_cost.generate_invoice or line_cost.invoice_id:
239+ line_ids = line_cost.id
240+ lcp_pool.write(cr, uid, line_ids, {'active': False})
241+
242+ res = super(purchase_order, self).wkf_approve_order(cr, uid, ids,
243+ context=context)
244+ lcp_pool.write(cr, uid, line_ids, {'active': True})
245+ return res
246
247=== added file 'purchase_landed_costs_extended/purchase_view.xml'
248--- purchase_landed_costs_extended/purchase_view.xml 1970-01-01 00:00:00 +0000
249+++ purchase_landed_costs_extended/purchase_view.xml 2014-06-19 02:41:00 +0000
250@@ -0,0 +1,173 @@
251+<?xml version="1.0" encoding="UTF-8"?>
252+<openerp>
253+ <data>
254+
255+
256+
257+ <record id="purchase_order_form" model="ir.ui.view">
258+ <field name="name">purchase.order.form</field>
259+ <field name="model">purchase.order</field>
260+ <field name="inherit_id" ref="purchase_landed_costs.c2c_purchase_order_landed_cost_view" />
261+ <field name="arch" type="xml" >
262+ <field name="order_line" position="attributes">
263+ <attribute name="attrs">{'readonly': [('pricelist_id', '=', False)]}</attribute>
264+ <attribute name="context">{'pricelist_id': pricelist_id}</attribute>
265+ </field>
266+ <xpath expr="//field[@name='order_line']/tree" position="attributes">
267+ <attribute name="editable">False</attribute>
268+ </xpath>
269+ <field name="landed_cost_line_ids" position="attributes">
270+ <attribute name="attrs">{'readonly': [('pricelist_id', '=', False)]}</attribute>
271+ <attribute name="context">{'pricelist_id': pricelist_id}</attribute>
272+ </field>
273+ <xpath expr="//field[@name='landed_cost_line_ids']/tree/field[@name='amount']" position="before">
274+ <field
275+ name="amount_currency"
276+ on_change="onchange_amount_currency(amount_currency, currency_id, date_po, context)"
277+ />
278+ <field
279+ name="currency_id"
280+ on_change="onchange_amount_currency(amount_currency, currency_id, date_po, context)"
281+ />
282+ </xpath>
283+ <xpath expr="//field[@name='landed_cost_line_ids']/tree/field[@name='amount']" position="after">
284+ <field name="invoice_id" readonly="True" />
285+ <button name="open_invoice" type="object" attrs="{'invisible': [('invoice_id', '=', False)]}" string="Invoice" icon="gtk-open" />
286+
287+ <field name="date_po" invisible="True" />
288+ </xpath>
289+
290+ <xpath expr="//field[@name='landed_cost_line_ids']/tree/field[@name='partner_id']" position="attributes">
291+ <attribute name="on_change">onchange_partner_id(partner_id)</attribute>
292+ </xpath>
293+ </field>
294+ </record>
295+
296+ <record id="purchase_order_line_form" model="ir.ui.view">
297+ <field name="name">purchase.order.line.form</field>
298+ <field name="model">purchase.order.line</field>
299+ <field name="inherit_id" ref="purchase_landed_costs.purchase_oder_line_landed_cost_view" />
300+ <field name="arch" type="xml" >
301+ <field name="product_id" position="attributes">
302+ <attribute name="attrs">{'readonly': [('state', '!=', 'draft')]}</attribute>
303+ </field>
304+ <field name="product_qty" position="attributes">
305+ <attribute name="attrs">{'readonly': [('state', '!=', 'draft')]}</attribute>
306+ </field>
307+ <field name="price_unit" position="attributes">
308+ <attribute name="attrs">{'readonly': [('state', '!=', 'draft')]}</attribute>
309+ </field>
310+ <field name="taxes_id" position="attributes">
311+ <attribute name="attrs">{'readonly': [('state', '!=', 'draft')]}</attribute>
312+ </field>
313+ <field name="date_planned" position="attributes">
314+ <attribute name="attrs">{'readonly': [('state', '!=', 'draft')]}</attribute>
315+ </field>
316+ <field name="name" position="attributes">
317+ <attribute name="attrs">{'readonly': [('state', '!=', 'draft')]}</attribute>
318+ </field>
319+ <field name="product_id" position="after">
320+ <field name="state" invisible="True" />
321+ </field>
322+ <field name="landed_cost_line_ids" position="attributes">
323+ <attribute name="context">{'pricelist_id': context['pricelist_id']}</attribute>
324+ </field>
325+ </field>
326+ </record>
327+
328+ <record model="ir.ui.view" id="c2c_landed_cost_tree">
329+ <field name="name">c2clanded.cost.tree</field>
330+ <field name="model">landed.cost.position</field>
331+ <field name="inherit_id" ref="purchase_landed_costs.c2c_landed_cost_tree" />
332+ <field name="arch" type="xml">
333+ <field name="partner_id" position="attributes">
334+ <attribute name="on_change">onchange_partner_id(partner_id)</attribute>
335+ </field>
336+ <field name="amount" position="before">
337+ <field
338+ name="amount_currency"
339+ on_change="onchange_amount_currency(amount_currency, currency_id, date_po, context)"
340+ />
341+ <field
342+ name="currency_id"
343+ on_change="onchange_amount_currency(amount_currency, currency_id, date_po, context)"
344+ />
345+ </field>
346+ <field name="amount" position="after">
347+ <field name="invoice_id" readonly="True" />
348+ <button name="open_invoice" type="object" attrs="{'invisible': [('invoice_id', '=', False)]}" string="Invoice" icon="gtk-open" />
349+ <field name="date_po" invisible="True" />
350+ </field>
351+ </field>
352+ </record>
353+
354+ <record model="ir.ui.view" id="c2c_landed_cost_form">
355+ <field name="name">c2clanded.cost.form</field>
356+ <field name="model">landed.cost.position</field>
357+ <field name="inherit_id" ref="purchase_landed_costs.c2c_landed_cost_form" />
358+ <field name="arch" type="xml">
359+ <field name="partner_id" position="attributes">
360+ <attribute name="on_change">onchange_partner_id(partner_id)</attribute>
361+ </field>
362+ <field name="amount" position="before">
363+ <field
364+ name="amount_currency"
365+ on_change="onchange_amount_currency(amount_currency, currency_id, date_po, context)"
366+ />
367+ <field
368+ name="currency_id"
369+ on_change="onchange_amount_currency(amount_currency, currency_id, date_po, context)"
370+ />
371+ </field>
372+ <field name="amount" position="after">
373+ <field name="invoice_id" readonly="True" />
374+ <button name="open_invoice" type="object" attrs="{'invisible': [('invoice_id', '=', False)]}" string="Invoice" icon="gtk-open" />
375+ <field name="date_po" invisible="True" />
376+ </field>
377+ </field>
378+ </record>
379+
380+
381+
382+ <record model="ir.ui.view" id="landed_cost_tree">
383+ <field name="name">landed.cost.tree</field>
384+ <field name="model">landed.cost.position</field>
385+ <field name="priority">50</field>
386+ <field name="type">tree</field>
387+ <field name="arch" type="xml">
388+ <tree string="Landing Costs" editable="bottom" create="false">
389+ <field name="purchase_order_id"/>
390+ <field name="generate_invoice"/>
391+ <field name="product_id" context="{'landed_cost_type':'per_unit'}" on_change="onchange_product_id(product_id)"/>
392+ <field name="account_id" invisible="1"/>
393+ <field name="partner_id" on_change="onchange_partner_id(partner_id)" />
394+ <field
395+ name="amount_currency"
396+ on_change="onchange_amount_currency(amount_currency, currency_id, date_po, context)"
397+ />
398+ <field
399+ name="currency_id"
400+ on_change="onchange_amount_currency(amount_currency, currency_id, date_po, context)"
401+ />
402+ <field name="amount"/>
403+ <field name="po_currency_id"/>
404+ <field name="distribution_type_id" domain="[('apply_on','=','line')]" widget="selection"/>
405+ <field name="invoice_id" readonly="True" />
406+ <button name="open_invoice" type="object" attrs="{'invisible': [('invoice_id', '=', False)]}" string="Invoice" icon="gtk-open" />
407+ <field name="date_po" invisible="True" />
408+ </tree>
409+ </field>
410+ </record>
411+
412+
413+ <record id="po_landed_costs_extended" model="ir.actions.act_window">
414+ <field name="name">Landed Costs</field>
415+ <field name="res_model">landed.cost.position</field>
416+ <field name="view_type">form</field>
417+ <field name="view_mode">tree,form</field>
418+ <field name="view_id" ref="landed_cost_tree"></field>
419+ </record>
420+
421+ <menuitem action="po_landed_costs_extended" id="menu_action_landed_cost" parent="purchase.menu_procurement_management_invoice" sequence="100"/>
422+ </data>
423+</openerp>
424
425=== added directory 'purchase_landed_costs_extended/report'
426=== added file 'purchase_landed_costs_extended/report/__init__.py'
427--- purchase_landed_costs_extended/report/__init__.py 1970-01-01 00:00:00 +0000
428+++ purchase_landed_costs_extended/report/__init__.py 2014-06-19 02:41:00 +0000
429@@ -0,0 +1,22 @@
430+# -*- coding: utf-8 -*-
431+##############################################################################
432+#
433+# OpenERP, Open Source Management Solution
434+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
435+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@elico-corp.com>
436+#
437+# This program is free software: you can redistribute it and/or modify
438+# it under the terms of the GNU Affero General Public License as
439+# published by the Free Software Foundation, either version 3 of the
440+# License, or (at your option) any later version.
441+#
442+# This program is distributed in the hope that it will be useful,
443+# but WITHOUT ANY WARRANTY; without even the implied warranty of
444+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
445+# GNU Affero General Public License for more details.
446+#
447+# You should have received a copy of the GNU Affero General Public License
448+# along with this program. If not, see <http://www.gnu.org/licenses/>.
449+#
450+##############################################################################
451+import purchase_report
452
453=== added file 'purchase_landed_costs_extended/report/purchase_report.py'
454--- purchase_landed_costs_extended/report/purchase_report.py 1970-01-01 00:00:00 +0000
455+++ purchase_landed_costs_extended/report/purchase_report.py 2014-06-19 02:41:00 +0000
456@@ -0,0 +1,399 @@
457+# -*- coding: utf-8 -*-
458+##############################################################################
459+#
460+# OpenERP, Open Source Management Solution
461+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
462+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@elico-corp.com>
463+#
464+# This program is free software: you can redistribute it and/or modify
465+# it under the terms of the GNU Affero General Public License as
466+# published by the Free Software Foundation, either version 3 of the
467+# License, or (at your option) any later version.
468+#
469+# This program is distributed in the hope that it will be useful,
470+# but WITHOUT ANY WARRANTY; without even the implied warranty of
471+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
472+# GNU Affero General Public License for more details.
473+#
474+# You should have received a copy of the GNU Affero General Public License
475+# along with this program. If not, see <http://www.gnu.org/licenses/>.
476+#
477+##############################################################################
478+#
479+# Please note that these reports are not multi-currency !!!
480+#
481+from openerp.osv import fields, orm
482+from openerp import tools
483+
484+
485+class purchase_landed_cost_report(orm.Model):
486+ _name = "purchase.landed.cost.report"
487+ _description = "Purchases Orders"
488+ _auto = False
489+ _columns = {
490+ 'date': fields.date(
491+ 'Order Date', readonly=True,
492+ help="Date on which this document has been created"),
493+ 'name': fields.char('Year', size=64, required=False, readonly=True),
494+ 'day': fields.char('Day', size=128, readonly=True),
495+ 'state': fields.selection([
496+ ('draft', 'Request for Quotation'),
497+ ('confirmed', 'Waiting Supplier Ack'),
498+ ('approved', 'Approved'),
499+ ('except_picking', 'Shipping Exception'),
500+ ('except_invoice', 'Invoice Exception'),
501+ ('done', 'Done'),
502+ ('cancel', 'Cancelled')],
503+ 'Order Status', readonly=True),
504+ 'product_id': fields.many2one(
505+ 'product.product', 'Product', readonly=True),
506+ 'warehouse_id': fields.many2one(
507+ 'stock.warehouse', 'Warehouse', readonly=True),
508+ 'location_id': fields.many2one(
509+ 'stock.location', 'Destination', readonly=True),
510+ 'partner_id': fields.many2one(
511+ 'res.partner', 'Supplier', readonly=True),
512+ 'pricelist_id': fields.many2one(
513+ 'product.pricelist', 'Pricelist', readonly=True),
514+ 'date_approve': fields.date(
515+ 'Date Approved', readonly=True),
516+ 'expected_date': fields.date(
517+ 'Expected Date', readonly=True),
518+ 'validator': fields.many2one(
519+ 'res.users', 'Validated By', readonly=True),
520+ 'product_uom': fields.many2one(
521+ 'product.uom', 'Reference Unit of Measure', required=True),
522+ 'company_id': fields.many2one(
523+ 'res.company', 'Company', readonly=True),
524+ 'user_id': fields.many2one(
525+ 'res.users', 'Responsible', readonly=True),
526+ 'quantity': fields.float('Quantity', readonly=True),
527+ 'price_total': fields.float('Total Price', readonly=True),
528+ 'price_average': fields.float(
529+ 'Average Price', readonly=True,
530+ group_operator="avg"),
531+ 'negociation': fields.float(
532+ 'Purchase-Standard Price', readonly=True,
533+ group_operator="avg"),
534+ 'price_standard': fields.float(
535+ 'Products Value', readonly=True,
536+ group_operator="sum"),
537+ 'nbr': fields.integer('# of Lines', readonly=True),
538+ 'month': fields.selection(
539+ [
540+ ('01', 'January'), ('02', 'February'), ('03', 'March'),
541+ ('04', 'April'), ('05', 'May'), ('06', 'June'),
542+ ('07', 'July'), ('08', 'August'), ('09', 'September'),
543+ ('10', 'October'), ('11', 'November'), ('12', 'December')
544+ ], 'Month', readonly=True),
545+ 'category_id': fields.many2one('product.category', 'Category',
546+ readonly=True),
547+ 'landed_cost_total': fields.float(
548+ 'Landed cost total', readonly=True,
549+ group_operator="sum"),
550+ 'landed_cost_unit': fields.float(
551+ 'Landed cost unit', readonly=True,
552+ group_operator="sum"),
553+ 'purchase_order_id': fields.many2one(
554+ 'purchase.order', 'Purchase Order', readonly=True),
555+ }
556+ _order = 'name desc,price_total desc'
557+
558+ def init(self, cr):
559+ tools.sql.drop_view_if_exists(cr, 'purchase_landed_cost_report')
560+ cr.execute("""
561+ CREATE OR REPLACE FUNCTION po_landed_cost_per_unit(int)
562+ RETURNS numeric
563+ AS '
564+ SELECT sum(subtotal) FROM (SELECT
565+
566+ ((po_lcp.amount_company_currency
567+ / (SELECT sum(product_qty) FROM
568+ purchase_order_line
569+ WHERE order_id = pol.order_id))
570+ * pol.product_qty
571+ ) as subtotal
572+ FROM purchase_order_line POL
573+ LEFT JOIN landed_cost_position po_lcp
574+ ON po_lcp.purchase_order_id = pol.order_id
575+ LEFT JOIN landed_cost_distribution_type
576+ po_lcdt
577+ ON po_lcdt.id = po_lcp.distribution_type_id
578+ WHERE pol.id = $1
579+ AND po_lcp.active = true
580+ AND po_lcp.purchase_order_line_id is null
581+ AND po_lcdt.landed_cost_type = ''per_unit''
582+ GROUP BY pol.id, po_lcp.id, po_lcdt.id)
583+ as result'
584+ LANGUAGE SQL;
585+
586+ CREATE OR REPLACE FUNCTION po_landed_cost_per_value(int)
587+ RETURNS numeric
588+ AS '
589+ SELECT sum(subtotal)
590+ FROM (
591+ SELECT (
592+ (po_lcp.amount_company_currency
593+ * (pol.price_unit
594+ * pol.product_qty)) / po.amount_untaxed
595+ ) as subtotal
596+ FROM purchase_order_line POL
597+ LEFT JOIN purchase_order po
598+ ON po.id = pol.order_id
599+ LEFT JOIN landed_cost_position po_lcp
600+ ON po_lcp.purchase_order_id = pol.order_id
601+ LEFT JOIN landed_cost_distribution_type po_lcdt
602+ ON po_lcdt.id = po_lcp.distribution_type_id
603+ WHERE pol.id = $1
604+ AND po_lcp.active = true
605+ AND po_lcp.purchase_order_line_id is null
606+ AND po_lcdt.landed_cost_type = ''value''
607+ GROUP BY pol.id, po.id, po_lcp.id, po_lcdt.id) as
608+ result'
609+ LANGUAGE SQL;
610+
611+
612+ CREATE OR REPLACE FUNCTION pol_landed_cost_per_unit(int) RETURNS
613+ numeric
614+ AS '
615+ SELECT sum(subtotal)
616+ FROM (
617+ SELECT
618+ pol.id as polid,
619+ (
620+ pol_lcp.amount_company_currency
621+ * pol.product_qty
622+ ) as subtotal
623+ FROM purchase_order_line POL
624+ LEFT JOIN landed_cost_position pol_lcp
625+ ON pol_lcp.purchase_order_line_id = pol.id
626+ LEFT JOIN landed_cost_distribution_type
627+ pol_lcdt
628+ ON
629+ pol_lcdt.id = pol_lcp.distribution_type_id
630+ WHERE pol.id = $1
631+ AND pol_lcp.active = true
632+ AND
633+ pol_lcdt.landed_cost_type = ''per_unit''
634+ GROUP BY pol.id, pol_lcp.id, pol_lcdt.id)
635+ as result'
636+ LANGUAGE SQL;
637+
638+ CREATE OR REPLACE FUNCTION pol_landed_cost_per_value(int) RETURNS
639+ numeric
640+ AS 'SELECT sum(subtotal)
641+ FROM (
642+ SELECT
643+ pol.id as polid,
644+ pol_lcp.amount_company_currency as subtotal
645+ FROM purchase_order_line POL
646+ LEFT JOIN landed_cost_position pol_lcp
647+ ON pol_lcp.purchase_order_line_id = pol.id
648+ LEFT JOIN landed_cost_distribution_type
649+ pol_lcdt
650+ ON
651+ pol_lcdt.id = pol_lcp.distribution_type_id
652+ WHERE pol.id = $1
653+ AND pol_lcp.active = true
654+ AND pol_lcdt.landed_cost_type = ''value''
655+ GROUP BY pol.id, pol_lcp.id, pol_lcdt.id)
656+ as result'
657+ LANGUAGE SQL;
658+
659+
660+ CREATE OR REPLACE FUNCTION pol_landed_cost_total(int) RETURNS
661+ numeric
662+ AS 'SELECT sum(subtotal)
663+ FROM (select po_landed_cost_per_unit as subtotal
664+ from po_landed_cost_per_unit($1) UNION
665+ select po_landed_cost_per_value as subtotal
666+ from po_landed_cost_per_value($1) UNION
667+ select pol_landed_cost_per_unit as subtotal
668+ from pol_landed_cost_per_unit($1) UNION
669+ select pol_landed_cost_per_value as subtotal
670+ from pol_landed_cost_per_value($1)) as result'
671+ LANGUAGE SQL;
672+
673+ CREATE OR REPLACE FUNCTION single_pol_po_landed_cost_per_unit(int)
674+ RETURNS numeric
675+ AS '
676+ SELECT sum(subtotal) FROM (SELECT
677+
678+ ((po_lcp.amount_company_currency
679+ / (SELECT sum(product_qty) FROM
680+ purchase_order_line WHERE
681+ order_id = pol.order_id))
682+ ) as subtotal
683+ FROM purchase_order_line POL
684+ LEFT JOIN landed_cost_position po_lcp
685+ ON po_lcp.purchase_order_id = pol.order_id
686+ LEFT JOIN landed_cost_distribution_type
687+ po_lcdt
688+ ON po_lcdt.id = po_lcp.distribution_type_id
689+ WHERE pol.id = $1
690+ AND po_lcp.active = true
691+ AND po_lcp.purchase_order_line_id is null
692+ AND po_lcdt.landed_cost_type = ''per_unit''
693+ GROUP BY pol.id, po_lcp.id, po_lcdt.id)
694+ as result'
695+ LANGUAGE SQL;
696+ CREATE OR REPLACE FUNCTION single_pol_po_landed_cost_per_value(int)
697+ RETURNS numeric
698+ AS '
699+ SELECT sum(subtotal)
700+ FROM (
701+ SELECT (
702+ (po_lcp.amount_company_currency * pol.price_unit) /
703+ po.amount_untaxed
704+ ) as subtotal
705+ FROM purchase_order_line POL
706+ LEFT JOIN purchase_order po
707+ ON po.id = pol.order_id
708+ LEFT JOIN landed_cost_position po_lcp
709+ ON po_lcp.purchase_order_id = pol.order_id
710+ LEFT JOIN landed_cost_distribution_type po_lcdt
711+ ON po_lcdt.id = po_lcp.distribution_type_id
712+ WHERE pol.id = $1
713+ AND po_lcp.active = true
714+ AND po_lcp.purchase_order_line_id is null
715+ AND po_lcdt.landed_cost_type = ''value''
716+ GROUP BY pol.id, po.id, po_lcp.id, po_lcdt.id)
717+ as result'
718+ LANGUAGE SQL;
719+
720+
721+ CREATE OR REPLACE FUNCTION single_pol_landed_cost_per_unit(int)
722+ RETURNS numeric
723+ AS '
724+ SELECT sum(subtotal)
725+ FROM (
726+ SELECT
727+ pol.id as polid,
728+ pol_lcp.amount_company_currency as subtotal
729+ FROM purchase_order_line POL
730+ LEFT JOIN landed_cost_position pol_lcp
731+ ON pol_lcp.purchase_order_line_id = pol.id
732+ LEFT JOIN landed_cost_distribution_type
733+ pol_lcdt
734+ ON
735+ pol_lcdt.id = pol_lcp.distribution_type_id
736+ WHERE pol.id = $1
737+ AND pol_lcp.active = true
738+ AND
739+ pol_lcdt.landed_cost_type = ''per_unit''
740+ GROUP BY pol.id, pol_lcp.id, pol_lcdt.id)
741+ as result'
742+ LANGUAGE SQL;
743+
744+ CREATE OR REPLACE FUNCTION single_pol_landed_cost_per_value(int) RETURNS
745+ numeric
746+ AS 'SELECT sum(subtotal)
747+ FROM (
748+ SELECT
749+ pol.id as polid,
750+ (
751+ pol_lcp.amount_company_currency /
752+ pol.product_qty
753+ )as subtotal
754+ FROM purchase_order_line POL
755+ LEFT JOIN landed_cost_position pol_lcp
756+ ON pol_lcp.purchase_order_line_id = pol.id
757+ LEFT JOIN landed_cost_distribution_type
758+ pol_lcdt
759+ ON
760+ pol_lcdt.id = pol_lcp.distribution_type_id
761+ WHERE pol.id = $1
762+ AND pol_lcp.active = true
763+ AND pol_lcdt.landed_cost_type = ''value''
764+ GROUP BY pol.id, pol_lcp.id, pol_lcdt.id)
765+ as result'
766+ LANGUAGE SQL;
767+ CREATE OR REPLACE FUNCTION pol_landed_cost_unit(int)
768+ RETURNS numeric
769+ AS 'SELECT sum(subtotal)
770+ FROM (select single_pol_po_landed_cost_per_unit as subtotal
771+ from single_pol_po_landed_cost_per_unit($1) UNION
772+ select single_pol_po_landed_cost_per_value as subtotal
773+ from single_pol_po_landed_cost_per_value($1) UNION
774+ select single_pol_landed_cost_per_unit as subtotal
775+ from single_pol_landed_cost_per_unit($1) UNION
776+ select single_pol_landed_cost_per_value as subtotal
777+ from single_pol_landed_cost_per_value($1)) as result'
778+ LANGUAGE SQL;
779+ create or replace view purchase_landed_cost_report as (
780+ select
781+ min(l.id) as id,
782+ s.id as purchase_order_id,
783+ s.date_order as date,
784+ to_char(s.date_order, 'YYYY') as name,
785+ to_char(s.date_order, 'MM') as month,
786+ to_char(s.date_order, 'YYYY-MM-DD') as day,
787+ s.state,
788+ s.date_approve,
789+ s.minimum_planned_date as expected_date,
790+ s.dest_address_id,
791+ s.pricelist_id,
792+ s.validator,
793+ s.warehouse_id as warehouse_id,
794+ s.partner_id as partner_id,
795+ s.create_uid as user_id,
796+ s.company_id as company_id,
797+ l.product_id,
798+ t.categ_id as category_id,
799+ t.uom_id as product_uom,
800+ s.location_id as location_id,
801+ sum(l.product_qty/u.factor*u2.factor) as quantity,
802+ count(*) as nbr,
803+ sum(l.price_unit*l.product_qty)::decimal(16,2)
804+ as price_total,
805+ avg(100.0 * (l.price_unit*l.product_qty) / NULLIF(
806+ t.standard_price*l.product_qty/
807+ u.factor*u2.factor, 0.0))::decimal(16,2)
808+ as negociation,
809+ sum(t.standard_price*l.product_qty/u.factor*u2.factor
810+ )::decimal(16,2) as price_standard,
811+ (sum(l.product_qty*l.price_unit)/NULLIF(sum(
812+ l.product_qty/u.factor*u2.factor),0.0)
813+ )::decimal(16,2) as price_average,
814+ pol_landed_cost_total(l.id)::decimal(16,2) as
815+ landed_cost_total,
816+ pol_landed_cost_unit(l.id)::decimal(16,2) as
817+ landed_cost_unit
818+ from purchase_order_line l
819+ join purchase_order s on (l.order_id=s.id)
820+ left join product_product p on (l.product_id=p.id)
821+ left join product_template t on (
822+ p.product_tmpl_id=t.id)
823+ left join product_uom u on (u.id=l.product_uom)
824+ left join product_uom u2 on (u2.id=t.uom_id)
825+ group by
826+ s.company_id,
827+ s.create_uid,
828+ s.partner_id,
829+ u.factor,
830+ s.location_id,
831+ l.id,
832+ s.id,
833+ l.price_unit,
834+ s.date_approve,
835+ l.date_planned,
836+ l.product_uom,
837+ s.minimum_planned_date,
838+ s.pricelist_id,
839+ s.validator,
840+ s.dest_address_id,
841+ l.product_id,
842+ t.categ_id,
843+ s.date_order,
844+ to_char(s.date_order, 'YYYY'),
845+ to_char(s.date_order, 'MM'),
846+ to_char(s.date_order, 'YYYY-MM-DD'),
847+ s.state,
848+ s.warehouse_id,
849+ u.uom_type,
850+ u.category_id,
851+ t.uom_id,
852+ u.id,
853+ u2.factor
854+ )
855+ """)
856
857=== added file 'purchase_landed_costs_extended/report/purchase_report_view.xml'
858--- purchase_landed_costs_extended/report/purchase_report_view.xml 1970-01-01 00:00:00 +0000
859+++ purchase_landed_costs_extended/report/purchase_report_view.xml 2014-06-19 02:41:00 +0000
860@@ -0,0 +1,144 @@
861+<?xml version="1.0" encoding="UTF-8"?>
862+<openerp>
863+ <data>
864+ <record model="ir.ui.view" id="view_purchase_order_landed_cost_graph">
865+ <field name="name">product.month.graph</field>
866+ <field name="model">purchase.landed.cost.report</field>
867+ <field name="arch" type="xml">
868+ <graph string="Purchase Orders Statistics" type="bar">
869+ <field name="product_id"/>
870+ <field name="price_total" operator="+"/>
871+ </graph>
872+ </field>
873+ </record>
874+
875+ <record id="view_purchase_order_landed_cost_tree" model="ir.ui.view">
876+ <field name="name">purchase.order.landed.cost.tree</field>
877+ <field name="model">purchase.landed.cost.report</field>
878+ <field name="arch" type="xml">
879+ <tree string="Purchase Orders Statistics" create="false">
880+ <field name="date" invisible="1"/>
881+ <field name="date_approve" invisible="1"/>
882+ <field name="expected_date" invisible="1"/>
883+ <field name="user_id" invisible="1"/>
884+ <field name="partner_id" invisible="1"/>
885+ <field name="product_id" invisible="1"/>
886+ <field name="category_id" invisible="1"/>
887+ <field name="product_uom" invisible="1"/>
888+ <field name="day" invisible="1"/>
889+ <field name="name" invisible="1"/>
890+ <field name="month" invisible="1"/>
891+ <field name="warehouse_id" invisible="1"/>
892+ <field name="validator" invisible="1"/>
893+ <field name="company_id" invisible="1"/>
894+ <field name="state" invisible="1"/>
895+ <field name="location_id" invisible="1"/>
896+ <field name="nbr" sum="# of Lines"/>
897+ <field name="quantity" sum="Quantity"/>
898+ <field name="price_average" sum="Average Price"/>
899+ <field name="price_total" sum="Total Price"/>
900+ <field name="price_standard" sum="Products Value"/>
901+ <field name="negociation" widget="progressbar"/>
902+ <field name="landed_cost_unit" sum="Landed cost unit"/>
903+ <field name="landed_cost_total" sum="Landed cost unit"/>
904+ </tree>
905+ </field>
906+ </record>
907+
908+ <record id="view_purchase_order_landed_cost_search" model="ir.ui.view">
909+ <field name="name">report.purchase.order.landed.cost.search</field>
910+ <field name="model">purchase.landed.cost.report</field>
911+ <field name="arch" type="xml">
912+ <search string="Purchase Orders">
913+ <filter icon="terp-document-new" string="Quotations" name="quotes" domain="[('state','=','draft')]"/>
914+ <filter icon="terp-gtk-jump-to-rtl" string="Orders" name="orders" domain="[('state','&lt;&gt;','draft'),('state','&lt;&gt;','cancel')]"/>
915+ <field name="partner_id"/>
916+ <field name="product_id"/>
917+ <field name="purchase_order_id"/>
918+ <group expand="0" string="Extended Filters...">
919+ <field name="user_id"/>
920+ <field name="validator"/>
921+ <field name="location_id"/>
922+ <field name="warehouse_id"/>
923+ <field name="company_id" groups="base.group_multi_company"/>
924+ <field name="date"/>
925+ <field name="date_approve"/>
926+ <field name="expected_date"/>
927+ </group>
928+ <newline/>
929+ <group expand="1" string="Group By...">
930+ <filter string="Supplier" name="group_partner_id" icon="terp-personal" context="{'group_by':'partner_id'}"/>
931+ <filter string="Responsible" name="Responsible" icon="terp-personal" context="{'group_by':'user_id'}"/>
932+ <filter string="Validated by" icon="terp-personal" context="{'group_by':'validator'}"/>
933+ <filter string="Product" name="group_product_id" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
934+ <filter string="Order" name="group_purchase_order_id" icon="terp-accessories-archiver" context="{'group_by':'purchase_order_id'}"/>
935+ <filter string="Category" name="group_category_id" icon="terp-stock_symbol-selection" context="{'group_by':'category_id'}"/>
936+ <filter string="Warehouse" icon="terp-go-home" context="{'group_by':'warehouse_id'}"/>
937+ <filter string="Reference UOM" name="group_product_uom" icon="terp-mrp" context="{'group_by':'product_uom'}"/>
938+ <filter string="Destination" icon="terp-gtk-jump-to-ltr" context="{'group_by':'location_id'}"/>
939+ <filter string="Status" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
940+ <filter string="Company" icon="terp-go-home" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
941+ <filter string="Day" icon="terp-go-today" context="{'group_by':'day'}" help="Order of Day"/>
942+ <filter string="Month" icon="terp-go-month" context="{'group_by':'month'}" help="Order of Month"/>
943+ <filter string="Year" icon="terp-go-year" context="{'group_by':'name'}" help="Order of Year"/>
944+ </group>
945+ </search>
946+ </field>
947+ </record>
948+
949+ <record model="ir.ui.view" id="view_purchase_order_landed_cost_qty_amount_graph">
950+ <field name="name">purchase.order.landed.cost.qty.amount.graph</field>
951+ <field name="model">purchase.landed.cost.report</field>
952+ <field name="arch" type="xml">
953+ <graph string="Total Qty and Amount by month" type="bar">
954+ <field name="month"/>
955+ <field name="quantity" operator="+"/>
956+ <field name="price_total" operator="+"/>
957+ </graph>
958+ </field>
959+ </record>
960+
961+ <record model="ir.ui.view" id="view_purchase_order_landed_cost_by_user_graph">
962+ <field name="name">purchase.order.landed.cost.by.user.graph</field>
963+ <field name="model">purchase.landed.cost.report</field>
964+ <field name="arch" type="xml">
965+ <graph string="Total Orders Lines by User per month" orientation="vertical" type="bar">
966+ <field name="month" />
967+ <field name="nbr" operator="+"/>
968+ <field name="user_id" group="True" />
969+ </graph>
970+ </field>
971+ </record>
972+
973+
974+ <record id="action_purchase_order_landed_cost_landed_cost_report_all" model="ir.actions.act_window">
975+ <field name="name">Landed Cost Extended</field>
976+ <field name="res_model">purchase.landed.cost.report</field>
977+ <field name="view_type">form</field>
978+ <field name="view_mode">tree,graph</field>
979+ <field name="view_id" ref="view_purchase_order_landed_cost_tree"></field>
980+ <field name="context">{'search_default_year':1,'search_default_month':1,'search_default_group_partner_id':1,'search_default_group_product_id': 1, 'search_default_group_purchase_order_id': 1, 'search_default_orders': 1, 'group_by_no_leaf':1,'group_by':[]}</field>
981+ <field name="help">Purchase Analysis allows you to easily check and analyse your company purchase history and performance. From this menu you can track your negotiation performance, the delivery performance of your suppliers, etc.</field>
982+ </record>
983+
984+ <record id="action_purchase_order_landed_cost_landed_cost_report_graph" model="ir.actions.act_window">
985+ <field name="name">Total Qty and Amount by month</field>
986+ <field name="res_model">purchase.landed.cost.report</field>
987+ <field name="view_type">form</field>
988+ <field name="view_mode">graph,tree</field>
989+ <field name="view_id" ref="view_purchase_order_landed_cost_qty_amount_graph"></field>
990+ </record>
991+
992+ <record id="action_purchase_order_landed_cost_by_user_all" model="ir.actions.act_window">
993+ <field name="name">Total Orders by User per month</field>
994+ <field name="res_model">purchase.landed.cost.report</field>
995+ <field name="view_type">form</field>
996+ <field name="view_mode">graph,tree</field>
997+ <field name="view_id" ref="view_purchase_order_landed_cost_by_user_graph"></field>
998+ </record>
999+
1000+
1001+ <menuitem action="action_purchase_order_landed_cost_landed_cost_report_all" id="menu_action_purchase_order_landed_cost_landed_cost_report_all" parent="base.next_id_73" sequence="3"/>
1002+
1003+ </data>
1004+</openerp>
1005\ No newline at end of file
1006
1007=== added directory 'purchase_landed_costs_extended/security'
1008=== added file 'purchase_landed_costs_extended/security/ir.model.access.csv'
1009--- purchase_landed_costs_extended/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
1010+++ purchase_landed_costs_extended/security/ir.model.access.csv 2014-06-19 02:41:00 +0000
1011@@ -0,0 +1,3 @@
1012+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
1013+access_report_purchase_order_landed_cost,purchase_landed_costs_extended.purchase_landed_cost_report,model_purchase_landed_cost_report,purchase.group_purchase_manager,1,0,0,0
1014+access_report_purchase_order_landed_cost_user,purchase_landed_costs_extended.purchase_landed_cost_report user,model_purchase_landed_cost_report,purchase.group_purchase_user,1,0,0,0
1015\ No newline at end of file
1016
1017=== added directory 'purchase_landed_costs_extended/wizard'
1018=== added file 'purchase_landed_costs_extended/wizard/__init__.py'
1019--- purchase_landed_costs_extended/wizard/__init__.py 1970-01-01 00:00:00 +0000
1020+++ purchase_landed_costs_extended/wizard/__init__.py 2014-06-19 02:41:00 +0000
1021@@ -0,0 +1,22 @@
1022+# -*- coding: utf-8 -*-
1023+##############################################################################
1024+#
1025+# OpenERP, Open Source Management Solution
1026+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
1027+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@elico-corp.com>
1028+#
1029+# This program is free software: you can redistribute it and/or modify
1030+# it under the terms of the GNU Affero General Public License as
1031+# published by the Free Software Foundation, either version 3 of the
1032+# License, or (at your option) any later version.
1033+#
1034+# This program is distributed in the hope that it will be useful,
1035+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1036+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1037+# GNU Affero General Public License for more details.
1038+#
1039+# You should have received a copy of the GNU Affero General Public License
1040+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1041+#
1042+##############################################################################
1043+import landed_cost_position_invoice
1044
1045=== added file 'purchase_landed_costs_extended/wizard/landed_cost_position_invoice.py'
1046--- purchase_landed_costs_extended/wizard/landed_cost_position_invoice.py 1970-01-01 00:00:00 +0000
1047+++ purchase_landed_costs_extended/wizard/landed_cost_position_invoice.py 2014-06-19 02:41:00 +0000
1048@@ -0,0 +1,57 @@
1049+# -*- coding: utf-8 -*-
1050+##############################################################################
1051+#
1052+# OpenERP, Open Source Management Solution
1053+# Copyright (c) 2010-2014 Elico Corp. All Rights Reserved.
1054+# Augustin Cisterne-Kaas <augustin.cisterne-kaas@elico-corp.com>
1055+#
1056+# This program is free software: you can redistribute it and/or modify
1057+# it under the terms of the GNU Affero General Public License as
1058+# published by the Free Software Foundation, either version 3 of the
1059+# License, or (at your option) any later version.
1060+#
1061+# This program is distributed in the hope that it will be useful,
1062+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1063+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1064+# GNU Affero General Public License for more details.
1065+#
1066+# You should have received a copy of the GNU Affero General Public License
1067+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1068+#
1069+##############################################################################
1070+from openerp.osv import osv
1071+from openerp.tools.translate import _
1072+
1073+
1074+class landed_cost_position_invoice(osv.osv_memory):
1075+
1076+ """ To create invoice for purchase order line"""
1077+
1078+ _name = 'landed.cost.position.invoice'
1079+ _description = 'Landed Cost Position Make Invoice'
1080+
1081+ def make_invoices(self, cr, uid, ids, context=None):
1082+
1083+ context = context or None
1084+ record_ids = context.get('active_ids', [])
1085+ invoice_ids = []
1086+ if record_ids:
1087+ lcp_pool = self.pool.get('landed.cost.position')
1088+ po_pool = self.pool.get('purchase.order')
1089+
1090+ for order_cost in lcp_pool.browse(cr, uid, record_ids,
1091+ context=context):
1092+ if order_cost.generate_invoice and not order_cost.invoice_id:
1093+ inv_id = po_pool._generate_invoice_from_landed_cost(
1094+ cr, uid, order_cost, context=context)
1095+ invoice_ids.append(inv_id)
1096+ domain = "[('id','in', [" + ','.join(map(str, invoice_ids)) + "])]"
1097+ return {
1098+ 'domain': domain,
1099+ 'name': _('Landed Cost Invoices'),
1100+ 'view_type': 'form',
1101+ 'view_mode': 'tree,form',
1102+ 'res_model': 'account.invoice',
1103+ 'context': "{'type':'in_invoice', 'journal_type': 'purchase'}",
1104+ 'type': 'ir.actions.act_window'
1105+ }
1106
1107=== added file 'purchase_landed_costs_extended/wizard/landed_cost_position_invoice_view.xml'
1108--- purchase_landed_costs_extended/wizard/landed_cost_position_invoice_view.xml 1970-01-01 00:00:00 +0000
1109+++ purchase_landed_costs_extended/wizard/landed_cost_position_invoice_view.xml 2014-06-19 02:41:00 +0000
1110@@ -0,0 +1,32 @@
1111+<?xml version="1.0" encoding="utf-8"?>
1112+<openerp>
1113+ <data>
1114+
1115+ <!-- Make the invoice-->
1116+
1117+ <record id="view_landed_cost_position_invoice" model="ir.ui.view">
1118+ <field name="name">Create invoices</field>
1119+ <field name="model">landed.cost.position.invoice</field>
1120+ <field name="arch" type="xml">
1121+ <form string="Select an Open Landed Cost" version="7.0">
1122+ <group>
1123+ <label string="Do you want to generate the Landed Cost invoices?"/>
1124+ </group>
1125+ <footer>
1126+ <button name="make_invoices" string="Confirm" type="object" class="oe_highlight"/>
1127+ or
1128+ <button string="Cancel" class="oe_link" special="cancel" />
1129+ </footer>
1130+ </form>
1131+ </field>
1132+ </record>
1133+
1134+ <act_window name="Create invoices"
1135+ res_model="landed.cost.position.invoice"
1136+ src_model="landed.cost.position"
1137+ view_mode="form"
1138+ target="new"
1139+ key2="client_action_multi"
1140+ id="action_view_landed_cost_position_invoice"/>
1141+ </data>
1142+</openerp>
1143\ No newline at end of file

Subscribers

People subscribed via source and target branches