From 81d6d5550737af445900199afd6edf5824bd03e2 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 21 Oct 2024 16:33:48 +0700 Subject: cr active product product --- indoteknik_custom/models/product_template.py | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index af7f98cd..2ca4925b 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -405,6 +405,7 @@ class ProductProduct(models.Model): continue if any(variant.active for variant in variants): product_template.unpublished = False + variants.unpublished = False def update_internal_reference_variants(self, limit=100): variants = self.env['product.product'].search([ -- cgit v1.2.3 From c99e4d67c037a781b79e0ed198899d5f5c4a153b Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 22 Oct 2024 10:53:16 +0700 Subject: cr vendor approval --- indoteknik_custom/models/sale_order.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 891482cb..1ad08154 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -873,17 +873,16 @@ class SaleOrder(models.Model): }).send() def validate_different_vendor(self): - if self.vendor_approval_id and self.vendor_approval: - return False - - different_vendor = self.order_line.filtered(lambda l: l.vendor_id and l.vendor_md_id and l.vendor_id.id != l.vendor_md_id.id) - if self.vendor_approval_id and self.vendor_approval_id.state == 'draft': raise UserError('SO ini sedang dalam review Vendor Approval') if self.vendor_approval_id and self.vendor_approval_id.state == 'cancel': raise UserError('Vendor Approval SO ini Di Reject') + if self.vendor_approval_id and self.vendor_approval_id.state == 'done': + return False + + different_vendor = self.order_line.filtered(lambda l: l.vendor_id and l.vendor_md_id and l.vendor_id.id != l.vendor_md_id.id) if different_vendor: vendor_approval = self.env['vendor.approval'].create({ 'order_id': self.id, -- cgit v1.2.3 From adb901e780bd0f1e9abfefc9f403e335c155115c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 22 Oct 2024 12:01:55 +0700 Subject: ubah state id dari null menjadi 0 --- indoteknik_api/models/res_users.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_api/models/res_users.py b/indoteknik_api/models/res_users.py index 534898e1..2751ca7a 100644 --- a/indoteknik_api/models/res_users.py +++ b/indoteknik_api/models/res_users.py @@ -48,7 +48,7 @@ class ResUsers(models.Model): 'street': user.street or '', 'street2': user.street2 or '', 'city': None, - 'state_id': None, + 'state_id': 0, 'district': None, 'sub_district': None, 'zip': user.zip or '', -- cgit v1.2.3 From ecc3621e449af1393836cf67ca34d91ed32eea5c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 22 Oct 2024 15:26:24 +0700 Subject: cr status reserve --- indoteknik_custom/models/stock_picking.py | 82 ++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 8 deletions(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index a5482f9d..2a73d631 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -3,7 +3,7 @@ from odoo.exceptions import AccessError, UserError, ValidationError from odoo.tools.float_utils import float_is_zero from datetime import datetime from itertools import groupby -import pytz, datetime +import pytz, datetime, requests, json class StockPicking(models.Model): @@ -107,6 +107,51 @@ class StockPicking(models.Model): ('done', 'Done'), ('cancel', 'Cancelled'), ], string='Status Reserve', readonly=True, tracking=True, help="The current state of the stock picking.") + + def action_send_to_biteship(self): + url = "https://api.biteship.com/v1/orders" + + api_key = "biteship_test.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiSW5kb3Rla25payIsInVzZXJJZCI6IjY3MTViYTJkYzVkMjdkMDAxMjRjODk2MiIsImlhdCI6MTcyOTQ5ODAwMX0.L6C73couP4-cgVEfhKI2g7eMCMo3YOFSRZhS-KSuHNA" + + items_data = [] + for item in self.items: + items_data.append({ + "name": item.name, + "description": item.description, + "category": item.category, + "value": item.value, + "quantity": item.quantity, + "weight": item.weight + }) + + payload = { + "shipper_contact_name": self.carrier_id.pic_name or '', + "shipper_contact_phone": self.carrier_id.pic_phone or '', + # "shipper_contact_email": "sales@indoteknik.co.id", + "shipper_organization": self.carrier_id.name, + "origin_contact_name": "PT. Indoteknik Dotcom Gemilang", + "origin_contact_phone": "081717181922", + "origin_address": "Jl. Bandengan Utara Komp A & BRT. Penjaringan, Kec. Penjaringan, Jakarta (BELAKANG INDOMARET) KOTA JAKARTA UTARA PENJARINGAN", + "origin_postal_code": "14440", + "destination_contact_name": self.real_shipping_id.name, + "destination_contact_phone": self.real_shipping_id.phone or self.real_shipping_id.mobile, + "destination_contact_email": self.real_shipping_id.email or '', + "destination_address": self.real_shipping_id.street, + "destination_postal_code": self.real_shipping_id.zip, + "items": items_data + } + + headers = { + "Authorization": f"Bearer {api_key}", + "Content-Type": "application/json" + } + + response = requests.post(url, headers=headers, data=json.dumps(payload)) + + if response.status_code == 201: + return response.json() + else: + raise UserError(f"Error saat mengirim ke Biteship: {response.content}") @api.constrains('driver_departure_date') def constrains_driver_departure_date(self): @@ -145,18 +190,39 @@ class StockPicking(models.Model): return res + # def check_state_reserve(self): + # do = self.search([ + # ('state', 'not in', ['cancel', 'draft', 'done']), + # ('picking_type_code', '=', 'outgoing') + # ]) + + # for rec in do: + # rec.state_reserve = 'ready' + # rec.date_reserved = datetime.datetime.utcnow() + + # for line in rec.move_ids_without_package: + # if line.product_uom_qty > line.reserved_availability: + # rec.state_reserve = 'waiting' + # rec.date_reserved = '' + # break + def check_state_reserve(self): - do = self.search([ + picking = self.search([ ('state', 'not in', ['cancel', 'draft', 'done']), ('picking_type_code', '=', 'outgoing') ]) + + for data in picking: + fullfilment = self.env['sales.order.fullfillment'].search([ + ('sales_order_id', '=', data.sale_id.id) + ]) - for rec in do: - rec.state_reserve = 'ready' - - for line in rec.move_ids_without_package: - if line.product_uom_qty > line.reserved_availability: - rec.state_reserve = 'waiting' + data.state_reserve = 'ready' + data.date_reserved = datetime.datetime.utcnow() + for rec in fullfilment: + if rec.reserved_from not in ['Inventory On Hand', 'Reserved from stock', 'Free Stock']: + data.state_reserve = 'waiting' + data.date_reserved = '' break def _create_approval_notification(self, approval_role): -- cgit v1.2.3 From d588e3c431f428e09f1efc1736a2ad947ca5b61e Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 22 Oct 2024 16:53:04 +0700 Subject: cr due extension and dunning run --- indoteknik_custom/views/account_move_views.xml | 1 + indoteknik_custom/views/dunning_run.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/indoteknik_custom/views/account_move_views.xml b/indoteknik_custom/views/account_move_views.xml index 4acafb14..f4faf386 100644 --- a/indoteknik_custom/views/account_move_views.xml +++ b/indoteknik_custom/views/account_move_views.xml @@ -12,6 +12,7 @@ + diff --git a/indoteknik_custom/views/dunning_run.xml b/indoteknik_custom/views/dunning_run.xml index 522be8c9..2117a7bb 100644 --- a/indoteknik_custom/views/dunning_run.xml +++ b/indoteknik_custom/views/dunning_run.xml @@ -14,6 +14,7 @@ + -- cgit v1.2.3 From bd02dbfcfef14c016eec14811f9f257790e6e321 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 22 Oct 2024 16:57:56 +0700 Subject: create_date on due extension --- indoteknik_custom/views/account_move_views.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_custom/views/account_move_views.xml b/indoteknik_custom/views/account_move_views.xml index f4faf386..f7b753bd 100644 --- a/indoteknik_custom/views/account_move_views.xml +++ b/indoteknik_custom/views/account_move_views.xml @@ -13,6 +13,7 @@ + -- cgit v1.2.3 From 25645d93db289ea4855486630dba8d578efb2851 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 23 Oct 2024 09:13:53 +0700 Subject: cr due extension --- indoteknik_custom/models/account_move_due_extension.py | 7 +++++-- indoteknik_custom/views/account_move_views.xml | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/account_move_due_extension.py b/indoteknik_custom/models/account_move_due_extension.py index 23f8888c..6fc58cdd 100644 --- a/indoteknik_custom/models/account_move_due_extension.py +++ b/indoteknik_custom/models/account_move_due_extension.py @@ -1,6 +1,6 @@ from odoo import models, api, fields from odoo.exceptions import AccessError, UserError, ValidationError -from datetime import timedelta, date +from datetime import timedelta, date, datetime import logging _logger = logging.getLogger(__name__) @@ -31,7 +31,8 @@ class DueExtension(models.Model): ('21', '21 Hari'), ], string='Day Extension', help='Menambah Due Date yang sudah limit dari hari ini', tracking=True) counter = fields.Integer(string="Counter", compute='_compute_counter') - + approve_by = fields.Many2one('res.users', string="Approve By", readonly=True) + date_approve = fields.Datetime(string="Date Approve", readonly=True) def _compute_counter(self): for due in self: due.counter = due.partner_id.counter @@ -96,6 +97,8 @@ class DueExtension(models.Model): sales.action_confirm() self.order_id.due_id = self.id + self.approve_by = self.env.user.id + self.date_approve = datetime.utcnow() template = self.env.ref('indoteknik_custom.mail_template_due_extension_approve') template.send_mail(self.id, force_send=True) diff --git a/indoteknik_custom/views/account_move_views.xml b/indoteknik_custom/views/account_move_views.xml index f7b753bd..da25636e 100644 --- a/indoteknik_custom/views/account_move_views.xml +++ b/indoteknik_custom/views/account_move_views.xml @@ -12,6 +12,8 @@ + + @@ -60,12 +62,14 @@ + - + + -- cgit v1.2.3