From 84cbe80ad4f6f2bcb99386d92be7cc210d481dea Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 24 Oct 2022 14:08:18 +0700 Subject: add real shipping address in sale order and stock picking --- indoteknik_custom/models/sale_order.py | 9 +++++++++ indoteknik_custom/models/stock_picking.py | 9 +++++++++ indoteknik_custom/views/sale_order.xml | 1 + indoteknik_custom/views/stock_picking.xml | 3 +++ 4 files changed, 22 insertions(+) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 48794f92..2151264c 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -36,6 +36,15 @@ class SaleOrder(models.Model): have_outstanding_picking = fields.Boolean('Have Outstanding Picking', compute='_have_outstanding_picking') have_outstanding_po = fields.Boolean('Have Outstanding PO', compute='_have_outstanding_po') purchase_ids = fields.Many2many('purchase.order', string='Purchases', compute='_get_purchases') + real_shipping_id = fields.Many2one( + 'res.partner', string='Real Delivery Address', readonly=True, required=True, + states={'draft': [('readonly', False)], 'sent': [('readonly', False)], 'sale': [('readonly', False)]}, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", + help="Dipakai untuk alamat tempel") + + @api.onchange('partner_shipping_id') + def onchange_partner_shipping(self): + self.real_shipping_id = self.partner_shipping_id def _get_purchases(self): po_state = ['done', 'draft', 'purchase'] diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 70e9b68a..c1a3f12d 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -14,6 +14,10 @@ class StockPicking(models.Model): summary_qty_operation = fields.Float('Total Qty Operation', compute='_compute_summary_qty') count_line_detail = fields.Float('Total Item Detail', compute='_compute_summary_qty') count_line_operation = fields.Float('Total Item Operation', compute='_compute_summary_qty') + real_shipping_id = fields.Many2one( + 'res.partner', string='Real Delivery Address', required=True, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", + help="Dipakai untuk alamat tempel") # Delivery Order driver_departure_date = fields.Datetime( @@ -48,6 +52,11 @@ class StockPicking(models.Model): ('approved', 'Approved'), ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3) + def action_assign(self): + res = super(StockPicking, self).action_assign() + self.real_shipping_id = self.sale_id.real_shipping_id + return res + def ask_approval(self): if self.env.user.is_accounting: raise UserError("Bisa langsung Validate") diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index e5280ec6..138470b6 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -18,6 +18,7 @@ + diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 1b648d58..3b150f34 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -30,6 +30,9 @@ + + + -- cgit v1.2.3 From 646f9557c101bd6b8ed81fc46130e9761957b5c1 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 24 Oct 2022 14:51:37 +0700 Subject: add commision in sale order --- indoteknik_custom/models/purchase_order.py | 2 ++ indoteknik_custom/models/purchase_order_line.py | 2 ++ indoteknik_custom/models/sale_order.py | 13 ++++++++++++- indoteknik_custom/views/sale_order.xml | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 6023afdd..a816038e 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -184,6 +184,8 @@ class PurchaseOrder(models.Model): sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': sales_price -= sale_order_line.delivery_amt_line + if sale_order_line.order_id.fee_third_party > 0: + sales_price -= sale_order_line.fee_third_party_line sum_sales_price += sales_price purchase_price = line.price_subtotal if line.order_id.delivery_amount > 0: diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 85818394..60e4c8b0 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -62,6 +62,8 @@ class PurchaseOrderLine(models.Model): sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': sales_price -= sale_order_line.delivery_amt_line + if sale_order_line.order_id.fee_third_party > 0: + sales_price -= sale_order_line.fee_third_party_line sum_sales_price += sales_price purchase_price = line.price_subtotal if line.order_id.delivery_amount > 0: diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 2151264c..f21a80fe 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -41,6 +41,7 @@ class SaleOrder(models.Model): states={'draft': [('readonly', False)], 'sent': [('readonly', False)], 'sale': [('readonly', False)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Dipakai untuk alamat tempel") + fee_third_party = fields.Float('Fee Pihak Ketiga') @api.onchange('partner_shipping_id') def onchange_partner_shipping(self): @@ -201,6 +202,8 @@ class SaleOrder(models.Model): sales_price = line.price_reduce_taxexcl * line.product_uom_qty if line.order_id.shipping_cost_covered == 'indoteknik': sales_price -= line.delivery_amt_line + if line.order_id.fee_third_party > 0: + sales_price -= line.fee_third_party_line sum_sales_price += sales_price order.total_margin = total_margin if order.amount_untaxed > 0: @@ -241,6 +244,7 @@ class SaleOrderLine(models.Model): purchase_tax_id = fields.Many2one('account.tax', string='Tax', domain=['|', ('active', '=', False), ('active', '=', True)]) delivery_amt_line = fields.Float('DeliveryAmtLine', compute='compute_delivery_amt_line') + fee_third_party_line = fields.Float('FeeThirdPartyLine', compute='compute_fee_third_party_line', default=0) def compute_item_margin(self): for line in self: @@ -255,7 +259,8 @@ class SaleOrderLine(models.Model): # minus with delivery if covered by indoteknik if line.order_id.shipping_cost_covered == 'indoteknik': sales_price -= line.delivery_amt_line - # sales_price -= round((line.order_id.delivery_amt / line.order_id.count_line_product), 2) + if line.order_id.fee_third_party > 0: + sales_price -= line.fee_third_party_line purchase_price = line.purchase_price if line.purchase_tax_id.price_include: @@ -292,6 +297,12 @@ class SaleOrderLine(models.Model): delivery_amt = line.order_id.delivery_amt line.delivery_amt_line = delivery_amt * contribution + def compute_fee_third_party_line(self): + for line in self: + contribution = round((line.price_total / line.order_id.amount_total), 2) + fee = line.order_id.fee_third_party + line.fee_third_party_line = fee * contribution + @api.onchange('product_id', 'price_unit', 'product_uom', 'product_uom_qty', 'tax_id') def _onchange_discount(self): if not (self.product_id and self.product_uom and diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 138470b6..d7c811f7 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -16,6 +16,7 @@ + -- cgit v1.2.3