diff --git a/stock_valued_picking_report/README.rst b/stock_valued_picking_report/README.rst new file mode 100644 index 0000000..29e0f7f --- /dev/null +++ b/stock_valued_picking_report/README.rst @@ -0,0 +1,13 @@ +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. + +Credits +======= + +Contributors +------------ +* Pedro M. Baeza +* Antonio Espinosa 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..7cd8dc8 --- /dev/null +++ b/stock_valued_picking_report/__openerp__.py @@ -0,0 +1,53 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# Copyright (c) 2015 Antiun Ingenieria (http://www.antiun.com) +# Antonio Espinosa +# +# 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. +""", + "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..0c78931 --- /dev/null +++ b/stock_valued_picking_report/models/res_partner.py @@ -0,0 +1,30 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# Copyright (c) 2015 Antiun Ingenieria (http://www.antiun.com) +# Antonio Espinosa +# +# 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 import fields, models + + +class ResPartner(models.Model): + _inherit = 'res.partner' + # You can select which partners has valued pickings + valued_picking = fields.Boolean(string='Valued picking', default=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..4088968 --- /dev/null +++ b/stock_valued_picking_report/models/stock_move.py @@ -0,0 +1,58 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# Copyright (c) 2015 Antiun Ingenieria (http://www.antiun.com) +# Antonio Espinosa +# +# 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 import fields, models, api + + +class StockMove(models.Model): + _inherit = "stock.move" + + sale_price_unit = fields.Float( + string="Sale price unit", readonly=True, + related='procurement_id.sale_line_id.price_unit') + sale_discount = fields.Float( + string="Sale discount (%)", readonly=True, + related='procurement_id.sale_line_id.discount') + sale_price_subtotal = fields.Float( + string="Price subtotal", readonly=True, + compute='_get_sale_price_subtotal') + + @api.one + @api.depends( + 'sale_price_unit', + 'sale_discount', + 'product_qty', + 'procurement_id.sale_line_id.order_id.currency_id', + ) + def _get_sale_price_subtotal(self): + subtotal = (self.sale_price_unit * self.product_qty * + (1 - (self.sale_discount or 0.0) / 100.0)) + # Only get subtotal if this stock.move belongs to a + # stock.picking created from a sale.order + if self.procurement_id and self.procurement_id.sale_line_id: + # Round by currency precision + currency = self.procurement_id.sale_line_id.order_id.currency_id + if currency: + subtotal = currency.round(subtotal) + # Write subtotal into record (cache because this field is store=False) + self.sale_price_subtotal = subtotal 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..8d88085 --- /dev/null +++ b/stock_valued_picking_report/models/stock_picking.py @@ -0,0 +1,76 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# Copyright (c) 2015 Antiun Ingenieria (http://www.antiun.com) +# Antonio Espinosa +# +# 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 import fields, models, api +from openerp.addons.decimal_precision import decimal_precision as dp + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + valued = fields.Boolean( + string='Valued', related='partner_id.valued_picking', store=True, + readonly=True) + currency_id = fields.Many2one( + string='Sale currency', related='sale_id.currency_id', store=True, + readonly=True) + amount_untaxed = fields.Float( + string='Untaxed amount', compute='_compute_amounts', + digits=dp.get_precision('Account'), store=True, readonly=True) + amount_tax = fields.Float( + string='Taxes', compute='_compute_amounts', + digits=dp.get_precision('Account'), store=True, readonly=True) + amount_total = fields.Float( + string='Total', compute='_compute_amounts', + digits=dp.get_precision('Account'), store=True, readonly=True) + + @api.one + @api.depends( + 'move_lines.sale_price_subtotal', + 'move_lines.product_id', + 'move_lines.procurement_id.sale_line_id.tax_id', + 'move_lines.procurement_id.sale_line_id.order_id.partner_id', + ) + def _compute_amounts(self): + # Calculate untaxed amount + untaxed = 0.0 + for move in self.move_lines: + untaxed += move.sale_price_subtotal + # Calculate taxed amount + tax = 0.0 + for move in self.move_lines: + if not (move.procurement_id and + move.procurement_id.sale_line_id): + continue + sale_line = move.procurement_id.sale_line_id + for c in sale_line.tax_id.compute_all( + move.sale_price_subtotal, move.product_qty, + move.product_id, sale_line.order_id.partner_id)['taxes']: + tax += c.get('amount', 0.0) + currency = self.currency_id + if currency: + tax = currency.round(tax) + # Write calculated amounts into recorrd + self.amount_untaxed = untaxed + self.amount_tax = tax + self.amount_total = untaxed + tax 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..01aecd2 --- /dev/null +++ b/stock_valued_picking_report/report/stock_valued_report.xml @@ -0,0 +1,14 @@ + + + + + + Valued delivery order + stock.picking + stock_valued_picking_report.report_shipping + 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..a372370 --- /dev/null +++ b/stock_valued_picking_report/views/stock_picking_view.xml @@ -0,0 +1,34 @@ + + + + + + + Valued Stock Picking + stock.picking + + + + + + + + + + +
+ + + + + +