Merge PR #1292 into 13.0

Signed-off-by AaronHForgeFlow
This commit is contained in:
OCA-git-bot
2021-12-15 16:07:31 +00:00

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_context(force_company=move.company_id.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_context(
force_company=line.company_id.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"]
if not credit_expense_account: