diff --git a/multicompany_property_stock_account/README.rst b/multicompany_property_stock_account/README.rst new file mode 100644 index 00000000..5b3e6152 --- /dev/null +++ b/multicompany_property_stock_account/README.rst @@ -0,0 +1,52 @@ +.. image:: https://img.shields.io/badge/license-LGPL--3-blue.png + :target: https://www.gnu.org/licenses/lgpl + :alt: License: LGPL-3 + +=================================== +Multicompany Property Stock Account +=================================== + +This module is part of a set of modules that allow to set property fields on +a given model for multiple companies simultaneously. Specifically this module: + +* Allows to define the company-specific stock account fields of the product + and product category in the new 'Multi company' page of the product form + view. + + + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/133/11.0 + + +Credits +======= + +Contributors +------------ + +* Enric Tobella +* Jordi Ballester +* Miquel Raïch + +Do not contact contributors directly about support or help with technical issues. + + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/multicompany_property_stock_account/__init__.py b/multicompany_property_stock_account/__init__.py new file mode 100644 index 00000000..82ebbf3b --- /dev/null +++ b/multicompany_property_stock_account/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2017 Creu Blanca +# Copyright 2017 ForgeFlow, S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import models diff --git a/multicompany_property_stock_account/__manifest__.py b/multicompany_property_stock_account/__manifest__.py new file mode 100644 index 00000000..33c20df7 --- /dev/null +++ b/multicompany_property_stock_account/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2017 Creu Blanca +# Copyright 2017 ForgeFlow, S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +{ + "name": "Multi Company Stock Account", + "version": "15.0.1.0.0", + "summary": "Stock Account Company Properties", + "author": "Creu Blanca, ForgeFlow, Odoo Community Association (OCA)", + "sequence": 30, + "license": "LGPL-3", + "website": "https://github.com/ForgeFlow/multicompany-fixes", + "depends": ["multicompany_property_account", "multicompany_property_stock"], + "data": [ + "views/product_views.xml", + "views/product_category_views.xml", + "views/res_company_views.xml", + ], + "installable": True, + "application": False, + "auto_install": True, +} diff --git a/multicompany_property_stock_account/models/__init__.py b/multicompany_property_stock_account/models/__init__.py new file mode 100644 index 00000000..53553f3f --- /dev/null +++ b/multicompany_property_stock_account/models/__init__.py @@ -0,0 +1 @@ +from . import product_category diff --git a/multicompany_property_stock_account/models/product_category.py b/multicompany_property_stock_account/models/product_category.py new file mode 100644 index 00000000..88b6a2fd --- /dev/null +++ b/multicompany_property_stock_account/models/product_category.py @@ -0,0 +1,127 @@ +# Copyright 2017 Creu Blanca +# Copyright 2017 ForgeFlow, S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import fields, models + + +class ProductCategoryProperty(models.TransientModel): + _inherit = "product.category.property" + + property_valuation = fields.Selection( + [ + ("manual_periodic", "Periodic (manual)"), + ("real_time", "Perpetual (automated)"), + ], + string="Inventory Valuation", + compute="_compute_property_fields", + readonly=False, + required=True, + help="If perpetual valuation is enabled for a product, the system " + "will automatically create journal entries corresponding to " + "stock moves, with product price as specified by the 'Costing " + "Method'. The inventory variation account set on the product " + "category will represent the current inventory value, and the " + "stock input and stock output account will hold the counterpart " + "moves for incoming and outgoing products.", + ) + + property_cost_method = fields.Selection( + [ + ("standard", "Standard Price"), + ("fifo", "First In First Out (FIFO)"), + ("average", "Average Cost (AVCO)"), + ], + string="Costing Method", + compute="_compute_property_fields", + readonly=False, + required=True, + help="Standard Price: The products are valued at their standard cost " + "defined on the product.\nAverage Cost (AVCO): The products are valued " + "at weighted average cost.\nFirst In First Out (FIFO): The products " + "are valued supposing those that enter the company first will also " + "leave it first.", + ) + property_stock_journal = fields.Many2one( + "account.journal", + "Stock Journal", + compute="_compute_property_fields", + readonly=False, + required=True, + help="When doing real-time inventory valuation, this is " + "the Accounting Journal in which entries will be " + "automatically posted when stock moves are processed.", + ) + property_stock_account_input_categ_id = fields.Many2one( + "account.account", + "Stock Input Account", + domain=[("deprecated", "=", False)], + compute="_compute_property_fields", + readonly=False, + required=True, + help="When doing real-time inventory valuation, counterpart " + "journal items for all incoming stock moves will be posted " + "in this account, unless " + "there is a specific valuation account set on the " + "source location. This is the default value for all products " + "in this category. It " + "can also directly be set on each product", + ) + property_stock_account_output_categ_id = fields.Many2one( + "account.account", + "Stock Output Account", + domain=[("deprecated", "=", False)], + compute="_compute_property_fields", + readonly=False, + required=True, + help="When doing real-time inventory valuation, counterpart journal " + "items for all outgoing stock moves will be posted in this " + "account, unless there is a specific valuation account set " + "on the destination location. This is the default value " + "for all products in this category. It " + "can also directly be set on each product", + ) + property_stock_valuation_account_id = fields.Many2one( + "account.account", + "Stock Valuation Account", + compute="_compute_property_fields", + readonly=False, + required=True, + domain=[("deprecated", "=", False)], + help="When real-time inventory valuation is enabled " + "on a product, this account will hold the current " + "value of the products.", + ) + + def get_property_fields(self, obj, properties): + res = super(ProductCategoryProperty, self).get_property_fields(obj, properties) + for rec in self: + rec.property_valuation = rec.get_property_value( + "property_valuation", obj, properties + ) + rec.property_cost_method = rec.get_property_value( + "property_cost_method", obj, properties + ) + rec.property_stock_journal = rec.get_property_value( + "property_stock_journal", obj, properties + ) + rec.property_stock_account_input_categ_id = rec.get_property_value( + "property_stock_account_input_categ_id", obj, properties + ) + rec.property_stock_account_output_categ_id = rec.get_property_value( + "property_stock_account_output_categ_id", obj, properties + ) + rec.property_stock_valuation_account_id = rec.get_property_value( + "property_stock_valuation_account_id", obj, properties + ) + return res + + def get_property_fields_list(self): + res = super(ProductCategoryProperty, self).get_property_fields_list() + res.append("property_valuation") + res.append("property_cost_method") + res.append("property_stock_journal") + res.append("property_stock_account_input_categ_id") + res.append("property_stock_account_output_categ_id") + res.append("property_stock_valuation_account_id") + return res diff --git a/multicompany_property_stock_account/static/description/icon.png b/multicompany_property_stock_account/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/multicompany_property_stock_account/static/description/icon.png differ diff --git a/multicompany_property_stock_account/tests/__init__.py b/multicompany_property_stock_account/tests/__init__.py new file mode 100644 index 00000000..cf2eadf3 --- /dev/null +++ b/multicompany_property_stock_account/tests/__init__.py @@ -0,0 +1 @@ +from . import test_multicompany diff --git a/multicompany_property_stock_account/tests/test_multicompany.py b/multicompany_property_stock_account/tests/test_multicompany.py new file mode 100644 index 00000000..2b34b33a --- /dev/null +++ b/multicompany_property_stock_account/tests/test_multicompany.py @@ -0,0 +1,10 @@ +# Copyright 2017 Creu Blanca +# Copyright 2017 ForgeFlow, S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo.addons.multicompany_property_account.tests import test_multicompany + + +class TestMulticompanyProperty(test_multicompany.TestMulticompanyProperty): + def test_product(self): + return super().test_product() diff --git a/multicompany_property_stock_account/views/product_category_views.xml b/multicompany_property_stock_account/views/product_category_views.xml new file mode 100644 index 00000000..c5112e0d --- /dev/null +++ b/multicompany_property_stock_account/views/product_category_views.xml @@ -0,0 +1,81 @@ + + + + product.category.stock.property.form.inherit + product.category + + + + True + + + True + + + True + + + True + + + + + + product.category.stock.property.form.inherit + product.category + + + + True + + + True + + + + + + product.category.property.form + product.category.property + + + + + + + + + + + + + + + + + + + + + diff --git a/multicompany_property_stock_account/views/product_views.xml b/multicompany_property_stock_account/views/product_views.xml new file mode 100644 index 00000000..b4d01a31 --- /dev/null +++ b/multicompany_property_stock_account/views/product_views.xml @@ -0,0 +1,13 @@ + + + + product.template.form + product.template + + + + 1 + + + + diff --git a/multicompany_property_stock_account/views/res_company_views.xml b/multicompany_property_stock_account/views/res_company_views.xml new file mode 100644 index 00000000..3f4d29e0 --- /dev/null +++ b/multicompany_property_stock_account/views/res_company_views.xml @@ -0,0 +1,4 @@ + + + + diff --git a/setup/multicompany_property_stock_account/odoo/addons/multicompany_property_stock_account b/setup/multicompany_property_stock_account/odoo/addons/multicompany_property_stock_account new file mode 120000 index 00000000..fc90bd03 --- /dev/null +++ b/setup/multicompany_property_stock_account/odoo/addons/multicompany_property_stock_account @@ -0,0 +1 @@ +../../../../multicompany_property_stock_account \ No newline at end of file diff --git a/setup/multicompany_property_stock_account/setup.py b/setup/multicompany_property_stock_account/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/multicompany_property_stock_account/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)