-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
529 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
...d_djbc_kite_lap_pemakaian_bahan_baku/reports/djbc_kite_lap_pemakaian_bahan_baku_subkon.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, fields | ||
from openerp import tools | ||
|
||
|
||
class LapKitePemakaianBahanBakuSubkon(models.Model): | ||
_name = "l10n_id.lap_kite_pemakaian_bahan_baku_subkon" | ||
_description = "Laporan Pemakaian Bahan Baku Subkontrak KITE" | ||
_auto = False | ||
|
||
no_pengeluaran = fields.Many2one( | ||
string="Nomor Pengeluaran", | ||
comodel_name="stock.picking", | ||
) | ||
tgl_pengeluaran = fields.Datetime( | ||
string="Tanggal Pengeluaran", | ||
) | ||
kode_barang = fields.Char( | ||
string="Kode Barang", | ||
) | ||
nama_barang = fields.Char( | ||
string="Nama Barang", | ||
) | ||
satuan = fields.Many2one( | ||
string="Satuan", | ||
comodel_name="product.uom", | ||
) | ||
jumlah_digunakan = fields.Float( | ||
string="Jumlah Digunakan", | ||
) | ||
jumlah_disubkontrakkan = fields.Float( | ||
string="Jumlah Disubkontrakan", | ||
) | ||
penerima_subkontrak = fields.Many2one( | ||
string="Penerima Subkontrak", | ||
comodel_name="res.partner", | ||
) | ||
gudang = fields.Many2one( | ||
string="Gudang", | ||
comodel_name="stock.warehouse" | ||
) | ||
|
||
def _get_movement_type(self, cr): | ||
query = """ | ||
SELECT res_id | ||
FROM ir_model_data | ||
WHERE | ||
module = 'l10n_id_djbc_kite_lap_pemakaian_bahan_baku' AND | ||
name = 'djbc_kite_movement_type_pemakaian_bahan_baku_subkontrak' | ||
""" | ||
cr.execute(query) | ||
movement_type = cr.fetchone() | ||
if movement_type: | ||
return movement_type | ||
else: | ||
return 0 | ||
|
||
def _select(self): | ||
select_str = """ | ||
SELECT a.id as id, | ||
a.picking_id AS no_pengeluaran, | ||
a.date AS tgl_pengeluaran, | ||
c.name AS nama_barang, | ||
b.default_code AS kode_barang, | ||
a.product_uom AS satuan, | ||
0.0 AS jumlah_digunakan, | ||
a.product_uom_qty AS jumlah_disubkontrakkan, | ||
e.partner_id AS penerima_subkontrak, | ||
d.warehouse_id AS gudang | ||
""" | ||
return select_str | ||
|
||
def _from(self): | ||
from_str = """ | ||
FROM stock_move AS a | ||
""" | ||
return from_str | ||
|
||
def _join(self): | ||
join_str = """ | ||
JOIN product_product AS b ON a.product_id = b.id | ||
JOIN product_template AS c ON b.product_tmpl_id = c.id | ||
JOIN stock_picking_type AS d ON a.picking_type_id = d.id | ||
LEFT JOIN stock_picking AS e ON a.picking_id = e.id | ||
JOIN product_categ_rel AS f ON | ||
c.id = f.product_id | ||
JOIN product_category AS g ON | ||
f.categ_id = g.id | ||
JOIN ( | ||
SELECT res_id | ||
FROM ir_model_data AS e1 | ||
WHERE | ||
e1.module = 'l10n_id_djbc_kite_common' AND | ||
(e1.name = 'product_categ_kite_bahan_baku') | ||
) as h ON | ||
g.id = h.res_id | ||
""" | ||
return join_str | ||
|
||
def _where(self, movement_type_id): | ||
where_str = """ | ||
WHERE | ||
a.state = 'done' AND | ||
a.djbc_custom IS TRUE AND | ||
d.djbc_kite_scrap IS FALSE AND | ||
d.djbc_kite_movement_type_id=%s | ||
""" % (movement_type_id) | ||
return where_str | ||
|
||
def _order_by(self): | ||
join_str = """ | ||
ORDER BY a.date, a.id | ||
""" | ||
return join_str | ||
|
||
def init(self, cr): | ||
tools.drop_view_if_exists(cr, self._table) | ||
# pylint: disable=locally-disabled, sql-injection | ||
movement_type_id =\ | ||
self._get_movement_type(cr) | ||
cr.execute("""CREATE or REPLACE VIEW %s as ( | ||
%s | ||
%s | ||
%s | ||
%s | ||
%s | ||
)""" % ( | ||
self._table, | ||
self._select(), | ||
self._from(), | ||
self._join(), | ||
self._where(movement_type_id), | ||
self._order_by() | ||
)) |
105 changes: 105 additions & 0 deletions
105
...id_djbc_kite_lap_pemakaian_bahan_baku/reports/djbc_kite_lap_pemakaian_bahan_baku_union.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, fields | ||
from openerp import tools | ||
|
||
|
||
class LapKitePemakaianBahanBakuUnion(models.Model): | ||
_name = "l10n_id.lap_kite_pemakaian_bahan_baku_union" | ||
_description = "Laporan Pemakaian Bahan Baku Union KITE" | ||
_auto = False | ||
|
||
no_pengeluaran = fields.Many2one( | ||
string="Nomor Pengeluaran", | ||
comodel_name="stock.picking", | ||
) | ||
tgl_pengeluaran = fields.Datetime( | ||
string="Tanggal Pengeluaran", | ||
) | ||
kode_barang = fields.Char( | ||
string="Kode Barang", | ||
) | ||
nama_barang = fields.Char( | ||
string="Nama Barang", | ||
) | ||
satuan = fields.Many2one( | ||
string="Satuan", | ||
comodel_name="product.uom", | ||
) | ||
jumlah_digunakan = fields.Float( | ||
string="Jumlah Digunakan", | ||
) | ||
jumlah_disubkontrakkan = fields.Float( | ||
string="Jumlah Disubkontrakan", | ||
) | ||
penerima_subkontrak = fields.Many2one( | ||
string="Penerima Subkontrak", | ||
comodel_name="res.partner", | ||
) | ||
gudang = fields.Many2one( | ||
string="Gudang", | ||
comodel_name="stock.warehouse" | ||
) | ||
|
||
# Object: l10n_id.lap_kite_pemakaian_bahan_baku | ||
def _select_1(self): | ||
select_str = """ | ||
SELECT id, | ||
no_pengeluaran, | ||
tgl_pengeluaran, | ||
nama_barang, | ||
kode_barang, | ||
satuan, | ||
jumlah_digunakan, | ||
jumlah_disubkontrakkan, | ||
penerima_subkontrak, | ||
gudang | ||
""" | ||
return select_str | ||
|
||
def _from_1(self): | ||
from_str = """ | ||
FROM l10n_id_lap_kite_pemakaian_bahan_baku | ||
""" | ||
return from_str | ||
|
||
# Object: l10n_id.lap_kite_pemakaian_bahan_baku_subkon | ||
def _select_2(self): | ||
select_str = """ | ||
SELECT id, | ||
no_pengeluaran, | ||
tgl_pengeluaran, | ||
nama_barang, | ||
kode_barang, | ||
satuan, | ||
jumlah_digunakan, | ||
jumlah_disubkontrakkan, | ||
penerima_subkontrak, | ||
gudang | ||
""" | ||
return select_str | ||
|
||
def _from_2(self): | ||
from_str = """ | ||
FROM l10n_id_lap_kite_pemakaian_bahan_baku_subkon | ||
""" | ||
return from_str | ||
|
||
def init(self, cr): | ||
tools.drop_view_if_exists(cr, self._table) | ||
# pylint: disable=locally-disabled, sql-injection | ||
cr.execute("""CREATE or REPLACE VIEW %s as ( | ||
%s | ||
%s | ||
UNION | ||
%s | ||
%s | ||
)""" % ( | ||
self._table, | ||
self._select_1(), | ||
self._from_1(), | ||
self._select_2(), | ||
self._from_2(), | ||
)) |
2 changes: 2 additions & 0 deletions
2
l10n_id_djbc_kite_lap_pemakaian_bahan_baku/security/ir.model.access.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_all_djbc_lap_kite_pemakaian_bahan_baku,all user l10n_id.lap_kite_pemakaian_bahan_baku,model_l10n_id_lap_kite_pemakaian_bahan_baku,,1,0,0,0 | ||
access_all_djbc_lap_kite_pemakaian_bahan_baku_subkon,all user l10n_id.lap_kite_pemakaian_bahan_baku_subkon,model_l10n_id_lap_kite_pemakaian_bahan_baku_subkon,,1,0,0,0 | ||
access_all_djbc_lap_kite_pemakaian_bahan_baku_union,all user l10n_id.lap_kite_pemakaian_bahan_baku_union,model_l10n_id_lap_kite_pemakaian_bahan_baku_union,,1,0,0,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.