summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xindoteknik_custom/__manifest__.py5
-rwxr-xr-xindoteknik_custom/models/__init__.py3
-rwxr-xr-xindoteknik_custom/models/sale_order.py2
-rw-r--r--indoteknik_custom/models/stock_move.py33
-rw-r--r--indoteknik_custom/models/stock_picking.py12
-rw-r--r--indoteknik_custom/models/stock_picking_type.py6
-rw-r--r--indoteknik_custom/report/purchase_order.xml9
-rw-r--r--indoteknik_custom/views/ir_sequence.xml12
-rw-r--r--indoteknik_custom/views/stock_location.xml8
-rw-r--r--indoteknik_custom/views/stock_picking.xml29
-rw-r--r--indoteknik_custom/views/stock_picking_type.xml31
11 files changed, 149 insertions, 1 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index a2ecfb6c..7baa89c3 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -33,9 +33,14 @@
'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',
+ 'report/purchase_order.xml'
],
'demo': [],
'css': [],
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")
diff --git a/indoteknik_custom/report/purchase_order.xml b/indoteknik_custom/report/purchase_order.xml
new file mode 100644
index 00000000..09ded9dc
--- /dev/null
+++ b/indoteknik_custom/report/purchase_order.xml
@@ -0,0 +1,9 @@
+<odoo>
+ <template id="report_purchase_order_npwp" inherit_id="purchase.report_purchaseorder_document">
+ <xpath expr="//p[@t-field='o.notes']" position="after">
+ <div class="col-12" name="right_box">
+ <b>NPWP</b><br/>74.226.022.7-086.000<br/><b>PT. INDOTEKNIK DOTCOM GEMILANG</b><br/>JALAN BANDENGAN UTARA BLOK 85A NO 8-9<br/>PENJARINGAN, PENJARINGAN<br/>KOTA ADM, JAKARTA UTARA DKI JAKARTA 14440
+ </div>
+ </xpath>
+ </template>
+</odoo>
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