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 --- indoteknik_custom/__manifest__.py | 2 + indoteknik_custom/models/__init__.py | 2 + indoteknik_custom/models/purchasing_job.py | 42 +++++++++++ .../models/purchasing_job_multi_update.py | 22 ++++++ indoteknik_custom/security/ir.model.access.csv | 4 +- indoteknik_custom/views/purchasing_job.xml | 83 ++++++++++++++++++++++ .../views/purchasing_job_multi_update.xml | 31 ++++++++ 7 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 indoteknik_custom/models/purchasing_job.py create mode 100644 indoteknik_custom/models/purchasing_job_multi_update.py create mode 100644 indoteknik_custom/views/purchasing_job.xml create mode 100644 indoteknik_custom/views/purchasing_job_multi_update.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 39e5cdd9..d31ac21a 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -104,6 +104,8 @@ 'views/stock_warehouse_orderpoint.xml', 'views/customer_commision.xml', 'views/wati_history.xml', + 'views/purchasing_job.xml', + 'views/purchasing_job_multi_update.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 35f06f03..7a6b4251 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -93,3 +93,5 @@ from . import product_monitoring from . import account_bank_statement from . import stock_warehouse_orderpoint from . import commision +from . import purchasing_job +from . import purchasing_job_multi_update diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py new file mode 100644 index 00000000..c660b937 --- /dev/null +++ b/indoteknik_custom/models/purchasing_job.py @@ -0,0 +1,42 @@ +from odoo import fields, models, api, tools +import logging + +_logger = logging.getLogger(__name__) + + +class PurchasingJob(models.Model): + _name = 'v.purchasing.job' + _auto = False + _rec_name = 'product_id' + + id = fields.Integer() + product_id = fields.Many2one('product.product', string="Product") + brand = fields.Char(string='Brand') + item_code = fields.Char(string='Item Code') + product = fields.Char(string='Product Name') + onhand = fields.Float(string='OnHand') + incoming = fields.Float(string="Incoming") + outgoing = fields.Float(string="Outgoing") + action = fields.Char(string="Status") + + def init(self): + tools.drop_view_if_exists(self.env.cr, self._table) + self.env.cr.execute(""" + CREATE OR REPLACE VIEW %s AS ( + select product_id as id, product_id, brand, item_code, product, onhand, incoming, outgoing, action + from v_procurement_monitoring_by_product + where action = 'kurang beli' + ) + """ % self._table) + + def open_form_multi_generate_request_po(self): + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_generate_request_po') + action['context'] = { + 'product_ids': [x.id for x in self] + } + return action + + def generate_request_po(self): + # print(1) + for product in self: + print(product) 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 diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 56d00b3e..6dfa3ee4 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -83,4 +83,6 @@ access_customer_commision,access.customer.commision,model_customer_commision,,1, access_customer_commision_line,access.customer.commision.line,model_customer_commision_line,,1,1,1,1 access_customer_rebate,access.customer.rebate,model_customer_rebate,,1,1,1,1 access_wati_history,access.wati.history,model_wati_history,,1,1,1,1 -access_wati_history_line,access.wati.history.line,model_wati_history_line,,1,1,1,1 \ No newline at end of file +access_wati_history_line,access.wati.history.line,model_wati_history_line,,1,1,1,1 +access_v_purchasing_job,access.v.purchasing.job,model_v_purchasing_job,,1,1,1,1 +access_purchasing_job_multi_update,access.purchasing.job.multi.update,model_purchasing_job_multi_update,,1,1,1,1 \ No newline at end of file diff --git a/indoteknik_custom/views/purchasing_job.xml b/indoteknik_custom/views/purchasing_job.xml new file mode 100644 index 00000000..0af4455d --- /dev/null +++ b/indoteknik_custom/views/purchasing_job.xml @@ -0,0 +1,83 @@ + + + + v.purchasing.job.tree + v.purchasing.job + + + + + + + + + + + + + + + + v.purchasing.job.form + v.purchasing.job + +
+ + + + + + + + + + + + + + + + +
+
+
+ + + v.purchasing.job.list.select + v.purchasing.job + + + + + + + + + + + + Purchasing Job + ir.actions.act_window + v.purchasing.job + + tree,form + + + + Generate Automatic PO + + + form,list + code + action = records.open_form_multi_generate_request_po() + + + + +
\ No newline at end of file diff --git a/indoteknik_custom/views/purchasing_job_multi_update.xml b/indoteknik_custom/views/purchasing_job_multi_update.xml new file mode 100644 index 00000000..422d9e3c --- /dev/null +++ b/indoteknik_custom/views/purchasing_job_multi_update.xml @@ -0,0 +1,31 @@ + + + + + View Purchasing Job Multi Update + purchasing.job.multi.update + +
+ + + Apakah Anda Yakin Ingin Mengubah Invoice Status? + + +
+
+
+
+
+ + + Action Purchasing Job Multi Update + purchasing.job.multi.update + ir.actions.act_window + form + + new + +
+
\ 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.py | 6 +++--- indoteknik_custom/models/purchasing_job_multi_update.py | 4 ++-- indoteknik_custom/views/purchasing_job.xml | 4 ++-- indoteknik_custom/views/purchasing_job_multi_update.xml | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py index c660b937..18235d47 100644 --- a/indoteknik_custom/models/purchasing_job.py +++ b/indoteknik_custom/models/purchasing_job.py @@ -30,7 +30,7 @@ class PurchasingJob(models.Model): """ % self._table) def open_form_multi_generate_request_po(self): - action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_generate_request_po') + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchasing_job_multi_update') action['context'] = { 'product_ids': [x.id for x in self] } @@ -38,5 +38,5 @@ class PurchasingJob(models.Model): def generate_request_po(self): # print(1) - for product in self: - print(product) + for job in self: + print(job.product_id.name) 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', diff --git a/indoteknik_custom/views/purchasing_job.xml b/indoteknik_custom/views/purchasing_job.xml index 0af4455d..42dfd359 100644 --- a/indoteknik_custom/views/purchasing_job.xml +++ b/indoteknik_custom/views/purchasing_job.xml @@ -65,8 +65,8 @@ Generate Automatic PO - - + + form,list code action = records.open_form_multi_generate_request_po() diff --git a/indoteknik_custom/views/purchasing_job_multi_update.xml b/indoteknik_custom/views/purchasing_job_multi_update.xml index 422d9e3c..79b935c7 100644 --- a/indoteknik_custom/views/purchasing_job_multi_update.xml +++ b/indoteknik_custom/views/purchasing_job_multi_update.xml @@ -8,11 +8,11 @@
- Apakah Anda Yakin Ingin Mengubah Invoice Status? + Apakah Anda Yakin Ingin Create Automatic PO?
-
-- cgit v1.2.3 From 1a68a5e600e2f7f90bee44144557f6af2f35618c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 14 Dec 2023 15:42:41 +0700 Subject: add some field in automatic purchase --- indoteknik_custom/models/automatic_purchase.py | 14 ++++++++++++++ indoteknik_custom/views/automatic_purchase.xml | 18 +++++++++++++++--- indoteknik_custom/views/ir_sequence.xml | 11 +++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 502761e0..63eefb93 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -9,7 +9,10 @@ _logger = logging.getLogger(__name__) class AutomaticPurchase(models.Model): _name = 'automatic.purchase' _order = 'id desc' + _inherit = ['mail.thread'] + _rec_name = 'number' + number = fields.Char(string='Document No', index=True, copy=False, readonly=True) date_doc = fields.Date(string='Date', required=True, help='Isi tanggal hari ini') description = fields.Char(string='Description', help='bebas isi nya apa') purchase_lines = fields.One2many('automatic.purchase.line', 'automatic_purchase_id', string='Lines', auto_join=True) @@ -18,6 +21,16 @@ class AutomaticPurchase(models.Model): purchase_match = fields.One2many('automatic.purchase.match', 'automatic_purchase_id', string='Matches', auto_join=True) vendor_id = fields.Many2one('res.partner', string='Vendor', help='boleh kosong, jika diisi, maka hanya keluar data untuk vendor tersebut') responsible_id = fields.Many2one('res.users', string='Responsible', required=True) + apo_type = fields.Selection([ + ('regular', 'Regular Fulfill SO'), + ('reordering', 'Reordering Rule'), + ], string='Type') + + @api.model + def create(self, vals): + vals['number'] = self.env['ir.sequence'].next_by_code('automatic.purchase') or '0' + result = super(AutomaticPurchase, self).create(vals) + return result def create_po_from_automatic_purchase(self): if not self.purchase_lines: @@ -84,6 +97,7 @@ class AutomaticPurchase(models.Model): self.is_po = True def generate_automatic_purchase(self): + # for reordering rule only if self.purchase_lines: raise UserError('Sudah digenerate sebelumnya, hapus line terlebih dahulu') diff --git a/indoteknik_custom/views/automatic_purchase.xml b/indoteknik_custom/views/automatic_purchase.xml index 0478304e..6f10653f 100644 --- a/indoteknik_custom/views/automatic_purchase.xml +++ b/indoteknik_custom/views/automatic_purchase.xml @@ -5,7 +5,9 @@ automatic.purchase + + @@ -56,13 +58,14 @@
- + + - - + +
+
+
+