From 7d22bf1355720a8f571476738e0f06f580b2546c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 20 Jun 2025 16:19:34 +0700 Subject: source and pricelist item --- fixco_custom/models/detail_order.py | 10 +++++++--- fixco_custom/models/webhook_ginee.py | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fixco_custom/models/detail_order.py b/fixco_custom/models/detail_order.py index e2cb5cb..c9ace50 100755 --- a/fixco_custom/models/detail_order.py +++ b/fixco_custom/models/detail_order.py @@ -30,6 +30,10 @@ class DetailOrder(models.Model): ('already_so', 'SO Already Created'), ('processing_get_so', 'Processing Get SO'), ], 'Execute Status') + source = fields.Selection([ + ('webhook', 'From Webhook'), + ('manual', 'Manual'), + ], 'source') sale_id = fields.Many2one('sale.order', 'Sale Order') picking_id = fields.Many2one('stock.picking', 'Picking') invoice_id = fields.Many2one('account.move', 'Invoice') @@ -179,11 +183,11 @@ class DetailOrder(models.Model): bundling_lines = self.env['bundling.line'].search([('product_id', '=', product.id)]) bundling_variant_ids = bundling_lines.mapped('variant_id').ids - sale_pricelist = self.env['sale.pricelist'].search([('product_id', 'in', bundling_variant_ids)]) + sale_pricelist = self.env['product.pricelist.item'].search([('product_id', 'in', bundling_variant_ids), ('pricelist_id', '=', 17)]) price_bundling_bottom = sum(item.price for item in sale_pricelist) for bline in bundling_lines: - bottom_price = self.env['sale.pricelist'].search([('product_id', '=', bline.variant_id.id)], limit=1) - price = bottom_price.price + bottom_price = self.env['product.pricelist.item'].search([('product_id', '=', bline.variant_id.id), ('pricelist_id', '=', 17)], limit=1) + price = bottom_price.fixed_price price_unit = self.prorate_price_bundling(bline.variant_id,price_bundling_bottom,price,actual_price=item.get('actualPrice')) order_lines.append((0, 0, { 'product_id': bline.variant_id.id if bline.variant_id else product.id, diff --git a/fixco_custom/models/webhook_ginee.py b/fixco_custom/models/webhook_ginee.py index e1fb608..606bd21 100755 --- a/fixco_custom/models/webhook_ginee.py +++ b/fixco_custom/models/webhook_ginee.py @@ -37,5 +37,8 @@ class WebhookGinee(models.Model): rec.execute_queue() def execute_queue(self): - detail_order = self.env['detail.order'].create({'json_ginee': self.json_ginee}) + detail_order = self.env['detail.order'].create({ + 'json_ginee': self.json_ginee, + 'source': 'webhook' + }) self.execute_status = 'success' -- cgit v1.2.3