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 | |
| parent | a14315652c37267e437ce644190781486f73aa10 (diff) | |
| parent | 1e8c8cf61497f7bc67b8282c34641474107e9d8e (diff) | |
Merge branch 'internal-use'
# Conflicts:
# indoteknik_custom/models/__init__.py
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 4 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 3 | ||||
| -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 | ||||
| -rw-r--r-- | indoteknik_custom/views/ir_sequence.xml | 12 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_location.xml | 8 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_picking.xml | 29 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_picking_type.xml | 31 |
9 files changed, 138 insertions, 0 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index ec806121..7baa89c3 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -33,6 +33,10 @@ 'views/crm_lead.xml', 'views/sale_order.xml', 'views/account_asset_views.xml', + 'views/ir_sequence.xml', + 'views/stock_location.xml', + 'views/stock_picking.xml', + 'views/stock_picking_type.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', 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/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") diff --git a/indoteknik_custom/views/ir_sequence.xml b/indoteknik_custom/views/ir_sequence.xml new file mode 100644 index 00000000..9e057c0d --- /dev/null +++ b/indoteknik_custom/views/ir_sequence.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <record id="sequence_internal_use" model="ir.sequence"> + <field name="name">Internal Use</field> + <field name="code">internal.use</field> + <field name="active">TRUE</field> + <field name="prefix">IU/%(year)s/</field> + <field name="padding">5</field> + <field name="number_next">1</field> + <field name="number_increment">1</field> + </record> +</odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/stock_location.xml b/indoteknik_custom/views/stock_location.xml new file mode 100644 index 00000000..82ab2bc5 --- /dev/null +++ b/indoteknik_custom/views/stock_location.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <record id="stock_location_internal_use" model="stock.location"> + <field name="name">Internal Use</field> + <field name="location_id">3</field> + <field name="usage">inventory</field> + </record> +</odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml new file mode 100644 index 00000000..9081a58e --- /dev/null +++ b/indoteknik_custom/views/stock_picking.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <data> + <record id="stock_picking_form_view_inherit" model="ir.ui.view"> + <field name="name">Stock Picking</field> + <field name="model">stock.picking</field> + <field name="inherit_id" ref="stock.view_picking_form"/> + <field name="arch" type="xml"> + <field name="backorder_id" position="after"> + <field name="is_internal_use" + string="Internal Use" + type="object" + attrs="{'readonly': True}" + force_save="1" + /> + </field> + <field name="origin" position="after"> + <field name="account_id" + attrs="{ + 'readonly': [['state', 'in', ['done', 'cancel']]], + 'invisible': [['is_internal_use', '=', False]], + 'required': [['is_internal_use', '=', True]] + }" + /> + </field> + </field> + </record> + </data> +</odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/stock_picking_type.xml b/indoteknik_custom/views/stock_picking_type.xml new file mode 100644 index 00000000..1633c57a --- /dev/null +++ b/indoteknik_custom/views/stock_picking_type.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <data> + <record id="internal_use_operation_type" model="stock.picking.type"> + <field name="name">Internal Use</field> + <field name="sequence_id" ref="sequence_internal_use"/> + <field name="sequence_code">IU/%(year)s</field> + <field name="warehouse_id">2</field> + <field name="is_internal_use">TRUE</field> + <field name="code">outgoing</field> + <field name="show_operations">TRUE</field> + <field name="return_picking_type_id">10</field> + <field name="default_location_src_id">18</field> + <field name="default_location_dest_id" ref="stock_location_internal_use"/> + </record> + + <record id="stock_picking_type_form_view_inherit" model="ir.ui.view"> + <field name="name">Stock Picking Type</field> + <field name="model">stock.picking.type</field> + <field name="inherit_id" ref="stock.view_picking_type_form"/> + <field name="arch" type="xml"> + <field name="warehouse_id" position="after"> + <field name="is_internal_use" + string="Internal Use" + type="object" + /> + </field> + </field> + </record> + </data> +</odoo>
\ No newline at end of file |
