diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-01-22 16:58:11 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-01-22 16:58:11 +0700 |
| commit | e5dbcd62560f4083d413d474b123ed971926a2a0 (patch) | |
| tree | 050e1fbb121ae69a8be62dbd7baf3689e6540053 /indoteknik_custom/models/automatic_purchase.py | |
| parent | 53d5d5869f62d73be785400c050b389efb10b511 (diff) | |
final fix bug purchase pricelist
Diffstat (limited to 'indoteknik_custom/models/automatic_purchase.py')
| -rw-r--r-- | indoteknik_custom/models/automatic_purchase.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 502761e0..7b02a13e 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) + orderpoints = self.env['stock.warehouse.orderpoint'].search(query, limit=100) count = 0 for point in orderpoints: # _logger.info('test %s' % point.product_id.name) @@ -113,7 +113,7 @@ class AutomaticPurchase(models.Model): ], order='count_trx_po desc, count_trx_po_vendor desc', limit=1) vendor_id = purchase_price.vendor_id.id - price = self._get_valid_purchase_price(purchase_price) + price, taxes = self._get_valid_purchase_price(purchase_price) if self.vendor_id and self.vendor_id.id != vendor_id: continue @@ -129,6 +129,7 @@ class AutomaticPurchase(models.Model): # 'last_price': po_line.price_unit, 'partner_id': vendor_id, 'last_price': price, + 'taxes_id': taxes, 'subtotal': qty_purchase * price, 'last_order_id': po_line.order_id.id, 'last_orderline_id': po_line.id, @@ -142,14 +143,19 @@ class AutomaticPurchase(models.Model): p_price = 0 if purchase_price.system_price > 0 and purchase_price.product_price > 0: if purchase_price.human_last_update > purchase_price.system_last_update: - p_price = purchase_price.product_price + p_price = purchase_price.product_price + taxes = purchase_price.taxes_product_id else: p_price = purchase_price.system_price + taxes = purchase_price.taxes_system_id elif purchase_price.system_price > 0 and purchase_price.product_price == 0: p_price = purchase_price.system_price + taxes = purchase_price.taxes_system_id elif purchase_price.system_price == 0 and purchase_price.product_price > 0: p_price = purchase_price.product_price - return p_price + taxes = purchase_price.taxes_product_id + + return p_price, taxes class AutomaticPurchaseLine(models.Model): @@ -172,6 +178,7 @@ class AutomaticPurchaseLine(models.Model): current_po_id = fields.Many2one('purchase.order', string='Current') current_po_line_id = fields.Many2one('purchase.order.line', string='Current Line') brand_id = fields.Many2one('x_manufactures', string='Brand') + taxes_id = fields.Many2one('x_manufactures', string='Brand') class AutomaticPurchaseMatch(models.Model): |
