Skip to content

Commit

Permalink
[8.0.1.0.0] stock_production_lot_by_product
Browse files Browse the repository at this point in the history
  • Loading branch information
andhit-r committed Sep 25, 2018
1 parent 2458c8b commit 621dc80
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 0 deletions.
49 changes: 49 additions & 0 deletions stock_production_lot_by_product/README.rst
Original file line number Diff line number Diff line change
@@ -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
<https://github.com/open-synergy/opnsynid-stock-logistics-workflow/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 <andhitia.r@gmail.com>

Maintainer
----------

.. image:: https://opensynergy-indonesia.com/logo.png
:alt: OpenSynergy Indonesia
:target: https://opensynergy-indonesia.com

This module is maintained by the OpenSynergy Indonesia.
5 changes: 5 additions & 0 deletions stock_production_lot_by_product/__init__.py
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions stock_production_lot_by_product/__openerp__.py
Original file line number Diff line number Diff line change
@@ -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",
],
}
6 changes: 6 additions & 0 deletions stock_production_lot_by_product/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions stock_production_lot_by_product/models/product_product.py
Original file line number Diff line number Diff line change
@@ -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,
)
44 changes: 44 additions & 0 deletions stock_production_lot_by_product/models/stock_production_lot.py
Original file line number Diff line number Diff line change
@@ -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")
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions stock_production_lot_by_product/views/product_product_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 OpenSynergy Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<openerp>
<data>

<record id="product_product_view_form" model="ir.ui.view">
<field name="name">Production Lot By Production</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='lot']" position="inside">
<field name="lot_sequence_id"/>
</xpath>
</field>
</record>

</data>
</openerp>

0 comments on commit 621dc80

Please sign in to comment.