Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][IMP] stock transit #1132

Open
wants to merge 2 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion l10n_ro_stock_account/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
accounts["stock_valuation"] = stock_usage_giving_account

elif valued_type == "internal_transit_out":
accounts["stock_output"] = stock_transfer_account
accounts["stock_input"] = stock_transfer_account

Check warning on line 93 in l10n_ro_stock_account/models/product_template.py

View check run for this annotation

Codecov / codecov/patch

l10n_ro_stock_account/models/product_template.py#L93

Added line #L93 was not covered by tests

elif valued_type == "internal_transit_in":
accounts["stock_output"] = stock_transfer_account
Expand Down
80 changes: 64 additions & 16 deletions l10n_ro_stock_account/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"internal_transfer", # transfer intern
"usage_giving",
"usage_giving_return",
"internal_transit_out", # stock moves trasit to internal
"internal_transit_out", # stock moves transit to internal
"internal_transit_in", # stock moves internal to transit
]
return valued_types
Expand Down Expand Up @@ -234,15 +234,31 @@
- Se creaza SVL prin metoda _create_out_svl, dar pastram remaining
- SVL vor fi inregistrare cu - pe contul de gestiune de origine.
"""
move = self.with_context(standard=True, valued_type="internal_transit_in")
svls = move._create_out_svl(forced_quantity)
for svl in svls:
svl.write(
{
"remaining_qty": abs(svl.quantity),
"remaining_value": abs(svl.value),
}
)
svls = self.env["stock.valuation.layer"].sudo()

Check warning on line 237 in l10n_ro_stock_account/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_ro_stock_account/models/stock_move.py#L237

Added line #L237 was not covered by tests
# company_id = self.env.context.get("force_company", self.env.company.id)
# company = self.env["res.company"].browse(company_id)
# currency = company.currency_id
moves = self.with_context(standard=True, valued_type="internal_transit_in")

Check warning on line 241 in l10n_ro_stock_account/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_ro_stock_account/models/stock_move.py#L241

Added line #L241 was not covered by tests
for move in moves:
svls |= move._create_out_svl(forced_quantity)

Check warning on line 243 in l10n_ro_stock_account/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_ro_stock_account/models/stock_move.py#L243

Added line #L243 was not covered by tests
for svl in svls:
svl.write(

Check warning on line 245 in l10n_ro_stock_account/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_ro_stock_account/models/stock_move.py#L245

Added line #L245 was not covered by tests
{
"remaining_qty": abs(svl.quantity),
"remaining_value": abs(svl.value),
}
)
# vls_vals = move._prepare_common_svl_vals()
# quantity = forced_quantity or move.quantity
# product = move.product_id
# vls_vals.update({
# 'product_id': product.id,
# 'value': currency.round(-1*quantity * product.standard_price),
# 'unit_cost': product.standard_price,
# 'quantity': -1*quantity,
# 'l10n_ro_valued_type': 'internal_transit_in',
# })
# svls |= self.env["stock.valuation.layer"].create(vls_vals)
return svls

def _is_internal_transit_out(self):
Expand All @@ -260,18 +276,32 @@
- SVL vor fi inregistrare cu + pe contul de gestiune de destinatie.
"""
svls = self.env["stock.valuation.layer"].sudo()
# company_id = self.env.context.get("force_company", self.env.company.id)
# company = self.env["res.company"].browse(company_id)
# currency = company.currency_id
moves = self.with_context(standard=True, valued_type="internal_transit_out")
for move in moves:
svls |= move._create_out_svl(forced_quantity)
for _svl in svls:
_svl.write(
for svl in svls:
svl.write(

Check warning on line 286 in l10n_ro_stock_account/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_ro_stock_account/models/stock_move.py#L286

Added line #L286 was not covered by tests
{
"quantity": abs(_svl.quantity),
"value": abs(_svl.value),
"remaining_qty": abs(_svl.quantity),
"remaining_value": abs(_svl.value),
"quantity": abs(svl.quantity),
"value": abs(svl.value),
"remaining_qty": abs(svl.quantity),
"remaining_value": abs(svl.value),
}
)
# vls_vals = move._prepare_common_svl_vals()
# quantity = forced_quantity or move.quantity
# product = move.product_id
# vls_vals.update({
# 'product_id': product.id,
# 'value': currency.round(quantity * product.standard_price),
# 'unit_cost': product.standard_price,
# 'quantity': quantity,
# 'l10n_ro_valued_type': 'internal_transit_out',
# })
# svls |= self.env["stock.valuation.layer"].create(vls_vals)
return svls

def _is_internal_transfer(self):
Expand Down Expand Up @@ -380,6 +410,11 @@
qty, description, svl_id, cost
)

if svl.l10n_ro_valued_type == "internal_transit_in":
am_vals = self._account_entry_move_internal_transit_in(

Check warning on line 414 in l10n_ro_stock_account/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_ro_stock_account/models/stock_move.py#L414

Added line #L414 was not covered by tests
qty, description, svl_id, cost
)

if svl.l10n_ro_valued_type == "internal_transit_out":
am_vals = self._account_entry_move_internal_transit_out(
qty, description, svl_id, cost
Expand Down Expand Up @@ -415,6 +450,19 @@

return am_vals

def _account_entry_move_internal_transit_in(self, qty, description, svl_id, cost):
move = self.with_context(valued_type="internal_transit_in")
(

Check warning on line 455 in l10n_ro_stock_account/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_ro_stock_account/models/stock_move.py#L454-L455

Added lines #L454 - L455 were not covered by tests
journal_id,
acc_src,
acc_dest,
acc_valuation,
) = move._get_accounting_data_for_valuation()
am_vals = move._prepare_account_move_vals(

Check warning on line 461 in l10n_ro_stock_account/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_ro_stock_account/models/stock_move.py#L461

Added line #L461 was not covered by tests
acc_src, acc_dest, journal_id, qty, description, svl_id, -1 * cost
)
return [am_vals]

Check warning on line 464 in l10n_ro_stock_account/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_ro_stock_account/models/stock_move.py#L464

Added line #L464 was not covered by tests

def _account_entry_move_internal_transit_out(self, qty, description, svl_id, cost):
move = self.with_context(valued_type="internal_transit_out")
(
Expand Down
Loading