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')