Skip to content

Commit

Permalink
[ADD] stock_lot_name_adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
kanda999 committed Mar 27, 2023
1 parent e620836 commit 0e31318
Show file tree
Hide file tree
Showing 10 changed files with 548 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/stock_lot_name_adjust/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
54 changes: 54 additions & 0 deletions stock_lot_name_adjust/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
=====================
Stock Lot Name Adjust
=====================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-qrtl%2Faxls--custom-lightgray.png?logo=github
:target: https://github.com/qrtl/axls-custom/tree/16.0/stock_lot_name_adjust
:alt: qrtl/axls-custom

|badge1| |badge2| |badge3|

This module does the following:

* Adds the default code field to the lot, which should be part of the lot display name presentation and can also be used in product search.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/qrtl/axls-custom/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 <https://github.com/qrtl/axls-custom/issues/new?body=module:%20stock_lot_name_adjust%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Quartile Limited

Maintainers
~~~~~~~~~~~

This module is part of the `qrtl/axls-custom <https://github.com/qrtl/axls-custom/tree/16.0/stock_lot_name_adjust>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions stock_lot_name_adjust/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions stock_lot_name_adjust/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Stock Lot Name Adjust",
"version": "16.0.1.0.0",
"author": "Quartile Limited",
"website": "https://www.quartile.co",
"category": "Inventory",
"license": "AGPL-3",
"depends": ["stock"],
"data": [
"views/stock_lot_views.xml",
],
"installable": True,
}
1 change: 1 addition & 0 deletions stock_lot_name_adjust/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_lot
39 changes: 39 additions & 0 deletions stock_lot_name_adjust/models/stock_lot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import re
from odoo import models, api


class StockLot(models.Model):
_inherit = "stock.lot"
_rec_names_search = ["name", "product_id.default_code"]

def name_get(self):
name_list = []
for rec in self:
default_code = rec.product_id.default_code
name = rec.name
if default_code:
name = "[%s] %s" % (default_code, name)
name_list.append((rec.id, name))
return name_list

@api.model
def _name_search(
self, name, args=None, operator="ilike", limit=100, name_get_uid=None
):
args = []
if name:
lot_ids = list(self._search(args, limit=limit, access_rights_uid=name_get_uid))
args += [
"|",
("name", operator, name),
("product_id.default_code", operator, name),
]
if not lot_ids:
ptrn = re.compile('(\[(.*?)\])')
res = ptrn.search(name)
if res:
lot_ids = list(self._search([('default_code', '=', res.group(2))] + args, limit=limit, access_rights_uid=name_get_uid))
return lot_ids
3 changes: 3 additions & 0 deletions stock_lot_name_adjust/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module does the following:

* Adds the default code field to the lot, which should be part of the lot display name presentation and can also be used in product search.
Loading

0 comments on commit 0e31318

Please sign in to comment.