summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-09-28 10:59:19 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-09-28 10:59:19 +0700
commitd023b4f2564c7d2fbe3d61a2348250569f182dc4 (patch)
tree3514a547a1015a16da95839e5989b9f1ecc4fdc3
parent3a8710d164ced77e532b0b96988d84bb08515602 (diff)
Update sale_order.py and sale_order.xml
-rwxr-xr-xindoteknik_custom/models/sale_order.py36
-rwxr-xr-xindoteknik_custom/views/sale_order.xml2
2 files changed, 23 insertions, 15 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 70e2d63e..1cd358ab 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -21,15 +21,17 @@ 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_amt = fields.Float('Delivery Amt')
- shipping_cost_covered = fields.Boolean('Shipping Cost Covered', help='Centang jika Shipping Cost ditanggung oleh '
- 'Indoteknik (Finance), jika dicentang akan '
- 'mempengaruhi margin')
+ shipping_cost_covered = fields.Selection([
+ ('indoteknik', 'Indoteknik'),
+ ('customer', 'Customer')
+ ], string='Shipping Paid by', help='Siapa yang menanggung biaya ekspedisi?', copy=False)
shipping_paid_by = fields.Selection([
('indoteknik', 'Indoteknik'),
('customer', 'Customer')
- ], string='Shipping Paid by', help='Siapa yang talangin Biaya kirim?',copy=False)
+ ], string='Shipping Paid by', help='Siapa yang talangin dulu Biaya ekspedisi-nya?', copy=False)
+ sales_tax_id = fields.Many2one('account.tax', string='Tax',
+ domain=['|', ('active', '=', False), ('active', '=', True)])
def _compute_have_visit_service(self):
limit = 20000000
@@ -116,14 +118,11 @@ 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
- # order.delivery_amt = amount
+ @api.onchange('sales_tax_id')
+ def onchange_sales_tax_id(self):
+ for line in self.order_line:
+ # line.tax_id = self.sales_tax_id
+ line.product_id_change()
class SaleOrderLine(models.Model):
@@ -154,7 +153,7 @@ class SaleOrderLine(models.Model):
# calculate margin without tax
sales_price = line.price_reduce_taxexcl * line.product_uom_qty
# minus with delivery if covered by indoteknik
- if line.order_id.shipping_cost_covered:
+ if line.order_id.shipping_cost_covered == 'indoteknik':
sales_price -= round((line.order_id.delivery_amt / line.order_id.count_line_product), 2)
purchase_price = line.purchase_price
@@ -174,3 +173,12 @@ class SaleOrderLine(models.Model):
purchase_price = self.env['purchase.pricelist'].search(
[('vendor_id', '=', self.vendor_id.id), ('product_id', '=', self.product_id.id)], limit=1)
self.purchase_price = purchase_price.product_price
+ self.purchase_tax_id = 22
+
+ @api.onchange('product_id')
+ def product_id_change(self):
+ for line in self:
+ super(SaleOrderLine, self).product_id_change()
+ if line.product_id:
+ line.tax_id = line.order_id.sales_tax_id
+
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index 2260ddc1..17902aca 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -16,6 +16,7 @@
<field name="shipping_cost_covered"/>
<field name="shipping_paid_by"/>
<field name="delivery_amt"/>
+ <field name="sales_tax_id" domain="[('type_tax_use','=','sale')]"/>
</field>
<field name="partner_shipping_id" position="after">
<field name="approval_status" />
@@ -24,7 +25,6 @@
<field name="vendor_id" attrs="{'readonly': [('parent.state', 'not in', ['draft', 'sent', 'sale'])]}"/>
<field name="purchase_price" attrs="{'readonly': [('parent.state', 'not in', ['draft', 'sent', 'sale'])]}"/>
<field name="purchase_tax_id" attrs="{'readonly': [('parent.state', 'not in', ['draft', 'sent', 'sale'])]}"/>
- <field name="item_margin" groups="sales_team.group_sale_manager"/>
<field name="item_percent_margin" groups="sales_team.group_sale_manager"/>
</xpath>
<field name="amount_total" position="after">