summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchase_order.py
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-11-10 13:40:58 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-11-10 13:40:58 +0700
commit2aee5a44abbe36961dfe23cc3d656aa48e11e0f9 (patch)
tree8ec2b6552aaef4e14539aa52ed796552e24180d6 /indoteknik_custom/models/purchase_order.py
parent6a87e59e7220bdfa78e98b23003ccc4ef41bd0ce (diff)
parentb4e74170aeaf00937f78e5af9047218ddb17516c (diff)
Merge branch 'production' into change/feature/promotion-program
Diffstat (limited to 'indoteknik_custom/models/purchase_order.py')
-rwxr-xr-xindoteknik_custom/models/purchase_order.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 8ad25228..b0f1a569 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -47,6 +47,17 @@ class PurchaseOrder(models.Model):
count_line_product = fields.Float('Total Item', compute='compute_count_line_product')
note_description = fields.Char(string='Note', help='bisa diisi sebagai informasi indent barang tertentu atau apapun')
has_active_invoice = fields.Boolean(string='Has Active Invoice', compute='_compute_has_active_invoice')
+ description = fields.Char(string='Description', help='bisa diisi sebagai informasi indent barang tertentu atau apapun')
+ purchase_order_lines = fields.One2many('purchase.order.line', 'order_id', string='Indent', auto_join=True)
+ responsible_ids = fields.Many2many('res.users', string='Responsibles', compute='_compute_responsibles')
+
+ def _compute_responsibles(self):
+ for purchase in self:
+ resposible_ids = []
+ for line in purchase.order_line:
+ resposible_ids.append(line.product_id.x_manufacture.user_id.id)
+ resposible_ids = list(set(resposible_ids))
+ purchase.responsible_ids = resposible_ids
def _compute_has_active_invoice(self):
for order in self:
@@ -55,6 +66,14 @@ class PurchaseOrder(models.Model):
def add_product_to_pricelist(self):
for line in self.order_line:
current_time = datetime.utcnow()
+ price_unit = line.price_unit
+ taxes = line.taxes_id
+ for tax in taxes:
+ tax_include = tax.price_include
+ tax_amt = tax.amount
+ if taxes:
+ if not tax_include:
+ price_unit = price_unit + (price_unit * tax_amt / 100)
purchase_pricelist = self.env['purchase.pricelist'].search([
('product_id', '=', line.product_id.id),
@@ -66,7 +85,7 @@ class PurchaseOrder(models.Model):
'vendor_id': line.order_id.partner_id.id,
'product_id': line.product_id.id,
'product_price': 0.00,
- 'system_price': line.price_unit,
+ 'system_price': price_unit,
'system_last_update': current_time,
}])
return True
@@ -74,7 +93,7 @@ class PurchaseOrder(models.Model):
for pricelist in purchase_pricelist:
pricelist.write({
'system_last_update': current_time,
- 'system_price': line.price_unit
+ 'system_price': price_unit
})
def _compute_date_planned(self):
@@ -329,12 +348,11 @@ class PurchaseOrder(models.Model):
def re_calculate(self):
for line in self.order_line:
sale_order_line = self.env['sale.order.line'].search([
- ('id', '=', line.so_line_id.id),
+ ('product_id', 'in', [line.product_id.id]),
('order_id', '=', line.order_id.sale_order_id.id)
- ], limit=1, order='price_reduce_taxexcl')
+ ])
for so_line in sale_order_line:
- unit_price = line.price_unit
- so_line.purchase_price = unit_price
+ so_line.purchase_price = line.price_unit
def button_cancel(self):
res = super(PurchaseOrder, self).button_cancel()