Skip to content

Commit

Permalink
Refactor stock valuation accounting logic for l10n_ro.
Browse files Browse the repository at this point in the history
Updated `_get_accounting_data_for_valuation` to simplify and enhance logic for Romanian stock valuation. Introduced company-level configurable accounts for "reception_notice" and "reception_notice_return" types. Removed outdated commented-out logic to improve code clarity.
  • Loading branch information
dhongu committed Dec 17, 2024
1 parent 1ea6689 commit 7be9559
Showing 1 changed file with 66 additions and 52 deletions.
118 changes: 66 additions & 52 deletions l10n_ro_stock_account_notice/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,58 +217,72 @@ def _l10n_ro_get_sale_price(self):
)
return valuation_amount

# def _get_accounting_data_for_valuation(self):
# (
# journal_id,
# acc_src,
# acc_dest,
# acc_valuation,
# ) = super()._get_accounting_data_for_valuation()
# if (
# self.is_l10n_ro_record
# and self.product_id.categ_id.l10n_ro_stock_account_change
# ):
# location_from = self.location_id
# location_to = self.location_dest_id
# valued_type = self.env.context.get("valued_type", "indefinite")
#
# # in nir si factura se ca utiliza 408
# if valued_type == "invoice_in_notice":
# if location_to.l10n_ro_property_account_expense_location_id:
# acc_dest = (
# acc_valuation
# ) = location_to.l10n_ro_property_account_expense_location_id.id
# # if location_to.property_account_expense_location_id:
# # acc_dest = (
# # acc_valuation
# # ) = location_to.property_account_expense_location_id.id
# elif valued_type == "invoice_out_notice":
# if location_to.l10n_ro_property_account_income_location_id:
# acc_valuation = acc_dest
# acc_dest = (
# location_to.l10n_ro_property_account_income_location_id.id
# )
# if location_from.l10n_ro_property_account_income_location_id:
# acc_valuation = (
# location_from.l10n_ro_property_account_income_location_id.id
# )
#
# # in Romania iesirea din stoc de face de regula pe contul de cheltuiala
# elif valued_type in [
# "delivery_notice",
# ]:
# acc_dest = (
# location_from.l10n_ro_property_account_expense_location_id.id
# or acc_dest
# )
# elif valued_type in [
# "delivery_notice_return",
# ]:
# acc_src = (
# location_to.l10n_ro_property_account_expense_location_id.id
# or acc_src
# )
# return journal_id, acc_src, acc_dest, acc_valuation
def _get_accounting_data_for_valuation(self):
(
journal_id,
acc_src,
acc_dest,
acc_valuation,
) = super()._get_accounting_data_for_valuation()
if (
self.is_l10n_ro_record
and self.product_id.categ_id.l10n_ro_stock_account_change
):
location_from = self.location_id
location_to = self.location_dest_id
valued_type = self.env.context.get("valued_type", "indefinite")
company = self.company_id

payable_account_id = (
company.l10n_ro_property_stock_picking_payable_account_id
)
receivable_account_id = (
company.l10n_ro_property_stock_picking_receivable_account_id
)

if valued_type == "reception_notice":
acc_dest = payable_account_id.id
elif valued_type == "reception_notice_return":
acc_src = payable_account_id.id

#
# # in nir si factura se ca utiliza 408
# if valued_type == "invoice_in_notice":
# if location_to.l10n_ro_property_account_expense_location_id:
# acc_dest = (
# acc_valuation
# ) = location_to.l10n_ro_property_account_expense_location_id.id
# # if location_to.property_account_expense_location_id:
# # acc_dest = (
# # acc_valuation
# # ) = location_to.property_account_expense_location_id.id
# elif valued_type == "invoice_out_notice":
# if location_to.l10n_ro_property_account_income_location_id:
# acc_valuation = acc_dest
# acc_dest = (
# location_to.l10n_ro_property_account_income_location_id.id
# )
# if location_from.l10n_ro_property_account_income_location_id:
# acc_valuation = (
# location_from.l10n_ro_property_account_income_location_id.id
# )
#
# # in Romania iesirea din stoc de face de regula pe contul de cheltuiala
# elif valued_type in [
# "delivery_notice",
# ]:
# acc_dest = (
# location_from.l10n_ro_property_account_expense_location_id.id
# or acc_dest
# )
# elif valued_type in [
# "delivery_notice_return",
# ]:
# acc_src = (
# location_to.l10n_ro_property_account_expense_location_id.id
# or acc_src
# )
return journal_id, acc_src, acc_dest, acc_valuation

def _get_new_picking_values(self):
vals = super()._get_new_picking_values()
Expand Down

0 comments on commit 7be9559

Please sign in to comment.