summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/automatic_purchase.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-05-26 09:33:56 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-05-26 09:33:56 +0700
commitce4c8c6b5e8b61877a66b483f46c1c808f10a8b1 (patch)
tree1672520b36bb0f11d37a7876ed991e59a33d45fe /indoteknik_custom/models/automatic_purchase.py
parent8fefc2e71c5e8a9f040f2fe6c9310b20cd88db3f (diff)
parent64c86581b469e962789ea6a7ea45c17ed020fe9a (diff)
Merge branch 'odoo-backup' of bitbucket.org:altafixco/indoteknik-addons into odoo-backup
# Conflicts: # indoteknik_custom/models/sale_order_line.py
Diffstat (limited to 'indoteknik_custom/models/automatic_purchase.py')
-rw-r--r--indoteknik_custom/models/automatic_purchase.py39
1 files changed, 19 insertions, 20 deletions
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py
index ff10b814..c9edf07c 100644
--- a/indoteknik_custom/models/automatic_purchase.py
+++ b/indoteknik_custom/models/automatic_purchase.py
@@ -486,7 +486,7 @@ class AutomaticPurchase(models.Model):
# _logger.info('test %s' % point.product_id.name)
if point.product_id.qty_available_bandengan > point.product_min_qty:
continue
- qty_purchase = point.product_max_qty - point.product_id.qty_available_bandengan
+ qty_purchase = point.product_max_qty - point.product_id.qty_incoming_bandengan - point.product_id.qty_onhand_bandengan
po_line = self.env['purchase.order.line'].search([('product_id', '=', point.product_id.id), ('order_id.state', '=', 'done')], order='id desc', limit=1)
if self.vendor_id:
@@ -589,18 +589,18 @@ class AutomaticPurchaseLine(models.Model):
def _get_valid_purchase_price(self, purchase_price):
price = 0
- taxes = ''
+ taxes = 24
human_last_update = purchase_price.human_last_update or datetime.min
system_last_update = purchase_price.system_last_update or datetime.min
- if purchase_price.taxes_product_id.type_tax_use == 'purchase':
- price = purchase_price.product_price
- taxes = purchase_price.taxes_product_id.id
+ #if purchase_price.taxes_product_id.type_tax_use == 'purchase':
+ price = purchase_price.product_price
+ taxes = purchase_price.taxes_product_id.id or 24
if system_last_update > human_last_update:
- if purchase_price.taxes_system_id.type_tax_use == 'purchase':
- price = purchase_price.system_price
- taxes = purchase_price.taxes_system_id.id
+ #if purchase_price.taxes_system_id.type_tax_use == 'purchase':
+ price = purchase_price.system_price
+ taxes = purchase_price.taxes_system_id.id or 24
return price, taxes
@@ -720,18 +720,17 @@ class SaleNotInMatchPO(models.Model):
tools.drop_view_if_exists(self.env.cr, self._table)
self.env.cr.execute("""
CREATE OR REPLACE VIEW %s AS(
- SELECT apsm.id, apsm.automatic_purchase_id, apsm.automatic_purchase_line_id,
- apsm.sale_id, apsm.sale_line_id, apsm.picking_id, apsm.move_id,
- apsm.partner_id, apsm.partner_invoice_id, apsm.salesperson_id,
- apsm.product_id, apsm.qty_so, apsm.qty_po, apsm.create_uid,
- apsm.create_date, apsm.write_uid, apsm.write_date, apsm.purchase_price,
- apsm.purchase_tax_id, apsm.note_procurement
- FROM automatic_purchase_sales_match apsm
- WHERE apsm.sale_line_id NOT IN (
- SELECT posm.sale_line_id
- FROM purchase_order_sales_match posm
- JOIN purchase_order po ON po.id = posm.purchase_order_id
- WHERE po.state NOT IN ('cancel')
+ select apsm.id, apsm.automatic_purchase_id, apsm.automatic_purchase_line_id, apsm.sale_id, apsm.sale_line_id,
+ apsm.picking_id, apsm.move_id, apsm.partner_id,
+ apsm.partner_invoice_id, apsm.salesperson_id, apsm.product_id, apsm.qty_so, apsm.qty_po, apsm.create_uid,
+ apsm.create_date, apsm.write_uid, apsm.write_date, apsm.purchase_price,
+ apsm.purchase_tax_id, apsm.note_procurement
+ from automatic_purchase_sales_match apsm
+ where apsm.sale_line_id not in (
+ select distinct coalesce(posm.sale_line_id,0)
+ from purchase_order_sales_match posm
+ join purchase_order po on po.id = posm.purchase_order_id
+ where po.state not in ('cancel')
)
)
""" % self._table) \ No newline at end of file