From f15407bc670b236e97e2a1ca4b5d2a45e6cf1ade Mon Sep 17 00:00:00 2001 From: Yoshi Tashiro Date: Tue, 26 Mar 2024 05:17:40 +0000 Subject: [PATCH 1/3] [4334][ADD] stock_account_owner_valued --- .../odoo/addons/stock_account_owner_valued | 1 + setup/stock_account_owner_valued/setup.py | 6 + stock_account_owner_valued/README.rst | 78 ++++ stock_account_owner_valued/__init__.py | 1 + stock_account_owner_valued/__manifest__.py | 17 + stock_account_owner_valued/models/__init__.py | 4 + .../models/res_partner.py | 12 + .../models/stock_move.py | 14 + .../models/stock_move_line.py | 14 + .../models/stock_quant.py | 14 + .../readme/CONTRIBUTORS.rst | 3 + .../readme/DESCRIPTION.rst | 1 + .../static/description/index.html | 424 ++++++++++++++++++ stock_account_owner_valued/tests/__init__.py | 1 + .../tests/test_stock_account_owner_valued.py | 70 +++ .../views/res_partner_views.xml | 13 + 16 files changed, 673 insertions(+) create mode 120000 setup/stock_account_owner_valued/odoo/addons/stock_account_owner_valued create mode 100644 setup/stock_account_owner_valued/setup.py create mode 100644 stock_account_owner_valued/README.rst create mode 100644 stock_account_owner_valued/__init__.py create mode 100644 stock_account_owner_valued/__manifest__.py create mode 100644 stock_account_owner_valued/models/__init__.py create mode 100644 stock_account_owner_valued/models/res_partner.py create mode 100644 stock_account_owner_valued/models/stock_move.py create mode 100644 stock_account_owner_valued/models/stock_move_line.py create mode 100644 stock_account_owner_valued/models/stock_quant.py create mode 100644 stock_account_owner_valued/readme/CONTRIBUTORS.rst create mode 100644 stock_account_owner_valued/readme/DESCRIPTION.rst create mode 100644 stock_account_owner_valued/static/description/index.html create mode 100644 stock_account_owner_valued/tests/__init__.py create mode 100644 stock_account_owner_valued/tests/test_stock_account_owner_valued.py create mode 100644 stock_account_owner_valued/views/res_partner_views.xml diff --git a/setup/stock_account_owner_valued/odoo/addons/stock_account_owner_valued b/setup/stock_account_owner_valued/odoo/addons/stock_account_owner_valued new file mode 120000 index 00000000..69dd37d4 --- /dev/null +++ b/setup/stock_account_owner_valued/odoo/addons/stock_account_owner_valued @@ -0,0 +1 @@ +../../../../stock_account_owner_valued \ No newline at end of file diff --git a/setup/stock_account_owner_valued/setup.py b/setup/stock_account_owner_valued/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/stock_account_owner_valued/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_account_owner_valued/README.rst b/stock_account_owner_valued/README.rst new file mode 100644 index 00000000..01d40f35 --- /dev/null +++ b/stock_account_owner_valued/README.rst @@ -0,0 +1,78 @@ +========================== +Stock Account Owner Valued +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:296912c04b1ac01550f2d061d609e0fae9a481213f25fe36f3a289730cade3f4 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_account_owner_valued + :alt: OCA/stock-logistics-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_account_owner_valued + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module enables inventory valuation for owners whose value_owner_inventory is set to True. + +**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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Quartile Limited + +Contributors +~~~~~~~~~~~~ + +* `Quartile `__: + + * Aung Ko Ko Lin + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/stock-logistics-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_account_owner_valued/__init__.py b/stock_account_owner_valued/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/stock_account_owner_valued/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_account_owner_valued/__manifest__.py b/stock_account_owner_valued/__manifest__.py new file mode 100644 index 00000000..333b9411 --- /dev/null +++ b/stock_account_owner_valued/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2024 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Stock Account Owner Valued", + "version": "16.0.1.0.0", + "author": "Quartile Limited, Odoo Community Association (OCA)", + "category": "Stock", + "depends": ["stock_account"], + "website": "https://github.com/OCA/stock-logistics-workflow", + "data": [ + "views/res_partner_views.xml", + ], + "installable": True, + "auto_install": False, + "license": "AGPL-3", +} diff --git a/stock_account_owner_valued/models/__init__.py b/stock_account_owner_valued/models/__init__.py new file mode 100644 index 00000000..0367131f --- /dev/null +++ b/stock_account_owner_valued/models/__init__.py @@ -0,0 +1,4 @@ +from . import res_partner +from . import stock_move +from . import stock_move_line +from . import stock_quant diff --git a/stock_account_owner_valued/models/res_partner.py b/stock_account_owner_valued/models/res_partner.py new file mode 100644 index 00000000..a886b6dc --- /dev/null +++ b/stock_account_owner_valued/models/res_partner.py @@ -0,0 +1,12 @@ +# Copyright 2024 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + value_owner_inventory = fields.Boolean( + help="If enabled, the inventory valuation will be calculated for this partner." + ) diff --git a/stock_account_owner_valued/models/stock_move.py b/stock_account_owner_valued/models/stock_move.py new file mode 100644 index 00000000..62e67f53 --- /dev/null +++ b/stock_account_owner_valued/models/stock_move.py @@ -0,0 +1,14 @@ +# Copyright 2024 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockMove(models.Model): + _inherit = "stock.move" + + def _should_exclude_for_valuation(self): + self.ensure_one() + if self.restrict_partner_id.value_owner_inventory: + return False + return super()._should_exclude_for_valuation() diff --git a/stock_account_owner_valued/models/stock_move_line.py b/stock_account_owner_valued/models/stock_move_line.py new file mode 100644 index 00000000..645da420 --- /dev/null +++ b/stock_account_owner_valued/models/stock_move_line.py @@ -0,0 +1,14 @@ +# Copyright 2024 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockMoveLine(models.Model): + _inherit = "stock.move.line" + + def _should_exclude_for_valuation(self): + self.ensure_one() + if self.owner_id.value_owner_inventory: + return False + return super()._should_exclude_for_valuation() diff --git a/stock_account_owner_valued/models/stock_quant.py b/stock_account_owner_valued/models/stock_quant.py new file mode 100644 index 00000000..be3815ad --- /dev/null +++ b/stock_account_owner_valued/models/stock_quant.py @@ -0,0 +1,14 @@ +# Copyright 2024 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockQuant(models.Model): + _inherit = "stock.quant" + + def _should_exclude_for_valuation(self): + self.ensure_one() + if self.owner_id.value_owner_inventory: + return False + return super()._should_exclude_for_valuation() diff --git a/stock_account_owner_valued/readme/CONTRIBUTORS.rst b/stock_account_owner_valued/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..cd4e44ca --- /dev/null +++ b/stock_account_owner_valued/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Quartile `__: + + * Aung Ko Ko Lin diff --git a/stock_account_owner_valued/readme/DESCRIPTION.rst b/stock_account_owner_valued/readme/DESCRIPTION.rst new file mode 100644 index 00000000..5e8a4cd5 --- /dev/null +++ b/stock_account_owner_valued/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module enables inventory valuation for owners whose value_owner_inventory is set to True. diff --git a/stock_account_owner_valued/static/description/index.html b/stock_account_owner_valued/static/description/index.html new file mode 100644 index 00000000..9f0fc60a --- /dev/null +++ b/stock_account_owner_valued/static/description/index.html @@ -0,0 +1,424 @@ + + + + + + +Stock Account Owner Valued + + + +
+

Stock Account Owner Valued

+ + +

Beta License: AGPL-3 OCA/stock-logistics-workflow Translate me on Weblate Try me on Runboat

+

This module enables inventory valuation for owners whose value_owner_inventory is set to True.

+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Quartile Limited
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/stock-logistics-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/stock_account_owner_valued/tests/__init__.py b/stock_account_owner_valued/tests/__init__.py new file mode 100644 index 00000000..97b5e3f3 --- /dev/null +++ b/stock_account_owner_valued/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_account_owner_valued diff --git a/stock_account_owner_valued/tests/test_stock_account_owner_valued.py b/stock_account_owner_valued/tests/test_stock_account_owner_valued.py new file mode 100644 index 00000000..0c55629e --- /dev/null +++ b/stock_account_owner_valued/tests/test_stock_account_owner_valued.py @@ -0,0 +1,70 @@ +# Copyright 2024 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +from odoo.addons.stock_account.tests.test_stockvaluation import TestStockValuation + + +class TestStockOwnerValued(TestStockValuation): + @classmethod + def setUpClass(cls): + super(TestStockOwnerValued, cls).setUpClass() + cls.product = cls.env["product.product"].create( + { + "name": "Test Product", + "type": "product", + "categ_id": cls.env.ref("product.product_category_all").id, + "standard_price": 100.00, + } + ) + cls.product.categ_id.property_valuation = "real_time" + cls.owner2 = cls.env["res.partner"].create( + { + "name": "Owner 2", + "value_owner_inventory": True, + } + ) + + def _create_picking(self, owner): + picking = self.env["stock.picking"].create( + { + "location_id": self.supplier_location.id, + "location_dest_id": self.stock_location.id, + "partner_id": self.partner.id, + "picking_type_id": self.env.ref("stock.picking_type_in").id, + "owner_id": owner.id, + } + ) + move = self.env["stock.move"].create( + { + "picking_id": picking.id, + "name": "10 in", + "location_id": self.supplier_location.id, + "location_dest_id": self.stock_location.id, + "product_id": self.product.id, + "product_uom": self.uom_unit.id, + "product_uom_qty": 10.0, + "price_unit": 10, + } + ) + picking.action_confirm() + picking.action_assign() + move.move_line_ids.qty_done = 10 + picking._action_done() + return picking + + def test_stock_account_owner_valued(self): + # Create picking with owner1 + picking = self._create_picking(self.owner1) + move = picking.move_ids + # Picking with owner1 should not create valuation + self.assertEqual(move.restrict_partner_id.id, self.owner1.id) + self.assertFalse(move.stock_valuation_layer_ids) + + # Create Picking with owner2 + picking = self._create_picking(self.owner2) + move = picking.move_ids + # picking with owner2 should create valuation + self.assertEqual(move.restrict_partner_id.id, self.owner2.id) + self.assertTrue(move.stock_valuation_layer_ids) + self.assertTrue(bool(move.stock_valuation_layer_ids.account_move_id)) diff --git a/stock_account_owner_valued/views/res_partner_views.xml b/stock_account_owner_valued/views/res_partner_views.xml new file mode 100644 index 00000000..fd5d8091 --- /dev/null +++ b/stock_account_owner_valued/views/res_partner_views.xml @@ -0,0 +1,13 @@ + + + + view.partner.form + res.partner + + + + + + + + From 494fb5ce58dadda3f19a5940e37faf6bd761385f Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Wed, 3 Jul 2024 07:36:55 +0000 Subject: [PATCH 2/3] reflect oca changes --- .../tests/test_stock_account_owner_valued.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/stock_account_owner_valued/tests/test_stock_account_owner_valued.py b/stock_account_owner_valued/tests/test_stock_account_owner_valued.py index 0c55629e..2c59dfe4 100644 --- a/stock_account_owner_valued/tests/test_stock_account_owner_valued.py +++ b/stock_account_owner_valued/tests/test_stock_account_owner_valued.py @@ -1,14 +1,16 @@ # Copyright 2024 Quartile Limited # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.tests.common import TransactionCase -from odoo.addons.stock_account.tests.test_stockvaluation import TestStockValuation - -class TestStockOwnerValued(TestStockValuation): +class TestStockOwnerValued(TransactionCase): @classmethod def setUpClass(cls): - super(TestStockOwnerValued, cls).setUpClass() + super().setUpClass() + cls.supplier_location = cls.env.ref("stock.stock_location_suppliers") + cls.stock_location = cls.env.ref("stock.stock_location_stock") + cls.partner = cls.env["res.partner"].create({"name": "Test Partner"}) cls.product = cls.env["product.product"].create( { "name": "Test Product", @@ -18,6 +20,12 @@ def setUpClass(cls): } ) cls.product.categ_id.property_valuation = "real_time" + cls.owner1 = cls.env["res.partner"].create( + { + "name": "Owner 1", + "value_owner_inventory": False, + } + ) cls.owner2 = cls.env["res.partner"].create( { "name": "Owner 2", @@ -42,7 +50,7 @@ def _create_picking(self, owner): "location_id": self.supplier_location.id, "location_dest_id": self.stock_location.id, "product_id": self.product.id, - "product_uom": self.uom_unit.id, + "product_uom": self.product.uom_id.id, "product_uom_qty": 10.0, "price_unit": 10, } From 8fd90c7eb68ab620fe8a5d3e20dc9ca5f98d66a2 Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Wed, 26 Feb 2025 07:41:06 +0000 Subject: [PATCH 3/3] reflect oca changes --- stock_account_owner_valued/README.rst | 12 ++++++ .../readme/CONFIGURE.rst | 7 ++++ .../readme/DESCRIPTION.rst | 1 + .../static/description/index.html | 37 +++++++++++++------ 4 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 stock_account_owner_valued/readme/CONFIGURE.rst diff --git a/stock_account_owner_valued/README.rst b/stock_account_owner_valued/README.rst index 01d40f35..414b2763 100644 --- a/stock_account_owner_valued/README.rst +++ b/stock_account_owner_valued/README.rst @@ -29,12 +29,24 @@ Stock Account Owner Valued |badge1| |badge2| |badge3| |badge4| |badge5| This module enables inventory valuation for owners whose value_owner_inventory is set to True. +(By default, inventory held by owners is not included in valuation.) **Table of contents** .. contents:: :local: +Configuration +============= + +To configure this module, follow the steps below: + +1. Go to the Contact and open the Sale & Purchase tab. +2. Go to the Inventory section and enable the "Value Owner Inventory" option. + +- Access to the Inventory section requires Developer Mode to be activated. +- The Value Owner Inventory setting can only be updated by system administrators. + Bug Tracker =========== diff --git a/stock_account_owner_valued/readme/CONFIGURE.rst b/stock_account_owner_valued/readme/CONFIGURE.rst new file mode 100644 index 00000000..ebb43659 --- /dev/null +++ b/stock_account_owner_valued/readme/CONFIGURE.rst @@ -0,0 +1,7 @@ +To configure this module, follow the steps below: + +1. Go to the Contact and open the Sale & Purchase tab. +2. Go to the Inventory section and enable the "Value Owner Inventory" option. + +- Access to the Inventory section requires Developer Mode to be activated. +- The Value Owner Inventory setting can only be updated by system administrators. diff --git a/stock_account_owner_valued/readme/DESCRIPTION.rst b/stock_account_owner_valued/readme/DESCRIPTION.rst index 5e8a4cd5..e1a5b902 100644 --- a/stock_account_owner_valued/readme/DESCRIPTION.rst +++ b/stock_account_owner_valued/readme/DESCRIPTION.rst @@ -1 +1,2 @@ This module enables inventory valuation for owners whose value_owner_inventory is set to True. +(By default, inventory held by owners is not included in valuation.) diff --git a/stock_account_owner_valued/static/description/index.html b/stock_account_owner_valued/static/description/index.html index 9f0fc60a..3e67f81f 100644 --- a/stock_account_owner_valued/static/description/index.html +++ b/stock_account_owner_valued/static/description/index.html @@ -1,4 +1,3 @@ - @@ -370,21 +369,35 @@

Stock Account Owner Valued

!! source digest: sha256:296912c04b1ac01550f2d061d609e0fae9a481213f25fe36f3a289730cade3f4 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/stock-logistics-workflow Translate me on Weblate Try me on Runboat

-

This module enables inventory valuation for owners whose value_owner_inventory is set to True.

+

This module enables inventory valuation for owners whose value_owner_inventory is set to True. +(By default, inventory held by owners is not included in valuation.)

Table of contents

+
+

Configuration

+

To configure this module, follow the steps below:

+
    +
  1. Go to the Contact and open the Sale & Purchase tab.
  2. +
  3. Go to the Inventory section and enable the “Value Owner Inventory” option.
  4. +
+
    +
  • Access to the Inventory section requires Developer Mode to be activated.
  • +
  • The Value Owner Inventory setting can only be updated by system administrators.
  • +
+
-

Bug Tracker

+

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 to smash it by providing a detailed and welcomed @@ -392,15 +405,15 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

  • Quartile Limited
-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose