diff --git a/stock_picking_comment_template/README.rst b/stock_picking_comment_template/README.rst new file mode 100644 index 0000000..ca87572 --- /dev/null +++ b/stock_picking_comment_template/README.rst @@ -0,0 +1,84 @@ +================ +Picking Comments +================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--reporting-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-reporting/tree/11.0/stock_picking_comment_template + :alt: OCA/stock-logistics-reporting +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-reporting-11-0/stock-logistics-reporting-11-0-stock_picking_comment_template + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/151/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Adds comments on stock picking. +The comments can be edited directly on the stock picking or loaded from +templates. + +Two positions are available for the comments: + +- above stock picking lines +- below stock picking lines + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* C2i Change 2 improve + +Contributors +~~~~~~~~~~~~ + +* `C2i Change 2 improve `_: + + * Eduardo Magdalena + +Do not contact contributors directly about support or help with technical issues. + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/stock-logistics-reporting `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_picking_comment_template/__init__.py b/stock_picking_comment_template/__init__.py new file mode 100644 index 0000000..83e553a --- /dev/null +++ b/stock_picking_comment_template/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/stock_picking_comment_template/__manifest__.py b/stock_picking_comment_template/__manifest__.py new file mode 100644 index 0000000..9c3ef85 --- /dev/null +++ b/stock_picking_comment_template/__manifest__.py @@ -0,0 +1,26 @@ +# Copyright 2019 C2i Change 2 improve - Eduardo Magdalena +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Picking Comments", + "summary": "Comments texts templates on Picking documents", + "version": "11.0.1.0.0", + "category": "Warehouse Management", + "website": "https://github.com/OCA/stock-logistics-reporting", + "author": "C2i Change 2 improve," + "Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": [ + "stock", + "sale", + "base_comment_template", + ], + "data": [ + 'views/base_comment_template_view.xml', + 'views/report_picking.xml', + 'views/report_delivery_document.xml', + "views/stock_picking_view.xml", + 'security/ir.model.access.csv', + ], + 'installable': True, +} diff --git a/stock_picking_comment_template/models/__init__.py b/stock_picking_comment_template/models/__init__.py new file mode 100644 index 0000000..722ac40 --- /dev/null +++ b/stock_picking_comment_template/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import stock_picking +from . import res_partner diff --git a/stock_picking_comment_template/models/res_partner.py b/stock_picking_comment_template/models/res_partner.py new file mode 100644 index 0000000..8aafc89 --- /dev/null +++ b/stock_picking_comment_template/models/res_partner.py @@ -0,0 +1,13 @@ +# Copyright 2019 C2i Change 2 improve - Eduardo Magdalena +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + comment_template_id = fields.Many2one( + comodel_name='base.comment.template', + string='Conditions template', + ) diff --git a/stock_picking_comment_template/models/stock_picking.py b/stock_picking_comment_template/models/stock_picking.py new file mode 100644 index 0000000..026dd7e --- /dev/null +++ b/stock_picking_comment_template/models/stock_picking.py @@ -0,0 +1,37 @@ +# Copyright 2019 C2i Change 2 improve - Eduardo Magdalena +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class StockPicking(models.Model): + """Add text comment""" + + _inherit = "stock.picking" + + comment_template1_id = fields.Many2one('base.comment.template', + string='Top Comment Template') + comment_template2_id = fields.Many2one('base.comment.template', + string='Bottom Comment Template') + note1 = fields.Html('Top Comment') + note2 = fields.Html('Bottom Comment') + + @api.onchange('comment_template1_id') + def _set_note1(self): + comment = self.comment_template1_id + if comment: + self.note1 = comment.get_value(self.partner_id.id) + + @api.onchange('comment_template2_id') + def _set_note2(self): + comment = self.comment_template2_id + if comment: + self.note2 = comment.get_value(self.partner_id.id) + + @api.onchange('partner_id') + def _onchange_partner_id(self): + comment_template = self.partner_id.comment_template_id + if comment_template.position == 'before_lines': + self.comment_template1_id = comment_template + elif comment_template.position == 'after_lines': + self.comment_template2_id = comment_template diff --git a/stock_picking_comment_template/readme/CONTRIBUTORS.rst b/stock_picking_comment_template/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..4d52f88 --- /dev/null +++ b/stock_picking_comment_template/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* `C2i Change 2 improve `_: + + * Eduardo Magdalena + +Do not contact contributors directly about support or help with technical issues. diff --git a/stock_picking_comment_template/readme/DESCRIPTION.rst b/stock_picking_comment_template/readme/DESCRIPTION.rst new file mode 100644 index 0000000..22f0014 --- /dev/null +++ b/stock_picking_comment_template/readme/DESCRIPTION.rst @@ -0,0 +1,8 @@ +Adds comments on stock picking. +The comments can be edited directly on the stock picking or loaded from +templates. + +Two positions are available for the comments: + +- above stock picking lines +- below stock picking lines diff --git a/stock_picking_comment_template/security/ir.model.access.csv b/stock_picking_comment_template/security/ir.model.access.csv new file mode 100644 index 0000000..9f5bcf9 --- /dev/null +++ b/stock_picking_comment_template/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_base_comment_template_account_user,access_base_comment_template user,base_comment_template.model_base_comment_template,account.group_account_user,1,0,0,0 +access_base_comment_template_account_manager,access_base_comment_template manager,base_comment_template.model_base_comment_template,account.group_account_manager,1,1,1,1 diff --git a/stock_picking_comment_template/static/description/icon.png b/stock_picking_comment_template/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/stock_picking_comment_template/static/description/icon.png differ diff --git a/stock_picking_comment_template/static/description/index.html b/stock_picking_comment_template/static/description/index.html new file mode 100644 index 0000000..e9b01d8 --- /dev/null +++ b/stock_picking_comment_template/static/description/index.html @@ -0,0 +1,430 @@ + + + + + + +Picking Comments + + + +
+

Picking Comments

+ + +

Beta License: AGPL-3 OCA/stock-logistics-reporting Translate me on Weblate Try me on Runbot

+

Adds comments on stock picking. +The comments can be edited directly on the stock picking or loaded from +templates.

+

Two positions are available for the comments:

+
    +
  • above stock picking lines
  • +
  • below stock picking lines
  • +
+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • C2i Change 2 improve
  • +
+
+
+

Contributors

+ +

Do not contact contributors directly about support or help with technical issues.

+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/stock-logistics-reporting project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/stock_picking_comment_template/tests/__init__.py b/stock_picking_comment_template/tests/__init__.py new file mode 100644 index 0000000..19796c0 --- /dev/null +++ b/stock_picking_comment_template/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2019 C2i Change 2 improve - Eduardo Magdalena +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_stock_picking_report diff --git a/stock_picking_comment_template/tests/test_stock_picking_report.py b/stock_picking_comment_template/tests/test_stock_picking_report.py new file mode 100644 index 0000000..3c386a1 --- /dev/null +++ b/stock_picking_comment_template/tests/test_stock_picking_report.py @@ -0,0 +1,55 @@ +# Copyright 2019 C2i Change 2 improve - Eduardo Magdalena +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestStockPickingReport(TransactionCase): + at_install = False + post_install = True + + def setUp(self): + super(TestStockPickingReport, self).setUp() + self.base_comment_model = self.env['base.comment.template'] + self.before_comment = self._create_comment('before_lines') + self.after_comment = self._create_comment('after_lines') + self.partner = self.env['res.partner'].create({ + 'name': 'Partner Test' + }) + self.picking_model = self.env['stock.picking'] + self.picking = self.picking_model.create({ + 'partner_id': self.partner.id, + 'location_id': self.ref('stock.stock_location_stock'), + 'location_dest_id': self.ref('stock.stock_location_customers'), + 'picking_type_id': self.ref('stock.picking_type_out'), + 'comment_template1_id': self.before_comment.id, + 'comment_template2_id': self.after_comment.id + }) + + self.picking._set_note1() + self.picking._set_note2() + + def _create_comment(self, position): + return self.base_comment_model.create({ + 'name': 'Comment ' + position, + 'position': position, + 'text': 'Text ' + position + }) + + def test_comments_in_picking(self): + res = self.env['ir.actions.report']._get_report_from_name( + 'stock.report_picking' + ).render_qweb_html(self.picking.ids) + self.assertRegexpMatches(str(res[0]), self.before_comment.text) + self.assertRegexpMatches(str(res[0]), self.after_comment.text) + + def test_onchange_partner_id(self): + self.partner.comment_template_id = self.after_comment.id + new_picking = self.env['stock.picking'].new({ + 'partner_id': self.partner.id, + }) + new_picking._onchange_partner_id() + self.assertEqual(new_picking.comment_template2_id, self.after_comment) + self.partner.comment_template_id = self.before_comment.id + new_picking._onchange_partner_id() + self.assertEqual(new_picking.comment_template1_id, self.before_comment) diff --git a/stock_picking_comment_template/views/base_comment_template_view.xml b/stock_picking_comment_template/views/base_comment_template_view.xml new file mode 100644 index 0000000..3977eea --- /dev/null +++ b/stock_picking_comment_template/views/base_comment_template_view.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/stock_picking_comment_template/views/report_delivery_document.xml b/stock_picking_comment_template/views/report_delivery_document.xml new file mode 100644 index 0000000..2f618ba --- /dev/null +++ b/stock_picking_comment_template/views/report_delivery_document.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/stock_picking_comment_template/views/report_picking.xml b/stock_picking_comment_template/views/report_picking.xml new file mode 100644 index 0000000..297e83e --- /dev/null +++ b/stock_picking_comment_template/views/report_picking.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/stock_picking_comment_template/views/stock_picking_view.xml b/stock_picking_comment_template/views/stock_picking_view.xml new file mode 100644 index 0000000..69d06f8 --- /dev/null +++ b/stock_picking_comment_template/views/stock_picking_view.xml @@ -0,0 +1,30 @@ + + + + stock.picking.form.comment + stock.picking + + + + +

The comments will be displayed on the printed document. You can load a predefined template, write your own text or load a template and then modify it only for this document.

+ + + + + + + + +
+
+
+
+ +