summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-01-23 10:03:42 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-01-23 10:03:42 +0700
commitf7fe2253a8c79ff5172cf74c1f1aa341c9bf4f07 (patch)
tree9c3b7f9cd9b5fd1296d9670ec7337e715c60dc8e
parente5dbcd62560f4083d413d474b123ed971926a2a0 (diff)
fix bug purchase pricelist, bug automatic purchase, bug log saleorder eta date
-rw-r--r--indoteknik_custom/models/automatic_purchase.py4
-rwxr-xr-xindoteknik_custom/models/purchase_pricelist.py21
-rwxr-xr-xindoteknik_custom/models/sale_order.py2
3 files changed, 21 insertions, 6 deletions
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py
index 7b02a13e..3ab56e50 100644
--- a/indoteknik_custom/models/automatic_purchase.py
+++ b/indoteknik_custom/models/automatic_purchase.py
@@ -89,9 +89,9 @@ class AutomaticPurchase(models.Model):
query = [
('product_min_qty', '>', 0),
- # ('product_id.x_manufacture.user_id.id', '=', self.responsible_id.id)
+ ('product_id.x_manufacture.user_id.id', '=', self.responsible_id.id)
]
- orderpoints = self.env['stock.warehouse.orderpoint'].search(query, limit=100)
+ orderpoints = self.env['stock.warehouse.orderpoint'].search(query)
count = 0
for point in orderpoints:
# _logger.info('test %s' % point.product_id.name)
diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py
index 9c149ea9..af33abbf 100755
--- a/indoteknik_custom/models/purchase_pricelist.py
+++ b/indoteknik_custom/models/purchase_pricelist.py
@@ -32,11 +32,12 @@ class PurchasePricelist(models.Model):
else:
self.human_last_update = current_time
- @api.constrains('system_last_update','system_price')
+ @api.constrains('system_last_update','system_price','product_price','human_last_update')
def _contrains_include_price(self):
- taxes = self.taxes_system_id or self.taxes_product_id
+ price_unit, taxes = self._get_valid_price()
+ # taxes = self.taxes_system_id or self.taxes_product_id
+ # price_unit = self.system_price or self.product_price
tax_include = taxes.price_include
- price_unit = self.system_price or self.product_price
if taxes:
if tax_include:
price_unit = price_unit
@@ -47,6 +48,20 @@ class PurchasePricelist(models.Model):
self.include_price = price_unit
+ def _get_valid_price(self):
+ p_price = 0
+ taxes = False
+
+ if self.system_price > 0:
+ if self.product_price > 0 and self.human_last_update > self.system_last_update:
+ p_price, taxes = self.product_price, self.taxes_product_id
+ else:
+ p_price, taxes = self.system_price, self.taxes_system_id
+ elif self.product_price > 0:
+ p_price, taxes = self.product_price, self.taxes_product_id
+
+ return p_price, taxes
+
@api.constrains('vendor_id', 'product_id')
def _check_duplicate_purchase_pricelist(self):
for price in self:
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 44790480..f00f5b1d 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -82,7 +82,7 @@ class SaleOrder(models.Model):
email = fields.Char(string='Email')
picking_iu_id = fields.Many2one('stock.picking', 'Picking IU')
helper_by_id = fields.Many2one('res.users', 'Helper By')
- eta_date = fields.Datetime(string='ETA Date', tracking=3, copy=False, compute='_compute_eta_date')
+ eta_date = fields.Datetime(string='ETA Date', copy=False, compute='_compute_eta_date')
def _compute_eta_date(self):
max_leadtime = 0