summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-10-02 10:40:24 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-10-02 10:40:24 +0700
commit705f51eed8a817fe6ea3ef514402786d25f7c356 (patch)
treeb756a2ed1a1ef106739e935ce0ac47df12df473a /indoteknik_custom/models
parent37ee561ff633776ef984d4d9e441981aecbca762 (diff)
parent1754a77d402af8c9fccb896e0b0745eb6e591c0b (diff)
Merge branch 'production' into iman/switch-account
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/account_move_due_extension.py2
-rw-r--r--indoteknik_custom/models/res_partner.py53
-rw-r--r--indoteknik_custom/models/stock_picking.py4
-rw-r--r--indoteknik_custom/models/website_user_cart.py22
4 files changed, 73 insertions, 8 deletions
diff --git a/indoteknik_custom/models/account_move_due_extension.py b/indoteknik_custom/models/account_move_due_extension.py
index 0399c6a2..23f8888c 100644
--- a/indoteknik_custom/models/account_move_due_extension.py
+++ b/indoteknik_custom/models/account_move_due_extension.py
@@ -96,6 +96,8 @@ class DueExtension(models.Model):
sales.action_confirm()
self.order_id.due_id = self.id
+ template = self.env.ref('indoteknik_custom.mail_template_due_extension_approve')
+ template.send_mail(self.id, force_send=True)
def generate_due_line(self):
partners = self.partner_id.get_child_ids()
diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py
index ef857c55..2846c14b 100644
--- a/indoteknik_custom/models/res_partner.py
+++ b/indoteknik_custom/models/res_partner.py
@@ -85,15 +85,54 @@ class ResPartner(models.Model):
#
return res
- # def write(self, vals):
- # if self.company_type == 'person':
+ def write(self, vals):
+ # Fungsi rekursif untuk meng-update semua child, termasuk child dari child
+ def update_children_recursively(partner, vals_for_child):
+ # Lakukan update pada partner saat ini hanya dengan field yang diizinkan
+ partner.write(vals_for_child)
+
+ # Untuk setiap child dari partner ini, update juga child-nya
+ for child in partner.child_ids:
+ update_children_recursively(child, vals_for_child)
+
+ # Jika self tidak memiliki parent_id, artinya self adalah parent
+ if not self.parent_id:
+ # Ambil semua child dari parent ini
+ children = self.child_ids
+
+ # Perbarui vals dengan nilai dari parent jika tidak ada dalam vals
+ vals['customer_type'] = vals.get('customer_type', self.customer_type)
+ vals['nama_wajib_pajak'] = vals.get('nama_wajib_pajak', self.nama_wajib_pajak)
+ vals['npwp'] = vals.get('npwp', self.npwp)
+ vals['sppkp'] = vals.get('sppkp', self.sppkp)
+ vals['alamat_lengkap_text'] = vals.get('alamat_lengkap_text', self.alamat_lengkap_text)
+ vals['industry_id'] = vals.get('industry_id', self.industry_id.id if self.industry_id else None)
+ vals['company_type_id'] = vals.get('company_type_id',
+ self.company_type_id.id if self.company_type_id else None)
+
+ # Simpan hanya field yang perlu di-update pada child
+ vals_for_child = {
+ 'customer_type': vals.get('customer_type'),
+ 'nama_wajib_pajak': vals.get('nama_wajib_pajak'),
+ 'npwp': vals.get('npwp'),
+ 'sppkp': vals.get('sppkp'),
+ 'alamat_lengkap_text': vals.get('alamat_lengkap_text'),
+ 'industry_id': vals.get('industry_id'),
+ 'company_type_id': vals.get('company_type_id')
+ }
+
+ # Lakukan update pada semua child secara rekursif
+ for child in children:
+ update_children_recursively(child, vals_for_child)
+
+ # Lakukan write untuk parent dengan vals asli
+ res = super(ResPartner, self).write(vals)
+
+ return res
+
+ # if self.company_type == 'person' and not partner.parent_id:
# if self.parent_id:
# parent = self.parent_id
- # vals['customer_type'] = parent.customer_type
- # vals['nama_wajib_pajak'] = parent.nama_wajib_pajak
- # vals['npwp'] = parent.npwp
- # vals['sppkp'] = parent.sppkp
- # vals['alamat_lengkap_text'] = parent.alamat_lengkap_text
# vals['industry_id'] = parent.industry_id.id
# vals['company_type_id'] = parent.company_type_id.id
#
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 66a326ff..6f038386 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -406,6 +406,10 @@ class StockPicking(models.Model):
if product:
product.product_tmpl_id._create_solr_queue('_sync_product_stock_to_solr')
+ for move_line in self.move_line_ids_without_package:
+ if move_line.product_id:
+ move_line.product_id.product_tmpl_id._create_solr_queue('_sync_product_stock_to_solr')
+
if not self.date_reserved:
current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
self.date_reserved = current_time
diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py
index b0cf47f7..169f4a6b 100644
--- a/indoteknik_custom/models/website_user_cart.py
+++ b/indoteknik_custom/models/website_user_cart.py
@@ -1,4 +1,4 @@
-from odoo import fields, models
+from odoo import fields, models, api
from datetime import datetime, timedelta
class WebsiteUserCart(models.Model):
@@ -16,6 +16,26 @@ class WebsiteUserCart(models.Model):
], 'Source', default='add_to_cart')
user_other_carts = fields.One2many('website.user.cart', 'id', 'Other Products', compute='_compute_user_other_carts')
is_reminder = fields.Boolean(string='Reminder?')
+ phone_user = fields.Char(string='Phone', related='user_id.mobile')
+ price = fields.Float(string='Price', compute='_compute_price')
+ program_product_id = fields.Many2one('product.product', string='Program Products', compute='_compute_program_product_ids')
+
+ @api.depends('program_line_id')
+ def _compute_program_product_ids(self):
+ for record in self:
+ if record.program_line_id and record.program_line_id.product_ids:
+ product = record.program_line_id.product_ids[0]
+ record.program_product_id = product.product_id
+ record.product_id = product.product_id
+ else:
+ # Handle case where there are no product_ids
+ record.program_product_id = False
+
+ def _compute_price(self):
+ for record in self:
+ record.price = record.get_price_website(record.product_id.id)['price']
+ if record.program_line_id:
+ record.price = record.get_price_coret(record.program_line_id.id)
def _compute_user_other_carts(self):
for record in self: