From eabbbadc5114f6c1edb9ec6bb74a296477f02b5a Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 14 Dec 2023 14:13:32 +0700 Subject: initial commit purchasing job --- .../models/purchasing_job_multi_update.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 indoteknik_custom/models/purchasing_job_multi_update.py (limited to 'indoteknik_custom/models/purchasing_job_multi_update.py') diff --git a/indoteknik_custom/models/purchasing_job_multi_update.py b/indoteknik_custom/models/purchasing_job_multi_update.py new file mode 100644 index 00000000..e455c5a4 --- /dev/null +++ b/indoteknik_custom/models/purchasing_job_multi_update.py @@ -0,0 +1,22 @@ +from odoo import models, fields +import logging + +_logger = logging.getLogger(__name__) + + +class PurchasingJobMultiUpdate(models.TransientModel): + _name = 'purchasing.job.multi.update' + + def save_multi_update_purchasing_job(self): + product_ids = self._context['product_ids'] + product = self.env['product.product'].browse(product_ids) + product.action_multi_update_invoice_status() + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': 'Notification', + 'message': 'Invoice Status berhasil diubah', + 'next': {'type': 'ir.actions.act_window_close'}, + } + } \ No newline at end of file -- cgit v1.2.3 From ce2b8502ab85419096dda2bffaffbec4a096a99f Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 14 Dec 2023 15:16:55 +0700 Subject: bug fix window multi update --- indoteknik_custom/models/purchasing_job_multi_update.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models/purchasing_job_multi_update.py') diff --git a/indoteknik_custom/models/purchasing_job_multi_update.py b/indoteknik_custom/models/purchasing_job_multi_update.py index e455c5a4..c880980a 100644 --- a/indoteknik_custom/models/purchasing_job_multi_update.py +++ b/indoteknik_custom/models/purchasing_job_multi_update.py @@ -9,8 +9,8 @@ class PurchasingJobMultiUpdate(models.TransientModel): def save_multi_update_purchasing_job(self): product_ids = self._context['product_ids'] - product = self.env['product.product'].browse(product_ids) - product.action_multi_update_invoice_status() + product = self.env['v.purchasing.job'].browse(product_ids) + product.generate_request_po() return { 'type': 'ir.actions.client', 'tag': 'display_notification', -- cgit v1.2.3 From e2086bc4f96391260fb3430537feddbc25bdde40 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 19 Dec 2023 09:32:09 +0700 Subject: over to nathan --- indoteknik_custom/models/purchasing_job_multi_update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/purchasing_job_multi_update.py') diff --git a/indoteknik_custom/models/purchasing_job_multi_update.py b/indoteknik_custom/models/purchasing_job_multi_update.py index c880980a..a1b79907 100644 --- a/indoteknik_custom/models/purchasing_job_multi_update.py +++ b/indoteknik_custom/models/purchasing_job_multi_update.py @@ -16,7 +16,7 @@ class PurchasingJobMultiUpdate(models.TransientModel): 'tag': 'display_notification', 'params': { 'title': 'Notification', - 'message': 'Invoice Status berhasil diubah', + 'message': 'Berhasil membuat Automatic Purchase', 'next': {'type': 'ir.actions.act_window_close'}, } } \ No newline at end of file -- cgit v1.2.3 From b2377426bec8aa334277aac48b0b25f0dfac420f Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 25 Mar 2024 13:07:44 +0700 Subject: purchasing job feedback --- .../models/purchasing_job_multi_update.py | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'indoteknik_custom/models/purchasing_job_multi_update.py') diff --git a/indoteknik_custom/models/purchasing_job_multi_update.py b/indoteknik_custom/models/purchasing_job_multi_update.py index a1b79907..e7f19e50 100644 --- a/indoteknik_custom/models/purchasing_job_multi_update.py +++ b/indoteknik_custom/models/purchasing_job_multi_update.py @@ -1,5 +1,6 @@ -from odoo import models, fields +from odoo import models, fields, _ import logging +from odoo.exceptions import AccessError, UserError, ValidationError _logger = logging.getLogger(__name__) @@ -9,14 +10,22 @@ class PurchasingJobMultiUpdate(models.TransientModel): def save_multi_update_purchasing_job(self): product_ids = self._context['product_ids'] - product = self.env['v.purchasing.job'].browse(product_ids) - product.generate_request_po() + products = self.env['v.purchasing.job'].browse(product_ids) + for product in products: + if product.status_apo == 'apo': + raise UserError('Ada Purchase Order yang statusnya APO, proses dulu') + + purchasing_job_state = self.env['purchasing.job.state'] + purchasing_job_state.create({ + 'purchasing_job_id': product.id, + 'status_apo': 'apo', + }) + apo = products.generate_request_po() return { - 'type': 'ir.actions.client', - 'tag': 'display_notification', - 'params': { - 'title': 'Notification', - 'message': 'Berhasil membuat Automatic Purchase', - 'next': {'type': 'ir.actions.act_window_close'}, - } + 'name': _('Automatic Purchase'), + 'view_mode': 'tree,form', + 'res_model': 'automatic.purchase', + 'target': 'current', + 'type': 'ir.actions.act_window', + 'domain': [('id', '=', apo)], } \ No newline at end of file -- cgit v1.2.3