diff options
Diffstat (limited to 'indoteknik_custom/models/report_logbook_sj.py')
| -rw-r--r-- | indoteknik_custom/models/report_logbook_sj.py | 50 |
1 files changed, 40 insertions, 10 deletions
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') |
