diff --git a/.travis.yml b/.travis.yml index 044f4a3..744db1f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,24 @@ language: python + python: - "2.7" +env: + - VERSION="7.0" ODOO_REPO="odoo/odoo" + - VERSION="7.0" ODOO_REPO="OCA/OCB" + virtualenv: system_site_packages: true install: - - git clone https://github.com/OCA/maintainer-quality-tools.git $HOME/maintainer-quality-tools - - export PATH=$HOME/maintainer-quality-tools/travis:$PATH - - $HOME/maintainer-quality-tools/travis/travis_install_nightly 7.0 - - pip install coveralls flake8 - - git clone https://github.com/OCA/webkit-tools -b 7.0 $HOME/webkit-tools - -services: - - postgresql + - git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools + - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} + - travis_install_nightly ${VERSION} + - git clone https://github.com/OCA/webkit-tools ${HOME}/webkit-tools -b ${VERSION} script: - - travis_run_flake8 - - travis_run_tests 7.0 openerp_test $HOME/webkit-tools + - travis_run_flake8 + - travis_run_tests ${VERSION} ${HOME}/webkit-tools after_success: coveralls diff --git a/stock_bill_of_lading_webkit/__init__.py b/stock_bill_of_lading_webkit/__init__.py new file mode 100644 index 0000000..491d2eb --- /dev/null +++ b/stock_bill_of_lading_webkit/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2011-2013 Camptocamp SA (http://www.camptocamp.com) +# @author Nicolas Bessi +# +# 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 stock +from . import report diff --git a/stock_bill_of_lading_webkit/__openerp__.py b/stock_bill_of_lading_webkit/__openerp__.py new file mode 100644 index 0000000..e6e4bae --- /dev/null +++ b/stock_bill_of_lading_webkit/__openerp__.py @@ -0,0 +1,67 @@ +# -*- encoding: utf-8 -*- +############################################################################### +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Savoir-faire Linux +# (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################### + + +{ + 'name': 'Bill of Lading using Webkit Library', + 'version': '1.0', + 'category': 'Reports/Webkit', + 'description': """ + +A Bill of Lading is a document issued by a carrier to a shipper of goods. +It is a negotiable instrument, and it serves three purposes: + - it is a receipt for the goods shipped; + - it evidences the contract of carriage; + - it serves as a document of title (i.e. ownership). + +This document could be different from a Delivery Order as it has some legal +issues. + +Two reports are provided in this module + - Bill of Lading for Delivey Orders; + - Bill of Lading for Incoming Shipment (the use-case is shipment from an + international Warehouse +to the local Warehouse). + +This module also add a new field for a warehouse to pick form or deliver to; +this field will be used if the default warehouse_id is not set +(normally from a PO). + +Contributors +------------ +* Marc Cassuto (marc.cassuto@savoirfairelinux.com) +* Mathieu Benoit (mathieu.benoit@savoirfairelinux.com) +* Camptocamp with its original module stock_picking_webkit + """, + 'author': 'Savoir-faire Linux', + 'website': 'http://www.savoirfairelinux.com', + 'depends': [ + 'base', + 'report_webkit', + 'base_headers_webkit', + 'stock', + 'delivery' + ], + 'data': ['report.xml', 'stock_view.xml'], + 'installable': True, + 'auto_install': False, +} diff --git a/stock_bill_of_lading_webkit/i18n/fr.po b/stock_bill_of_lading_webkit/i18n/fr.po new file mode 100644 index 0000000..008da15 --- /dev/null +++ b/stock_bill_of_lading_webkit/i18n/fr.po @@ -0,0 +1,103 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * stock_bill_of_lading_webkit +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-05-09 15:06+0000\n" +"PO-Revision-Date: 2014-05-09 11:14-0500\n" +"Last-Translator: Marc Cassuto \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_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:58 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:56 +msgid "Origin" +msgstr "Origine" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:59 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:57 +msgid "Scheduled Date" +msgstr "Date prévue" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:76 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:74 +msgid "Description" +msgstr "Description" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:20 +msgid "Ship to:" +msgstr "Livré à:" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:61 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:59 +msgid "Delivery Method" +msgstr "Méthode de livraison" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:53 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:51 +msgid "Delivery Order" +msgstr "Ordre de livraison" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:75 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:73 +msgid "Item" +msgstr "Item" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:77 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:75 +msgid "Serial Number" +msgstr "N° lot / N° série" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:57 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:55 +msgid "Contact" +msgstr "Contact" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:78 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:76 +msgid "Weight (kg)" +msgstr "Poids (kg)" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:40 +msgid "Ship to :" +msgstr "Livré à:" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:79 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:77 +msgid "Quantity" +msgstr "Quantité" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:21 +msgid "From :" +msgstr "De :" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:60 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:58 +msgid "Total Weight" +msgstr "Poid total" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:38 +msgid "Customer name & address:" +msgstr "Nom et adresse du client:" + diff --git a/stock_bill_of_lading_webkit/i18n/stock_bill_of_lading_webkit.pot b/stock_bill_of_lading_webkit/i18n/stock_bill_of_lading_webkit.pot new file mode 100644 index 0000000..f0adba9 --- /dev/null +++ b/stock_bill_of_lading_webkit/i18n/stock_bill_of_lading_webkit.pot @@ -0,0 +1,103 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * stock_bill_of_lading_webkit +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-05-09 15:06+0000\n" +"PO-Revision-Date: 2014-05-09 15:06+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:58 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:56 +msgid "Origin" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:59 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:57 +msgid "Scheduled Date" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:76 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:74 +msgid "Description" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:20 +msgid "Ship to:" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:61 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:59 +msgid "Delivery Method" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:53 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:51 +msgid "Delivery Order" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:75 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:73 +msgid "Item" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:77 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:75 +msgid "Serial Number" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:57 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:55 +msgid "Contact" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:78 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:76 +msgid "Weight (kg)" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:40 +msgid "Ship to :" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:79 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:77 +msgid "Quantity" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:21 +msgid "From :" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_in.mako:60 +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:58 +msgid "Total Weight" +msgstr "" + +#. module: stock_bill_of_lading_webkit +#: report:addons/stock_bill_of_lading_webkit/report/bol_out.mako:38 +msgid "Customer name & address:" +msgstr "" + diff --git a/stock_bill_of_lading_webkit/report.xml b/stock_bill_of_lading_webkit/report.xml new file mode 100644 index 0000000..bda6ce1 --- /dev/null +++ b/stock_bill_of_lading_webkit/report.xml @@ -0,0 +1,25 @@ + + + + + + + + + diff --git a/stock_bill_of_lading_webkit/report/__init__.py b/stock_bill_of_lading_webkit/report/__init__.py new file mode 100644 index 0000000..9a849d3 --- /dev/null +++ b/stock_bill_of_lading_webkit/report/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Copyright (c) 2011-2013 Camptocamp SA (http://www.camptocamp.com) +# @author Nicolas Bessi +# +# 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 stock_report diff --git a/stock_bill_of_lading_webkit/report/bol_in.mako b/stock_bill_of_lading_webkit/report/bol_in.mako new file mode 100644 index 0000000..46d31ae --- /dev/null +++ b/stock_bill_of_lading_webkit/report/bol_in.mako @@ -0,0 +1,106 @@ +## -*- coding: utf-8 -*- + + + + + + + <%page expression_filter="entity"/> + <% + def carriage_returns(text): + return text.replace('\n', '
') + %> + %for picking in objects: + <% setLang(picking.partner_id.lang) %> +
+ <% + warehouse_addr = warehouse_address(picking) + %> + + + + %if warehouse_addr.contact_address: + <% address_lines = warehouse_addr.contact_address.split("\n") %> + %for part in address_lines: + %if part: + + %endif + %endfor + %endif +
${_("Ship to :")}
${warehouse_addr.title and warehouse_addr.title.name or ''} ${warehouse_addr.name }
${part}
+ + %if picking.partner_id: + + %if picking.partner_id.parent_id: + + + <% address_lines = picking.partner_id.contact_address.split("\n")[1:] %> + %else: + + <% address_lines = picking.partner_id.contact_address.split("\n") %> + %endif + %for part in address_lines: + %if part: + + %endif + %endfor + %endif +
${_("From :")}
${picking.partner_id.parent_id.name or ''}
${picking.partner_id.title and picking.partner_id.title.name or ''} ${picking.partner_id.name }
${picking.partner_id.title and picking.partner_id.title.name or ''} ${picking.partner_id.name }
${part}
+
+ +

${_(u'Delivery Order') } ${picking.name}

+ + + + + + + + + + + + + + + + +
${_("Contact")}${_("Origin")}${_("Scheduled Date")}${_('Total Weight')}${_('Delivery Method')}
${user.name}${picking.origin or ''}${formatLang(picking.min_date, date=True)}${picking.weight}${picking.carrier_id and picking.carrier_id.name or ''}
+ + + + + + + + + + + + + %for line in picking.move_lines: + <% + weight = line.product_id.weight * line.product_qty + %> + + + + + + + + %endfor +
${_("Item")}${_("Description")}${_("Serial Number")}${_("Weight (kg)")}${_("Quantity")}
${ line.product_id.name }${ line.product_id.description or '' }${ line.prodlot_id and line.prodlot_id.name or ''}${ formatLang(weight) }${ formatLang(line.product_qty) } ${line.product_uom.name}
+ +
+ %if picking.note : +

${picking.note | carriage_returns}

+ %endif + +

+
+ %endfor + + diff --git a/stock_bill_of_lading_webkit/report/bol_out.mako b/stock_bill_of_lading_webkit/report/bol_out.mako new file mode 100644 index 0000000..07b9187 --- /dev/null +++ b/stock_bill_of_lading_webkit/report/bol_out.mako @@ -0,0 +1,133 @@ +## -*- coding: utf-8 -*- + + + + + + + <%page expression_filter="entity"/> + <% + def carriage_returns(text): + return text.replace('\n', '
') + %> + %for picking in objects: + <% setLang(picking.partner_id.lang) %> +

+ <% + invoice_addr = invoice_address(picking) + %> + + + %if invoice_addr.phone: + + %endif + %if invoice_addr.mobile: + + %endif + %if invoice_addr.email: + + %endif +
${_("Contact info:")}
${_("Phone:")} ${invoice_addr.phone }
${_("Cell:")} ${invoice_addr.mobile }
${_("Email:")} ${invoice_addr.email }
+ + + + %if invoice_addr.contact_address: + <% address_lines = invoice_addr.contact_address.split("\n") %> + %for part in address_lines: + %if part: + + %endif + %endfor + %endif +
${_("Customer name & address:")}
${invoice_addr.title and invoice_addr.title.name or ''} ${invoice_addr.name }
${part}
+
+
+ <% + picking_addr = picking_address(picking) + %> + + + %if picking.partner_id.parent_id: + + + <% address_lines = picking.partner_id.contact_address.split("\n")[1:] %> + %else: + + <% address_lines = picking.partner_id.contact_address.split("\n") %> + %endif + %for part in address_lines: + %if part: + + %endif + %endfor +
${_("Ship to:")}
${picking.partner_id.parent_id.name or ''}
${picking.partner_id.title and picking.partner_id.title.name or ''} ${picking.partner_id.name }
${picking.partner_id.title and picking.partner_id.title.name or ''} ${picking.partner_id.name }
${part}
+ + + + %if picking_addr.contact_address: + <% address_lines = picking_addr.contact_address.split("\n") %> + %for part in address_lines: + %if part: + + %endif + %endfor + %endif +
${_("Pick from:")}
${picking_addr.title and picking_addr.title.name or ''} ${picking_addr.name }
${part}
+
+ +

${_(u'Delivery Order') } ${picking.name}

+ + + + + + + + + + + + + + + + +
${_("Customer Ref")}${_("Origin")}${_("Scheduled Date")}${_('Total Weight')}${_('Delivery Method')}
${picking.sale_id.client_order_ref if picking.sale_id else ''}${picking.origin or ''}${formatLang(picking.min_date, date=True)}${picking.weight}${picking.carrier_id and picking.carrier_id.name or ''}
+ + + + + + + + + + + + + %for line in picking.move_lines: + <% + weight = line.product_id.weight * line.product_qty + %> + + + + + + + + %endfor +
${_("Item")}${_("Description")}${_("Serial Number")}${_("Weight (kg)")}${_("Quantity")}
${ line.product_id.name }${ line.product_id.description or ''}${ line.prodlot_id and line.prodlot_id.name or ''}${ formatLang(weight) }${ formatLang(line.product_qty) } ${line.product_uom.name}
+ +
+ %if picking.note : +

${picking.note | carriage_returns}

+ %endif + +

+
+ %endfor + + diff --git a/stock_bill_of_lading_webkit/report/stock_report.py b/stock_bill_of_lading_webkit/report/stock_report.py new file mode 100644 index 0000000..8a536dd --- /dev/null +++ b/stock_bill_of_lading_webkit/report/stock_report.py @@ -0,0 +1,95 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Copyright (c) 2011-2013 Camptocamp SA (http://www.camptocamp.com) +# @author Nicolas Bessi +# Copyright (c) 2013 Agile Business Group (http://www.agilebg.com) +# @author Lorenzo Battistini +# +# 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 report import report_sxw +import time + + +class BillOfLadingOut(report_sxw.rml_parse): + def _get_invoice_address(self, picking): + if picking.sale_id: + return picking.sale_id.partner_invoice_id + partner_obj = self.pool.get('res.partner') + invoice_address_id = picking.partner_id.address_get( + adr_pref=['invoice'] + )['invoice'] + return partner_obj.browse( + self.cr, self.uid, invoice_address_id) + + def _get_picking_address(self, picking): + # By default, print the warehouse selected manually + if picking.manual_warehouse_id: + return picking.manual_warehouse_id.partner_id + # if not set, print the shipping address of the default company's + # warehouse + partner_obj = self.pool.get('res.partner') + warehouse_address_id = picking.company_id.partner_id.address_get( + adr_pref=['shipping'] + )['shipping'] + return partner_obj.browse( + self.cr, self.uid, warehouse_address_id) + + def __init__(self, cr, uid, name, context): + super(BillOfLadingOut, self).__init__(cr, uid, name, context=context) + self.localcontext.update({ + 'time': time, + 'invoice_address': self._get_invoice_address, + 'picking_address': self._get_picking_address, + }) + +report_sxw.report_sxw('report.webkit.bill_of_lading_out', + 'stock.picking', + 'addons/stock_bill_of_lading_webkit/report/bol_out.mako', + parser=BillOfLadingOut) + + +class BillOfLadingIn(report_sxw.rml_parse): + def _get_warehouse_address(self, picking): + # By default, print the warehouse selected from the related + # purchase order + if picking.purchase_id: + return picking.purchase_id.warehouse_id.partner_id + # else, print the warehouse selected manually + if picking.manual_warehouse_id: + return picking.manual_warehouse_id.partner_id + # if none of the above, print the shipping address of the default + # company's warehouse + partner_obj = self.pool.get('res.partner') + warehouse_address_id = picking.company_id.partner_id.address_get( + adr_pref=['shipping'] + )['shipping'] + return partner_obj.browse( + self.cr, self.uid, warehouse_address_id) + + def __init__(self, cr, uid, name, context): + super(BillOfLadingIn, self).__init__(cr, uid, name, context=context) + self.localcontext.update({ + 'time': time, + 'warehouse_address': self._get_warehouse_address, + }) + + +report_sxw.report_sxw('report.webkit.bill_of_lading_in', + 'stock.picking', + 'addons/stock_bill_of_lading_webkit/report/bol_in.mako', + parser=BillOfLadingIn) diff --git a/stock_bill_of_lading_webkit/stock.py b/stock_bill_of_lading_webkit/stock.py new file mode 100644 index 0000000..0db09c8 --- /dev/null +++ b/stock_bill_of_lading_webkit/stock.py @@ -0,0 +1,70 @@ +# -*- encoding: utf-8 -*- +############################################################################### +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Savoir-faire Linux +# (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################### +from openerp.osv import fields, orm + + +class StockPickingOutWarehouse(orm.Model): + _inherit = "stock.picking.out" + _columns = { + 'manual_warehouse_id': fields.many2one( + 'stock.warehouse', + 'Picking from', + readonly=True, + states={ + 'draft': [('readonly', False)], + 'confirmed': [('readonly', False)], + 'assigned': [('readonly', False)], + } + ), + } + + +class StockPickingInWarehouse(orm.Model): + _inherit = "stock.picking.in" + _columns = { + 'manual_warehouse_id': fields.many2one( + 'stock.warehouse', + 'Deliver to', + readonly=True, + states={ + 'draft': [('readonly', False)], + 'confirmed': [('readonly', False)], + 'assigned': [('readonly', False)], + } + ), + } + + +class StockPickingWarehouse(orm.Model): + _inherit = "stock.picking" + _columns = { + 'manual_warehouse_id': fields.many2one( + 'stock.warehouse', + 'Warehouse', + readonly=True, + states={ + 'draft': [('readonly', False)], + 'confirmed': [('readonly', False)], + 'assigned': [('readonly', False)], + } + ), + } diff --git a/stock_bill_of_lading_webkit/stock_view.xml b/stock_bill_of_lading_webkit/stock_view.xml new file mode 100644 index 0000000..db79cef --- /dev/null +++ b/stock_bill_of_lading_webkit/stock_view.xml @@ -0,0 +1,36 @@ + + + + + + stock.picking + + + + + + + + + + stock.picking.out + + + + + + + + + + stock.picking.in + + + + + + + + + + diff --git a/stock_picking_webkit/__init__.py b/stock_picking_webkit/__init__.py index cf0eee0..252a0e6 100644 --- a/stock_picking_webkit/__init__.py +++ b/stock_picking_webkit/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +############################################################################### # # Copyright (c) 2011-2013 Camptocamp SA (http://www.camptocamp.com) # @author Nicolas Bessi @@ -17,6 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -############################################################################## +############################################################################### from . import report diff --git a/stock_picking_webkit/__openerp__.py b/stock_picking_webkit/__openerp__.py index 4c7561f..f47f3e1 100644 --- a/stock_picking_webkit/__openerp__.py +++ b/stock_picking_webkit/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +############################################################################### # # Copyright (c) 2011-2013 Camptocamp SA (http://www.camptocamp.com) # @author Nicolas Bessi @@ -19,7 +19,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -############################################################################## +############################################################################### { 'name': 'Picking reports using Webkit Library', @@ -34,7 +34,11 @@ Three reports are provided: """, 'author': 'Camptocamp', 'website': 'http://www.openerp.com', - 'depends': ['base', 'report_webkit', 'base_headers_webkit', 'stock', 'delivery'], + 'depends': ['base', + 'report_webkit', + 'base_headers_webkit', + 'stock', + 'delivery'], 'data': ['report.xml', 'stock_view.xml', ], diff --git a/stock_picking_webkit/report/__init__.py b/stock_picking_webkit/report/__init__.py index cda5838..3bbbe54 100644 --- a/stock_picking_webkit/report/__init__.py +++ b/stock_picking_webkit/report/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +############################################################################### # # Copyright (c) 2011-2013 Camptocamp SA (http://www.camptocamp.com) # @author Nicolas Bessi @@ -17,5 +17,5 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -############################################################################## +############################################################################### import stock_report diff --git a/stock_picking_webkit/report/stock_report.py b/stock_picking_webkit/report/stock_report.py index 4561a71..ad3d30c 100644 --- a/stock_picking_webkit/report/stock_report.py +++ b/stock_picking_webkit/report/stock_report.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +############################################################################### # # Copyright (c) 2011-2013 Camptocamp SA (http://www.camptocamp.com) # @author Nicolas Bessi @@ -19,12 +19,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +############################################################################### import operator from report import report_sxw import pooler import time + class NullMove(object): """helper class to generate empty lines in the delivery report""" def __init__(self): @@ -32,8 +34,10 @@ class NullMove(object): self.picking_id = NullObj() self.product_qty = '' + class NullObj(object): - """the null obj has any attribute you want with an empty string as the value""" + """the null obj has any attribute you want with an empty string + as the value""" def __getattr__(self, attr): return '' @@ -52,11 +56,14 @@ class PickingAgregation(object): return hash((self.src_stock.id, self.dest_stock.id)) def __eq__(self, other): - return (self.src_stock.id, self.dest_stock.id) == (other.src_stock.id, other.dest_stock.id) + return (self.src_stock.id, + self.dest_stock.id) == (other.src_stock.id, + other.dest_stock.id) def moves_by_product(self): """iterate over moves sorted by product default_code""" - return sorted(self.stock_moves, key=operator.attrgetter('product_id.default_code')) + return sorted(self.stock_moves, + key=operator.attrgetter('product_id.default_code')) def moves_by_sale_order(self): """iterate over moves sorted by sale order name @@ -65,7 +72,8 @@ class PickingAgregation(object): the report displays an empty line """ origin = None - for move in sorted(self.stock_moves, key=operator.attrgetter('picking_id.origin')): + for move in sorted(self.stock_moves, + key=operator.attrgetter('picking_id.origin')): if origin is None: origin = move.picking_id.origin else: @@ -89,6 +97,7 @@ class PickingAgregation(object): for p_code in sorted(products): yield products[p_code], product_qty[p_code] + class PrintPick(report_sxw.rml_parse): def __init__(self, cursor, uid, name, context): @@ -104,7 +113,7 @@ class PrintPick(report_sxw.rml_parse): def set_context(self, objects, data, ids, report_type=None): """Return res.partner.category""" - #!! data form is manually set in wizard + # data form is manually set in wizard agreg = {} for pick in objects: for move in pick.move_lines: @@ -115,7 +124,8 @@ class PrintPick(report_sxw.rml_parse): for agr in agreg: print agr objects.append(PickingAgregation(agr[0], agr[1], agreg[agr])) - return super(PrintPick, self).set_context(objects, data, ids, report_type=report_type) + return super(PrintPick, self).set_context(objects, data, ids, + report_type=report_type) class DeliverySlip(report_sxw.rml_parse): @@ -135,7 +145,7 @@ class DeliverySlip(report_sxw.rml_parse): self.localcontext.update({ 'time': time, 'invoice_address': self._get_invoice_address, - }) + }) report_sxw.report_sxw('report.webkit.aggregated_picking', 'stock.picking',