From e2d42ebca210467698f163558e6e4390dcecaae9 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 22 Jul 2022 09:55:08 +0700 Subject: add compute web price and stock vendor --- indoteknik_custom/models/__init__.py | 2 +- indoteknik_custom/models/product_template.py | 19 +++++++++++++++++++ indoteknik_custom/models/stock_altama.py | 10 ---------- indoteknik_custom/models/stock_vendor.py | 10 ++++++++++ 4 files changed, 30 insertions(+), 11 deletions(-) delete mode 100644 indoteknik_custom/models/stock_altama.py create mode 100644 indoteknik_custom/models/stock_vendor.py (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 3da85d05..ee089698 100644 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -7,4 +7,4 @@ from . import product_public_category from . import product_template from . import x_partner_purchase_order from . import x_product_tags -from . import stock_altama +from . import stock_vendor diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index b2816d3f..61cf09e2 100644 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -17,3 +17,22 @@ class ProductTemplate(models.Model): x_lazada = fields.Text(string="Lazada") x_tokopedia = fields.Text(string="Tokopedia") +class ProductProduct(models.Model): + _inherit = "product.product" + web_price = fields.Float( + 'Web Price', compute='_compute_product_discount_price', + digits='Product Price', inverse='_set_product_lst_price', + help="Web Price with pricelist_id = 1") + qty_stock_vendor = fields.Float( + 'Qty Stock Vendor', compute='_compute_stock_vendor', + help="Stock Vendor") + + def _compute_product_discount_price(self): + for product in self: + product_pricelist_item = self.env['product.pricelist.item'].search([('pricelist_id', '=', 1),('product_id', '=', product.id)],limit=1) + product.web_price = product_pricelist_item.fixed_price + + def _compute_stock_vendor(self): + for product in self: + stock_vendor = self.env['stock.vendor'].search([('product_variant_id', '=', product.id)],limit=1) + product.qty_stock_vendor = stock_vendor.quantity+product.qty_available \ No newline at end of file diff --git a/indoteknik_custom/models/stock_altama.py b/indoteknik_custom/models/stock_altama.py deleted file mode 100644 index 9dae06e2..00000000 --- a/indoteknik_custom/models/stock_altama.py +++ /dev/null @@ -1,10 +0,0 @@ -from odoo import fields, models - - -class StockAltama(models.Model): - _name = "stock.altama" - _description = "Stock Altama" - _rec_name = "product_variant_id" - - product_variant_id = fields.Many2one("product.product", string="Product Variant") - quantity = fields.Integer(string="Quantity") diff --git a/indoteknik_custom/models/stock_vendor.py b/indoteknik_custom/models/stock_vendor.py new file mode 100644 index 00000000..78baf14c --- /dev/null +++ b/indoteknik_custom/models/stock_vendor.py @@ -0,0 +1,10 @@ +from odoo import fields, models + + +class StockVendor(models.Model): + _name = "stock.vendor" + _description = "Stock Vendor" + _rec_name = "product_variant_id" + + product_variant_id = fields.Many2one("product.product", string="Product Variant") + quantity = fields.Integer(string="Quantity") -- cgit v1.2.3