summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-02-02 13:32:55 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-02-02 13:32:55 +0700
commit8978868864925683d02342112020e7fc047a4acf (patch)
tree1176a2d6f65e71a4bccde20c6dd4cbea79b4b8fa
parentd6c7fad834f954f892cea0eb9e082db822bc8f2b (diff)
logbook sj and mark as cancel po
-rwxr-xr-xindoteknik_custom/__manifest__.py11
-rwxr-xr-xindoteknik_custom/models/__init__.py11
-rw-r--r--indoteknik_custom/models/logbook_sj.py117
-rw-r--r--indoteknik_custom/models/po_multi_cancel.py22
-rwxr-xr-xindoteknik_custom/models/purchase_order.py19
-rw-r--r--indoteknik_custom/models/report_logbook_sj.py34
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv17
-rw-r--r--indoteknik_custom/views/logbook_sj.xml52
-rw-r--r--indoteknik_custom/views/po_multi_cancel.xml31
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml9
-rw-r--r--indoteknik_custom/views/report_logbook_sj.xml90
11 files changed, 412 insertions, 1 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index c7e65b37..689103d8 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -107,6 +107,17 @@
'views/purchase_order_multi_update.xml',
'views/purchase_order_multi_confirm.xml',
'views/invoice_reklas_penjualan.xml',
+<<<<<<< Updated upstream
+<<<<<<< Updated upstream
+ 'views/po_multi_cancel.xml',
+=======
+ 'views/logbook_sj.xml',
+ 'views/report_logbook_sj.xml',
+>>>>>>> Stashed changes
+=======
+ 'views/logbook_sj.xml',
+ 'views/report_logbook_sj.xml',
+>>>>>>> Stashed changes
'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 76387ff8..4b29e71d 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -98,3 +98,14 @@ from . import purchase_order_multi_update
from . import invoice_reklas_penjualan
from . import purchase_order_multi_confirm
from . import stock_quant
+<<<<<<< Updated upstream
+<<<<<<< Updated upstream
+from . import po_multi_cancel
+=======
+from . import logbook_sj
+from . import report_logbook_sj
+>>>>>>> Stashed changes
+=======
+from . import logbook_sj
+from . import report_logbook_sj
+>>>>>>> Stashed changes
diff --git a/indoteknik_custom/models/logbook_sj.py b/indoteknik_custom/models/logbook_sj.py
new file mode 100644
index 00000000..567f1ae3
--- /dev/null
+++ b/indoteknik_custom/models/logbook_sj.py
@@ -0,0 +1,117 @@
+from odoo import models, fields, api, _
+from odoo.exceptions import UserError
+from pytz import timezone
+from datetime import datetime
+
+class LogbookSJ(models.TransientModel):
+ _name = 'logbook.sj'
+
+ name = fields.Char(string='Name', default='Logbook SJ')
+ logbook_sj_line = fields.One2many(
+ comodel_name='logbook.sj.line',
+ inverse_name='logbook_sj_id',
+ string='Logbook SJ Line'
+ )
+
+ def create_logbook_sj(self):
+ logbook_line = self.logbook_sj_line
+
+ current_time = datetime.utcnow()
+ report_logbook_ids = []
+ for line in logbook_line:
+ nomor_sj = line.name
+ picking = self.env['stock.picking'].search([
+ ('picking_code', '=', nomor_sj),
+ ])
+ parameters_header = {
+ 'name': nomor_sj,
+ 'date': current_time,
+ 'name_picking': picking.name,
+ 'partner_id': picking.partner_id.id,
+ }
+
+ report_logbook = self.env['report.logbook.sj'].create([parameters_header])
+
+
+ for stock in picking.move_line_ids_without_package:
+ data = {
+ 'product_id': stock.product_id.id,
+ 'location_id': stock.location_id.id,
+ 'product_uom_qty': stock.product_uom_qty,
+ 'qty_done': stock.qty_done,
+ 'product_uom_id': stock.product_uom_id.id,
+ 'report_logbook_sj_id': report_logbook.id
+ }
+ self.env['report.logbook.sj.line'].create([data])
+
+ report_logbook_ids.append(report_logbook.id)
+ line.unlink()
+
+ self.unlink()
+ return {
+ 'name': _('Report Logbook SJ'),
+ 'view_mode': 'tree,form',
+ 'res_model': 'report.logbook.sj',
+ 'target': 'current',
+ 'type': 'ir.actions.act_window',
+ 'domain': [('id', 'in', report_logbook_ids)],
+ }
+
+class LogbookSJLine(models.TransientModel):
+ _name = 'logbook.sj.line'
+
+ name = fields.Char(string='SJ Number')
+ driver_id = fields.Many2one(comodel_name='res.users', string='Driver')
+ departure_date = fields.Char(string='Departure Date')
+ arrival_date = fields.Char(string='Arrival Date')
+ carrier_id = fields.Many2one('delivery.carrier', string='Shipping Method')
+ tracking_no = fields.Char(string='Tracking No')
+ logbook_sj_id = fields.Many2one('logbook.sj', string='Logbook SJ')
+ partner_id = fields.Many2one('res.partner', string='Customer')
+
+ @api.onchange('name')
+ def onchange_name(self):
+ current_time = datetime.now(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S')
+
+ if self.name:
+ if len(self.name) == 13:
+ self.name = self.name[:-1]
+ picking = self.env['stock.picking'].search([('picking_code', '=', self.name)], limit=1)
+ if picking:
+ if picking.driver_id:
+ self.driver_id = picking.driver_id
+ else:
+ self.driver_id = self.env.uid
+
+ sale_order = False
+ if picking.origin:
+ sale_order = self.env['sale.order'].search([('name', '=', picking.origin)], limit=1)
+
+ if sale_order.carrier_id:
+ self.carrier_id = sale_order.carrier_id
+
+ self.tracking_no = picking.delivery_tracking_no
+
+ self.partner_id = picking.partner_id
+
+ delivery_type = self.get_delivery_type(picking.driver_departure_date, picking.driver_arrival_date)
+ if delivery_type != 'departure':
+ self.departure_date = picking.driver_departure_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S')
+
+ if delivery_type == 'departure':
+ self.departure_date = current_time
+ elif delivery_type == 'arrival':
+ self.arrival_date = current_time
+ else:
+ self.arrival_date = picking.driver_arrival_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S')
+ else:
+ raise UserError('Nomor DO tidak ditemukan')
+
+ def get_delivery_type(self, driver_departure_date, driver_arrival_date):
+ delivery_type = 'departure'
+ if driver_departure_date:
+ delivery_type = 'arrival'
+ if driver_arrival_date:
+ delivery_type = False
+
+ return delivery_type
diff --git a/indoteknik_custom/models/po_multi_cancel.py b/indoteknik_custom/models/po_multi_cancel.py
new file mode 100644
index 00000000..52c156b5
--- /dev/null
+++ b/indoteknik_custom/models/po_multi_cancel.py
@@ -0,0 +1,22 @@
+from odoo import models, fields
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class PoMultiCancel(models.TransientModel):
+ _name = 'po.multi.cancel'
+
+ def save_multi_cancel_po(self):
+ purchase_ids = self._context['purchase_ids']
+ purchase = self.env['purchase.order'].browse(purchase_ids)
+ purchase.button_cancel()
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'display_notification',
+ 'params': {
+ 'title': 'Notification',
+ 'message': 'Status berhasil diubah',
+ 'next': {'type': 'ir.actions.act_window_close'},
+ }
+ } \ No newline at end of file
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 67299d2c..dc654196 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -53,6 +53,25 @@ class PurchaseOrder(models.Model):
status_paid_cbd = fields.Boolean(string='Paid Status', tracking=3, help='Field ini diisi secara manual oleh Finance AP dan hanya untuk status PO CBD')
revisi_po = fields.Boolean(string='Revisi', tracking=3)
+ @api.model
+ def action_multi_cancel(self):
+ for purchase in self:
+ purchase.update({
+ 'state': 'cancel',
+ })
+
+ if purchase.state == 'cancel':
+ purchase.update({
+ 'approval_status': False,
+ })
+
+ def open_form_multi_cancel(self):
+ action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_po_multi_cancel')
+ action['context'] = {
+ 'purchase_ids': [x.id for x in self]
+ }
+ return action
+
def delete_line(self):
lines_to_delete = self.order_line.filtered(lambda line: line.suggest == 'masih cukup')
if not lines_to_delete:
diff --git a/indoteknik_custom/models/report_logbook_sj.py b/indoteknik_custom/models/report_logbook_sj.py
new file mode 100644
index 00000000..d2008608
--- /dev/null
+++ b/indoteknik_custom/models/report_logbook_sj.py
@@ -0,0 +1,34 @@
+from odoo import models, fields, api
+from odoo.exceptions import UserError
+from pytz import timezone
+from datetime import datetime
+
+class ReportLogbookSJ(models.Model):
+ _name = 'report.logbook.sj'
+
+ name = fields.Char(string='Nomor SJ', default='Logbook SJ')
+ date = fields.Datetime(string='Date')
+ name_picking = fields.Char(string='Picking Name')
+ partner_id = fields.Many2one('res.partner', string='Customer')
+ approve_by_finance = fields.Boolean(string='Approve By Finance')
+ report_logbook_sj_line = fields.One2many(
+ comodel_name='report.logbook.sj.line',
+ inverse_name='report_logbook_sj_id',
+ string='Logbook SJ Line'
+ )
+
+ def approve(self):
+ if self.env.user.is_accounting:
+ self.approve_by_finance = True
+ else:
+ raise UserError('Hanya Accounting yang bisa Approve')
+
+class ReportLogbookSJLine(models.Model):
+ _name = 'report.logbook.sj.line'
+
+ product_id = fields.Many2one(comodel_name='product.product', string='Product')
+ location_id = fields.Many2one(comodel_name='stock.location', string='From')
+ product_uom_qty = fields.Float(string='Reserved')
+ qty_done = fields.Float(string='Done')
+ product_uom_id = fields.Many2one('uom.uom', string='Unit of Measure')
+ report_logbook_sj_id = fields.Many2one('report.logbook.sj', string='Logbook SJ') \ No newline at end of file
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index 8d014b69..c2bfaa10 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -88,4 +88,19 @@ access_sale_advance_payment_inv,access.sale.advance.payment.inv,model_sale_advan
access_purchase_order_multi_update,access.purchase.order.multi_update,model_purchase_order_multi_update,,1,1,1,1
access_invoice_reklas_penjualan,access.invoice.reklas.penjualan,model_invoice_reklas_penjualan,,1,1,1,1
access_invoice_reklas_penjualan_line,access.invoice.reklas.penjualan.line,model_invoice_reklas_penjualan_line,,1,1,1,1
-access_purchase_order_multi_confirm,access.purchase.order.multi_confirm,model_purchase_order_multi_confirm,,1,1,1,1 \ No newline at end of file
+access_purchase_order_multi_confirm,access.purchase.order.multi_confirm,model_purchase_order_multi_confirm,,1,1,1,1
+<<<<<<< Updated upstream
+<<<<<<< Updated upstream
+access_po_multi_cancel,access.po.multi.cancel,model_po_multi_cancel,,1,1,1,1
+=======
+access_logbook_sj,access.logbook.sj,model_logbook_sj,,1,1,1,1
+access_logbook_sj_line,access.logbook.sj.line,model_logbook_sj_line,,1,1,1,1
+access_report_logbook_sj,access.report.logbook.sj,model_report_logbook_sj,,1,1,1,1
+access_report_logbook_sj_line,access.report.logbook.sj.line,model_report_logbook_sj_line,,1,1,1,1
+>>>>>>> Stashed changes
+=======
+access_logbook_sj,access.logbook.sj,model_logbook_sj,,1,1,1,1
+access_logbook_sj_line,access.logbook.sj.line,model_logbook_sj_line,,1,1,1,1
+access_report_logbook_sj,access.report.logbook.sj,model_report_logbook_sj,,1,1,1,1
+access_report_logbook_sj_line,access.report.logbook.sj.line,model_report_logbook_sj_line,,1,1,1,1
+>>>>>>> Stashed changes
diff --git a/indoteknik_custom/views/logbook_sj.xml b/indoteknik_custom/views/logbook_sj.xml
new file mode 100644
index 00000000..9eb9aa12
--- /dev/null
+++ b/indoteknik_custom/views/logbook_sj.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<odoo>
+ <record id="view_logbook_sj_form" model="ir.ui.view">
+ <field name="name">Logbook SJ</field>
+ <field name="model">logbook.sj</field>
+ <field name="arch" type="xml">
+ <form>
+ <sheet>
+ <field name="name" invisible="1"/>
+ <field
+ name="logbook_sj_line"
+ mode="tree"
+ >
+ <tree editable="bottom">
+ <control>
+ <create name="add_logbook_sj_line_control" string="Add a logbook"/>
+ </control>
+ <field name="name" required="1"/>
+ <field name="driver_id" readonly="1"/>
+ <field name="departure_date" readonly="1"/>
+ <field name="arrival_date" readonly="1"/>
+ <field name="carrier_id" readonly="1"/>
+ <field name="tracking_no" readonly="1"/>
+ <field name="partner_id" readonly="1"/>
+ </tree>
+ </field>
+ </sheet>
+ <footer>
+ <button name="create_logbook_sj" string="Submit" type="object" default_focus="1" class="oe_highlight"/>
+ <button string="Cancel" class="btn btn-secondary" special="cancel" />
+ </footer>
+ </form>
+ </field>
+ </record>
+
+ <record id="action_logbook_sj" model="ir.actions.act_window">
+ <field name="name">Logbook SJ</field>
+ <field name="res_model">logbook.sj</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="view_mode">form</field>
+ <field name="view_id" ref="view_logbook_sj_form"/>
+ <field name="target">new</field>
+ </record>
+
+ <menuitem
+ action="action_logbook_sj"
+ id="logbook_sj"
+ parent="stock.menu_stock_warehouse_mgmt"
+ name="Logbook SJ"
+ sequence="1"
+ />
+</odoo> \ No newline at end of file
diff --git a/indoteknik_custom/views/po_multi_cancel.xml b/indoteknik_custom/views/po_multi_cancel.xml
new file mode 100644
index 00000000..c17fc5a7
--- /dev/null
+++ b/indoteknik_custom/views/po_multi_cancel.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+ <data>
+ <record id="view_po_multi_cancel_form" model="ir.ui.view">
+ <field name="name">PO Multi Cancel</field>
+ <field name="model">po.multi.cancel</field>
+ <field name="arch" type="xml">
+ <form>
+ <sheet>
+ <group>
+ <span>Apakah Anda Yakin Ingin Mengubah Status Menjadi Cancel?</span>
+ </group>
+ </sheet>
+ <footer>
+ <button name="save_multi_cancel_po" string="Update" type="object" default_focus="1" class="oe_highlight"/>
+ <button string="Cancel" class="btn btn-secondary" special="cancel" />
+ </footer>
+ </form>
+ </field>
+ </record>
+
+ <record id="action_po_multi_cancel" model="ir.actions.act_window">
+ <field name="name">PO Multi Cancel</field>
+ <field name="res_model">po.multi.cancel</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="view_mode">form</field>
+ <field name="view_id" ref="view_po_multi_cancel_form"/>
+ <field name="target">new</field>
+ </record>
+ </data>
+</odoo> \ No newline at end of file
diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml
index 52e98787..a6f28ffa 100755
--- a/indoteknik_custom/views/purchase_order.xml
+++ b/indoteknik_custom/views/purchase_order.xml
@@ -213,4 +213,13 @@
<field name="code">action = records.open_form_multi_confirm_po()</field>
</record>
</data>
+ <data>
+ <record id="purchase_order_multi_cancel_ir_actions_server" model="ir.actions.server">
+ <field name="name">Cancel PO</field>
+ <field name="model_id" ref="purchase.model_purchase_order"/>
+ <field name="binding_model_id" ref="purchase.model_purchase_order"/>
+ <field name="state">code</field>
+ <field name="code">action = records.open_form_multi_cancel()</field>
+ </record>
+ </data>
</odoo> \ No newline at end of file
diff --git a/indoteknik_custom/views/report_logbook_sj.xml b/indoteknik_custom/views/report_logbook_sj.xml
new file mode 100644
index 00000000..52e00d17
--- /dev/null
+++ b/indoteknik_custom/views/report_logbook_sj.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+ <record id="report_logbook_sj_tree" model="ir.ui.view">
+ <field name="name">report.logbook.sj.tree</field>
+ <field name="model">report.logbook.sj</field>
+ <field name="arch" type="xml">
+ <tree create="0">
+ <field name="name"/>
+ <field name="date"/>
+ <field name="name_picking"/>
+ <field name="approve_by_finance"/>
+ <field name="partner_id"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="report_logbook_sj_line_tree" model="ir.ui.view">
+ <field name="name">report.logbook.sj.line.tree</field>
+ <field name="model">report.logbook.sj.line</field>
+ <field name="arch" type="xml">
+ <tree>
+ <field name="product_id"/>
+ <field name="location_id"/>
+ <field name="product_uom_qty"/>
+ <field name="qty_done"/>
+ <field name="product_uom_id"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="report_logbook_sj_form" model="ir.ui.view">
+ <field name="name">report.logbook.sj.form</field>
+ <field name="model">report.logbook.sj</field>
+ <field name="arch" type="xml">
+ <form>
+ <header>
+ <button name="approve"
+ string="Approve"
+ type="object"
+ />
+ </header>
+ <sheet string="Report logbook SJ">
+ <div class="oe_button_box" name="button_box"/>
+ <group>
+ <group>
+ <field name="name" readonly="1"/>
+ <field name="date" readonly="1"/>
+ </group>
+ <group>
+ <field name="name_picking" readonly="1"/>
+ <field name="partner_id" readonly="1"/>
+ <field name="approve_by_finance" readonly="1"/>
+ </group>
+ </group>
+ <notebook>
+ <page string="Line">
+ <field name="report_logbook_sj_line"/>
+ </page>
+ </notebook>
+ </sheet>
+ </form>
+ </field>
+ </record>
+<!--
+ <record id="view_report_logbook_sj_filter" model="ir.ui.view">
+ <field name="name">report.logbook.sj.list.select</field>
+ <field name="model">report.logbook.sj</field>
+ <field name="priority" eval="15"/>
+ <field name="arch" type="xml">
+ <search string="Search Report Logbook SJ">
+ <field name="number"/>
+ <field name="partner_id"/>
+ <field name="dunning_line" string="Invoice" filter_domain="[('dunning_line.invoice_id', 'ilike', self)]"/>
+ </search>
+ </field>
+ </record> -->
+
+ <record id="report_logbook_sj_action" model="ir.actions.act_window">
+ <field name="name">Report Logbook SJ</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">report.logbook.sj</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <menuitem id="menu_report_logbook_sj"
+ name="Report Logbook SJ"
+ action="report_logbook_sj_action"
+ parent="account.menu_finance_reports"
+ sequence="200"/>
+</odoo> \ No newline at end of file