[REF] stock_account: stock inventory to is own file

No changes on the code.

task-1875873
This commit is contained in:
Simon Lejeune
2019-06-09 14:11:36 +00:00
parent 515fb62fc4
commit 806d0a52a1
3 changed files with 44 additions and 39 deletions
+1
View File
@@ -7,4 +7,5 @@ from . import account_move
from . import account_reconciliation_widget
from . import product
from . import stock
from . import stock_inventory
from . import res_config_settings
-39
View File
@@ -11,45 +11,6 @@ import logging
_logger = logging.getLogger(__name__)
class StockInventory(models.Model):
_inherit = "stock.inventory"
accounting_date = fields.Date(
'Accounting Date',
help="Date at which the accounting entries will be created"
" in case of automated inventory valuation."
" If empty, the inventory date will be used.")
has_account_moves = fields.Boolean(compute='_compute_has_account_moves')
def _compute_has_account_moves(self):
for inventory in self:
if inventory.state == 'done' and inventory.move_ids:
account_move = self.env['account.move'].search_count([
('stock_move_id.id', 'in', inventory.move_ids.ids)
])
inventory.has_account_moves = account_move > 0
else:
inventory.has_account_moves = False
def action_get_account_moves(self):
self.ensure_one()
action_ref = self.env.ref('account.action_move_journal_line')
if not action_ref:
return False
action_data = action_ref.read()[0]
action_data['domain'] = [('stock_move_id.id', 'in', self.move_ids.ids)]
return action_data
@api.multi
def post_inventory(self):
acc_inventories = self.filtered(lambda inventory: inventory.accounting_date)
for inventory in acc_inventories:
super(StockInventory, inventory.with_context(force_period_date=inventory.accounting_date)).post_inventory()
other_inventories = self - acc_inventories
if other_inventories:
super(StockInventory, other_inventories).post_inventory()
class StockLocation(models.Model):
_inherit = "stock.location"
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class StockInventory(models.Model):
_inherit = "stock.inventory"
accounting_date = fields.Date(
'Accounting Date',
help="Date at which the accounting entries will be created"
" in case of automated inventory valuation."
" If empty, the inventory date will be used.")
has_account_moves = fields.Boolean(compute='_compute_has_account_moves')
def _compute_has_account_moves(self):
for inventory in self:
if inventory.state == 'done' and inventory.move_ids:
account_move = self.env['account.move'].search_count([
('stock_move_id.id', 'in', inventory.move_ids.ids)
])
inventory.has_account_moves = account_move > 0
else:
inventory.has_account_moves = False
def action_get_account_moves(self):
self.ensure_one()
action_ref = self.env.ref('account.action_move_journal_line')
if not action_ref:
return False
action_data = action_ref.read()[0]
action_data['domain'] = [('stock_move_id.id', 'in', self.move_ids.ids)]
return action_data
def post_inventory(self):
acc_inventories = self.filtered(lambda inventory: inventory.accounting_date)
for inventory in acc_inventories:
super(StockInventory, inventory.with_context(force_period_date=inventory.accounting_date)).post_inventory()
other_inventories = self - acc_inventories
if other_inventories:
super(StockInventory, other_inventories).post_inventory()