Skip to content

Commit

Permalink
[MIG] stock_account_operating_unit: Migration to V13
Browse files Browse the repository at this point in the history
  • Loading branch information
alan196 committed Dec 16, 2021
1 parent 0a999b5 commit 5e9c858
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
6 changes: 6 additions & 0 deletions setup/stock_account_operating_unit/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
2 changes: 1 addition & 1 deletion stock_account_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "Stock account moves with Operating Unit",
"summary": "Create journal entries in moves between internal locations "
"with different operating units.",
"version": "12.0.1.0.0",
"version": "13.0.1.0.0",
"category": "Generic Modules/Sales & Purchases",
"author": "Eficent Business and IT Consulting Services S.L., "
"Serpent Consulting Services Pvt. Ltd.,"
Expand Down
12 changes: 7 additions & 5 deletions stock_account_operating_unit/model/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# - Jordi Ballester Alomar
# © 2019 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, exceptions, models
from odoo import _, exceptions, models


class StockMove(models.Model):
Expand All @@ -16,6 +16,7 @@ def _generate_valuation_lines_data(
credit_value,
debit_account_id,
credit_account_id,
description,
):
res = super(StockMove, self)._generate_valuation_lines_data(
partner_id,
Expand All @@ -24,6 +25,7 @@ def _generate_valuation_lines_data(
credit_value,
debit_account_id,
credit_account_id,
description,
)
if res:
debit_line_vals = res.get("debit_line_vals")
Expand Down Expand Up @@ -69,16 +71,15 @@ def _generate_valuation_lines_data(
return rslt
return res

@api.multi
def _action_done(self):
def _action_done(self, cancel_backorder=False):
"""
Generate accounting moves if the product being moved is subject
to real_time valuation tracking,
and the source or destination location are
a transit location or is outside of the company or the source or
destination locations belong to different operating units.
"""
res = super(StockMove, self)._action_done()
res = super(StockMove, self)._action_done(cancel_backorder)
for move in self:

if move.product_id.valuation == "real_time":
Expand All @@ -101,6 +102,7 @@ def _action_done(self):
move.product_id.standard_price,
acc_valuation,
acc_valuation,
_("%s - OU Move") % move.product_id.display_name,
)
am = (
self.env["account.move"]
Expand All @@ -114,7 +116,7 @@ def _action_done(self):
"line_ids": move_lines,
"company_id": move.company_id.id,
"ref": move.picking_id and move.picking_id.name,
"stock_move_id": self.id,
"stock_move_id": move.id,
}
)
)
Expand Down
1 change: 1 addition & 0 deletions stock_account_operating_unit/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Eficent Business and IT Consulting Services S.L. <contact@eficent.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
* Jarsa Sistemas <info@jarsa.com.mx>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def setUp(self):
self.account_model = self.env["account.account"]
self.product_model = self.env["product.product"]
self.product_cteg_model = self.env["product.category"]
self.inv_line_model = self.env["account.invoice.line"]
self.acc_type_model = self.env["account.account.type"]
self.operating_unit_model = self.env["operating.unit"]
self.company_model = self.env["res.company"]
Expand Down Expand Up @@ -147,15 +146,15 @@ def _create_product(self):

def _create_picking(self, user, ou_id, picking_type, src_loc_id, dest_loc_id):
"""Create a Picking."""
picking = self.picking_model.sudo(user.id).create(
picking = self.picking_model.with_user(user.id).create(
{
"picking_type_id": picking_type.id,
"location_id": src_loc_id.id,
"location_dest_id": dest_loc_id.id,
"operating_unit_id": ou_id.id,
}
)
self.move_model.sudo(user.id).create(
self.move_model.with_user(user.id).create(
{
"name": "a move",
"product_id": self.product.id,
Expand All @@ -174,7 +173,7 @@ def _confirm_receive(self, user_id, picking):
"""
picking.action_confirm()
picking.action_assign()
res = picking.sudo(user_id).button_validate()
res = picking.with_user(user_id).button_validate()
validate_id = res["res_id"]
validate = self.env["stock.immediate.transfer"].browse(validate_id)
validate.process()
Expand Down

0 comments on commit 5e9c858

Please sign in to comment.