diff --git a/stock_production_lot_by_product/README.rst b/stock_production_lot_by_product/README.rst new file mode 100644 index 0000000..ebf6771 --- /dev/null +++ b/stock_production_lot_by_product/README.rst @@ -0,0 +1,49 @@ +.. 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 + +========================= +Production Lot By Product +========================= + + + + +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-workflow +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 *Production Lot By Product* +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 +------------ + +* 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_production_lot_by_product/__init__.py b/stock_production_lot_by_product/__init__.py new file mode 100644 index 0000000..814c523 --- /dev/null +++ b/stock_production_lot_by_product/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/stock_production_lot_by_product/__openerp__.py b/stock_production_lot_by_product/__openerp__.py new file mode 100644 index 0000000..c05dd7c --- /dev/null +++ b/stock_production_lot_by_product/__openerp__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Production Lot By Product", + "version": "8.0.1.0.0", + "category": "Stock Management", + "website": "https://opensynergy-indonesia.com", + "author": "OpenSynergy Indonesia", + "license": "AGPL-3", + "installable": True, + "depends": [ + "stock", + ], + "data": [ + "views/product_product_views.xml", + ], +} diff --git a/stock_production_lot_by_product/models/__init__.py b/stock_production_lot_by_product/models/__init__.py new file mode 100644 index 0000000..0842b9f --- /dev/null +++ b/stock_production_lot_by_product/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import product_product +from . import stock_production_lot diff --git a/stock_production_lot_by_product/models/product_product.py b/stock_production_lot_by_product/models/product_product.py new file mode 100644 index 0000000..f21a762 --- /dev/null +++ b/stock_production_lot_by_product/models/product_product.py @@ -0,0 +1,15 @@ +# -*- 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 ProductProduct(models.Model): + _inherit = "product.product" + + lot_sequence_id = fields.Many2one( + string="Lot Sequence", + comodel_name="ir.sequence", + company_dependent=True, + ) diff --git a/stock_production_lot_by_product/models/stock_production_lot.py b/stock_production_lot_by_product/models/stock_production_lot.py new file mode 100644 index 0000000..ed8450c --- /dev/null +++ b/stock_production_lot_by_product/models/stock_production_lot.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 OpenSynergy Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields, api + + +class StockProductionLot(models.Model): + _inherit = "stock.production.lot" + + @api.model + def _default_name(self): + return "/" + + name = fields.Char( + string="Serial Number", + required=True, + help="Unique Serial Number", + default=lambda self: self._default_name(), + ) + + @api.model + def create(self, values): + product_id = values["product_id"] + if values["name"] == "/": + values["name"] = self._create_sequence(product_id) + _super = super(StockProductionLot, self) + return _super.create(values) + + @api.model + def _create_sequence(self, product_id): + sequence = self._get_sequence(product_id) + name = self.env["ir.sequence"].\ + next_by_id(sequence.id) + return name + + @api.model + def _get_sequence(self, product_id): + obj_product = self.env["product.product"] + product = obj_product.browse([product_id])[0] + if product.lot_sequence_id: + return product.lot_sequence_id + else: + return self.env.ref("stock.sequence_production_lots") diff --git a/stock_production_lot_by_product/static/description/icon.png b/stock_production_lot_by_product/static/description/icon.png new file mode 100644 index 0000000..270415f Binary files /dev/null and b/stock_production_lot_by_product/static/description/icon.png differ diff --git a/stock_production_lot_by_product/views/product_product_views.xml b/stock_production_lot_by_product/views/product_product_views.xml new file mode 100644 index 0000000..ac42496 --- /dev/null +++ b/stock_production_lot_by_product/views/product_product_views.xml @@ -0,0 +1,20 @@ + + + + + + + + Production Lot By Production + product.product + + + + + + + + + +