summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-02-09 13:49:36 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-02-09 13:49:36 +0700
commit1418dbbb581228383df151f1f8df6fc48a0fb9cc (patch)
tree7d09263aaee2973ef3213cc8522a9cc5049008a1
parent1a339c7e5b644add00c3bd7c623cb6d4553277cf (diff)
change request logbook sj
-rw-r--r--indoteknik_custom/models/logbook_sj.py45
-rw-r--r--indoteknik_custom/models/report_logbook_sj.py50
-rw-r--r--indoteknik_custom/views/ir_sequence.xml10
-rw-r--r--indoteknik_custom/views/report_logbook_sj.xml28
4 files changed, 89 insertions, 44 deletions
diff --git a/indoteknik_custom/models/logbook_sj.py b/indoteknik_custom/models/logbook_sj.py
index 567f1ae3..bf4acd14 100644
--- a/indoteknik_custom/models/logbook_sj.py
+++ b/indoteknik_custom/models/logbook_sj.py
@@ -18,31 +18,27 @@ class LogbookSJ(models.TransientModel):
current_time = datetime.utcnow()
report_logbook_ids = []
+ parameters_header = {
+ 'date': current_time,
+ }
+
+ report_logbook = self.env['report.logbook.sj'].create([parameters_header])
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,
+ picking = self.env['stock.picking'].search([('picking_code', '=', line.name)], limit=1)
+ stock = picking
+
+ data = {
+ 'picking_id': stock.id,
+ 'name': stock.name,
+ 'driver_id': stock.driver_id.id,
+ 'departure_date': stock.driver_departure_date,
+ 'arrival_date': stock.driver_arrival_date,
+ 'carrier_id': stock.carrier_id.id,
+ 'tracking_no': stock.delivery_tracking_no,
+ 'partner_id': stock.partner_id.id,
+ 'report_logbook_sj_id': report_logbook.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])
+ self.env['report.logbook.sj.line'].create([data])
report_logbook_ids.append(report_logbook.id)
line.unlink()
@@ -68,6 +64,7 @@ class LogbookSJLine(models.TransientModel):
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')
+ picking_id = fields.Many2one('res.partner', string='Customer')
@api.onchange('name')
def onchange_name(self):
@@ -94,6 +91,8 @@ class LogbookSJLine(models.TransientModel):
self.partner_id = picking.partner_id
+ self.picking_id = picking.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')
diff --git a/indoteknik_custom/models/report_logbook_sj.py b/indoteknik_custom/models/report_logbook_sj.py
index d2008608..5ff56c9a 100644
--- a/indoteknik_custom/models/report_logbook_sj.py
+++ b/indoteknik_custom/models/report_logbook_sj.py
@@ -6,29 +6,59 @@ 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')
+ name = fields.Char(string='Name', default='Logbook SJ')
+ date = fields.Datetime(string='Date Created')
+ date_approve = fields.Datetime(string='Date Approve')
approve_by_finance = fields.Boolean(string='Approve By Finance')
+ approve_by = fields.Many2one(comodel_name='res.users', string='Approve By')
report_logbook_sj_line = fields.One2many(
comodel_name='report.logbook.sj.line',
inverse_name='report_logbook_sj_id',
string='Logbook SJ Line'
)
+ state = fields.Selection(
+ [('belum_terima', 'Belum Terima'),
+ ('terima_sebagian', 'Terima Sebagian'),
+ ('terima_semua', 'Sudah di terima semua'),
+ ],
+ default='terima_semua',
+ string='Status',
+ tracking=True
+ )
+
+ @api.model
+ def create(self, vals):
+ vals['name'] = self.env['ir.sequence'].next_by_code('report.logbook.sj') or '0'
+ result = super(ReportLogbookSJ, self).create(vals)
+ return result
def approve(self):
+ current_time = datetime.utcnow()
if self.env.user.is_accounting:
self.approve_by_finance = True
+ self.date_approve = current_time
+ self.approve_by = self.env.user.id
+ if any(line.not_exist for line in self.report_logbook_sj_line):
+ if all(line.not_exist for line in self.report_logbook_sj_line):
+ self.state = 'belum_terima'
+ else:
+ self.state = 'terima_sebagian'
+ else:
+ self.state = 'terima_semua'
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
+ 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('report.logbook.sj', string='Logbook SJ') # Corrected model name
+ partner_id = fields.Many2one('res.partner', string='Customer')
+ picking_id = fields.Many2one('stock.picking', string='Picking')
+ report_logbook_sj_id = fields.Many2one('report.logbook.sj', string='Logbook SJ')
+ not_exist = fields.Boolean(string='Not Exist')
diff --git a/indoteknik_custom/views/ir_sequence.xml b/indoteknik_custom/views/ir_sequence.xml
index 86259b12..56921839 100644
--- a/indoteknik_custom/views/ir_sequence.xml
+++ b/indoteknik_custom/views/ir_sequence.xml
@@ -10,6 +10,16 @@
<field name="number_next">1</field>
<field name="number_increment">1</field>
</record>
+
+ <record id="sequence_logbook_sj" model="ir.sequence">
+ <field name="name">Logbook SJ</field>
+ <field name="code">report.logbook.sj</field>
+ <field name="active">TRUE</field>
+ <field name="prefix">LSJ/%(year)s/</field>
+ <field name="padding">5</field>
+ <field name="number_next">1</field>
+ <field name="number_increment">1</field>
+ </record>
<record id="sequence_stock_picking_code" model="ir.sequence">
<field name="name">Stock Picking Code</field>
diff --git a/indoteknik_custom/views/report_logbook_sj.xml b/indoteknik_custom/views/report_logbook_sj.xml
index 52e00d17..ea58aefd 100644
--- a/indoteknik_custom/views/report_logbook_sj.xml
+++ b/indoteknik_custom/views/report_logbook_sj.xml
@@ -6,10 +6,11 @@
<field name="arch" type="xml">
<tree create="0">
<field name="name"/>
+ <field name="approve_by"/>
<field name="date"/>
- <field name="name_picking"/>
+ <field name="date_approve"/>
<field name="approve_by_finance"/>
- <field name="partner_id"/>
+ <field name="state"/>
</tree>
</field>
</record>
@@ -18,12 +19,16 @@
<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 editable="bottom">
+ <field name="name"/>
+ <field name="driver_id"/>
+ <field name="departure_date"/>
+ <field name="arrival_date"/>
+ <field name="carrier_id"/>
+ <field name="tracking_no"/>
+ <field name="partner_id"/>
+ <field name="picking_id"/>
+ <field name="not_exist"/>
</tree>
</field>
</record>
@@ -35,7 +40,7 @@
<form>
<header>
<button name="approve"
- string="Approve"
+ string="Validate"
type="object"
/>
</header>
@@ -45,11 +50,12 @@
<group>
<field name="name" readonly="1"/>
<field name="date" readonly="1"/>
+ <field name="date_approve" readonly="1"/>
</group>
<group>
- <field name="name_picking" readonly="1"/>
- <field name="partner_id" readonly="1"/>
<field name="approve_by_finance" readonly="1"/>
+ <field name="state" readonly="1"/>
+ <field name="approve_by" readonly="1"/>
</group>
</group>
<notebook>