summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2022-08-19 11:38:51 +0700
committerIT Fixcomart <it@fixcomart.co.id>2022-08-19 11:38:51 +0700
commita836a99c12e1ebf4b764810036ecb64183890ad2 (patch)
tree447a83cceb28322ff2143d25017a233b3722e940
parentb75b17182b374acc9a70d9cf45a501691428fbfe (diff)
Inherit function menggunakan super
-rwxr-xr-xindoteknik_custom/models/purchase_order.py1
-rwxr-xr-xindoteknik_custom/models/purchase_order_line.py63
2 files changed, 2 insertions, 62 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 2c589d36..cb048182 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -8,7 +8,6 @@ class PurchaseOrder(models.Model):
procurement_status = fields.Char(string='Procurement Status', compute='get_procurement_status',readonly=True)
def get_procurement_status(self):
-
for purchase_order in self:
product_uom_qty = sum_qty_received = 0
diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py
index 22d65ee8..b4be9ffc 100755
--- a/indoteknik_custom/models/purchase_order_line.py
+++ b/indoteknik_custom/models/purchase_order_line.py
@@ -6,66 +6,9 @@ class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'
# Override method from addons/purchase/models/purchase.py
- @api.onchange('product_id')
- def onchange_product_id(self):
- if not self.product_id:
- return
-
- # Reset date, price and quantity since _onchange_quantity will provide default values
- self.price_unit = self.product_qty = 0.0
-
- self._product_id_change()
-
- self._suggest_quantity()
- self._onchange_quantity()
-
- # Override method from addons/purchase/models/purchase.py
@api.onchange('product_qty', 'product_uom')
def _onchange_quantity(self):
- if not self.product_id:
- return
- params = {'order_id': self.order_id}
- seller = self.product_id._select_seller(
- partner_id=self.partner_id,
- quantity=self.product_qty,
- date=self.order_id.date_order and self.order_id.date_order.date(),
- uom_id=self.product_uom,
- params=params)
-
- if seller or not self.date_planned:
- self.date_planned = self._get_date_planned(seller).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
-
- # If not seller, use the standard price. It needs a proper currency conversion.
- if not seller:
- po_line_uom = self.product_uom or self.product_id.uom_po_id
- price_unit = self.env['account.tax']._fix_tax_included_price_company(
- self.product_id.uom_id._compute_price(self.product_id.standard_price, po_line_uom),
- self.product_id.supplier_taxes_id,
- self.taxes_id,
- self.company_id,
- )
- if price_unit and self.order_id.currency_id and self.order_id.company_id.currency_id != self.order_id.currency_id:
- price_unit = self.order_id.company_id.currency_id._convert(
- price_unit,
- self.order_id.currency_id,
- self.order_id.company_id,
- self.date_order or fields.Date.today(),
- )
-
- self.price_unit = price_unit
- #return
-
- price_unit = self.env['account.tax']._fix_tax_included_price_company(seller.price,
- self.product_id.supplier_taxes_id,
- self.taxes_id,
- self.company_id) if seller else 0.0
- if price_unit and seller and self.order_id.currency_id and seller.currency_id != self.order_id.currency_id:
- price_unit = seller.currency_id._convert(
- price_unit, self.order_id.currency_id, self.order_id.company_id, self.date_order or fields.Date.today())
-
- if seller and self.product_uom and seller.product_uom != self.product_uom:
- price_unit = seller.product_uom._compute_price(price_unit, self.product_uom)
-
+ res = super(PurchaseOrderLine, self)._onchange_quantity()
# Custom script
purchase_pricelist = self.env['purchase.pricelist'].search([
('product_id', '=', self.product_id.id),
@@ -81,6 +24,4 @@ class PurchaseOrderLine(models.Model):
price_unit = product_supplierinfo.price
self.price_unit = price_unit
- return {
- 'warning': {'title': "Warning", 'message': 'ABCDEF', 'type': 'notification'},
- }
+ return res