[FIX] stock_account_prepare_anglo_saxon_out_lines_hook: update hook

This commit is contained in:
Miquel Raïch
2021-12-15 14:18:00 +01:00
parent 3831e09833
commit 9960ea0293

View File

@@ -8,6 +8,9 @@ def post_load_hook():
def new_stock_account_prepare_anglo_saxon_out_lines_vals(self):
lines_vals_list = []
for move in self:
# Make the loop multi-company safe when accessing models like product.product
move = move.with_company(move.company_id)
if (
not move.is_sale_document(include_receipts=True)
or not move.company_id.anglo_saxon_accounting
@@ -23,9 +26,9 @@ def post_load_hook():
# FIRST HOOK ENDS
# Retrieve accounts needed to generate the COGS.
accounts = line.product_id.product_tmpl_id.with_company(
line.company_id
).get_product_accounts(fiscal_pos=move.fiscal_position_id)
accounts = line.product_id.product_tmpl_id.get_product_accounts(
fiscal_pos=move.fiscal_position_id
)
debit_interim_account = accounts["stock_output"]
credit_expense_account = (
accounts["expense"] or self.journal_id.default_account_id