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..414b2763 --- /dev/null +++ b/stock_account_owner_valued/README.rst @@ -0,0 +1,90 @@ +========================== +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. +(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 +=========== + +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/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/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..e1a5b902 --- /dev/null +++ b/stock_account_owner_valued/readme/DESCRIPTION.rst @@ -0,0 +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 new file mode 100644 index 00000000..3e67f81f --- /dev/null +++ b/stock_account_owner_valued/static/description/index.html @@ -0,0 +1,437 @@ + + + + + +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. +(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

+

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..2c59dfe4 --- /dev/null +++ b/stock_account_owner_valued/tests/test_stock_account_owner_valued.py @@ -0,0 +1,78 @@ +# Copyright 2024 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestStockOwnerValued(TransactionCase): + @classmethod + def setUpClass(cls): + 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", + "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.owner1 = cls.env["res.partner"].create( + { + "name": "Owner 1", + "value_owner_inventory": False, + } + ) + 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.product.uom_id.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 + + + + + + + +