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
50 changes: 50 additions & 0 deletions multicompany_property_account_product_analytic/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

==============================================
Multicompany Property Account Product Analytic
==============================================

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 product analytic 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
------------

* Jordi Masvidal <jordi.masvidal@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_account_product_analytic/__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
17 changes: 17 additions & 0 deletions multicompany_property_account_product_analytic/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2022 ForgeFlow, S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Multi Company Account Product Analytic",
"version": "15.0.1.0.0",
"summary": "Product Analytic Company Properties",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"sequence": 30,
"license": "AGPL-3",
"website": "https://github.com/ForgeFlow/multicompany-fixes",
"depends": ["multicompany_property_account", "product_analytic"],
"data": ["views/product_views.xml", "views/product_category_views.xml"],
"installable": True,
"application": False,
"auto_install": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import product_category
from . import product
38 changes: 38 additions & 0 deletions multicompany_property_account_product_analytic/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2022 ForgeFlow, S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ProductProperty(models.TransientModel):
_inherit = "product.property"

income_analytic_account_id = fields.Many2one(
"account.analytic.account",
string="Income Analytic Account",
compute="_compute_property_fields",
readonly=False,
)
expense_analytic_account_id = fields.Many2one(
"account.analytic.account",
string="Expense Analytic Account",
compute="_compute_property_fields",
readonly=False,
)

def get_property_fields(self, obj, properties):
res = super(ProductProperty, self).get_property_fields(obj, properties)
for rec in self:
rec.income_analytic_account_id = rec.get_property_value(
"income_analytic_account_id", obj, properties
)
rec.expense_analytic_account_id = rec.get_property_value(
"expense_analytic_account_id", obj, properties
)
return res

def get_property_fields_list(self):
res = super(ProductProperty, self).get_property_fields_list()
res.append("income_analytic_account_id")
res.append("expense_analytic_account_id")
return res
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2022 ForgeFlow, S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ProductCategoryProperty(models.TransientModel):
_inherit = "product.category.property"

income_analytic_account_id = fields.Many2one(
"account.analytic.account",
string="Income Analytic Account",
compute="_compute_property_fields",
readonly=False,
)
expense_analytic_account_id = fields.Many2one(
"account.analytic.account",
string="Expense Analytic Account",
compute="_compute_property_fields",
readonly=False,
)

def get_property_fields(self, obj, properties):
res = super(ProductCategoryProperty, self).get_property_fields(obj, properties)
for rec in self:
rec.income_analytic_account_id = rec.get_property_value(
"income_analytic_account_id", obj, properties
)
rec.expense_analytic_account_id = rec.get_property_value(
"expense_analytic_account_id", obj, properties
)
return res

def get_property_fields_list(self):
res = super(ProductCategoryProperty, self).get_property_fields_list()
res.append("income_analytic_account_id")
res.append("expense_analytic_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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_multicompany
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,38 @@
<?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="product_analytic.view_category_property_form" />
<field name="arch" type="xml">
<field name="income_analytic_account_id" position="attributes">
<attribute name="readonly">True</attribute>
</field>
<field name="expense_analytic_account_id" 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">
<field name="property_account_income_categ_id" position="after">
<field
name="income_analytic_account_id"
domain="[('company_id','=',company_id)]"
/>
</field>
<field name="property_account_expense_categ_id" position="after">
<field
name="expense_analytic_account_id"
domain="[('company_id','=',company_id)]"
/>
</field>
</field>
</record>
</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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="product_analytic.product_template_form_view" />
<field name="arch" type="xml">
<field name="income_analytic_account_id" position="attributes">
<attribute name="readonly">True</attribute>
</field>
<field name="expense_analytic_account_id" position="attributes">
<attribute name="readonly">True</attribute>
</field>
</field>
</record>
<record id="view_product_property_form" model="ir.ui.view">
<field name="name">product.property.form</field>
<field name="model">product.property</field>
<field
name="inherit_id"
ref="multicompany_property_account.view_product_property_form"
/>
<field name="arch" type="xml">
<field name="property_account_income_id" position="after">
<field
name="income_analytic_account_id"
domain="[('company_id','=',company_id)]"
/>
</field>
<field name="property_account_expense_id" position="after">
<field
name="expense_analytic_account_id"
domain="[('company_id','=',company_id)]"
/>
</field>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/multicompany_property_account_product_analytic/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,
)