From c69e9c05b9a1cf87cd118cb64e68c55b0737499f Mon Sep 17 00:00:00 2001 From: AaronHForgeFlow Date: Fri, 29 Oct 2021 16:40:58 +0200 Subject: [PATCH] [MIG] stock_account_prepare_anglo_saxon_out_lines_hook --- ...account_prepare_anglo_saxon_out_lines_hook | 1 + .../setup.py | 6 ++++++ .../__manifest__.py | 2 +- .../hooks.py | 20 +++++-------------- 4 files changed, 13 insertions(+), 16 deletions(-) create mode 120000 setup/stock_account_prepare_anglo_saxon_out_lines_hook/odoo/addons/stock_account_prepare_anglo_saxon_out_lines_hook create mode 100644 setup/stock_account_prepare_anglo_saxon_out_lines_hook/setup.py diff --git a/setup/stock_account_prepare_anglo_saxon_out_lines_hook/odoo/addons/stock_account_prepare_anglo_saxon_out_lines_hook b/setup/stock_account_prepare_anglo_saxon_out_lines_hook/odoo/addons/stock_account_prepare_anglo_saxon_out_lines_hook new file mode 120000 index 000000000..60f627826 --- /dev/null +++ b/setup/stock_account_prepare_anglo_saxon_out_lines_hook/odoo/addons/stock_account_prepare_anglo_saxon_out_lines_hook @@ -0,0 +1 @@ +../../../../stock_account_prepare_anglo_saxon_out_lines_hook \ No newline at end of file diff --git a/setup/stock_account_prepare_anglo_saxon_out_lines_hook/setup.py b/setup/stock_account_prepare_anglo_saxon_out_lines_hook/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_account_prepare_anglo_saxon_out_lines_hook/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_account_prepare_anglo_saxon_out_lines_hook/__manifest__.py b/stock_account_prepare_anglo_saxon_out_lines_hook/__manifest__.py index dfc241c28..4004ab83b 100644 --- a/stock_account_prepare_anglo_saxon_out_lines_hook/__manifest__.py +++ b/stock_account_prepare_anglo_saxon_out_lines_hook/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Stock Account Prepare Anglo Saxon Oout Lines Hook", "summary": "Modify when and how anglo saxon journal items are created", - "version": "13.0.1.0.0", + "version": "14.0.1.0.0", "author": "ForgeFlow, Odoo Community Association (OCA)", "website": "https://github.com/OCA/account-financial-tools", "category": "Generic", diff --git a/stock_account_prepare_anglo_saxon_out_lines_hook/hooks.py b/stock_account_prepare_anglo_saxon_out_lines_hook/hooks.py index 78fab6342..a32d1c1e1 100644 --- a/stock_account_prepare_anglo_saxon_out_lines_hook/hooks.py +++ b/stock_account_prepare_anglo_saxon_out_lines_hook/hooks.py @@ -23,27 +23,17 @@ def post_load_hook(): # FIRST HOOK ENDS # Retrieve accounts needed to generate the COGS. - accounts = line.product_id.product_tmpl_id.with_context( - force_company=line.company_id.id + accounts = line.product_id.product_tmpl_id.with_company( + line.company_id ).get_product_accounts(fiscal_pos=move.fiscal_position_id) debit_interim_account = accounts["stock_output"] - credit_expense_account = accounts["expense"] - if not credit_expense_account: - if self.type == "out_refund": - credit_expense_account = ( - self.journal_id.default_credit_account_id - ) - else: # out_invoice/out_receipt - credit_expense_account = ( - self.journal_id.default_debit_account_id - ) + credit_expense_account = ( + accounts["expense"] or self.journal_id.default_account_id + ) if not debit_interim_account or not credit_expense_account: continue - # Add interim account line. # SECOND HOOK STARTS - if not debit_interim_account or not credit_expense_account: - continue interim_account_line_vals = self._prepare_interim_account_line_vals( line, move, debit_interim_account )