From e47eb953c67422b3fc2158a9111f941578dd1c50 Mon Sep 17 00:00:00 2001 From: "Tatsuki Kanda (Quratile)" <101688144+kanda999@users.noreply.github.com> Date: Mon, 24 Jul 2023 11:01:13 +0900 Subject: [PATCH] [3546][ADD] stock_lot_suffix (#37) * [3546][ADD] stock_lot_suffix --- .../odoo/addons/stock_lot_suffix | 1 + setup/stock_lot_suffix/setup.py | 6 + stock_lot_suffix/README.rst | 57 +++ stock_lot_suffix/__init__.py | 1 + stock_lot_suffix/__manifest__.py | 18 + stock_lot_suffix/i18n/ja.po | 92 ++++ stock_lot_suffix/models/__init__.py | 5 + .../models/account_analytic_account.py | 10 + stock_lot_suffix/models/purchase_order.py | 16 + stock_lot_suffix/models/res_partner.py | 10 + stock_lot_suffix/models/stock_lot.py | 24 + stock_lot_suffix/models/stock_move_line.py | 25 ++ stock_lot_suffix/readme/DESCRIPTION.rst | 6 + .../static/description/index.html | 412 ++++++++++++++++++ .../views/account_analytic_account_views.xml | 13 + .../views/purchase_order_views.xml | 13 + stock_lot_suffix/views/res_partner_views.xml | 13 + stock_lot_suffix/views/stock_lot_views.xml | 14 + test-requirements.txt | 1 + 19 files changed, 737 insertions(+) create mode 120000 setup/stock_lot_suffix/odoo/addons/stock_lot_suffix create mode 100644 setup/stock_lot_suffix/setup.py create mode 100644 stock_lot_suffix/README.rst create mode 100644 stock_lot_suffix/__init__.py create mode 100644 stock_lot_suffix/__manifest__.py create mode 100644 stock_lot_suffix/i18n/ja.po create mode 100644 stock_lot_suffix/models/__init__.py create mode 100644 stock_lot_suffix/models/account_analytic_account.py create mode 100644 stock_lot_suffix/models/purchase_order.py create mode 100644 stock_lot_suffix/models/res_partner.py create mode 100644 stock_lot_suffix/models/stock_lot.py create mode 100644 stock_lot_suffix/models/stock_move_line.py create mode 100644 stock_lot_suffix/readme/DESCRIPTION.rst create mode 100644 stock_lot_suffix/static/description/index.html create mode 100644 stock_lot_suffix/views/account_analytic_account_views.xml create mode 100644 stock_lot_suffix/views/purchase_order_views.xml create mode 100644 stock_lot_suffix/views/res_partner_views.xml create mode 100644 stock_lot_suffix/views/stock_lot_views.xml diff --git a/setup/stock_lot_suffix/odoo/addons/stock_lot_suffix b/setup/stock_lot_suffix/odoo/addons/stock_lot_suffix new file mode 120000 index 00000000..79a522f0 --- /dev/null +++ b/setup/stock_lot_suffix/odoo/addons/stock_lot_suffix @@ -0,0 +1 @@ +../../../../stock_lot_suffix \ No newline at end of file diff --git a/setup/stock_lot_suffix/setup.py b/setup/stock_lot_suffix/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/stock_lot_suffix/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_lot_suffix/README.rst b/stock_lot_suffix/README.rst new file mode 100644 index 00000000..d47a4ada --- /dev/null +++ b/stock_lot_suffix/README.rst @@ -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 `_. +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 `_. + +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 `_ project on GitHub. + +You are welcome to contribute. diff --git a/stock_lot_suffix/__init__.py b/stock_lot_suffix/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/stock_lot_suffix/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_lot_suffix/__manifest__.py b/stock_lot_suffix/__manifest__.py new file mode 100644 index 00000000..a6ab4093 --- /dev/null +++ b/stock_lot_suffix/__manifest__.py @@ -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, +} diff --git a/stock_lot_suffix/i18n/ja.po b/stock_lot_suffix/i18n/ja.po new file mode 100644 index 00000000..6e32d042 --- /dev/null +++ b/stock_lot_suffix/i18n/ja.po @@ -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 "運送" diff --git a/stock_lot_suffix/models/__init__.py b/stock_lot_suffix/models/__init__.py new file mode 100644 index 00000000..9c0a802d --- /dev/null +++ b/stock_lot_suffix/models/__init__.py @@ -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 diff --git a/stock_lot_suffix/models/account_analytic_account.py b/stock_lot_suffix/models/account_analytic_account.py new file mode 100644 index 00000000..80a06980 --- /dev/null +++ b/stock_lot_suffix/models/account_analytic_account.py @@ -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() diff --git a/stock_lot_suffix/models/purchase_order.py b/stock_lot_suffix/models/purchase_order.py new file mode 100644 index 00000000..244c67b0 --- /dev/null +++ b/stock_lot_suffix/models/purchase_order.py @@ -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 diff --git a/stock_lot_suffix/models/res_partner.py b/stock_lot_suffix/models/res_partner.py new file mode 100644 index 00000000..49679f80 --- /dev/null +++ b/stock_lot_suffix/models/res_partner.py @@ -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() diff --git a/stock_lot_suffix/models/stock_lot.py b/stock_lot_suffix/models/stock_lot.py new file mode 100644 index 00000000..a01f51e3 --- /dev/null +++ b/stock_lot_suffix/models/stock_lot.py @@ -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 diff --git a/stock_lot_suffix/models/stock_move_line.py b/stock_lot_suffix/models/stock_move_line.py new file mode 100644 index 00000000..920ca33a --- /dev/null +++ b/stock_lot_suffix/models/stock_move_line.py @@ -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 diff --git a/stock_lot_suffix/readme/DESCRIPTION.rst b/stock_lot_suffix/readme/DESCRIPTION.rst new file mode 100644 index 00000000..7dc492a8 --- /dev/null +++ b/stock_lot_suffix/readme/DESCRIPTION.rst @@ -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. diff --git a/stock_lot_suffix/static/description/index.html b/stock_lot_suffix/static/description/index.html new file mode 100644 index 00000000..b893ccdc --- /dev/null +++ b/stock_lot_suffix/static/description/index.html @@ -0,0 +1,412 @@ + + + + + + +Stock Lot Suffix + + + +
+

Stock Lot Suffix

+ + +

Beta License: AGPL-3 qrtl/axls-custom

+

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

+ +
+

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.

+

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 project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/stock_lot_suffix/views/account_analytic_account_views.xml b/stock_lot_suffix/views/account_analytic_account_views.xml new file mode 100644 index 00000000..cf3c483b --- /dev/null +++ b/stock_lot_suffix/views/account_analytic_account_views.xml @@ -0,0 +1,13 @@ + + + + analytic.analytic.account.form + account.analytic.account + + + + + + + + diff --git a/stock_lot_suffix/views/purchase_order_views.xml b/stock_lot_suffix/views/purchase_order_views.xml new file mode 100644 index 00000000..a158eda2 --- /dev/null +++ b/stock_lot_suffix/views/purchase_order_views.xml @@ -0,0 +1,13 @@ + + + + purchase.order.form + purchase.order + + + + + + + + diff --git a/stock_lot_suffix/views/res_partner_views.xml b/stock_lot_suffix/views/res_partner_views.xml new file mode 100644 index 00000000..2e336be1 --- /dev/null +++ b/stock_lot_suffix/views/res_partner_views.xml @@ -0,0 +1,13 @@ + + + + view.partner.form + res.partner + + + + + + + + diff --git a/stock_lot_suffix/views/stock_lot_views.xml b/stock_lot_suffix/views/stock_lot_views.xml new file mode 100644 index 00000000..57020ae2 --- /dev/null +++ b/stock_lot_suffix/views/stock_lot_views.xml @@ -0,0 +1,14 @@ + + + + stock.lot + stock.lot + + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt index bdb0fb98..fc6a47d7 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,4 @@ git+https://github.com/qrtl/axls-oca@16.0#subdirectory=setup/currency_rate_update git+https://github.com/qrtl/axls-oca@16.0#subdirectory=setup/report_csv git+https://github.com/qrtl/axls-oca@16.0#subdirectory=setup/purchase_reception_status +git+https://github.com/qrtl/axls-oca@16.0#subdirectory=setup/analytic_mixin_analytic_account