diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2022-08-31 17:10:10 +0700 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2022-08-31 17:10:10 +0700 |
| commit | e682e0518fcaa62588287bb974d8697ceed8300f (patch) | |
| tree | eebe5fca40c038aa21fc230f7b5707fa38b27b20 /indoteknik_custom/models/stock_move.py | |
| parent | a14315652c37267e437ce644190781486f73aa10 (diff) | |
| parent | 1e8c8cf61497f7bc67b8282c34641474107e9d8e (diff) | |
Merge branch 'internal-use'
# Conflicts:
# indoteknik_custom/models/__init__.py
Diffstat (limited to 'indoteknik_custom/models/stock_move.py')
| -rw-r--r-- | indoteknik_custom/models/stock_move.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py new file mode 100644 index 00000000..c2786762 --- /dev/null +++ b/indoteknik_custom/models/stock_move.py @@ -0,0 +1,33 @@ +from odoo import fields, models + + +class StockMove(models.Model): + _inherit = 'stock.move' + + def _create_account_move_line(self, credit_account_id, debit_account_id, journal_id, qty, description, svl_id, cost): + self.ensure_one() + if self.picking_id.is_internal_use: + AccountMove = self.env['account.move'].with_context(default_journal_id=journal_id) + + # 538 is static id for "Biaya Umum Lain-Lain" on account.account model + # 440 is static id for "PPN Keluaran" on account.account model + debit_account_id = self.picking_id.account_id.id if self.picking_id.account_id.id else 538 + + tax = cost * (11 / 100) + move_lines = self._prepare_account_move_line(qty, cost, credit_account_id, debit_account_id, description) + move_lines += self._prepare_account_move_line(qty, tax, 440, debit_account_id, description) + + if move_lines: + date = self._context.get('force_period_date', fields.Date.context_today(self)) + new_account_move = AccountMove.sudo().create({ + 'journal_id': journal_id, + 'line_ids': move_lines, + 'date': date, + 'ref': description, + 'stock_move_id': self.id, + 'stock_valuation_layer_ids': [(6, None, [svl_id])], + 'move_type': 'entry', + }) + new_account_move._post() + return True + return super(StockMove, self)._create_account_move_line(credit_account_id, debit_account_id, journal_id, qty, description, svl_id, cost) |
