diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2024-08-02 15:32:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2024-08-02 15:32:50 +0700 |
| commit | 7229d06c4d4557fd1e92e3afbda789620f5a2d0c (patch) | |
| tree | 3648a0b699e4fb152f532754ac5f38a9cd270ccc | |
| parent | 56bb6d2f83a2c8dec98160bed397a26007df7450 (diff) | |
fix for test case
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 41 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 4 |
2 files changed, 30 insertions, 15 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 2a930a73..a4c3d079 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -844,18 +844,8 @@ class SaleOrder(models.Model): ('order_id.state', 'in', state), ('id', '!=', order_line.id) ], limit=1, order='create_date desc') - # if rec_vendor_id == self.vendor_id and rec_purchase_price == last_so.purchase_price: - # selling_price = last_so.price_unit - # tax_id = last_so.tax_id - if rec_vendor_id == order_line.vendor_id.id and rec_purchase_price != last_so.purchase_price: - rec_taxes = self.env['account.tax'].search([('id', '=', rec_taxes_id)], limit=1) - if rec_taxes.price_include: - selling_price = (rec_purchase_price / 1.11) / (1 - (last_so.item_percent_margin / 100)) - else: - selling_price = rec_purchase_price / (1 - (last_so.item_percent_margin / 100)) - tax_id = last_so.tax_id - discount = 0 - elif rec_vendor_id != last_so.vendor_id.id: + + if rec_vendor_id != last_so.vendor_id.id: last_so = self.env['sale.order.line'].search([ ('order_id.partner_id.id', '=', order_line.order_id.partner_id.id), ('product_id.id', '=', order_line.product_id.id), @@ -863,9 +853,31 @@ class SaleOrder(models.Model): ('vendor_id', '=', rec_vendor_id), ('id', '!=', order_line.id) ], limit=1, order='create_date desc') - selling_price = last_so.price_unit + if rec_purchase_price != last_so.purchase_price: + rec_taxes = self.env['account.tax'].search([('id', '=', rec_taxes_id)], limit=1) + if rec_taxes.price_include: + selling_price = (rec_purchase_price / 1.11) / (1 - (last_so.item_percent_margin / 100)) + else: + selling_price = rec_purchase_price / (1 - (last_so.item_percent_margin / 100)) + tax_id = last_so.tax_id + for tax in tax_id: + if tax.price_include: + selling_price = selling_price + (selling_price*11/100) + else: + selling_price = selling_price + discount = 0 + else: + selling_price = last_so.price_unit + tax_id = last_so.tax_id + discount = last_so.discount + elif rec_vendor_id == order_line.vendor_id.id and rec_purchase_price != last_so.purchase_price: + rec_taxes = self.env['account.tax'].search([('id', '=', rec_taxes_id)], limit=1) + if rec_taxes.price_include: + selling_price = (rec_purchase_price / 1.11) / (1 - (last_so.item_percent_margin / 100)) + else: + selling_price = rec_purchase_price / (1 - (last_so.item_percent_margin / 100)) tax_id = last_so.tax_id - discount = last_so.discount + discount = 0 else: selling_price = last_so.price_unit tax_id = last_so.tax_id @@ -873,4 +885,3 @@ class SaleOrder(models.Model): order_line.price_unit = selling_price order_line.tax_id = tax_id order_line.discount = discount - print(1) diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 04f21d83..c13026ed 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -66,6 +66,10 @@ string="Override Create Invoice" type="object" /> + <button name="calculate_selling_price" + string="Calculate Selling Price" + type="object" + /> </field> <field name="partner_shipping_id" position="after"> <field name="real_shipping_id"/> |
