From 5d78d113bb8b6dff3ceab0d5c94db950a668394e Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 16 May 2024 15:55:50 +0700 Subject: add new field on promotion program line --- indoteknik_custom/models/promotion/promotion_program_line.py | 2 ++ indoteknik_custom/views/promotion/promotion_program_line.xml | 1 + 2 files changed, 3 insertions(+) diff --git a/indoteknik_custom/models/promotion/promotion_program_line.py b/indoteknik_custom/models/promotion/promotion_program_line.py index 4bf50ac9..4db70644 100644 --- a/indoteknik_custom/models/promotion/promotion_program_line.py +++ b/indoteknik_custom/models/promotion/promotion_program_line.py @@ -31,7 +31,9 @@ class PromotionProgramLine(models.Model): order_promotion_ids = fields.One2many('sale.order.promotion', 'program_line_id', 'Promotions') active = fields.Boolean(string="Active", default=True) + active = fields.Boolean(string="Active", default=True) solr_flag = fields.Integer(string="Solr Flag", default=1) + description = fields.Char('Description') def get_active_promotions(self, product_id): current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') diff --git a/indoteknik_custom/views/promotion/promotion_program_line.xml b/indoteknik_custom/views/promotion/promotion_program_line.xml index 7c8e403d..3f077a13 100644 --- a/indoteknik_custom/views/promotion/promotion_program_line.xml +++ b/indoteknik_custom/views/promotion/promotion_program_line.xml @@ -25,6 +25,7 @@ + -- cgit v1.2.3 From 23240cd6ba13e4737fa06e20a10c9d242e221eca Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 16 May 2024 16:18:18 +0700 Subject: remove duplicate field --- indoteknik_custom/models/promotion/promotion_program_line.py | 1 - 1 file changed, 1 deletion(-) diff --git a/indoteknik_custom/models/promotion/promotion_program_line.py b/indoteknik_custom/models/promotion/promotion_program_line.py index 4db70644..34b70ca5 100644 --- a/indoteknik_custom/models/promotion/promotion_program_line.py +++ b/indoteknik_custom/models/promotion/promotion_program_line.py @@ -31,7 +31,6 @@ class PromotionProgramLine(models.Model): order_promotion_ids = fields.One2many('sale.order.promotion', 'program_line_id', 'Promotions') active = fields.Boolean(string="Active", default=True) - active = fields.Boolean(string="Active", default=True) solr_flag = fields.Integer(string="Solr Flag", default=1) description = fields.Char('Description') -- cgit v1.2.3 From 99faeeac589cee3da9f47dceaab7ebcb5f1c1213 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 16 May 2024 16:53:24 +0700 Subject: add role while edit shipping method stock picking --- indoteknik_custom/models/stock_picking.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 9b4fffb1..c5ff4eb8 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -86,6 +86,11 @@ class StockPicking(models.Model): date_availability = fields.Datetime(string="Date Availability", copy=False, tracking=True) sale_order = fields.Char(string='Matches SO', copy=False) + @api.constrains('carrier_id') + def constrains_carrier_id(self): + if not self.env.user.logistic_approver: + raise UserError('Hanya Logistic yang bisa mengubah shipping method') + def do_unreserve(self): res = super(StockPicking, self).do_unreserve() current_time = datetime.datetime.utcnow() -- cgit v1.2.3 From 585d5a3f434361756ff3e8c778f4bba25db227f1 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 16 May 2024 17:04:55 +0700 Subject: fix error --- indoteknik_custom/models/stock_picking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index c5ff4eb8..6e439c41 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -88,7 +88,7 @@ class StockPicking(models.Model): @api.constrains('carrier_id') def constrains_carrier_id(self): - if not self.env.user.logistic_approver: + if not self.env.user.is_logistic_approver: raise UserError('Hanya Logistic yang bisa mengubah shipping method') def do_unreserve(self): -- cgit v1.2.3 From 45482a112be240b8d8ca66abfef129c427fbcb6d Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 16 May 2024 17:07:29 +0700 Subject: fix error --- indoteknik_custom/models/stock_picking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 6e439c41..22aceaf4 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -86,7 +86,7 @@ class StockPicking(models.Model): date_availability = fields.Datetime(string="Date Availability", copy=False, tracking=True) sale_order = fields.Char(string='Matches SO', copy=False) - @api.constrains('carrier_id') + @api.onchange('carrier_id') def constrains_carrier_id(self): if not self.env.user.is_logistic_approver: raise UserError('Hanya Logistic yang bisa mengubah shipping method') -- cgit v1.2.3 From 39c13cc7ebe48344e3088bc5bb921458ba4f7972 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 17 May 2024 09:47:30 +0700 Subject: change request api --- indoteknik_api/controllers/api_v1/sale_order.py | 7 +++++++ indoteknik_custom/models/purchasing_job_multi_update.py | 13 +++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index 957d49c7..948ecd03 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -52,6 +52,7 @@ class SaleOrder(controller.Controller): params = self.get_request_params(kw, { 'partner_id': ['number'], 'name': [], + 'site': [], 'limit': ['default:0', 'number'], 'offset': ['default:0', 'number'], 'context': [] @@ -80,6 +81,12 @@ class SaleOrder(controller.Controller): ('partner_purchase_order_name', 'ilike', '%' + name + '%') ] + if params['value']['site']: + site = params['value']['site'].replace(' ', '%') + domain += [ + ('partner_id.site_id.name', 'ilike', '%' + site + '%') + ] + sale_orders = request.env['sale.order'].search( domain, offset=offset, limit=limit) data = { diff --git a/indoteknik_custom/models/purchasing_job_multi_update.py b/indoteknik_custom/models/purchasing_job_multi_update.py index 65feba71..0145b112 100644 --- a/indoteknik_custom/models/purchasing_job_multi_update.py +++ b/indoteknik_custom/models/purchasing_job_multi_update.py @@ -14,12 +14,17 @@ class PurchasingJobMultiUpdate(models.TransientModel): 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_state = self.env['purchasing.job.state'].search([ + ('purchasing_job_id', '=', product.id), + ('status_apo', '=', 'apo') + ]) + + if not purchasing_job_state: + purchasing_job_state.create({ 'purchasing_job_id': product.id, 'status_apo': 'apo', - }) - + }) + apo = self.env['automatic.purchase'].generate_regular_purchase(products) return { 'name': _('Automatic Purchase'), -- cgit v1.2.3