Skip to content

Commit

Permalink
Merge PR #189 into 10.0
Browse files Browse the repository at this point in the history
Signed-off-by aheficent
  • Loading branch information
OCA-git-bot committed Nov 28, 2019
2 parents a3e0e6b + 46b0f4c commit 00d5972
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
27 changes: 21 additions & 6 deletions stock_account_operating_unit/model/stock_move.py
Expand Up @@ -3,7 +3,7 @@
# - Jordi Ballester Alomar
# © 2015-17 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from openerp import _, api, exceptions, models
from odoo import _, api, exceptions, models


class StockMove(models.Model):
Expand All @@ -17,6 +17,10 @@ def _prepare_account_move_line(self, qty, cost, credit_account_id,
if res:
debit_line_vals = res[0][2]
credit_line_vals = res[1][2]
if len(res) == 3:
price_diff_line = res[2][2]
else:
price_diff_line = {}

if (
self.operating_unit_id and self.operating_unit_dest_id and
Expand All @@ -28,12 +32,23 @@ def _prepare_account_move_line(self, qty, cost, credit_account_id,
' and destination accounts related to different '
'operating units.')
)
if (not self.operating_unit_dest_id
and not self.operating_unit_id.id):
ou_id = self.picking_id.picking_type_id.warehouse_id.\
operating_unit_id.id
else:
ou_id = False

debit_line_vals['operating_unit_id'] = (
debit_line_vals['operating_unit_id'] = ou_id or \
self.operating_unit_dest_id.id or self.operating_unit_id.id
)
credit_line_vals['operating_unit_id'] = (
credit_line_vals['operating_unit_id'] = ou_id or \
self.operating_unit_id.id or self.operating_unit_dest_id.id
)
return [(0, 0, debit_line_vals), (0, 0, credit_line_vals)]

rslt = [(0, 0, debit_line_vals), (0, 0, credit_line_vals)]
if price_diff_line:
price_diff_line['operating_unit_id'] = ou_id \
or self.operating_unit_id.id or \
self.operating_unit_dest_id.id
rslt.extend([(0, 0, price_diff_line)])
return rslt
return res
10 changes: 5 additions & 5 deletions stock_account_operating_unit/model/stock_quant.py
Expand Up @@ -3,7 +3,7 @@
# - Jordi Ballester Alomar
# © 2015-17 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from openerp import api, models
from odoo import api, models


class StockQuant(models.Model):
Expand All @@ -22,11 +22,10 @@ def _account_entry_move(self, move):
if move.product_id.valuation == 'real_time':
# Inter-operating unit moves do not accept to
# from/to non-internal location
if (
if (move.location_id.company_id and
move.location_id.company_id ==
move.location_dest_id.company_id and
move.operating_unit_id != move.operating_unit_dest_id
):
move.operating_unit_id != move.operating_unit_dest_id):
src_company_ctx = dict(
force_company=move.location_id.company_id.id
)
Expand All @@ -45,10 +44,11 @@ def _account_entry_move(self, move):
move_lines = move._prepare_account_move_line(qty, cost,
acc_valuation,
acc_valuation)
move_obj.with_context(company_ctx).create({
val_move = move_obj.with_context(company_ctx).create({
'journal_id': journal_id,
'line_ids': move_lines,
'company_id': move.company_id.id,
'ref': move.picking_id and move.picking_id.name,
})
val_move.post()
return res

0 comments on commit 00d5972

Please sign in to comment.