From 469ffc15ee2b614b729ad95ca1af3e499906f814 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Fri, 6 Mar 2026 16:12:07 +0700 Subject: cr shopify --- fixco_custom/models/detail_order.py | 26 ++++++++++++++++++++++++++ fixco_custom/models/sale.py | 33 +++++++++++++++++++++++++++++++++ fixco_custom/views/sale_order.xml | 28 ++++++++++++---------------- 3 files changed, 71 insertions(+), 16 deletions(-) diff --git a/fixco_custom/models/detail_order.py b/fixco_custom/models/detail_order.py index 6cf291c..a01e7a1 100755 --- a/fixco_custom/models/detail_order.py +++ b/fixco_custom/models/detail_order.py @@ -206,8 +206,20 @@ class DetailOrder(models.Model): return partner.id def prepare_data_so(self, json_data): + order = json_data.get('data', [{}])[0] date_str = json_data.get('data', [{}])[0].get('promisedToShipBefore') deadline_date = False + partner = self.get_partner(json_data.get('data', {})[0].get('shopId')) + if partner == 281: + payment_info = order.get('paymentInfo', {}) + total_discounts = payment_info.get('totalDiscounts', 0) or 0 + discount_shipping = payment_info.get('totalDiscountShipping', 0) or 0 + total_tax = payment_info.get('totalTaxation', 0) or 0 + total_shipping_fee = payment_info.get('totalShippingFee', 0) or 0 + if discount_shipping > 0: + total_discounts += discount_shipping + + total_discounts = -total_discounts if date_str: # utc_dt = datetime.strptime( @@ -231,7 +243,13 @@ class DetailOrder(models.Model): 'source': 'ginee', 'channel': json_data.get('data', {})[0].get('channel'), 'deadline_date': deadline_date, + } + if partner == 281: + data['marketplace_discount'] = total_discounts + data['marketplace_tax'] = total_tax + data['delivery_amount'] = total_shipping_fee + return data def _combine_order_items(self, items, lazada_id): @@ -285,6 +303,10 @@ class DetailOrder(models.Model): limit=1 ) + if product.id == 6031: + product.id = 5792 + product_not_found = True + if product and item.get('masterSkuType') == 'BUNDLE': order_lines.append((0, 0, { 'display_type': 'line_note', @@ -332,12 +354,16 @@ class DetailOrder(models.Model): })) continue + partner = self.get_partner(json_data.get('data', {})[0].get('shopId')) + # Regular product line line_data = { 'product_id': product.id if product else 5792, 'product_uom_qty': combined_item['quantity'], 'price_unit': combined_item['actualPrice'], } + if partner == 281: + line_data['tax_id'] = [(5, 0, 0)] if not product: line_data['name'] = f"{sku} ({combined_item['productName']})" diff --git a/fixco_custom/models/sale.py b/fixco_custom/models/sale.py index 90cc581..ab03acd 100755 --- a/fixco_custom/models/sale.py +++ b/fixco_custom/models/sale.py @@ -1,5 +1,8 @@ from odoo import api, fields, models, _ from odoo.exceptions import UserError +import logging + +_logger = logging.getLogger(__name__) class SaleOrder(models.Model): @@ -28,6 +31,31 @@ class SaleOrder(models.Model): ) uangmuka_exist = fields.Boolean(string='Uang Muka Exist', copy=False) + delivery_amount = fields.Monetary("Delivery Amount", currency_field='currency_id') + + marketplace_discount = fields.Monetary( + string="Marketplace Discount", + currency_field='currency_id' + ) + + marketplace_tax = fields.Monetary( + string="Marketplace Tax", + currency_field='currency_id' + ) + + @api.depends('order_line.price_total', 'delivery_amount') + def _amount_all(self): + super()._amount_all() + + for order in self: + if order.partner_id.id == 281: + subtotal = sum(line.price_subtotal for line in order.order_line) + tax = order.marketplace_tax + delivery = order.delivery_amount or 0 + discount = order.marketplace_discount or 0 + + order.amount_total = subtotal + tax + delivery + discount + @api.depends( 'order_line.price_unit', 'order_line.product_uom_qty', @@ -35,6 +63,11 @@ class SaleOrder(models.Model): ) def _compute_total_discount(self): for order in self: + if order.partner_id.id == 281: + # Biar gk error + order.total_discount = order.total_discount + continue + total = 0.0 for line in order.order_line: if line.discount: diff --git a/fixco_custom/views/sale_order.xml b/fixco_custom/views/sale_order.xml index 2d2a923..11ec935 100755 --- a/fixco_custom/views/sale_order.xml +++ b/fixco_custom/views/sale_order.xml @@ -7,25 +7,15 @@ - - @@ -33,8 +23,14 @@ + + + + - + + + @@ -50,7 +46,7 @@ - + Sale Order @@ -68,7 +64,7 @@ - + Quotations -- cgit v1.2.3