From f6bb7e8c0236c4a3b3c89101d13ca593d7170283 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 29 May 2024 14:56:48 +0700 Subject: add api get sale order --- fixco_api/models/__init__.py | 1 + fixco_api/models/sale.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 fixco_api/models/__init__.py create mode 100644 fixco_api/models/sale.py (limited to 'fixco_api/models') diff --git a/fixco_api/models/__init__.py b/fixco_api/models/__init__.py new file mode 100644 index 0000000..8a0dc04 --- /dev/null +++ b/fixco_api/models/__init__.py @@ -0,0 +1 @@ +from . import sale diff --git a/fixco_api/models/sale.py b/fixco_api/models/sale.py new file mode 100644 index 0000000..4c81fad --- /dev/null +++ b/fixco_api/models/sale.py @@ -0,0 +1,25 @@ +from odoo import models + + +class SaleOrder(models.Model): + _inherit = 'sale.order.line' + + def api_single_response(self, line): + tax = 0 + for taxes in line.tax_id: + tax = taxes.name + data = { + 'product_id': line.product_id.id, + 'product_name': line.product_id.name, + 'qty': line.product_uom_qty, + 'tax': tax, + 'price_unit': line.price_unit, + 'price_subtotal': line.price_subtotal, + 'price_tax': line.price_tax, + 'price_total': line.price_total, + 'price_reduce': line.price_reduce, + 'price_reduce_taxinc': line.price_reduce_taxinc, + 'price_reduce_taxexcl': line.price_reduce_taxexcl, + 'discount': line.discount, + } + return data -- cgit v1.2.3