From 1829416edc7b2a8f6ab82cc8a0f7cdd0d07f2fbe Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 15 Dec 2023 08:34:03 +0700 Subject: mark upload efaktur & validate email sale order --- indoteknik_custom/models/account_move.py | 11 +++++++++++ indoteknik_custom/models/sale_order.py | 8 ++++++++ indoteknik_custom/views/account_move.xml | 3 +++ 3 files changed, 22 insertions(+) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 699191d6..82a86a39 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -31,6 +31,17 @@ class AccountMove(models.Model): due_line = fields.One2many('due.extension.line', 'invoice_id', compute='_compute_due_line', string='Due Extension Lines') no_faktur_pajak = fields.Char(string='No Faktur Pajak') date_completed = fields.Datetime(string='Date Completed') + mark_upload_efaktur = fields.Selection([ + ('belum_upload', 'Belum Upload FP'), + ('sudah_upload', 'Sudah Upload FP'), + ], 'Mark Upload Faktur', compute='_compute_mark_upload_efaktur', default='belum_upload') + + def _compute_mark_upload_efaktur(self): + for move in self: + if move.date_efaktur_exported or move.is_efaktur_exported or move.efaktur_document: + move.mark_upload_efaktur = 'sudah_upload' + else: + move.mark_upload_efaktur = 'belum_upload' def _compute_due_line(self): for invoice in self: diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 55a6bd26..bf10246a 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -84,6 +84,14 @@ class SaleOrder(models.Model): helper_by_id = fields.Many2one('res.users', 'Helper By') # picking_ids = fields.Many2many('stock.picking', string='Pickings', compute='_get_pickings', readonly=True, copy=False, search="_search_picking_ids") + @api.constrains('email') + def _validate_email(self): + rule_regex = self.env['ir.config_parameter'].sudo().get_param('sale.order.validate_email') or '' + pattern = rf'^{rule_regex}$' + + if self.email and not re.match(pattern, self.email): + raise UserError('Email harus menggunakan karakter @') + def override_allow_create_invoice(self): if not self.env.user.is_accounting: raise UserError('Hanya Finance Accounting yang dapat klik tombol ini') diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index b0a206bf..973bfc01 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -56,6 +56,9 @@ + -- cgit v1.2.3