Skip to content

Commit 50e4895

Browse files
[5508][ADD] product_category_specific_identification (#120)
[5508][ADD] product_category_specific_identification (#120)
1 parent e0c3d58 commit 50e4895

12 files changed

Lines changed: 693 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
========================================
2+
Product Category Specific Identification
3+
========================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:7d89c94e9f882569ec84d38257cbca58f90d2753414222d7a3f89a7a2f2ab7b5
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-qrtl%2Faxls--custom-lightgray.png?logo=github
20+
:target: https://github.com/qrtl/axls-custom/tree/16.0/product_category_specific_identification
21+
:alt: qrtl/axls-custom
22+
23+
|badge1| |badge2| |badge3|
24+
25+
This module adds two new fields — enable_specific_identification_method
26+
and axls_property_cost_method — to the product category model. The
27+
axls_property_cost_method field mirrors the standard Odoo costing method
28+
with an additional value: "Specific Identification".
29+
30+
When enable_specific_identification_method is enabled and the standard
31+
costing method is set to FIFO, the axls_property_cost_method will
32+
display "Specific Identification". Otherwise, it will reflect the
33+
standard costing method value.
34+
35+
**Table of contents**
36+
37+
.. contents::
38+
:local:
39+
40+
Bug Tracker
41+
===========
42+
43+
Bugs are tracked on `GitHub Issues <https://github.com/qrtl/axls-custom/issues>`_.
44+
In case of trouble, please check there if your issue has already been reported.
45+
If you spotted it first, help us to smash it by providing a detailed and welcomed
46+
`feedback <https://github.com/qrtl/axls-custom/issues/new?body=module:%20product_category_specific_identification%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
47+
48+
Do not contact contributors directly about support or help with technical issues.
49+
50+
Credits
51+
=======
52+
53+
Authors
54+
-------
55+
56+
* Quartile
57+
58+
Maintainers
59+
-----------
60+
61+
This module is part of the `qrtl/axls-custom <https://github.com/qrtl/axls-custom/tree/16.0/product_category_specific_identification>`_ project on GitHub.
62+
63+
You are welcome to contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2025 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
{
4+
"name": "Product Category Specific Identification",
5+
"version": "16.0.1.0.0",
6+
"author": "Quartile",
7+
"website": "https://www.quartile.co",
8+
"category": "Product",
9+
"license": "AGPL-3",
10+
"depends": ["stock_account"],
11+
"data": [
12+
"views/product_category_views.xml",
13+
],
14+
"installable": True,
15+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * product_category_specific_identification
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 16.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2025-07-07 09:30+0000\n"
10+
"PO-Revision-Date: 2025-07-07 09:30+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: product_category_specific_identification
19+
#: model:ir.model.fields.selection,name:product_category_specific_identification.selection__product_category__category_cost_method__average
20+
msgid "Average Cost (AVCO)"
21+
msgstr "移動平均原価(AVCO)"
22+
23+
#. module: product_category_specific_identification
24+
#: model:ir.model.fields,field_description:product_category_specific_identification.field_product_category__category_cost_method
25+
msgid "Category Costing Method"
26+
msgstr "カテゴリ原価計算法"
27+
28+
#. module: product_category_specific_identification
29+
#: model:ir.model.fields,field_description:product_category_specific_identification.field_product_category__enable_specific_identification_method
30+
msgid "Enable Specific Identification Method"
31+
msgstr "個別原価計算を有効化"
32+
33+
#. module: product_category_specific_identification
34+
#: model:ir.model.fields.selection,name:product_category_specific_identification.selection__product_category__category_cost_method__fifo
35+
msgid "First In First Out (FIFO)"
36+
msgstr "先入先出(FIFO)"
37+
38+
#. module: product_category_specific_identification
39+
#: model:ir.model,name:product_category_specific_identification.model_product_template
40+
msgid "Product"
41+
msgstr "プロダクト"
42+
43+
#. module: product_category_specific_identification
44+
#: model:ir.model,name:product_category_specific_identification.model_product_category
45+
msgid "Product Category"
46+
msgstr "プロダクトカテゴリ"
47+
48+
#. module: product_category_specific_identification
49+
#: model:ir.model.fields.selection,name:product_category_specific_identification.selection__product_category__category_cost_method__specific_identification
50+
msgid "Specific Identification"
51+
msgstr "個別原価"
52+
53+
#. module: product_category_specific_identification
54+
#: model:ir.model.fields.selection,name:product_category_specific_identification.selection__product_category__category_cost_method__standard
55+
msgid "Standard Price"
56+
msgstr "標準原価"
57+
58+
#. module: product_category_specific_identification
59+
#. odoo-python
60+
#: code:addons/product_category_specific_identification/models/product_template.py:0
61+
#, python-format
62+
msgid ""
63+
"The selected category requires this product to use serial or lot tracking."
64+
msgstr "選択されたプロダクトカテゴリを使う場合、この製品でシリアルまたはロットの追跡を設定する必要があります。"
65+
66+
#. module: product_category_specific_identification
67+
#. odoo-python
68+
#: code:addons/product_category_specific_identification/models/product_category.py:0
69+
#, python-format
70+
msgid ""
71+
"You cannot enable Specific Identification Method for this category because the following products do not have serial or lot tracking:\n"
72+
" - %s"
73+
msgstr ""
74+
"以下の製品にシリアルまたはロットの追跡が設定されていないため、このカテゴリで個別原価計算を有効にすることはできません。:\n"
75+
" - %s"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import product_category
2+
from . import product_template
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Copyright 2025 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import _, api, fields, models
5+
from odoo.exceptions import ValidationError
6+
7+
8+
class ProductCategory(models.Model):
9+
_inherit = "product.category"
10+
11+
enable_specific_identification_method = fields.Boolean(
12+
compute="_compute_enable_specific_identification_method",
13+
readonly=False,
14+
store=True,
15+
)
16+
category_cost_method = fields.Selection(
17+
[
18+
("standard", "Standard Price"),
19+
("fifo", "First In First Out (FIFO)"),
20+
("average", "Average Cost (AVCO)"),
21+
("specific_identification", "Specific Identification"),
22+
],
23+
string="Category Costing Method",
24+
compute="_compute_category_cost_method",
25+
)
26+
27+
@api.depends("property_cost_method")
28+
def _compute_enable_specific_identification_method(self):
29+
for rec in self:
30+
if rec.property_cost_method != "fifo":
31+
rec.enable_specific_identification_method = False
32+
33+
@api.depends("enable_specific_identification_method", "property_cost_method")
34+
def _compute_category_cost_method(self):
35+
for rec in self:
36+
if (
37+
rec.enable_specific_identification_method
38+
and rec.property_cost_method == "fifo"
39+
):
40+
rec.category_cost_method = "specific_identification"
41+
continue
42+
rec.category_cost_method = rec.property_cost_method
43+
44+
@api.constrains("enable_specific_identification_method")
45+
def _check_enable_specific_identification_method(self):
46+
for rec in self:
47+
if not (
48+
rec.enable_specific_identification_method
49+
and rec.property_cost_method == "fifo"
50+
):
51+
continue
52+
products = self.env["product.template"].search(
53+
[("categ_id", "=", rec.id), ("tracking", "=", "none")]
54+
)
55+
if not products:
56+
continue
57+
product_names = "\n - ".join(p.name for p in products)
58+
raise ValidationError(
59+
_(
60+
"You cannot enable Specific Identification Method for this category "
61+
"because the following products do not have serial or lot "
62+
"tracking:\n - %s"
63+
)
64+
% product_names
65+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2025 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import _, api, models
5+
from odoo.exceptions import ValidationError
6+
7+
8+
class ProductTemplate(models.Model):
9+
_inherit = "product.template"
10+
11+
@api.constrains("categ_id", "tracking")
12+
def _check_specific_identification_tracking(self):
13+
for rec in self:
14+
if (
15+
rec.categ_id.enable_specific_identification_method
16+
and rec.categ_id.property_cost_method == "fifo"
17+
and rec.tracking == "none"
18+
):
19+
raise ValidationError(
20+
_(
21+
"The selected category requires this product to use "
22+
"serial or lot tracking."
23+
)
24+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This module adds two new fields — enable_specific_identification_method and
2+
axls_property_cost_method — to the product category model. The
3+
axls_property_cost_method field mirrors the standard Odoo costing method
4+
with an additional value: "Specific Identification".
5+
6+
When enable_specific_identification_method is enabled and the standard costing
7+
method is set to FIFO, the axls_property_cost_method will display
8+
"Specific Identification". Otherwise, it will reflect the standard costing
9+
method value.

0 commit comments

Comments
 (0)