Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions multicompany_property_stock_account/README.rst
Original file line number Diff line number Diff line change
@@ -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 <etobella@creublanca.es>
* Jordi Ballester <jordi.ballester@forgeflow.com>
* Miquel Raïch <miquel.raich@forgeflow.com>

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.
5 changes: 5 additions & 0 deletions multicompany_property_stock_account/__init__.py
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions multicompany_property_stock_account/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
1 change: 1 addition & 0 deletions multicompany_property_stock_account/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_category
127 changes: 127 additions & 0 deletions multicompany_property_stock_account/models/product_category.py
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions multicompany_property_stock_account/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_multicompany
10 changes: 10 additions & 0 deletions multicompany_property_stock_account/tests/test_multicompany.py
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_category_property_form" model="ir.ui.view">
<field name="name">product.category.stock.property.form.inherit</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="stock_account.view_category_property_form" />
<field name="arch" type="xml">
<field name="property_stock_account_input_categ_id" position="attributes">
<attribute name="readonly">True</attribute>
</field>
<field name="property_stock_account_output_categ_id" position="attributes">
<attribute name="readonly">True</attribute>
</field>
<field name="property_stock_valuation_account_id" position="attributes">
<attribute name="readonly">True</attribute>
</field>
<field name="property_stock_journal" position="attributes">
<attribute name="readonly">True</attribute>
</field>
</field>
</record>

<record id="view_category_property_form_stock" model="ir.ui.view">
<field name="name">product.category.stock.property.form.inherit</field>
<field name="model">product.category</field>
<field
name="inherit_id"
ref="stock_account.view_category_property_form_stock"
/>
<field name="arch" type="xml">
<field name="property_cost_method" position="attributes">
<attribute name="readonly">True</attribute>
</field>
<field name="property_valuation" position="attributes">
<attribute name="readonly">True</attribute>
</field>
</field>
</record>

<record id="view_product_category_property_form" model="ir.ui.view">
<field name="name">product.category.property.form</field>
<field name="model">product.category.property</field>
<field
name="inherit_id"
ref="multicompany_property_account.view_product_category_property_form"
/>
<field name="arch" type="xml">
<group name="account_property" position="inside">
<group name="account_stock_property" string="Account Stock Properties">
<field
name="property_stock_account_input_categ_id"
domain="[('deprecated', '=', False),('company_id','=',company_id)]"
/>
<field
name="property_stock_account_output_categ_id"
domain="[('deprecated', '=', False),('company_id','=',company_id)]"
/>
<field
name="property_stock_valuation_account_id"
domain="[('deprecated', '=', False),('company_id','=',company_id)]"
/>
<field
name="property_stock_journal"
domain="[('company_id','=',company_id)]"
/>
</group>
</group>
<group name="account_property" position="before">
<group>
<group string="Inventory Valuation">
<field
name="property_cost_method"
groups="stock.group_stock_manager"
/>
<field name="property_valuation" />
</group>
</group>
</group>
</field>
</record>
</odoo>
13 changes: 13 additions & 0 deletions multicompany_property_stock_account/views/product_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="stock.view_template_property_form" />
<field name="arch" type="xml">
<field name="standard_price" position="attributes">
<attribute name="readonly">1</attribute>
</field>
</field>
</record>
</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

</odoo>
6 changes: 6 additions & 0 deletions setup/multicompany_property_stock_account/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)