-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by legalsylvain
- Loading branch information
Showing
15 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
============================ | ||
User Limited Access Settings | ||
============================ | ||
|
||
Create a new Administration group with limited access to create only users and companies | ||
|
||
Purpose | ||
======= | ||
|
||
This module does this and that... | ||
|
||
Explain the use case. | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
#. Go to ... | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
#. Go to ... | ||
|
||
|
||
How to test | ||
=========== | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2024 GRAP | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Product - Accounting Settings", | ||
"summary": """Compute and display income - expense account | ||
at product level""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "GRAP", | ||
"website": "https://github.com/grap/grap-odoo-incubator", | ||
"depends": ["account"], | ||
"data": [ | ||
"views/view_product_template.xml", | ||
"views/view_product_product.xml", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * product_accounts | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-12-03 22:37+0000\n" | ||
"PO-Revision-Date: 2024-12-03 22:37+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: product_accounts | ||
#: model:ir.model.fields,field_description:product_accounts.field_product_product__accounts | ||
#: model:ir.model.fields,field_description:product_accounts.field_product_template__accounts | ||
msgid "Accounts" | ||
msgstr "Comptes" | ||
|
||
#. module: product_accounts | ||
#: model:ir.model,name:product_accounts.model_product_template | ||
msgid "Product" | ||
msgstr "Produit" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import product_template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2024 Sylvain LE GAL - GRAP | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
accounts = fields.Char(compute="_compute_accounting_settings") | ||
|
||
@api.depends( | ||
"company_id", | ||
"categ_id.property_account_income_categ_id", | ||
"categ_id.property_account_expense_categ_id", | ||
"property_account_income_id", | ||
"property_account_expense_id", | ||
) | ||
def _compute_accounting_settings(self): | ||
for template in self: | ||
company = template.company_id or self.env.company | ||
res = template.with_company(company)._get_product_accounts() | ||
expense_code = res["expense"] and res["expense"].code or "-" | ||
income_code = res["income"] and res["income"].code or "-" | ||
template.accounts = f"{expense_code} / {income_code}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
This module extends the odoo account module, to display explicitely | ||
accounts configured on products tree view. | ||
|
||
.. figure:: ../static/description/product_tree.png | ||
|
||
The information is also available on product form view. | ||
|
||
.. figure:: ../static/description/product_form.png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestModule(TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.AccountAccount = cls.env["account.account"] | ||
cls.product = cls.env.ref("product.product_product_25_product_template") | ||
cls.category = cls.env.ref("product.product_category_5") | ||
cls.company = cls.env.ref("base.main_company") | ||
cls.product.company_id = cls.company.id | ||
cls.product.property_account_expense_id = False | ||
cls.product.property_account_income_id = False | ||
cls.category.property_account_expense_categ_id = False | ||
cls.category.property_account_income_categ_id = False | ||
cls.expense_account_1 = cls.AccountAccount.create( | ||
{ | ||
"code": "6P.EXP1", | ||
"name": "6P.EXP1 Name", | ||
"account_type": "expense", | ||
"company_id": cls.company.id, | ||
} | ||
) | ||
cls.income_account_1 = cls.AccountAccount.create( | ||
{ | ||
"code": "7P.INC1", | ||
"name": "7P.INC1 Name", | ||
"account_type": "income", | ||
"company_id": cls.company.id, | ||
} | ||
) | ||
cls.expense_account_2 = cls.AccountAccount.create( | ||
{ | ||
"code": "6P.EXP2", | ||
"name": "6P.EXP2 Name", | ||
"account_type": "expense", | ||
"company_id": cls.company.id, | ||
} | ||
) | ||
cls.income_account_2 = cls.AccountAccount.create( | ||
{ | ||
"code": "7P.INC2", | ||
"name": "7P.INC2 Name", | ||
"account_type": "income", | ||
"company_id": cls.company.id, | ||
} | ||
) | ||
|
||
def test_account_computation(self): | ||
self.assertEqual(self.product.accounts, "- / -") | ||
|
||
self.category.property_account_expense_categ_id = self.expense_account_1.id | ||
self.assertEqual(self.product.accounts, "6P.EXP1 / -") | ||
|
||
self.category.property_account_income_categ_id = self.income_account_1.id | ||
self.assertEqual(self.product.accounts, "6P.EXP1 / 7P.INC1") | ||
|
||
self.product.property_account_expense_id = self.expense_account_2.id | ||
self.product.property_account_income_id = self.income_account_2.id | ||
self.assertEqual(self.product.accounts, "6P.EXP2 / 7P.INC2") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2024 Sylvain LE GAL - GRAP | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
|
||
<odoo> | ||
|
||
<record id="view_product_product_tree" model="ir.ui.view"> | ||
<field name="model">product.product</field> | ||
<field name="inherit_id" ref="product.product_product_tree_view" /> | ||
<field name="arch" type="xml"> | ||
<field name="uom_id" position="after"> | ||
<field name="accounts" optional="show"/> | ||
</field> | ||
</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2024 Sylvain LE GAL - GRAP | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
|
||
<odoo> | ||
|
||
<record id="view_product_template_form" model="ir.ui.view"> | ||
<field name="model">product.template</field> | ||
<field name="inherit_id" ref="product.product_template_form_view" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='sale_ok']/.." position="before"> | ||
<span class="d-inline-block"> | ||
<label for="accounts"/> | ||
<field name="accounts" style="margin-right: 5px;"/> | ||
</span> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="view_product_template_tree" model="ir.ui.view"> | ||
<field name="model">product.template</field> | ||
<field name="inherit_id" ref="product.product_template_tree_view" /> | ||
<field name="arch" type="xml"> | ||
<field name="uom_id" position="after"> | ||
<field name="accounts" optional="show"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="view_product_template_tree_account" model="ir.ui.view"> | ||
<field name="model">product.template</field> | ||
<field name="inherit_id" ref="account.product_template_view_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="list_price" position="after"> | ||
<field name="accounts" optional="show"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../product_accounts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |