diff --git a/stock_valued_picking_report/__init__.py b/stock_valued_picking_report/__init__.py new file mode 100644 index 0000000..01ebe5c --- /dev/null +++ b/stock_valued_picking_report/__init__.py @@ -0,0 +1,20 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# +# 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 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +from . import models diff --git a/stock_valued_picking_report/__openerp__.py b/stock_valued_picking_report/__openerp__.py new file mode 100644 index 0000000..0c4c9aa --- /dev/null +++ b/stock_valued_picking_report/__openerp__.py @@ -0,0 +1,54 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# +# 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 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 . +# +############################################################################## + +{ + "name" : "Valued picking list", + "version" : "1.0", + "author" : "Serv. Tecnol. Avanzados - Pedro M. Baeza", + "website" : "www.serviciosbaeza.com", + "category": "Warehouse Management", + "description": """ +Valued pickings +=============== + +Add amount information to picking list report and delivery order view. + +You can select at partner level if picking list report must be valued or not. + +Inspired in stock_valued 6.x module by Acysos S.L., Pablo Rocandio, NaN·tic and +Zikzakmedia SL.""", + "license" : "GPL-3", + "depends" : [ + "base", + "account", + "stock", + "sale", + "delivery", + ], + "data" : [ + 'views/res_partner_view.xml', + 'views/stock_picking_view.xml', + 'report/stock_valued_report.xml', + ], + "installable": True +} + diff --git a/stock_valued_picking_report/i18n/es.po b/stock_valued_picking_report/i18n/es.po new file mode 100644 index 0000000..dba6cd3 --- /dev/null +++ b/stock_valued_picking_report/i18n/es.po @@ -0,0 +1,102 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * stock_valued_picking +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-04-29 10:48+0000\n" +"PO-Revision-Date: 2014-05-29 09:18+0000\n" +"Last-Translator: Pedro Manuel Baeza \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2014-10-21 07:24+0000\n" +"X-Generator: Launchpad (build 17203)\n" + +#. module: stock_valued_picking +#: code:_description:0 +#: model:ir.model,name:stock_valued_picking.model_stock_picking_out +#, python-format +msgid "Delivery Orders" +msgstr "Albaranes de salida" + +#. module: stock_valued_picking +#: code:_description:0 +#: model:ir.model,name:stock_valued_picking.model_res_partner +#, python-format +msgid "Partner" +msgstr "Empresa" + +#. module: stock_valued_picking +#: code:_description:0 +#: model:ir.model,name:stock_valued_picking.model_stock_picking +#, python-format +msgid "Picking List" +msgstr "Albarán" + +#. module: stock_valued_picking +#: field:stock.move,sale_price_subtotal:0 +msgid "Price subtotal" +msgstr "Subtotal" + +#. module: stock_valued_picking +#: field:stock.picking,currency_id:0 +#: field:stock.picking.out,currency_id:0 +msgid "Sale currency" +msgstr "Moneda de la venta" + +#. module: stock_valued_picking +#: field:stock.move,sale_discount:0 +msgid "Sale discount (%)" +msgstr "Descuento de la venta (%)" + +#. module: stock_valued_picking +#: field:stock.move,sale_price_unit:0 +msgid "Sale price unit" +msgstr "Precio unitario de la venta" + +#. module: stock_valued_picking +#: code:_description:0 +#: model:ir.model,name:stock_valued_picking.model_stock_move +#, python-format +msgid "Stock Move" +msgstr "Movimiento de existencias" + +#. module: stock_valued_picking +#: field:stock.picking,amount_tax:0 +#: field:stock.picking.out,amount_tax:0 +#: report:sale.shipping:0 +msgid "Taxes" +msgstr "Impuestos" + +#. module: stock_valued_picking +#: field:stock.picking,amount_total:0 +#: field:stock.picking.out,amount_total:0 +#: report:sale.shipping:0 +msgid "Total" +msgstr "Total" + +#. module: stock_valued_picking +#: field:stock.picking,amount_untaxed:0 +#: field:stock.picking.out,amount_untaxed:0 +#: report:sale.shipping:0 +msgid "Untaxed amount" +msgstr "Base imponible" + +#. module: stock_valued_picking +#: field:res.partner,valued_picking:0 +msgid "Valued picking" +msgstr "Albarán valorado" + +#. module: stock_valued_picking +#: report:sale.shipping:0 +msgid "Unit price" +msgstr "Precio unitario" + +#. module: stock_valued_picking +#: report:sale.shipping:0 +msgid "Subtotal" +msgstr "Subtotal" diff --git a/stock_valued_picking_report/i18n/stock_valued_picking.pot b/stock_valued_picking_report/i18n/stock_valued_picking.pot new file mode 100644 index 0000000..1545f5c --- /dev/null +++ b/stock_valued_picking_report/i18n/stock_valued_picking.pot @@ -0,0 +1,102 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * stock_valued_picking +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-04-29 10:48+0000\n" +"PO-Revision-Date: 2014-04-29 12:49+0100\n" +"Last-Translator: Pedro Manuel Baeza \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" + +#. module: stock_valued_picking +#: code:_description:0 +#: model:ir.model,name:stock_valued_picking.model_stock_picking_out +#, python-format +msgid "Delivery Orders" +msgstr "" + +#. module: stock_valued_picking +#: code:_description:0 +#: model:ir.model,name:stock_valued_picking.model_res_partner +#, python-format +msgid "Partner" +msgstr "" + +#. module: stock_valued_picking +#: code:_description:0 +#: model:ir.model,name:stock_valued_picking.model_stock_picking +#, python-format +msgid "Picking List" +msgstr "" + +#. module: stock_valued_picking +#: field:stock.move,sale_price_subtotal:0 +msgid "Price subtotal" +msgstr "" + +#. module: stock_valued_picking +#: field:stock.picking,currency_id:0 +#: field:stock.picking.out,currency_id:0 +msgid "Sale currency" +msgstr "" + +#. module: stock_valued_picking +#: field:stock.move,sale_discount:0 +msgid "Sale discount (%)" +msgstr "" + +#. module: stock_valued_picking +#: field:stock.move,sale_price_unit:0 +msgid "Sale price unit" +msgstr "" + +#. module: stock_valued_picking +#: code:_description:0 +#: model:ir.model,name:stock_valued_picking.model_stock_move +#, python-format +msgid "Stock Move" +msgstr "" + +#. module: stock_valued_picking +#: field:stock.picking,amount_tax:0 +#: field:stock.picking.out,amount_tax:0 +#: report:sale.shipping:0 +msgid "Taxes" +msgstr "" + +#. module: stock_valued_picking +#: field:stock.picking,amount_total:0 +#: field:stock.picking.out,amount_total:0 +#: report:sale.shipping:0 +msgid "Total" +msgstr "" + +#. module: stock_valued_picking +#: field:stock.picking,amount_untaxed:0 +#: field:stock.picking.out,amount_untaxed:0 +#: report:sale.shipping:0 +msgid "Untaxed amount" +msgstr "" + +#. module: stock_valued_picking +#: field:res.partner,valued_picking:0 +msgid "Valued picking" +msgstr "" + +#. module: stock_valued_picking +#: report:sale.shipping:0 +msgid "Unit price" +msgstr "" + +#. module: stock_valued_picking +#: report:sale.shipping:0 +msgid "Subtotal" +msgstr "" + diff --git a/stock_valued_picking_report/models/__init__.py b/stock_valued_picking_report/models/__init__.py new file mode 100644 index 0000000..e7621b0 --- /dev/null +++ b/stock_valued_picking_report/models/__init__.py @@ -0,0 +1,22 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# +# 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 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +from . import res_partner +from . import stock_move +from . import stock_picking diff --git a/stock_valued_picking_report/models/res_partner.py b/stock_valued_picking_report/models/res_partner.py new file mode 100644 index 0000000..6de00a2 --- /dev/null +++ b/stock_valued_picking_report/models/res_partner.py @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# +# 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 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv import fields, orm + +class ResPartner(orm.Model): + _inherit = 'res.partner' + _columns = { + 'valued_picking': fields.boolean('Valued picking'), + } + _defaults = { + 'valued_picking': True, + } diff --git a/stock_valued_picking_report/models/stock_move.py b/stock_valued_picking_report/models/stock_move.py new file mode 100644 index 0000000..07f6c5b --- /dev/null +++ b/stock_valued_picking_report/models/stock_move.py @@ -0,0 +1,52 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# +# 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 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv import fields, orm + +class StockMove(orm.Model): + _inherit = "stock.move" + + def _get_sale_price_subtotal(self, cr, uid, ids, field_name, arg, + context=None): + res = {} + cur_obj = self.pool['res.currency'] + for move in self.browse(cr, uid, ids, context=context): + res[move.id] = False + if move.sale_line_id: + subtotal = move.sale_price_unit * move.product_qty * \ + (1 - (move.sale_discount or 0.0) / 100.0) + # Round by currency precision + cur = move.sale_line_id.order_id.currency_id + res[move.id] = cur_obj.round(cr, uid, cur, subtotal) + return res + + _columns = { + 'sale_price_unit': fields.related('sale_line_id', 'price_unit', + type="float", readonly=True, + string="Sale price unit"), + 'sale_discount': fields.related('sale_line_id', 'discount', + type="float", readonly=True, + string="Sale discount (%)"), + 'sale_price_subtotal': fields.function(_get_sale_price_subtotal, + string='Price subtotal', + type='float', method=True, + readonly=True), + } diff --git a/stock_valued_picking_report/models/stock_picking.py b/stock_valued_picking_report/models/stock_picking.py new file mode 100644 index 0000000..f576d3c --- /dev/null +++ b/stock_valued_picking_report/models/stock_picking.py @@ -0,0 +1,103 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# +# 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 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv import fields, orm +from openerp.addons.decimal_precision import decimal_precision as dp + +class StockPicking(orm.Model): + _inherit = "stock.picking" + + def _get_currency_id(self, cr, uid, ids, field_name, arg, context=None): + res = {} + for picking in self.browse(cr, uid, ids, context=context): + res[picking.id] = False + total_tax = 0.0 + for move in picking.move_lines: + if not move.sale_line_id: + continue + # Take one of the sale order lines currencies (it would be + # alwaysthe same for all) + res[picking.id] = move.sale_line_id.order_id.currency_id.id + break + return res + + def _amount_untaxed(self, cr, uid, ids, field_name, arg, context=None): + res = {} + for picking in self.browse(cr, uid, ids, context=context): + res[picking.id] = 0.0 + for move in picking.move_lines: + res[picking.id] += move.sale_price_subtotal + return res + + def _amount_tax(self, cr, uid, ids, field_name, arg, context=None): + res = {} + tax_obj = self.pool['account.tax'] + cur_obj = self.pool['res.currency'] + for picking in self.browse(cr, uid, ids, context=context): + cur = False + total_tax = 0.0 + for move in picking.move_lines: + if not move.sale_line_id: + continue + price_unit = (move.sale_price_unit * + (100 - move.sale_discount or 0.0) / 100.0) + for c in tax_obj.compute_all(cr, uid, move.sale_line_id.tax_id, + price_unit, + move.product_qty, move.product_id, + move.sale_line_id.order_id.partner_id + )['taxes']: + total_tax += c.get('amount', 0.0) + res[picking.id] = (picking.currency_id and + cur_obj.round(cr, uid, picking.currency_id, + total_tax) + or 0.0) + return res + + def _amount_total(self, cr, uid, ids, field_name, arg, context=None): + res = {} + for picking in self.browse(cr, uid, ids, context=context): + res[picking.id] = picking.amount_untaxed + picking.amount_tax + return res + + _columns = { + 'currency_id': fields.related('sale_id', 'currency_id', + type="many2one", relation="res.currency", + store=True, string='Sale currency', readonly=True), + 'amount_untaxed': fields.function(_amount_untaxed, type="float", + digits_compute=dp.get_precision('Account'), + method=True, string='Untaxed amount', readonly=True), + 'amount_tax': fields.function(_amount_tax, type="float", + digits_compute=dp.get_precision('Account'), + method=True, string='Taxes', readonly=True), + 'amount_total': fields.function(_amount_total, type="float", + digits_compute=dp.get_precision('Account'), + method=True, string='Total', readonly=True), + } + +class StockPickingOut(orm.Model): + _inherit = "stock.picking.out" + + def __init__(self, pool, cr): + super(StockPickingOut, self).__init__(pool, cr) + picking_obj = self.pool['stock.picking'] + for field_name in ('currency_id', 'amount_untaxed', 'amount_tax', + 'amount_total'): + self._columns[field_name] = picking_obj._columns[field_name] \ No newline at end of file diff --git a/stock_valued_picking_report/report/shipping.rml b/stock_valued_picking_report/report/shipping.rml new file mode 100644 index 0000000..0ae0875 --- /dev/null +++ b/stock_valued_picking_report/report/shipping.rml @@ -0,0 +1,302 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[repeatIn(objects,'o')]] + + + + [[ (not(o.sale_id) and o.type== 'out') and 'Error, no sale order attached to this picking !' or removeParentNode('para') ]] + + + + Invoiced to + [[ o.sale_id and o.sale_id.partner_invoice_id and o.sale_id.partner_invoice_id.name or '']] + [[ o.sale_id and o.sale_id.partner_invoice_id and display_address(o.sale_id.partner_invoice_id) ]] + + + [[ o.partner_id and o.partner_id and o.partner_id.name or '' ]] + [[ o.partner_id and o.partner_id and display_address(o.partner_id) ]] + + + + Delivery Order : [[ o.name ]] + + + + + + + Order Ref. + + + Order Date + + + Shipping Date + + + Carrier + + + Weight + + + + + + + [[ o.sale_id and o.sale_id.name ]] + + + [[ formatLang(o.date,date_time=True) ]] + + + [[ formatLang(o.min_date,date_time = True) ]] + + + [[ o.carrier_id and o.carrier_id.name or '' ]] + + + [[ formatLang(o.weight) ]] + + + + + + + + + + + + + [[ o.sale_id and o.sale_id.partner_id and o.sale_id.partner_id.valued_picking and ' ' or removeParentNode('tr') ]] Description + + + Unit price + + + Quantity + + + Subtotal + + + + + Description + + + [[ o.sale_id and o.sale_id.partner_id and not o.sale_id.partner_id.valued_picking and ' ' or removeParentNode('tr') ]] + + + Lot + + + Quantity + + + +
+ [[repeatIn(o.move_lines,'line')]] + + + + [[line.product_id.code ]] [[ line.product_id and line.product_id.name or '']] + + + [[ o.sale_id and o.sale_id.partner_id and o.sale_id.partner_id.valued_picking and formatLang(line.sale_price_unit, dp='Product Price', currency_obj=o.sale_id.currency_id) or removeParentNode('tr') ]] + + + [[ formatLang(line.product_qty) ]] [[ line.product_uom and line.product_uom.name ]] + + + [[ formatLang(line.sale_price_subtotal, dp='Account', currency_obj=o.sale_id.currency_id) ]] + + + + + [[line.product_id.code ]] [[ line.product_id and line.product_id.name or '']] + + + [[ o.sale_id and o.sale_id.partner_id and not o.sale_id.partner_id.valued_picking and ' ' or removeParentNode('tr') ]] + + + [[ (line.prodlot_id and (line.prodlot_id.name + (line.prodlot_id.ref and ('/' + line.prodlot_id.ref) or ''))) or ' ' ]] + + + [[ formatLang(line.product_qty) ]] [[ line.product_uom and line.product_uom.name ]] + + + +
+ + + + [[ o.sale_id and o.sale_id.partner_id and o.sale_id.partner_id.valued_picking and ' ' or removeParentNode('tr') ]] + + + Untaxed amount + + + [[ formatLang(o.amount_untaxed, dp='Account', currency_obj=o.sale_id.currency_id) ]] + + + + + [[ o.sale_id and o.sale_id.partner_id and o.sale_id.partner_id.valued_picking and ' ' or removeParentNode('tr') ]] + + + Taxes + + + [[ formatLang(o.amount_tax, dp='Account', currency_obj=o.sale_id.currency_id) ]] + + + + + [[ o.sale_id and o.sale_id.partner_id and o.sale_id.partner_id.valued_picking and ' ' or removeParentNode('tr') ]] + + + Total + + + [[ formatLang(o.amount_total, dp='Account', currency_obj=o.sale_id.currency_id) ]] + + + + + + + + + + + + + + + + + + + + + + + +
+
+ diff --git a/stock_valued_picking_report/report/shipping.sxw b/stock_valued_picking_report/report/shipping.sxw new file mode 100644 index 0000000..98e751b Binary files /dev/null and b/stock_valued_picking_report/report/shipping.sxw differ diff --git a/stock_valued_picking_report/report/shipping_convert.sh b/stock_valued_picking_report/report/shipping_convert.sh new file mode 100755 index 0000000..f503dc4 --- /dev/null +++ b/stock_valued_picking_report/report/shipping_convert.sh @@ -0,0 +1 @@ +python /opt/openerp/v7/ocb-addons/base_report_designer/openerp_sxw2rml/openerp_sxw2rml.py ./shipping.sxw > ./shipping.rml diff --git a/stock_valued_picking_report/report/stock_valued_report.xml b/stock_valued_picking_report/report/stock_valued_report.xml new file mode 100644 index 0000000..b04cb5a --- /dev/null +++ b/stock_valued_picking_report/report/stock_valued_report.xml @@ -0,0 +1,11 @@ + + + + + + stock_valued_picking/report/shipping.rml + + + + + diff --git a/stock_valued_picking_report/views/res_partner_view.xml b/stock_valued_picking_report/views/res_partner_view.xml new file mode 100644 index 0000000..1f7957b --- /dev/null +++ b/stock_valued_picking_report/views/res_partner_view.xml @@ -0,0 +1,18 @@ + + + + + + Partner view (Valued picking) + res.partner + + + + + + + + + + diff --git a/stock_valued_picking_report/views/stock_picking_view.xml b/stock_valued_picking_report/views/stock_picking_view.xml new file mode 100644 index 0000000..ccd27f9 --- /dev/null +++ b/stock_valued_picking_report/views/stock_picking_view.xml @@ -0,0 +1,28 @@ + + + + + + stock.picking.out + + + + + + + + +
+ + + + + +