diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-09-27 14:42:59 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-09-27 14:42:59 +0700 |
| commit | 3a8710d164ced77e532b0b96988d84bb08515602 (patch) | |
| tree | 976ebb25089d80d938ca5bc9132aacb669e041cf /indoteknik_custom/models/sale_order.py | |
| parent | 90ee21e0c1b2179b53d1dbadd6232bf22a3eea5a (diff) | |
Update purchase_order.py, sale_order.py, and sale_order.xml
Diffstat (limited to 'indoteknik_custom/models/sale_order.py')
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 73047171..70e2d63e 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -21,10 +21,15 @@ class SaleOrder(models.Model): have_visit_service = fields.Boolean(string='Have Visit Service', help='To compute is customer get visit service', compute='_compute_have_visit_service') count_line_product = fields.Float('Count Line Product', compute='compute_count_line_product') - delivery_amount = fields.Float('Delivery Amount', compute='compute_delivery_amount') + # delivery_amount = fields.Float('Delivery Amount', compute='compute_delivery_amount') + delivery_amt = fields.Float('Delivery Amt') shipping_cost_covered = fields.Boolean('Shipping Cost Covered', help='Centang jika Shipping Cost ditanggung oleh ' - 'Indoteknik, jika dicentang akan ' + 'Indoteknik (Finance), jika dicentang akan ' 'mempengaruhi margin') + shipping_paid_by = fields.Selection([ + ('indoteknik', 'Indoteknik'), + ('customer', 'Customer') + ], string='Shipping Paid by', help='Siapa yang talangin Biaya kirim?',copy=False) def _compute_have_visit_service(self): limit = 20000000 @@ -39,10 +44,12 @@ class SaleOrder(models.Model): raise UserError("Status harus draft atau sent") approval1 = approval2 = 0 for line in order.order_line: - if line.product_id.id == 232383: - raise UserError(_('Tidak bisa Confirm menggunakan Produk Sementara')) if not line.product_id or line.product_id.type == 'service': continue + if line.product_id.id == 232383: + raise UserError(_('Tidak bisa Confirm menggunakan Produk Sementara')) + if not line.vendor_id or not line.purchase_price or not line.purchase_tax_id: + raise UserError(_('Isi Vendor, Harga Beli, dan Tax sebelum Request Approval')) if (line.item_percent_margin <= 15) and ( self.env.user.id != 6 and self.env.user.id != 7): # akbar or tyas approval2 += 1 @@ -109,13 +116,14 @@ class SaleOrder(models.Model): else: order.count_line_product = count - def compute_delivery_amount(self): - for order in self: - amount = 0 - for line in order.order_line: - if line.product_id.type == 'service': - amount += line.price_total - order.delivery_amount = amount + # def compute_delivery_amount(self): + # for order in self: + # amount = 0 + # for line in order.order_line: + # if line.product_id.type == 'service': + # amount += line.price_total + # order.delivery_amount = amount + # order.delivery_amt = amount class SaleOrderLine(models.Model): @@ -147,7 +155,7 @@ class SaleOrderLine(models.Model): sales_price = line.price_reduce_taxexcl * line.product_uom_qty # minus with delivery if covered by indoteknik if line.order_id.shipping_cost_covered: - sales_price -= round((line.order_id.delivery_amount / line.order_id.count_line_product), 2) + sales_price -= round((line.order_id.delivery_amt / line.order_id.count_line_product), 2) purchase_price = line.purchase_price if line.purchase_tax_id.price_include: |
