Skip to content

Commit

Permalink
[3546][ADD] stock_lot_suffix (#37)
Browse files Browse the repository at this point in the history
* [3546][ADD] stock_lot_suffix
  • Loading branch information
kanda999 authored Jul 24, 2023
1 parent 01b63c2 commit e47eb95
Show file tree
Hide file tree
Showing 19 changed files with 737 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup/stock_lot_suffix/odoo/addons/stock_lot_suffix
6 changes: 6 additions & 0 deletions setup/stock_lot_suffix/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,
)
57 changes: 57 additions & 0 deletions stock_lot_suffix/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
================
Stock Lot Suffix
================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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_suffix
:alt: qrtl/axls-custom

|badge1| |badge2| |badge3|

This module provides the functionality to add suffixes to the display name of lots/serials.

Suffixes are added to lots/serials created from purchase receipts with following conditions:

- Purchase order has the channel_category set.
- Purchase order line has an analytic account with lot suffix.

**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_suffix%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_suffix>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions stock_lot_suffix/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions stock_lot_suffix/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Stock Lot Suffix",
"version": "16.0.1.0.0",
"author": "Quartile Limited",
"website": "https://www.quartile.co",
"category": "Inventory",
"license": "AGPL-3",
"depends": ["purchase_stock", "analytic_mixin_analytic_account"],
"data": [
"views/account_analytic_account_views.xml",
"views/stock_lot_views.xml",
"views/purchase_order_views.xml",
"views/res_partner_views.xml",
],
"installable": True,
}
92 changes: 92 additions & 0 deletions stock_lot_suffix/i18n/ja.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_lot_suffix
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-14 09:37+0000\n"
"PO-Revision-Date: 2023-07-14 09:37+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_lot_suffix
#: model:ir.model.fields,field_description:stock_lot_suffix.field_purchase_order__analytic_distribution
msgid "Analytic"
msgstr "分析"

#. module: stock_lot_suffix
#: model:ir.model,name:stock_lot_suffix.model_account_analytic_account
msgid "Analytic Account"
msgstr "分析勘定"

#. module: stock_lot_suffix
#: model:ir.model.fields,field_description:stock_lot_suffix.field_purchase_order__analytic_account_names
msgid "Analytic Account Names"
msgstr "分析勘定名"

#. module: stock_lot_suffix
#: model:ir.model.fields,field_description:stock_lot_suffix.field_purchase_order__analytic_account_ids
msgid "Analytic Accounts"
msgstr "分析勘定"

#. module: stock_lot_suffix
#: model:ir.model.fields,field_description:stock_lot_suffix.field_account_analytic_account__lot_suffix
#: model:ir.model.fields,field_description:stock_lot_suffix.field_stock_lot__lot_suffix
msgid "Lot Suffix"
msgstr "ロットサフィックス"

#. module: stock_lot_suffix
#: model:ir.model.fields,field_description:stock_lot_suffix.field_purchase_order__analytic_distribution_search
msgid "Analytic Distribution Search"
msgstr "分析分配検索"

#. module: stock_lot_suffix
#: model:ir.model.fields,field_description:stock_lot_suffix.field_purchase_order__analytic_precision
msgid "Analytic Precision"
msgstr "分析精度"

#. module: stock_lot_suffix
#: model:ir.model.fields,help:stock_lot_suffix.field_purchase_order__analytic_account_ids
msgid "Analytic accounts computed from analytic distribution."
msgstr "分析分配に指定した分析勘定"

#. module: stock_lot_suffix
#: model:ir.model.fields,field_description:stock_lot_suffix.field_purchase_order__channel_category
#: model:ir.model.fields,field_description:stock_lot_suffix.field_res_partner__channel_category
#: model:ir.model.fields,field_description:stock_lot_suffix.field_res_users__channel_category
#: model:ir.model.fields,field_description:stock_lot_suffix.field_stock_lot__channel_category
msgid "Channel Category"
msgstr "チャネルカテゴリ"

#. module: stock_lot_suffix
#: model:ir.model.fields,help:stock_lot_suffix.field_purchase_order__analytic_account_names
msgid ""
"Comma-separated analytic account names, in case it is useful to be included "
"in the exported data."
msgstr ""

#. module: stock_lot_suffix
#: model:ir.model,name:stock_lot_suffix.model_res_partner
msgid "Contact"
msgstr "連絡先"

#. module: stock_lot_suffix
#: model:ir.model,name:stock_lot_suffix.model_stock_lot
msgid "Lot/Serial"
msgstr "ロット/シリアル"

#. module: stock_lot_suffix
#: model:ir.model,name:stock_lot_suffix.model_purchase_order
msgid "Purchase Order"
msgstr "購買オーダ"

#. module: stock_lot_suffix
#: model:ir.model,name:stock_lot_suffix.model_stock_picking
msgid "Transfer"
msgstr "運送"
5 changes: 5 additions & 0 deletions stock_lot_suffix/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import account_analytic_account
from . import purchase_order
from . import res_partner
from . import stock_lot
from . import stock_move_line
10 changes: 10 additions & 0 deletions stock_lot_suffix/models/account_analytic_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class AccountAnalyticAccount(models.Model):
_inherit = "account.analytic.account"

lot_suffix = fields.Char()
16 changes: 16 additions & 0 deletions stock_lot_suffix/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class PurchaseOrder(models.Model):
_name = "purchase.order"
_inherit = ["purchase.order", "analytic.mixin"]

channel_category = fields.Char()

@api.onchange("partner_id")
def _onchange_partner_id(self):
if self.partner_id:
self.channel_category = self.partner_id.channel_category
10 changes: 10 additions & 0 deletions stock_lot_suffix/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResPartner(models.Model):
_inherit = "res.partner"

channel_category = fields.Char()
24 changes: 24 additions & 0 deletions stock_lot_suffix/models/stock_lot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class StockLot(models.Model):
_inherit = "stock.lot"

channel_category = fields.Char()
lot_suffix = fields.Char()

def name_get(self):
name_list = super().name_get()
new_name_list = []
for name in name_list:
rec = self.browse(name[0])
new_name = name[1]
if rec.lot_suffix:
new_name += "-" + rec.lot_suffix
if rec.channel_category:
new_name += "-" + rec.channel_category
new_name_list.append((name[0], new_name))
return new_name_list
25 changes: 25 additions & 0 deletions stock_lot_suffix/models/stock_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class StockMoveLine(models.Model):
_inherit = "stock.move.line"

def _action_done(self):
res = super()._action_done()
for ml in self:
if not ml.lot_id:
continue
vals = {}
purchase_line = ml.move_id.purchase_line_id
vals["channel_category"] = purchase_line.order_id.channel_category
# We assume that there is only one analytic account with lot_suffix if any.
analytic_account = purchase_line.analytic_account_ids.filtered(
lambda x: x.lot_suffix
)
if analytic_account:
vals["lot_suffix"] = analytic_account[0].lot_suffix
ml.lot_id.write(vals)
return res
6 changes: 6 additions & 0 deletions stock_lot_suffix/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module provides the functionality to add suffixes to the display name of lots/serials.

Suffixes are added to lots/serials created from purchase receipts with following conditions:

- Purchase order has the channel_category set.
- Purchase order line has an analytic account with lot suffix.
Loading

0 comments on commit e47eb95

Please sign in to comment.