From 88fe0d99a7363d2aad0da9b52c969f18209acf22 Mon Sep 17 00:00:00 2001 From: Daniel Reis Date: Sat, 22 May 2021 13:50:50 +0100 Subject: [PATCH 01/36] [ADD] account_analytic_wip: Analytic Accounting support for WIP and Variances --- account_analytic_wip/README.rst | 1 + account_analytic_wip/__init__.py | 4 + account_analytic_wip/__manifest__.py | 24 ++ account_analytic_wip/data/ir_cron_data.xml | 18 ++ account_analytic_wip/models/__init__.py | 9 + .../models/account_analytic_line.py | 13 + .../models/account_analytic_tracked.py | 83 ++++++ .../models/account_analytic_tracking.py | 265 ++++++++++++++++++ account_analytic_wip/models/account_move.py | 15 + .../models/product_category.py | 48 ++++ .../models/product_template.py | 33 +++ account_analytic_wip/readme/CONFIGURATION.rst | 7 + account_analytic_wip/readme/CONTRIBUTORS.rst | 3 + account_analytic_wip/readme/DESCRIPTION.rst | 15 + account_analytic_wip/readme/USAGE.rst | 50 ++++ .../security/ir.model.access.csv | 3 + .../static/description/icon.png | Bin 0 -> 9455 bytes account_analytic_wip/tests/__init__.py | 1 + account_analytic_wip/tests/test_analytic.py | 53 ++++ .../views/account_analytic_line.xml | 17 ++ .../views/account_analytic_tracking.xml | 93 ++++++ account_analytic_wip/views/account_move.xml | 17 ++ .../views/product_category.xml | 26 ++ 23 files changed, 798 insertions(+) create mode 100644 account_analytic_wip/README.rst create mode 100644 account_analytic_wip/__init__.py create mode 100644 account_analytic_wip/__manifest__.py create mode 100644 account_analytic_wip/data/ir_cron_data.xml create mode 100644 account_analytic_wip/models/__init__.py create mode 100644 account_analytic_wip/models/account_analytic_line.py create mode 100644 account_analytic_wip/models/account_analytic_tracked.py create mode 100644 account_analytic_wip/models/account_analytic_tracking.py create mode 100644 account_analytic_wip/models/account_move.py create mode 100644 account_analytic_wip/models/product_category.py create mode 100644 account_analytic_wip/models/product_template.py create mode 100644 account_analytic_wip/readme/CONFIGURATION.rst create mode 100644 account_analytic_wip/readme/CONTRIBUTORS.rst create mode 100644 account_analytic_wip/readme/DESCRIPTION.rst create mode 100644 account_analytic_wip/readme/USAGE.rst create mode 100644 account_analytic_wip/security/ir.model.access.csv create mode 100644 account_analytic_wip/static/description/icon.png create mode 100644 account_analytic_wip/tests/__init__.py create mode 100644 account_analytic_wip/tests/test_analytic.py create mode 100644 account_analytic_wip/views/account_analytic_line.xml create mode 100644 account_analytic_wip/views/account_analytic_tracking.xml create mode 100644 account_analytic_wip/views/account_move.xml create mode 100644 account_analytic_wip/views/product_category.xml diff --git a/account_analytic_wip/README.rst b/account_analytic_wip/README.rst new file mode 100644 index 0000000000..876fdb5f40 --- /dev/null +++ b/account_analytic_wip/README.rst @@ -0,0 +1 @@ +Generated diff --git a/account_analytic_wip/__init__.py b/account_analytic_wip/__init__.py new file mode 100644 index 0000000000..bb83730e95 --- /dev/null +++ b/account_analytic_wip/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/account_analytic_wip/__manifest__.py b/account_analytic_wip/__manifest__.py new file mode 100644 index 0000000000..ad91e899fa --- /dev/null +++ b/account_analytic_wip/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Analytic Accounting support for WIP and Variances", + "version": "14.0.1.0.0", + "author": "Open Source Integrators, Odoo Community Association (OCA)", + "summary": "Track and report WIP and Variances based on Analytic Items", + "website": "https://github.com/OCA/account-analytic", + "license": "AGPL-3", + "depends": ["stock_account"], + "category": "Accounting/Accounting", + "data": [ + "security/ir.model.access.csv", + "data/ir_cron_data.xml", + "views/product_category.xml", + "views/account_move.xml", + "views/account_analytic_line.xml", + "views/account_analytic_tracking.xml", + ], + "development_status": "Alpha", + "maintainers": ["dreispt"], + "installable": True, +} diff --git a/account_analytic_wip/data/ir_cron_data.xml b/account_analytic_wip/data/ir_cron_data.xml new file mode 100644 index 0000000000..95508ddf0f --- /dev/null +++ b/account_analytic_wip/data/ir_cron_data.xml @@ -0,0 +1,18 @@ + + + Account Analytic: post WIP and Variances journal entries + 1 + days + -1 + + + + model._cron_process_wip_and_variance() + code + + diff --git a/account_analytic_wip/models/__init__.py b/account_analytic_wip/models/__init__.py new file mode 100644 index 0000000000..91bc5605af --- /dev/null +++ b/account_analytic_wip/models/__init__.py @@ -0,0 +1,9 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import product_category +from . import product_template +from . import account_move +from . import account_analytic_line +from . import account_analytic_tracking +from . import account_analytic_tracked diff --git a/account_analytic_wip/models/account_analytic_line.py b/account_analytic_wip/models/account_analytic_line.py new file mode 100644 index 0000000000..fa2cf876a6 --- /dev/null +++ b/account_analytic_wip/models/account_analytic_line.py @@ -0,0 +1,13 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import fields, models + + +class AnalyticLine(models.Model): + _inherit = "account.analytic.line" + + analytic_tracking_item_id = fields.Many2one( + "account.analytic.tracking.item", string="Tracking Item" + ) diff --git a/account_analytic_wip/models/account_analytic_tracked.py b/account_analytic_wip/models/account_analytic_tracked.py new file mode 100644 index 0000000000..3477c99a52 --- /dev/null +++ b/account_analytic_wip/models/account_analytic_tracked.py @@ -0,0 +1,83 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import api, fields, models + + +class AnalyticTrackedItem(models.AbstractModel): + _name = "account.analytic.tracked.mixin" + _description = "Cost Tracked Mixin" + + analytic_tracking_item_id = fields.Many2one( + "account.analytic.tracking.item", + string="Tracking Item", + ondelete="cascade", + copy=False, + ) + + def _prepare_tracking_item_values(self): + """ + To be implemented by inheriting models. + Return a dict with the values to create the related Tracking Item. + + return { + "analytic_id": ..., + "product_id": ..., + ..., + } + """ + self.ensure_one() + return {} + + def _get_tracking_planned_qty(self): + """ + To be extended by inheriting Model + """ + return 0.0 + + def set_tracking_item(self, update_planned=False, force=False): + """ + Create and set the related Tracking Item, where actuals will be accumulated to. + The _prepare_tracking_item_values() provides the values used to create it. + + If the update_planned flag is set, the planned amount is updated. + The _get_tracking_planned_qty() method provides the planned quantity. + + By default is is not set, and will be zero for new tracking items. + + Returns one Tracking Item record or an empty recordset. + """ + TrackingItem = self.env["account.analytic.tracking.item"] + for item in self: + if not item.analytic_tracking_item_id or force: + vals = item._prepare_tracking_item_values() + item.analytic_tracking_item_id = vals and TrackingItem.create(vals) + # The Product my be a Cost Type with child Products + cost_rules = item.analytic_tracking_item_id.product_id.activity_cost_ids + for cost_type in cost_rules.product_id: + child_vals = dict(vals) + child_vals.update( + { + "parent_id": item.analytic_tracking_item_id.id, + "product_id": cost_type.id, + } + ) + TrackingItem.create(child_vals) + + if update_planned and item.analytic_tracking_item_id: + planned_qty = item._get_tracking_planned_qty() + tracking_item = item.analytic_tracking_item_id + for subitem in tracking_item | tracking_item.child_ids: + qty = planned_qty if subitem.to_calculate else 0.0 + unit_cost = subitem.product_id.standard_price + subitem.planned_amount = qty * unit_cost + + @api.model + def create(self, vals): + """ + New tracked records automatically create Tracking Items, if possible. + """ + new = super().create(vals) + new.set_tracking_item() + return new diff --git a/account_analytic_wip/models/account_analytic_tracking.py b/account_analytic_wip/models/account_analytic_tracking.py new file mode 100644 index 0000000000..fb79f5b5c9 --- /dev/null +++ b/account_analytic_wip/models/account_analytic_tracking.py @@ -0,0 +1,265 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import _, api, fields, models + + +class AnalyticTrackingItem(models.Model): + """ + Tracking Items provide a central point to report WIP and Variances. + Expected amounts are stored on a key event, such a confirming an order. + Done amounts are captured by Analytic items. + They can then be posted as journal entries. + """ + + _name = "account.analytic.tracking.item" + _description = "Cost Tracking Item" + + name = fields.Char(compute="_compute_name", store=True) + date = fields.Date(default=fields.Date.today()) + analytic_id = fields.Many2one( + "account.analytic.account", + string="Analytic Account", + required=True, + ondelete="restrict", + ) + product_id = fields.Many2one( + "product.product", string="Cost Product", ondelete="restrict" + ) + analytic_line_ids = fields.One2many( + "account.analytic.line", + "analytic_tracking_item_id", + string="Analytic Items", + help="Related analytic items with the project actuals.", + ) + account_move_ids = fields.One2many( + "account.move", + "analytic_tracking_item_id", + string="Journal Entries", + help="Related journal entries with the posted WIP.", + ) + state = fields.Selection( + [ + ("open", "Open"), + ("close", "Closed"), + ("cancel", "Cancelled"), + ], + default="open", + help="Open operations are in progress, no negative variances are computed. " + "Done operations are completed, negative variances are computed. " + "Closed operations are done and posting, no more actions to do.", + ) + to_calculate = fields.Boolean(compute="_compute_to_calculate", store=True) + + parent_id = fields.Many2one( + "account.analytic.tracking.item", "Parent Tracking Item", ondelete="cascade" + ) + child_ids = fields.One2many( + "account.analytic.tracking.item", "parent_id", string="Child Tracking Items" + ) + + # Planned Amount + planned_amount = fields.Float() + + # Actual Amounts + actual_amount = fields.Float( + compute="_compute_actual_amounts", + help="Total cost amount of the related Analytic Items. " + "These Analytic Items are generated when a cost is incurred, " + "and will later generated WIP and Variance Journal Entries.", + ) + wip_actual_amount = fields.Float( + compute="_compute_actual_amounts", + help="Actual amount incurred below the planned amount limit.", + ) + variance_actual_amount = fields.Float( + compute="_compute_actual_amounts", + help="Actual amount incurred above the planned amount limit.", + ) + remaining_actual_amount = fields.Float( + compute="_compute_actual_amounts", + help="Actual amount planned and not yet consumed.", + ) + pending_amount = fields.Float( + compute="_compute_actual_amounts", + help="Amount not yet posted to journal entries.", + ) + + # Accounted Amounts + accounted_amount = fields.Float( + help="Amount accounted in Journal Entries. " + "Directly set by the routine creating the Journal Entries, " + "and not directly read from the jpunral items." + ) + wip_accounted_amount = fields.Float( + help="Accounted amount incurred below the planned amount limit." + ) + variance_accounted_amount = fields.Float( + help="Accounted amount incurred above the planned amount limit." + ) + + @api.depends("product_id") + def _compute_name(self): + for item in self: + item.name = item.product_id.display_name + + @api.depends("state", "parent_id", "child_ids") + def _compute_to_calculate(self): + for tracking in self: + tracking.to_calculate = tracking.state != "cancel" and ( + tracking.parent_id or not tracking.child_ids + ) + + @api.depends( + "analytic_line_ids.amount", + "planned_amount", + "accounted_amount", + "state", + "child_ids", + ) + def _compute_actual_amounts(self): + for item in self: + # Actuals + if not item.to_calculate: + item.actual_amount = 0 + else: + if item.parent_id: + actuals = item.parent_id.analytic_line_ids.filtered( + lambda x: x.product_id == item.product_id + ) + else: + actuals = item.analytic_line_ids + item.actual_amount = -sum(actuals.mapped("amount")) or 0.0 + + item.pending_amount = item.actual_amount - item.accounted_amount + item.wip_actual_amount = min(item.actual_amount, item.planned_amount) + + if not item.to_calculate: + item.remaining_actual_amount = 0 + item.variance_actual_amount = 0 + item.pending_amount = 0 + elif item.state == "open": + # Negative variances show in the Remaining column + item.remaining_actual_amount = ( + item.planned_amount - item.wip_actual_amount + ) + item.variance_actual_amount = max( + item.actual_amount - item.planned_amount, 0 + ) + else: + # Negative variances show in the Variance column + item.remaining_actual_amount = 0 + item.variance_actual_amount = item.actual_amount - item.planned_amount + + def _prepare_account_move(self, journal): + return { + "journal_id": journal.id, + "date": self.env.context.get( + "force_period_date", fields.Date.context_today(self) + ), + "ref": self.display_name, + "move_type": "entry", + "analytic_tracking_item_id": self.id, + } + + def _prepare_account_move_line(self, account, debit_amount=0, credit_amount=0): + self.ensure_one() + vals = {} + if account and (debit_amount or credit_amount): + debit = (debit_amount if debit_amount > 0 else 0) + ( + -credit_amount if credit_amount < 0 else 0 + ) + credit = (credit_amount if credit_amount > 0 else 0) + ( + -debit_amount if debit_amount < 0 else 0 + ) + vals = { + "name": self.display_name, + "product_id": self.product_id.id, + "product_uom_id": self.product_id.uom_id.id, + "analytic_account_id": self.analytic_id.id, + "ref": self.display_name, + "account_id": account.id, + "debit": debit, + "credit": credit, + } + return vals + + def _create_jornal_entry(self, wip_amount, var_amount): + self.ensure_one() + if wip_amount or var_amount: + accounts = self.product_id.product_tmpl_id.get_product_accounts() + move_lines = [ + self._prepare_account_move_line( + accounts["stock_input"], debit_amount=wip_amount + ), + self._prepare_account_move_line( + accounts["stock_variance"], debit_amount=var_amount + ), + ] + if var_amount < 0: + move_lines.extend( + [ + self._prepare_account_move_line( + accounts["stock_valuation"], credit_amount=wip_amount + ), + self._prepare_account_move_line( + accounts["stock_valuation"], credit_amount=var_amount + ), + ] + ) + else: + move_lines.append( + self._prepare_account_move_line( + accounts["stock_valuation"], + credit_amount=wip_amount + var_amount, + ) + ) + wip_journal = accounts["wip_journal"] + if wip_journal: + je_vals = self._prepare_account_move(wip_journal) + je_vals["line_ids"] = [(0, 0, x) for x in move_lines if x] + je_new = self.env["account.move"].sudo().create(je_vals) + je_new._post() + # Update Analytic lines with the Consumption journal item + consume_move = je_new.line_ids.filtered( + lambda x: x.account_id == accounts["stock_valuation"] + ) + self.analytic_line_ids.write({"move_id": consume_move[:1].id}) + return bool(wip_journal) + + def process_wip_and_variance(self): + """ + For each Analytic Tracking Item with a Pending Amount different from zero, + generate Journal Entries for WIP and excess Variances + """ + all_tracking = self | self.child_ids + for item in all_tracking.filtered("pending_amount"): + # TODO: use float_compare() + wip_pending = round(item.wip_actual_amount - item.wip_accounted_amount, 6) + var_pending = round( + item.variance_actual_amount - item.variance_accounted_amount, 6 + ) + is_posted = item._create_jornal_entry(wip_pending, var_pending) + if is_posted: + # Update accounted amount to equal actual amounts + item.accounted_amount = item.actual_amount + item.wip_accounted_amount = item.wip_actual_amount + item.variance_accounted_amount = item.variance_actual_amount + + def _cron_process_wip_and_variance(self): + items = self.search([("state", "not in", ["close", "cancel"])]) + items.process_wip_and_variance() + + def reverse_wip_moves(self): + all_tracking = self | self.child_ids + all_tracking.write({"state": "close"}) + wip_moves = all_tracking.mapped("account_move_ids") + default_values = [{"ref": _("Reversal of: %s") % x.ref} for x in wip_moves] + reverse_moves = wip_moves._reverse_moves(default_values) + reverse_moves._post() + + def action_cancel(self): + # TODO: what to do if there are JEs done? + all_tracking = self | self.child_ids + all_tracking.write({"state": "cancel"}) diff --git a/account_analytic_wip/models/account_move.py b/account_analytic_wip/models/account_move.py new file mode 100644 index 0000000000..865382fca0 --- /dev/null +++ b/account_analytic_wip/models/account_move.py @@ -0,0 +1,15 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import fields, models + + +class AccountMove(models.Model): + _inherit = "account.move" + + analytic_tracking_item_id = fields.Many2one( + "account.analytic.tracking.item", + string="Tracking Item", + help="Tracking item generating this journal entry", + ) diff --git a/account_analytic_wip/models/product_category.py b/account_analytic_wip/models/product_category.py new file mode 100644 index 0000000000..db1a2a4bc3 --- /dev/null +++ b/account_analytic_wip/models/product_category.py @@ -0,0 +1,48 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import _, api, exceptions, fields, models + + +class ProductCategory(models.Model): + _inherit = "product.category" + + property_wip_journal_id = fields.Many2one( + "account.journal", + "WIP Journal", + company_dependent=True, + domain="[('company_id', '=', allowed_company_ids[0])]", + check_company=True, + help="When doing automated WIP valuation, this is the Accounting Journal " + "in which entries will be automatically posted.", + ) + property_variance_account_id = fields.Many2one( + "account.account", + "Variance Account", + company_dependent=True, + domain="[('company_id', '=', allowed_company_ids[0]), " + "('deprecated', '=', False)]", + check_company=True, + ) + + @api.constrains( + "property_wip_journal_id", + "property_variance_account_id", + ) + def _constrains_wip_config(self): + for categ in self: + configs = [ + categ.property_wip_journal_id, + categ.property_variance_account_id, + ] + if any(configs) and not all(configs): + raise exceptions.ValidationError( + _( + "Then configuring costing, a Journal " + " and account for Consumption," + " WIP and Variance must be provided. " + "Check the configuration in Category %s." + ) + % categ.display_name + ) diff --git a/account_analytic_wip/models/product_template.py b/account_analytic_wip/models/product_template.py new file mode 100644 index 0000000000..2810d04e3e --- /dev/null +++ b/account_analytic_wip/models/product_template.py @@ -0,0 +1,33 @@ +# Copyright (C) 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + def _get_product_accounts(self): + """ + Add the Variance account, used to post WIP amount exceeding the expected. + The "Consumed" account (credited) is the stock_input, + and the "WIP" account (debited) is the sock_valuation account. + """ + self.ensure_one() + accounts = super()._get_product_accounts() + accounts.update( + { + "stock_variance": self.categ_id.property_variance_account_id or False, + } + ) + return accounts + + def get_product_accounts(self, fiscal_pos=None): + """ + Add the journal to use for WIP journal entries, 'wip_journal' + """ + self.ensure_one() + accounts = super().get_product_accounts(fiscal_pos=fiscal_pos) + accounts.update({"wip_journal": self.categ_id.property_wip_journal_id or False}) + return accounts diff --git a/account_analytic_wip/readme/CONFIGURATION.rst b/account_analytic_wip/readme/CONFIGURATION.rst new file mode 100644 index 0000000000..9a469b742c --- /dev/null +++ b/account_analytic_wip/readme/CONFIGURATION.rst @@ -0,0 +1,7 @@ +On the Product Category, "Costing" section, configure the accounts to use: + +* **Consumption Account**: the account to credit. + +* **Work in Progress Account**: the account to debit the work in progress amounts. + +* **Variance Account**: the account to debit the variance versus the expected. diff --git a/account_analytic_wip/readme/CONTRIBUTORS.rst b/account_analytic_wip/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..f5d2c92978 --- /dev/null +++ b/account_analytic_wip/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Open Source Integrators `: + + * Daniel Reis diff --git a/account_analytic_wip/readme/DESCRIPTION.rst b/account_analytic_wip/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..7f27125fe8 --- /dev/null +++ b/account_analytic_wip/readme/DESCRIPTION.rst @@ -0,0 +1,15 @@ +This feature proposes a strategy to track and report work in progress and variances. + +The base components are implemented here, a minimum viable process is working, +but the process is best leveraged by other apps, such as Projects or Manufacturing. + +Resource consumption is to be recorded as Analytic Items +when operations are logged in the system of resources. + +These Analytic Items are then used to calculate WIP and variances +versus the original expected amounts. +An "Analytic Tracking Items" object is used to hold the expected amount, +and calculate the WIP and variances to record. + +A regular scheduled job uses that information +to generate the corresponding accounting moves. diff --git a/account_analytic_wip/readme/USAGE.rst b/account_analytic_wip/readme/USAGE.rst new file mode 100644 index 0000000000..a01d184347 --- /dev/null +++ b/account_analytic_wip/readme/USAGE.rst @@ -0,0 +1,50 @@ +The "Analytic Tracking Items" holds planned amounts, and track their WIP and variances. +These must be automatically created by specific logic in the Apps supporting them. + +With this module alone the Tracking Item creation can be done manually: + +* Navigate to ''Invoicing/Accounting > Reporting > Management > Analytic Tracking'' + +* Create an Analytic Tracking Item: + + * Set the Analytic Account. + + * Set the Product, use one that has a non-zero cost + and belongs to a category with the "Costing" section configured. + + * Set the Planned Amount. + + +Analytic Items are used to record the actual costs: + +* Navigate to *Invoicing/Accounting > Configuration + > Analytic Accounting > Analytic Items*. + +* Create an Analytic Item: + + * Set the Analytic Account, Description and Date. + + * Set the Product, use one that has a non-zero cost + and belongs to a category with the "Costing" section configured. + + * Set the quantity consumed. + + * The Amount field should be automatically computed, with a negative amount. + + +Analytic Tracking Items are used to follow the costs incurred +and the comparison with the planned amounts. This can be used for analysis: + +* Navigate to ''Invoicing/Accounting > Reporting > Management > Analytic Tracking'' + +* The list presents lines being tracked, and displays columns with Actual Amount, + Expected Amount, WIP Amount, Variance Amount, etc. + + +WIP and variances journal entries are generated by a scheduled job: + +* Navigate to *Setting > Technical > Automation > Scheduled Actions*. + +* Locate and open the *Account: Process WIP and Variances* record, and click on the RUN MANUALLY button. + +* Check the generated journal entries, at *Accounting > Miscellaneous > Journal Entries*. diff --git a/account_analytic_wip/security/ir.model.access.csv b/account_analytic_wip/security/ir.model.access.csv new file mode 100644 index 0000000000..09c8a97f49 --- /dev/null +++ b/account_analytic_wip/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_account_analytic_tracking_item_user,Analytic Tracking Item: User,model_account_analytic_tracking_item,base.group_user,1,1,1,1 +access_account_analytic_tracking_item_mngr,Analytic Tracking Item: Manager,model_account_analytic_tracking_item,account.group_account_manager,1,1,1,1 diff --git a/account_analytic_wip/static/description/icon.png b/account_analytic_wip/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)( z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB}d+*K?#sY_jqPdg{Sm2HdYzdEx zOGVPhVRTGPtv0o}RfVP;Nd(|CB)I;*t&QO8h zFfekr30S!-LHmV_Su-W+rEwYXJ^;6&3|L$mMC8*bQptyOo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Gha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/account_analytic_wip/tests/__init__.py b/account_analytic_wip/tests/__init__.py new file mode 100644 index 0000000000..f8ce2f2644 --- /dev/null +++ b/account_analytic_wip/tests/__init__.py @@ -0,0 +1 @@ +from . import test_analytic diff --git a/account_analytic_wip/tests/test_analytic.py b/account_analytic_wip/tests/test_analytic.py new file mode 100644 index 0000000000..5e62e80567 --- /dev/null +++ b/account_analytic_wip/tests/test_analytic.py @@ -0,0 +1,53 @@ +from odoo import exceptions +from odoo.tests import common + + +class TestAnalytic(common.TransactionCase): + def setUp(self): + super().setUp() + self.analytic_x = self.env["account.analytic.account"].create( + {"name": "Analytic X"} + ) + self.wip_journal = self.env["account.journal"].create( + {"name": "Inventory WIP", "type": "general", "code": "WIP"} + ) + self.consume_account = self.env["account.account"].create( + { + "code": "600010", + "name": "Costing Consumed", + "user_type_id": self.env.ref("account.data_account_type_expenses").id, + } + ) + self.variance_account = self.consume_account.copy( + {"code": "600012", "name": "Costing Variance"} + ) + self.costing_categ = self.env["product.category"].create( + { + "name": "Costing", + "property_cost_method": "standard", + "property_valuation": "real_time", + "property_wip_journal_id": self.wip_journal.id, + "property_variance_account_id": self.variance_account.id, + } + ) + self.cost_product_template = self.env["product.template"].create( + { + "name": "Cost Service", + "type": "service", + "categ_id": self.costing_categ.id, + } + ) + self.cost_product = self.cost_product_template.product_variant_ids.write( + {"standard_price": 10.0} + ) + + def test_100_categ_config_complete(self): + with self.assertRaises(exceptions.ValidationError): + self.env["product.category"].create( + { + "name": "Engineer to Order", + "property_cost_method": "standard", + "property_valuation": "real_time", + "property_variance_account_id": self.variance_account.id, + } + ) diff --git a/account_analytic_wip/views/account_analytic_line.xml b/account_analytic_wip/views/account_analytic_line.xml new file mode 100644 index 0000000000..03340af0fa --- /dev/null +++ b/account_analytic_wip/views/account_analytic_line.xml @@ -0,0 +1,17 @@ + + + Analytic Line Form: add Tracking Item + account.analytic.line + + + + + + + + + + diff --git a/account_analytic_wip/views/account_analytic_tracking.xml b/account_analytic_wip/views/account_analytic_tracking.xml new file mode 100644 index 0000000000..89e974022d --- /dev/null +++ b/account_analytic_wip/views/account_analytic_tracking.xml @@ -0,0 +1,93 @@ + + + account.analytic.tracking.form + account.analytic.tracking.item + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +