diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2022-09-01 07:58:42 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2022-09-01 07:58:42 +0000 |
| commit | 645b385f1feea20975f1abaacdf6ffdcb0af7ff1 (patch) | |
| tree | eebe5fca40c038aa21fc230f7b5707fa38b27b20 /indoteknik_custom/models | |
| parent | 8e7e127bb6e7f5b67771e24ba12322ff2718399a (diff) | |
| parent | e682e0518fcaa62588287bb974d8697ceed8300f (diff) | |
Merged in master (pull request #6)
Master
Diffstat (limited to 'indoteknik_custom/models')
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 3 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_move.py | 33 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 12 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking_type.py | 6 |
5 files changed, 55 insertions, 1 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 41c0b184..6407387c 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -20,3 +20,6 @@ from . import sale_monitoring from . import account_move from . import account_asset from . import blog_post +from . import stock_move +from . import stock_picking +from . import stock_picking_type diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index d9ef0b85..6f901809 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -92,7 +92,7 @@ class SaleOrderLine(models.Model): def compute_item_margin(self): for line in self: - if not line.product_id or line.price_unit == 0: + if not line.product_id or line.price_unit <= 0 or line.product_uom_qty <= 0: line.item_margin = 0 line.item_percent_margin = 0 continue 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) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py new file mode 100644 index 00000000..9b5f0036 --- /dev/null +++ b/indoteknik_custom/models/stock_picking.py @@ -0,0 +1,12 @@ +from odoo import fields, models, api + + +class StockPicking(models.Model): + _inherit = 'stock.picking' + is_internal_use = fields.Boolean('Internal Use', help="flag which is internal use or not") + account_id = fields.Many2one('account.account', string="Account") + + @api.onchange('picking_type_id') + def _onchange_operation_type(self): + self.is_internal_use = self.picking_type_id.is_internal_use + return diff --git a/indoteknik_custom/models/stock_picking_type.py b/indoteknik_custom/models/stock_picking_type.py new file mode 100644 index 00000000..064946ed --- /dev/null +++ b/indoteknik_custom/models/stock_picking_type.py @@ -0,0 +1,6 @@ +from odoo import fields, models + + +class StockPickingType(models.Model): + _inherit = 'stock.picking.type' + is_internal_use = fields.Boolean(string="Internal Use") |
