diff --git a/stock_picking_invoice_journal_policy/README.rst b/stock_picking_invoice_journal_policy/README.rst new file mode 100644 index 0000000..c89274c --- /dev/null +++ b/stock_picking_invoice_journal_policy/README.rst @@ -0,0 +1,48 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============================================ +Create Invoice From Picking's Journal Policy +============================================ + + +Installation +============ + +To install this module, you need to: + +1. Clone the branch 8.0 of the repository https://github.com/open-synergy/opnsynid-stock-logistics-warehouse +2. Add the path to this repository in your configuration (addons-path) +3. Update the module list +4. Go to menu *Setting -> Modules -> Local Modules* +5. Search For *Create Invoice From Picking's Journal Policy* +6. Install the module + +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. + + +Credits +======= + +Contributors +------------ + +* Michael Viriyananda +* Andhitia Rama + +Maintainer +---------- + +.. image:: https://opensynergy-indonesia.com/logo.png + :alt: OpenSynergy Indonesia + :target: https://opensynergy-indonesia.com + +This module is maintained by the OpenSynergy Indonesia. diff --git a/stock_picking_invoice_journal_policy/__init__.py b/stock_picking_invoice_journal_policy/__init__.py new file mode 100644 index 0000000..42acb48 --- /dev/null +++ b/stock_picking_invoice_journal_policy/__init__.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import ( + models, + wizards, +) diff --git a/stock_picking_invoice_journal_policy/__openerp__.py b/stock_picking_invoice_journal_policy/__openerp__.py new file mode 100644 index 0000000..5db9a75 --- /dev/null +++ b/stock_picking_invoice_journal_policy/__openerp__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# pylint: disable=locally-disabled, manifest-required-author +{ + "name": "Create Invoice From Picking's Journal Policy", + "version": "8.0.1.0.0", + "category": "Stock Management", + "website": "https://opensynergy-indonesia.com", + "author": "OpenSynergy Indonesia", + "license": "AGPL-3", + "installable": True, + "depends": [ + "stock_account", + ], + "data": [ + "wizards/stock_invoice_onshipping.xml", + "views/stock_picking_type_views.xml", + ], +} diff --git a/stock_picking_invoice_journal_policy/models/__init__.py b/stock_picking_invoice_journal_policy/models/__init__.py new file mode 100644 index 0000000..96b5c75 --- /dev/null +++ b/stock_picking_invoice_journal_policy/models/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import ( + stock_picking_type, +) diff --git a/stock_picking_invoice_journal_policy/models/stock_picking_type.py b/stock_picking_invoice_journal_policy/models/stock_picking_type.py new file mode 100644 index 0000000..345319a --- /dev/null +++ b/stock_picking_invoice_journal_policy/models/stock_picking_type.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields + + +class StockPickingType(models.Model): + _inherit = "stock.picking.type" + + allowed_invoice_journal_ids = fields.Many2many( + string="Allowed Invoice Journals", + comodel_name="account.journal", + relation="rel_stock_picking_type_2_invoice_journal", + column1="stock_picking_id", + column2="journal_id", + ) + default_invoice_journal_id = fields.Many2one( + string="Default Invoice Journal", + comodel_name="account.journal", + ) diff --git a/stock_picking_invoice_journal_policy/static/description/icon.png b/stock_picking_invoice_journal_policy/static/description/icon.png new file mode 100644 index 0000000..270415f Binary files /dev/null and b/stock_picking_invoice_journal_policy/static/description/icon.png differ diff --git a/stock_picking_invoice_journal_policy/views/stock_picking_type_views.xml b/stock_picking_invoice_journal_policy/views/stock_picking_type_views.xml new file mode 100644 index 0000000..c85a244 --- /dev/null +++ b/stock_picking_invoice_journal_policy/views/stock_picking_type_views.xml @@ -0,0 +1,20 @@ + + + + + Stock Picking Type Policy Form + stock.picking.type + + + + + + + + + + + + + + diff --git a/stock_picking_invoice_journal_policy/wizards/__init__.py b/stock_picking_invoice_journal_policy/wizards/__init__.py new file mode 100644 index 0000000..2b273ea --- /dev/null +++ b/stock_picking_invoice_journal_policy/wizards/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import stock_invoice_onshipping diff --git a/stock_picking_invoice_journal_policy/wizards/stock_invoice_onshipping.py b/stock_picking_invoice_journal_policy/wizards/stock_invoice_onshipping.py new file mode 100644 index 0000000..d0da10e --- /dev/null +++ b/stock_picking_invoice_journal_policy/wizards/stock_invoice_onshipping.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, api, fields + + +class StockInvoiceOnshipping(models.TransientModel): + _inherit = "stock.invoice.onshipping" + + @api.model + def _default_stock_picking_id(self): + active_ids = self._context.get("active_ids", []) + if len(active_ids) > 0: + return active_ids[0] + else: + return False + + stock_picking_id = fields.Many2one( + string="Stock Picking", + comodel_name="stock.picking", + default=lambda self: self._default_stock_picking_id(), + ) + allowed_invoice_journal_ids = fields.Many2many( + string="Allowed Invoice Journals", + comodel_name="account.journal", + related="stock_picking_id.picking_type_id.allowed_invoice_journal_ids", + ) + + @api.onchange("stock_picking_id") + def onchange_journal_id(self): + self.journal_id = False + if self.stock_picking_id: + picking = self.stock_picking_id + if picking.picking_type_id: + picking_type = picking.picking_type_id + if picking_type.default_invoice_journal_id: + self.journal_id = picking_type.default_invoice_journal_id diff --git a/stock_picking_invoice_journal_policy/wizards/stock_invoice_onshipping.xml b/stock_picking_invoice_journal_policy/wizards/stock_invoice_onshipping.xml new file mode 100644 index 0000000..e8bcce6 --- /dev/null +++ b/stock_picking_invoice_journal_policy/wizards/stock_invoice_onshipping.xml @@ -0,0 +1,23 @@ + + + + + stock.invoice.onshipping form + stock.invoice.onshipping + extension + + + + + + + + + [('id','in',allowed_invoice_journal_ids[0][2])] + + + + + + +